we in era3 boys; overhauled expression system, and variables are now in maps
This commit is contained in:
parent
bf29e6c3dd
commit
43e450c207
14 changed files with 945 additions and 452 deletions
|
|
@ -610,7 +610,7 @@ func (v *FunctionValue) Type() ValueType {
|
|||
}
|
||||
|
||||
func (v *FunctionValue) String() string {
|
||||
return fmt.Sprintf("<function name=%s>", v.Name)
|
||||
return fmt.Sprintf("<function name=%s block=%p>", v.Name, v.Chunk)
|
||||
}
|
||||
|
||||
func (v *FunctionValue) DebugString() string {
|
||||
|
|
@ -619,7 +619,6 @@ func (v *FunctionValue) DebugString() string {
|
|||
|
||||
func (v *FunctionValue) Equals(other Value) bool {
|
||||
return other.Type() == FunctionValueType &&
|
||||
v.Name == other.(*FunctionValue).Name &&
|
||||
v.Chunk == other.(*FunctionValue).Chunk
|
||||
}
|
||||
|
||||
|
|
@ -675,43 +674,3 @@ func (v *BuiltinFunctionValue) Clone() Value {
|
|||
v.Constant,
|
||||
}
|
||||
}
|
||||
|
||||
// VariableValue a value wrapper for variables kept on the stack
|
||||
type VariableValue struct {
|
||||
name string
|
||||
value Value
|
||||
scope Pos
|
||||
}
|
||||
|
||||
func (v *VariableValue) Type() ValueType {
|
||||
return VariableValueType
|
||||
}
|
||||
|
||||
func (v *VariableValue) String() string {
|
||||
return fmt.Sprintf("<variable name=%s value=%s scope=%d>", v.name, v.value, v.scope)
|
||||
|
||||
// variables should not be accessed on the stack; normal values should be pushed and popped predictably
|
||||
//panic("tried getting string value of a unreachable value")
|
||||
}
|
||||
|
||||
func (v *VariableValue) DebugString() string {
|
||||
return v.String()
|
||||
}
|
||||
|
||||
func (v *VariableValue) Equals(other Value) bool {
|
||||
return other.Type() == VariableValueType &&
|
||||
v.name == other.(*VariableValue).name &&
|
||||
v.value.Equals(other.(*VariableValue).value)
|
||||
}
|
||||
|
||||
func (v *VariableValue) Get(_ string) (Value, error) {
|
||||
return nil, errors.New("variables have no properties")
|
||||
}
|
||||
|
||||
func (v *VariableValue) Clone() Value {
|
||||
return &VariableValue{
|
||||
v.name,
|
||||
v.value.Clone(),
|
||||
v.scope,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue