Misc stuff, probably crashes
This commit is contained in:
@@ -196,7 +196,7 @@ GroundBytecode _GroundNewBytecode(GroundProgram* program, GroundState* state) {
|
||||
|
||||
// Copy constants into heap at their assigned offsets
|
||||
HASH_ITER(hh, state->variables, s, tmp) {
|
||||
bytecode.heap.heap[s->_offset] = Ground.Copy.Value(&s->value);
|
||||
bytecode.heap.heap[s->_offset] = Ground.New.BytecodeValue(Ground.Copy.Value(&s->value));
|
||||
if (Ground.Flags.error) return bytecode;
|
||||
}
|
||||
|
||||
|
||||
50
src/New/BytecodeValue.c
Normal file
50
src/New/BytecodeValue.c
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
GroundBytecodeValue _GroundNewBytecodeValue(GroundValue value) {
|
||||
|
||||
GroundBytecodeValue bv = {
|
||||
.type = value.type
|
||||
};
|
||||
|
||||
switch (value.type.type) {
|
||||
// Literal values, no need for compilcated copy
|
||||
case GroundType_Int: {
|
||||
bv.as.Int = value.as.Int;
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
bv.as.Double = value.as.Double;
|
||||
break;
|
||||
}
|
||||
case GroundType_Bool: {
|
||||
bv.as.Bool = value.as.Bool;
|
||||
break;
|
||||
}
|
||||
case GroundType_Char: {
|
||||
bv.as.Char = value.as.Char;
|
||||
break;
|
||||
}
|
||||
case GroundType_String: {
|
||||
bv.as.String = Ground.Copy.String(&value.as.String);
|
||||
break;
|
||||
}
|
||||
case GroundType_Function: {
|
||||
// TODO - convert to bytecode function
|
||||
break;
|
||||
}
|
||||
case GroundType_List: {
|
||||
// TODO - convert to bytecode list
|
||||
break;
|
||||
}
|
||||
case GroundType_Struct: {
|
||||
// TODO - convert to bytecode struct
|
||||
break;
|
||||
}
|
||||
case GroundType_Object: {
|
||||
// TODO - convert to bytecode object
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bv;
|
||||
}
|
||||
Reference in New Issue
Block a user