Skip to content

Commit c0cc361

Browse files
committed
ras: renaming of p to env in environment.go
Signed-off-by: Olivier Bégassat <olivier.begassat.cours@gmail.com>
1 parent 3721199 commit c0cc361

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

pkg/zkc/compiler/parser/environment.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,76 +50,76 @@ func EmptyEnvironment() Environment {
5050
// Clone constructs a clone of this environment, such that variables declared in
5151
// the clone will not clash with those declared elsewhere. The inLoop parameter
5252
// indicates whether the cloned environment is inside a loop.
53-
func (p *Environment) Clone(inLoop bool) Environment {
53+
func (env *Environment) Clone(inLoop bool) Environment {
5454
var local localEnvironment
5555
// Clone local variables
56-
local.visible = p.local.visible.Clone()
56+
local.visible = env.local.visible.Clone()
5757
local.inLoop = inLoop
5858
// Otherwise, keep global as is
59-
return Environment{global: p.global, local: &local}
59+
return Environment{global: env.global, local: &local}
6060
}
6161

6262
// InLoop returns whether the current environment is inside a loop body.
63-
func (p *Environment) InLoop() bool {
64-
return p.local.inLoop
63+
func (env *Environment) InLoop() bool {
64+
return env.local.inLoop
6565
}
6666

6767
// Effects returns the set of memory effects declared globally
68-
func (p *Environment) Effects() []*symbol.Unresolved {
69-
return p.global.effects
68+
func (env *Environment) Effects() []*symbol.Unresolved {
69+
return env.global.effects
7070
}
7171

7272
// Variables returns the set of variables declared globally
73-
func (p *Environment) Variables() []VariableDescriptor {
74-
return p.global.variables
73+
func (env *Environment) Variables() []VariableDescriptor {
74+
return env.global.variables
7575
}
7676

7777
// DeclareEffect declares a new effect. If an effect with the same name
7878
// already exists, this panics.
79-
func (p *Environment) DeclareEffect(effect *symbol.Unresolved) {
79+
func (env *Environment) DeclareEffect(effect *symbol.Unresolved) {
8080
//
81-
if p.IsDeclared(effect.Name) {
81+
if env.IsDeclared(effect.Name) {
8282
panic(fmt.Sprintf("effect %s already declared", effect.Name))
8383
}
8484
//
85-
p.global.effects = append(p.global.effects, effect)
85+
env.global.effects = append(env.global.effects, effect)
8686
}
8787

8888
// DeclareVariable declares a new register with the given name and bitwidth. If
8989
// a register with the same name already exists, this panics.
90-
func (p *Environment) DeclareVariable(kind variable.Kind, name string, datatype Type) {
90+
func (env *Environment) DeclareVariable(kind variable.Kind, name string, datatype Type) {
9191
// Determine global index of this variable
92-
var index = uint(len(p.global.variables))
92+
var index = uint(len(env.global.variables))
9393
// Check whether it clashes with another variable in the same (local) environment
94-
if p.IsDeclared(name) {
94+
if env.IsDeclared(name) {
9595
panic(fmt.Sprintf("variable %s already declared", name))
9696
}
9797
// Update global environment
98-
p.global.variables = append(p.global.variables, variable.New(kind, name, datatype))
98+
env.global.variables = append(env.global.variables, variable.New(kind, name, datatype))
9999
// Update local environment
100-
p.local.visible.Insert(index)
100+
env.local.visible.Insert(index)
101101
}
102102

103103
// IsDeclared checks whether or not a given name is already declared (either as
104104
// an effect or a variable).
105-
func (p *Environment) IsDeclared(name string) bool {
105+
func (env *Environment) IsDeclared(name string) bool {
106106
// check effects
107-
for _, effect := range p.global.effects {
107+
for _, effect := range env.global.effects {
108108
if effect.Name == name {
109109
return true
110110
}
111111
}
112112
// check local variables
113-
return p.IsDeclaredVariable(name)
113+
return env.IsDeclaredVariable(name)
114114
}
115115

116116
// IsDeclaredVariable checks whether or not a given name is already declared as
117117
// a variable.
118-
func (p *Environment) IsDeclaredVariable(name string) bool {
118+
func (env *Environment) IsDeclaredVariable(name string) bool {
119119
// check local variables
120-
for iter := p.local.visible.Iter(); iter.HasNext(); {
120+
for iter := env.local.visible.Iter(); iter.HasNext(); {
121121
var index = iter.Next()
122-
if p.global.variables[index].Name == name {
122+
if env.global.variables[index].Name == name {
123123
return true
124124
}
125125
}
@@ -128,11 +128,11 @@ func (p *Environment) IsDeclaredVariable(name string) bool {
128128
}
129129

130130
// LookupVariable looks up the index for a given register.
131-
func (p *Environment) LookupVariable(name string) variable.Id {
131+
func (env *Environment) LookupVariable(name string) variable.Id {
132132
// check local variables
133-
for iter := p.local.visible.Iter(); iter.HasNext(); {
133+
for iter := env.local.visible.Iter(); iter.HasNext(); {
134134
var index = iter.Next()
135-
if p.global.variables[index].Name == name {
135+
if env.global.variables[index].Name == name {
136136
return index
137137
}
138138
}

0 commit comments

Comments
 (0)