|
@@ -204,6 +204,7 @@ func builtin_return(vm *VM, args ...Value) []Value {
|
|
|
|
|
|
func to(vm *VM, args ...Value) []Value {
|
|
|
var name string
|
|
|
+
|
|
|
rest, err := ParseArgs(args, &name)
|
|
|
if err != nil {
|
|
|
return Fail(err)
|
|
@@ -218,10 +219,10 @@ func to(vm *VM, args ...Value) []Value {
|
|
|
if ! isBlock {
|
|
|
return Fail(NewErrorValuef("Not a block: %v", last))
|
|
|
}
|
|
|
- param := rest[0:len(rest)-1]
|
|
|
+ param := args[1:len(args)-1]
|
|
|
sign, err := NewSignatureWithNames(param...)
|
|
|
if err != nil {
|
|
|
- return Fail(NewErrorValuef("Not a word value: %v", name))
|
|
|
+ return Fail(NewErrorValuef("Could not parse arguments: %v: %s", name, err))
|
|
|
}
|
|
|
|
|
|
|
|
@@ -465,7 +466,7 @@ func (vm *VM) RegisterBuiltins() {
|
|
|
vm.RegisterBuiltinTypes()
|
|
|
vm.RegisterBuiltinWithHelp("addl", addl, "adds an element to a list").Takes(ListType, AnyType).Returns(ListType)
|
|
|
vm.RegisterBuiltinWithHelp("addi", addi, `adds two integers together`).Takes(IntType, IntType).Returns(BoolType)
|
|
|
- vm.RegisterBuiltinWithHelp("addf", addf, `adds two floats together`).Takes(IntType, IntType).Returns(IntType)
|
|
|
+ vm.RegisterBuiltinWithHelp("addf", addf, `adds two floats together`).Takes(FloatType, FloatType).Returns(FloatType)
|
|
|
vm.RegisterBuiltinWithHelp("andb", andb, `returns true if all it's arguments are true`).Takes(BoolType, BoolType).Returns(BoolType)
|
|
|
vm.RegisterBuiltin(",", comma)
|
|
|
|
|
@@ -504,19 +505,34 @@ func (vm *VM) RegisterBuiltins() {
|
|
|
Over("muli", 0, IntType, IntType),
|
|
|
Over("mulf", 0, FloatType, IntType),
|
|
|
Over("mulf", 0, IntType, FloatType))
|
|
|
-
|
|
|
- vm.AddOverloads("*",
|
|
|
- Over("mulf", 0, FloatType, FloatType),
|
|
|
- Over("muli", 0, IntType, IntType),
|
|
|
- Over("mulf", 0, FloatType, IntType),
|
|
|
- Over("mulf", 0, IntType, FloatType))
|
|
|
-
|
|
|
|
|
|
vm.AddOverloads("add",
|
|
|
Over("addf", 0, FloatType, FloatType),
|
|
|
Over("addi", 0, IntType, IntType),
|
|
|
Over("addf", 0, FloatType, IntType),
|
|
|
Over("addf", 0, IntType, FloatType))
|
|
|
+
|
|
|
+ vm.AddOverloads("div",
|
|
|
+ Over("divf", 0, FloatType, FloatType),
|
|
|
+ Over("divi", 0, IntType, IntType),
|
|
|
+ Over("divf", 0, FloatType, IntType),
|
|
|
+ Over("divf", 0, IntType, FloatType))
|
|
|
+
|
|
|
+ vm.AddOverloads("sub",
|
|
|
+ Over("subf", 0, FloatType, FloatType),
|
|
|
+ Over("subi", 0, IntType, IntType),
|
|
|
+ Over("subf", 0, FloatType, IntType),
|
|
|
+ Over("subf", 0, IntType, FloatType))
|
|
|
+
|
|
|
+ vm.Alias("*", "mul")
|
|
|
+ vm.Alias("+", "add")
|
|
|
+ vm.Alias("/", "div")
|
|
|
+ vm.Alias("-", "sub")
|
|
|
+ vm.Alias("||", "orb")
|
|
|
+ vm.Alias("&&", "andb")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
vm.SetHelp("mul", " Num: Multiplies two numbers. Cover for muli and mulf.")
|