Open thautwarm opened 3 years ago
encoding of dict
:
| keyobj1 | valueobj1 | ... | keyobjn | valueobj n|
The special encoding is for bool
and None
:
bool
: true
= 0b10000011
, false
= `0b10000010
.
None
: 0b10000000
Bytecode encoding:
no arg instrs: 1 byte instrs with arg: 1 byte for instr, 4 byte for operand(int)
see details at https://github.com/thautwarm/DianaScript/blob/012a7eba2b267f7b63405a6ebf96dfe6c4fe6b93/src/Parser.cs#L129-L136
The specification has changed a lot. The new representation is a hybrid version of bytecode and optimised flatten AST.
An AST is stored as a Ptr
: https://github.com/thautwarm/DianaScript/blob/69133de17684c2bc9293a851fa0381406a5c7581/dianascript/code_cons.py#L78
but it's not a native pointer, instead it's a (int8, int56)
. The first 8 bits are used for AST tag(indexing an array storage of AST data of specific type), the second 56 bits are used to position the data from the storage.
Bytecode specification: https://github.com/thautwarm/DianaScript/blob/master/src/Parser.cs#L161
encoding of
code
objects:encoding of
int
s,float
s: 4 byte. encoding ofstring
s: 4 byte head indicates the lengthN
, the leftN * 2
bytes for the string contents(use UTF-16 encoding).