about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/vm.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-10-20 r/2980 refactor(tazjin/rlox): Introduce newtypes for various indicesVincent Ambo1-3/+3
Since this code is essentially a fairly plain translation from C, it is a bit confusing to deal with the original untyped code. This is an attempt to try and clean some of it up. Change-Id: Icd21f531932e1a811c0d6dbf2e9acba61ca9c45d Reviewed-on: https://cl.tvl.fyi/c/depot/+/3734 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-10-19 r/2978 feat(tazjin/rlox): Support local variablesVincent Ambo1-0/+10
WIP Change-Id: I78fbc885faaac165c380cbd9aa98b4b64a9b8274 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3685 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-10-19 r/2977 feat(tazjin/rlox): Global variable assignmentVincent Ambo1-0/+13
Needed for example code compatibility. Change-Id: Id83210eaaad7dcfef5aa238dd3a7ec159f6935e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3684 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-03-06 r/2274 feat(tazjin/rlox): Implement global variable accessVincent Ambo1-0/+11
This also includes a fix for an issue where the identifiers of variables were pushed onto the stack, which is incorrect. Change-Id: Id89b388268efad295f29978d767aa4b33c4ded14 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2594 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-03-06 r/2273 feat(tazjin/rlox): Implement global variable definitionVincent Ambo1-0/+14
identifier_str might look a bit overengineered, but we want to reuse this bit of code and it needs a reference to the token from which to pick the identifier. The problem with this is that the token would be owned by self, but the function needs to mutate (the interner), so this implementation is the most straightforward way of acquiring and working with an immutable reference to the token before interning the identifier. Change-Id: I618ce8f789cb59b3a9c5b79a13111ea6d00b2424 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2592 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-03-03 r/2265 feat(tazjin/rlox): Implement expression statementsVincent Ambo1-4/+18
These aren't particularly useful without side effects, but one step at a time. This diverges slightly from the book, in that OpPop retains the last value it "forgot" from the stack in a special field on the interpreter. This makes it possible to return values from expression statements, which helps in cases where Lox is embedded as a scripting language (please don't do this ever) or in tests. Change-Id: Ided0bc04c6e80ddb23ba4693d61ac9e08b002d58 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2584 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-03-03 r/2264 feat(tazjin/rlox): Add support for print statementVincent Ambo1-0/+19
Change-Id: Ic3e7e722325c8784b848c0bcd573c2e51e123c40 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2583 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-03-02 r/2263 feat(tazjin/rlox): Intern all string constantsVincent Ambo1-6/+30
This is again a step closer to the book, but there are some notable differences: * Only constants encountered by the compiler are interned, all other string operations (well, concatenation) happen with heap objects. * OpReturn will always ensure that a returned string value is newly heap allocated and does not reference the interner. Change-Id: If4f04309446e01b8ff2db51094e9710d465dbc50 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2582 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-03-01 r/2258 feat(tazjin/rlox): Add initial support for stringsVincent Ambo1-1/+23
... including concatenation. This diverges significantly from the book, as I'm using std::String instead of implementing the book's whole heap object management system. It's possible that Lox in Rust actually doesn't need a GC and the ownership model works just fine. Change-Id: I374a0461d627cfafc26b2b54bfefac8b7c574d00 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2577 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-02-28 r/2256 feat(tazjin/rlox): Implement comparison operatorsVincent Ambo1-0/+3
Change-Id: I03b751db52a3bd502fb4fbda6e89cad087ccad74 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2575 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2255 feat(tazjin/rlox): Implement equality operatorVincent Ambo1-0/+6
Change-Id: I5587a11646e228c5af4dc7ca6da026bb4a2592a6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2574 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2254 refactor(tazjin/rlox): Let binary_op! work on different typesVincent Ambo1-9/+13
This makes it possible to specify the input & output types of the binary_op macro. If only one type is specified, it is assumed that the input and output types are the same. Change-Id: Idfcc9ba462db3976b69379b6693d091e1a525a3b Reviewed-on: https://cl.tvl.fyi/c/depot/+/2573 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2253 feat(tazjin/rlox): Implement unary negation operatorVincent Ambo1-0/+5
Change-Id: I9a5bd3581d4ed05371651697ec496341eb7971ae Reviewed-on: https://cl.tvl.fyi/c/depot/+/2572 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2252 feat(tazjin/rlox): Support trivial literals in bytecode compilerVincent Ambo1-0/+4
Adds support for true, false & nil. These each come with a new separate opcode and are pushed directly on the stack. Change-Id: I405b5b09496dcf99d514d3411c083e0834377167 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2571 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2251 refactor(tazjin/rlox): Represent VM values as enumsVincent Ambo1-3/+31
Introduces a new enum which represents the different types of possible values, and modifies the rest of the existing code to wrap/unwrap these enum variants correctly. Notably in the vm module, a new macro has been introduced that makes it possible to encode a type expectation and return a runtime error in case of a type mismatch. Change-Id: I325b5e31e395c62d8819ab2af6d398e1277333c0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2570 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2249 chore(tazjin/rlox): Add stack printing when 'disassemble' is onVincent Ambo1-0/+3
Change-Id: I71ae83101002f8fead3fa6cbd4cb229a2d6e3902 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2568 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-02-28 r/2246 fix(tazjin/rlox): Fix identifier order in binary_op macroVincent Ambo1-1/+1
Change-Id: I92253e875436bcb42732a157979a9d1e7ca0cd06 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2565 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-18 r/2129 refactor(tazjin/rlox): Add Interpreter trait for switching implsVincent Ambo1-6/+3
Change-Id: Iae28d64ce879014c5e5d7e145c536c1f16ad307d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2418 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-17 r/2128 feat(tazjin/rlox): Implement simple arithmetic operatorsVincent Ambo1-0/+18
Change-Id: I9873bcd281053f4e9820a5119f5992a0b8cb8cfc Reviewed-on: https://cl.tvl.fyi/c/depot/+/2417 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-01-17 r/2127 feat(tazjin/rlox): Bootstrap VM for Lox bytecodeVincent Ambo1-0/+59
Change-Id: I479e20bf2087e5c4aa20e31b364c57ed0d961bcf Reviewed-on: https://cl.tvl.fyi/c/depot/+/2416 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>