.
This commit is contained in:
105
TODO.md
105
TODO.md
@@ -1,65 +1,52 @@
|
||||
## Bytecode
|
||||
## C
|
||||
|
||||
- [x] Byte array
|
||||
- Auto-expand
|
||||
- Add/retrive byte/int/float/string
|
||||
- Should not be larger than the byte array itself
|
||||
- [x] Bytecode
|
||||
- Add/retrive all types of data
|
||||
- Keeps no memory except for caching
|
||||
- [x] Refactor bytecode code
|
||||
Decisions:
|
||||
- How to handle errors
|
||||
- How values and heap values will be represented
|
||||
- Transparency and log levels
|
||||
|
||||
Improvements:
|
||||
- [x] Fixed int type (based on opcode)
|
||||
- [x] Constant type (only floats and strings for now)
|
||||
|
||||
After some additional development:
|
||||
- [ ] Bytecode debugging info
|
||||
|
||||
|
||||
## VM
|
||||
|
||||
- [x] VM
|
||||
- [x] Code
|
||||
- [x] Simple bytecode loader
|
||||
- [x] Output bytecode format
|
||||
- [x] Value object
|
||||
- [x] Stack object
|
||||
- [x] External interface
|
||||
- [x] Code execution (except functions)
|
||||
- [x] Functions
|
||||
- [x] Print stack
|
||||
- [x] Assembler
|
||||
- [ ] VM execution
|
||||
- [x] Stack operations (nil, integer, float, string, function)
|
||||
- [x] Integer
|
||||
- [x] Float
|
||||
- [x] String
|
||||
- [x] Expressions
|
||||
- [x] Integer
|
||||
- [x] Float
|
||||
- [x] String
|
||||
- [ ] Local/global variables
|
||||
- [ ] Makefile
|
||||
- [ ] Value and stack value
|
||||
- [ ] Stack
|
||||
- [ ] Test application (C++?)
|
||||
- [ ] Heap
|
||||
- [ ] VM
|
||||
- [ ] (Lua interface) call assembler
|
||||
- [ ] (Lua) generate bytecode
|
||||
- [ ] Labels
|
||||
- [ ] Code
|
||||
- [ ] Interpret bytecode (fast)
|
||||
- [ ] Execution loop (fast)
|
||||
- [ ] VM operations
|
||||
- [ ] Expressions
|
||||
- [ ] Local variables
|
||||
- [ ] Functions
|
||||
- [ ] Constants
|
||||
- [ ] Other operations
|
||||
- [ ] Arrays
|
||||
- [ ] Iteration
|
||||
- [ ] Expressions
|
||||
- [ ] Tables
|
||||
- [ ] Iteration
|
||||
- [ ] Metatables
|
||||
- [ ] Expressions
|
||||
- [ ] With parameters
|
||||
- [ ] Control flow
|
||||
- [ ] Compilation
|
||||
- [ ] Recursion
|
||||
- [ ] Strings
|
||||
- [ ] From constants
|
||||
- [ ] Garbage collection
|
||||
- [ ] Arrays
|
||||
- [ ] Garbage collection
|
||||
- [ ] Tables
|
||||
- [ ] Garbage collection
|
||||
- [ ] Metatables
|
||||
- [ ] Iteration
|
||||
- [ ] Floats (real)
|
||||
- [ ] Globals (?)
|
||||
- [ ] Error handling
|
||||
- [ ] C++ API
|
||||
- [ ] Run native code on VM
|
||||
- [ ] Run tyche code from C++
|
||||
- [ ] C API
|
||||
- [ ] Stack trace in case of errors
|
||||
- [ ] Closure/upvalues
|
||||
- [ ] Rest of opcodes
|
||||
- [ ] Prepare for release
|
||||
- [ ] Documentation and webpage
|
||||
|
||||
After some additional development:
|
||||
- [ ] Bytecode loader
|
||||
- Combine multiple chunks
|
||||
- Resolve function ids, constant ids, etc
|
||||
- [ ] Upvalues
|
||||
## Future versions
|
||||
|
||||
- [ ] Debugging information
|
||||
- [ ] Debugger
|
||||
- [ ] Dynamic language
|
||||
- [ ] Support tools
|
||||
- [ ] Editor syntax file, etc
|
||||
- [ ] Static language
|
||||
|
||||
63
doc/OPCODES
63
doc/OPCODES
@@ -22,12 +22,13 @@ Stack operations:
|
||||
a0 c0 e0 pushi [int] Push int
|
||||
a1 c1 e1 pushc [index] Push constant
|
||||
a2 c2 e2 pushf [function] Push function id
|
||||
00 pushz Push zero (or false)
|
||||
01 pusht Push true
|
||||
02 newa Push (create) empty array
|
||||
03 newt Push (create) empty table
|
||||
04 pop
|
||||
05 dup
|
||||
00 pushn Push nil
|
||||
01 pushz Push zero (or false)
|
||||
02 pusht Push true
|
||||
03 newa Push (create) empty array
|
||||
04 newt Push (create) empty table
|
||||
05 pop
|
||||
06 dup
|
||||
|
||||
Local variables:
|
||||
a3 c3 e3 pushv [int] Push n nil values into the stack (used to init local vars)
|
||||
@@ -44,12 +45,12 @@ Function operations:
|
||||
Table and array operations:
|
||||
16 getkv Get table's value based on key (pull 1 value, push 1 value)
|
||||
17 setkv Set table's key and value (pull 2 values from stack)
|
||||
18 geta Get array's position value
|
||||
19 seta Set array's position value (pull 2 values from stack)
|
||||
1a appnd Add value to the end of array
|
||||
1b next Push the next pair into the stack (for loops)
|
||||
1c smt Set value metatable
|
||||
1d mt Get value metatable
|
||||
a8 c8 e8 geti Get array's position value
|
||||
a9 c9 e9 seti Set array's position value
|
||||
18 appnd Add value to the end of array
|
||||
19 next Push the next pair into the stack (for loops)
|
||||
1a smt Set value metatable
|
||||
1b mt Get value metatable
|
||||
|
||||
Logical/arithmetic:
|
||||
20 sum Sum top 2 values in stack
|
||||
@@ -57,24 +58,24 @@ Logical/arithmetic:
|
||||
22 mul Multiply top 2 values in stack
|
||||
23 div Float division
|
||||
24 idiv Integer division
|
||||
25 eq Equality
|
||||
26 neq Inequality
|
||||
27 lt Less than
|
||||
28 lte Less than or equals
|
||||
29 gt Greater than
|
||||
2a gte Greater than or equals
|
||||
2b and Bitwise AND
|
||||
2c or Bitwise OR
|
||||
2d xor Bitwise XOR
|
||||
2e pow Power
|
||||
2f shl Shift left
|
||||
30 shr Shift right
|
||||
31 mod Modulo
|
||||
25 mod Modulo
|
||||
26 eq Equality
|
||||
27 neq Inequality
|
||||
28 lt Less than
|
||||
29 lte Less than or equals
|
||||
2a gt Greater than
|
||||
2b gte Greater than or equals
|
||||
2c and Bitwise AND
|
||||
2d or Bitwise OR
|
||||
2e xor Bitwise XOR
|
||||
2f pow Power
|
||||
30 shl Shift left
|
||||
31 shr Shift right
|
||||
|
||||
Other value operations:
|
||||
40 len Get table, array or string size
|
||||
41 type Get type from value at the top of the stack
|
||||
b0 cast [type] Cast type to another type
|
||||
aa cast [type] Cast type to another type
|
||||
42 ver Return VM version
|
||||
|
||||
External code:
|
||||
@@ -82,12 +83,14 @@ External code:
|
||||
49 asmbl Assemble code to bytecode format
|
||||
4a load Load bytecode as function (will place function on stack)
|
||||
|
||||
Control flow:
|
||||
a8 c8 e8 bz [pc] Branch if zero
|
||||
a9 c9 e9 bnz [pc] Branch if not zero
|
||||
aa ca ea jmp [pc] Unconditional jump
|
||||
Control flow (the destination is always a 16-bit field):
|
||||
ca bz [pc] Branch if zero
|
||||
cb bnz [pc] Branch if not zero
|
||||
cc jmp [pc] Unconditional jump
|
||||
* Jumps can only happen within the same function.
|
||||
|
||||
Memory management:
|
||||
4b gc Call garbage collector
|
||||
|
||||
Error handling: (0xa0~0xaf)
|
||||
???
|
||||
|
||||
Reference in New Issue
Block a user