Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce special self-variable #3235

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions runtime/cmd/execute/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func (d *InteractiveDebugger) Next() {
// Show shows the values for the variables with the given names.
// If no names are given, lists all non-base variables
func (d *InteractiveDebugger) Show(names []string) {
current := d.debugger.CurrentActivation(d.stop.Interpreter)
inter := d.stop.Interpreter
current := d.debugger.CurrentActivation(inter)
switch len(names) {
case 0:
for name := range current.FunctionValues() { //nolint:maprange
Expand All @@ -88,7 +89,7 @@ func (d *InteractiveDebugger) Show(names []string) {
return
}

fmt.Println(colorizeValue(variable.GetValue()))
fmt.Println(colorizeValue(variable.GetValue(inter)))

default:
for _, name := range names {
Expand All @@ -100,7 +101,7 @@ func (d *InteractiveDebugger) Show(names []string) {
fmt.Printf(
"%s = %s\n",
name,
colorizeValue(variable.GetValue()),
colorizeValue(variable.GetValue(inter)),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/debugger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestRuntimeDebugger(t *testing.T) {
variable := activation.Find("answer")
require.NotNil(t, variable)

value := variable.GetValue()
value := variable.GetValue(stop.Interpreter)
require.Equal(
t,
interpreter.NewUnmeteredIntValueFromInt64(42),
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestRuntimeDebuggerBreakpoints(t *testing.T) {
variable := activation.Find("answer")
require.NotNil(t, variable)

value := variable.GetValue()
value := variable.GetValue(stop.Interpreter)
require.Equal(
t,
interpreter.NewUnmeteredIntValueFromInt64(42),
Expand Down
4 changes: 2 additions & 2 deletions runtime/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (e *interpreterEnvironment) interpreterBaseActivationFor(

baseActivation := e.baseActivationsByLocation[location]
if baseActivation == nil {
baseActivation = activations.NewActivation[*interpreter.Variable](nil, defaultBaseActivation)
baseActivation = activations.NewActivation[interpreter.Variable](nil, defaultBaseActivation)
if e.baseActivationsByLocation == nil {
e.baseActivationsByLocation = map[common.Location]*interpreter.VariableActivation{}
}
Expand Down Expand Up @@ -1106,7 +1106,7 @@ func (e *interpreterEnvironment) InterpretContract(
)
}

contract = variable.GetValue().(*interpreter.CompositeValue)
contract = variable.GetValue(inter).(*interpreter.CompositeValue)

return
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/interpreter/globalvariables.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package interpreter

// GlobalVariables represents global variables defined in a program.
type GlobalVariables struct {
variables map[string]*Variable
variables map[string]Variable
}

func (g *GlobalVariables) Contains(name string) bool {
Expand All @@ -31,16 +31,16 @@ func (g *GlobalVariables) Contains(name string) bool {
return ok
}

func (g *GlobalVariables) Get(name string) *Variable {
func (g *GlobalVariables) Get(name string) Variable {
if g.variables == nil {
return nil
}
return g.variables[name]
}

func (g *GlobalVariables) Set(name string, variable *Variable) {
func (g *GlobalVariables) Set(name string, variable Variable) {
if g.variables == nil {
g.variables = map[string]*Variable{}
g.variables = map[string]Variable{}
}
g.variables[name] = variable
}
Loading
Loading