|
@@ -66,8 +66,8 @@ func (astkind AstBasicMetaKind) String() string {
|
|
|
return string(astkind)
|
|
|
}
|
|
|
|
|
|
-func (astkind AstBasicMetaKind) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return EmptyListValue()
|
|
|
+func (astkind AstBasicMetaKind) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{}
|
|
|
}
|
|
|
|
|
|
func (astkind AstMetaKindNone) String() string { return "AstNone " }
|
|
@@ -95,110 +95,114 @@ func (astkind AstMetaKindError) String() string { return "AstError "
|
|
|
func (astkind AstMetaKindFlatten) String() string { return "AstFlatten " }
|
|
|
|
|
|
|
|
|
-func (astkind AstMetaKindNone) Run(vm *VM, ast Ast, val ...Value) Value { return EmptyValue{} }
|
|
|
+func (astkind AstMetaKindNone) Run(vm *VM, ast Ast, val ...Value) []Value { return ReturnEmpty() }
|
|
|
|
|
|
-func (astkind AstMetaKindProgram) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return vm.RunChildrenLastResult(ast, val...)
|
|
|
+func (astkind AstMetaKindProgram) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{vm.RunChildrenLastResult(ast, val...)}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindStatements) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return vm.RunChildrenLastResult(ast, val...)
|
|
|
+func (astkind AstMetaKindStatements) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{vm.RunChildrenLastResult(ast, val...)}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindStatement) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindStatement) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
panic("AstMetaKindStatement")
|
|
|
return vm.RunChildren(ast, val...)
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindClosed) Run(vm *VM, ast Ast, val ...Value) Value {return EmptyListValue() }
|
|
|
-func (astkind AstMetaKindSet) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindClosed) Run(vm *VM, ast Ast, val ...Value) []Value {return ReturnEmpty() }
|
|
|
+func (astkind AstMetaKindSet) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
varName := ast.Value()
|
|
|
value := vm.RunChildren(ast, val...)
|
|
|
- vm.Register(varName.String(), value)
|
|
|
+ vm.Register(varName.String(), value[0])
|
|
|
return value
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindGet) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindGet) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
target := vm.RunChildrenFirstResult(ast, val...).(ListValue)
|
|
|
- return vm.Lookup(target.String())
|
|
|
+ return []Value{vm.Lookup(target.String())}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindTarget) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return ast.Value()
|
|
|
+func (astkind AstMetaKindTarget) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{ast.Value()}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindCommand) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindCommand) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
commandName := ast.Value()
|
|
|
arguments := vm.RunChildrenFirstResult(ast, val...)
|
|
|
if argList, isList := arguments.(ListValue) ; isList {
|
|
|
log.Printf("Command execute: %s %v", commandName.String(), argList)
|
|
|
- return vm.CallNamed(commandName.String(), argList)
|
|
|
+ return vm.CallNamed(commandName.String(), argList.List...)
|
|
|
+ } else if _, isEmpty := arguments.(EmptyValue) ; isEmpty {
|
|
|
+ return vm.CallNamed(commandName.String())
|
|
|
} else {
|
|
|
- return NewErrorValuef("Internal error when calling %s.", commandName.String())
|
|
|
+ return []Value{NewErrorValuef("Internal error when calling %s.", commandName.String())}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindArguments) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindArguments) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
return vm.RunChildren(ast, val...)
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindArgument) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindArgument) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
panic("AstMetaKindArgument")
|
|
|
- return vm.RunChildrenFirstResult(ast, val...)
|
|
|
+ return []Value{vm.RunChildrenFirstResult(ast, val...)}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindExpression) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindExpression) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
panic("AstMetaKindExpression")
|
|
|
- return vm.RunChildrenLastResult(ast, val...)
|
|
|
+ return []Value{vm.RunChildrenLastResult(ast, val...)}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindBlock) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return vm.RunChildrenLastResult(ast, val...)
|
|
|
+func (astkind AstMetaKindBlock) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{vm.RunChildrenLastResult(ast, val...)}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindParenthesis) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return vm.RunChildrenLastResult(ast, val...)
|
|
|
+func (astkind AstMetaKindParenthesis) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{vm.RunChildrenLastResult(ast, val...)}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindList) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return vm.RunChildren(ast, val...)
|
|
|
+func (astkind AstMetaKindList) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ result := vm.RunChildren(ast, val...)
|
|
|
+ list := ListValue{List:result}
|
|
|
+ return []Value{list}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindCapture) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
+func (astkind AstMetaKindCapture) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
return vm.RunChildren(ast, val...)
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindWordValue) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return ast.Value()
|
|
|
+func (astkind AstMetaKindWordValue) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{ast.Value()}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindWord) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return ast.Value()
|
|
|
+func (astkind AstMetaKindWord) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{ast.Value()}
|
|
|
}
|
|
|
-func (astkind AstMetaKindType) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return ast.Value()
|
|
|
+func (astkind AstMetaKindType) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{ast.Value()}
|
|
|
}
|
|
|
-func (astkind AstMetaKindValue) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return ast.Value()
|
|
|
+func (astkind AstMetaKindValue) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{ast.Value()}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindEnd) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return EmptyValue{}
|
|
|
+func (astkind AstMetaKindEnd) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{EmptyValue{}}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindError) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return ast.Value()
|
|
|
+func (astkind AstMetaKindError) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return []Value{ast.Value()}
|
|
|
}
|
|
|
|
|
|
-func (astkind AstMetaKindFlatten) Run(vm *VM, ast Ast, val ...Value) Value {
|
|
|
- return EmptyListValue()
|
|
|
+func (astkind AstMetaKindFlatten) Run(vm *VM, ast Ast, val ...Value) []Value {
|
|
|
+ return ReturnEmpty()
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type AstKind interface {
|
|
|
String() string
|
|
|
- Run(vm *VM, ast Ast, val ...Value) Value
|
|
|
+ Run(vm *VM, ast Ast, val ...Value) []Value
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -343,10 +347,10 @@ func (ast Ast) Child(index int) *Ast {
|
|
|
return ast.children[index]
|
|
|
}
|
|
|
|
|
|
-func (ast Ast) Run(vm *VM, val ...Value) Value {
|
|
|
+func (ast Ast) Run(vm *VM, val ...Value) []Value {
|
|
|
res := ast.AstKind.Run(vm, ast, val...)
|
|
|
if vm != nil && vm.Tracer != nil {
|
|
|
- vm.Trace(*vm, ast, res)
|
|
|
+ vm.Trace(*vm, ast, res...)
|
|
|
}
|
|
|
return res
|
|
|
}
|