Peon bytecode files can now be executed directly

This commit is contained in:
Mattia Giambirtone 2022-12-09 13:42:52 +01:00
parent f86925edba
commit b912d58cad
1 changed files with 35 additions and 32 deletions

View File

@ -177,6 +177,7 @@ proc runFile(f: string, fromString: bool = false, dump: bool = true, breakpoints
else:
input = f
f = "<string>"
if not f.endsWith(".pbc"):
tokens = tokenizer.lex(input, f)
if tokens.len() == 0:
return
@ -210,6 +211,8 @@ proc runFile(f: string, fromString: bool = false, dump: bool = true, breakpoints
serialized = serializer.loadFile(path)
else:
serialized = serializer.loadBytes(serializer.dumpBytes(compiled, f))
else:
serialized = serializer.loadFile(f)
when debugSerializer:
styledEcho fgCyan, "Serialization step: "
styledEcho fgBlue, "\t- Peon version: ", fgYellow, &"{serialized.version.major}.{serialized.version.minor}.{serialized.version.patch}", fgBlue, " (commit ", fgYellow, serialized.commit[0..8], fgBlue, ") on branch ", fgYellow, serialized.branch