Commit Graph

24 Commits

Author SHA1 Message Date
Luna 036e76d3a5 fix for latest zig 2019-06-30 00:01:03 -03:00
Luna 69dda36d16 add SetGlobal/SetGlobalLong opcodes
- main: split compile/runtime error messages
2019-06-03 01:41:22 -03:00
Luna 8bc220d2f8 chunk: split writing side-effects into own function
split writeConstant() into that and writeConstantRaw() for the places
where we don't want OP_CONSTANT written as well.

this caused a bug where doing `"some const string" + x` would cause an
unecessary OP_CONSTANT to be added for the x variable and would cause
the wrong result to be given.

 - main: reset stack on repl tick (?)
2019-06-03 00:55:50 -03:00
Luna 3936b4a426 main: keep a long-running vm instance for REPL
enables us to declare variables and keep them going for as long as the
REPL goes.

 - vm: remove source arg from init(), move to interpret()
2019-06-03 00:02:07 -03:00
Luna 3f2a8f3801 add object list cleaning on VM.deinit 2019-06-02 15:39:04 -03:00
Luna 589413488c move towards dynamically typed values
- remove InterpretResult as an enum, replace by error.
 - scanner: fix peekNext()
 - vm: add runtime errors, add VM.peek()
2019-06-01 23:33:53 -03:00
Luna 6b9cc575d9 add draft scanner, remove messy Token union, replace by struct 2019-06-01 16:37:24 -03:00
Luna b80cd52c50 main: readd runPrompt and runFile
- main: make run() use the VM struct instance
2019-06-01 16:17:28 -03:00
Luna a9dca436bd remove chunk running code, add draft compiler struct 2019-06-01 16:12:39 -03:00
Luna 088674bf0b vm: add dynamically-sized growing stack 2019-06-01 15:45:30 -03:00
Luna 3377d1675c vm, chunk: add binary operators 2019-06-01 15:40:18 -03:00
Luna 2822676707 vm: add negate opcode 2019-06-01 15:27:19 -03:00
Luna 456bc95138 vm: add debug flags 2019-06-01 15:01:39 -03:00
Luna dae3c259fd add basic virtual machine code 2019-06-01 14:55:11 -03:00
Luna 14fa63e1f6 finish impl for ConstantLong 2019-06-01 14:18:44 -03:00
Luna 2d33e03efb add incomplete ConstantLong instruction
- move ValueList's count to usize for ConstantLong
2019-06-01 02:06:23 -03:00
Luna ba78b39300 add constant values to the virtual machine 2019-06-01 01:46:01 -03:00
Luna c4401dc8cf moving to the virtual machine part of the book, pt 1
the java part would still fuck me up since it lies on OOP stuff
that zig doesnt provide, so i'm skipping towards the C part of the book
which will hopefully be more understandable from a zig perspective.
2019-06-01 01:20:06 -03:00
Luna 9d4c1249b4 add keyword map when scanner is initialized
- add basic identifier reading
2019-05-31 22:34:10 -03:00
Luna 69aa7b493d add number tokens 2019-05-31 22:08:41 -03:00
Luna d1db7a0bd9 add consumption of comments and strings 2019-05-31 21:46:18 -03:00
Luna 9a2c50a53e add basic tokens and a basic lexer 2019-05-31 21:23:51 -03:00
Luna 31b0fa783c add file reads and main prompt 2019-05-31 17:07:08 -03:00
Luna b3ea9637bd move to zig 2019-05-31 16:15:27 -03:00