Added support for GenericPrint opcode
This commit is contained in:
parent
ff0ae8fcba
commit
67b44dbfc9
|
@ -470,6 +470,8 @@ proc dispatch*(self: PeonVM) =
|
||||||
discard self.pop()
|
discard self.pop()
|
||||||
continue
|
continue
|
||||||
echo self.pop()
|
echo self.pop()
|
||||||
|
of GenericPrint:
|
||||||
|
echo self.pop()
|
||||||
of PopN:
|
of PopN:
|
||||||
# Pops N elements off the call stack
|
# Pops N elements off the call stack
|
||||||
for _ in 0..<int(self.readShort()):
|
for _ in 0..<int(self.readShort()):
|
||||||
|
|
|
@ -896,6 +896,8 @@ proc handleBuiltinFunction(self: Compiler, fn: Name, args: seq[Expression]) =
|
||||||
elif len(args) == 1:
|
elif len(args) == 1:
|
||||||
self.expression(args[0])
|
self.expression(args[0])
|
||||||
case fn.valueType.builtinOp:
|
case fn.valueType.builtinOp:
|
||||||
|
of "GenericPrint":
|
||||||
|
self.emitByte(GenericPrint)
|
||||||
of "AddInt64":
|
of "AddInt64":
|
||||||
self.emitByte(AddInt64)
|
self.emitByte(AddInt64)
|
||||||
of "SubInt64":
|
of "SubInt64":
|
||||||
|
|
|
@ -90,6 +90,7 @@ type
|
||||||
LoadNan,
|
LoadNan,
|
||||||
LoadInf,
|
LoadInf,
|
||||||
## Operations on primitive types
|
## Operations on primitive types
|
||||||
|
GenericPrint,
|
||||||
NegInt64, # No unsigned variants (how would you negate something that has no sign?)
|
NegInt64, # No unsigned variants (how would you negate something that has no sign?)
|
||||||
NegInt32,
|
NegInt32,
|
||||||
NegInt16,
|
NegInt16,
|
||||||
|
@ -199,7 +200,7 @@ const simpleInstructions* = {Return, LoadNil,
|
||||||
SubFloat64, DivFloat64, MulFloat64,
|
SubFloat64, DivFloat64, MulFloat64,
|
||||||
AddFloat32, SubFloat32, DivFloat32,
|
AddFloat32, SubFloat32, DivFloat32,
|
||||||
MulFloat32, NegFloat32, NegFloat64,
|
MulFloat32, NegFloat32, NegFloat64,
|
||||||
LessThanInt64, SysClock64
|
LessThanInt64, SysClock64, GenericPrint,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Constant instructions are instructions that operate on the bytecode constant table
|
# Constant instructions are instructions that operate on the bytecode constant table
|
||||||
|
|
|
@ -193,7 +193,7 @@ proc runFile(f: string, interactive: bool = false, fromString: bool = false) =
|
||||||
serialized: Serialized
|
serialized: Serialized
|
||||||
tokenizer = newLexer()
|
tokenizer = newLexer()
|
||||||
parser = newParser()
|
parser = newParser()
|
||||||
compiler = newCompiler(replMode=true)
|
compiler = newCompiler()
|
||||||
debugger {.used.} = newDebugger()
|
debugger {.used.} = newDebugger()
|
||||||
serializer = newSerializer()
|
serializer = newSerializer()
|
||||||
vm = newPeonVM()
|
vm = newPeonVM()
|
||||||
|
|
Loading…
Reference in New Issue