le objects now go to the the bytecode
This commit is contained in:
@@ -52,6 +52,60 @@ static inline GroundBytecodeFunction doFunction(GroundFunction* function) {
|
||||
return bf;
|
||||
}
|
||||
|
||||
static inline GroundBytecodeStruct doStruct(GroundStruct* gs) {
|
||||
GroundBytecodeStruct gbs = {
|
||||
.values = malloc(sizeof(GroundBytecodeValue) * 16),
|
||||
.capacity = 16,
|
||||
.size = 0
|
||||
};
|
||||
|
||||
GroundObjectField *s, *tmp;
|
||||
|
||||
HASH_ITER(hh, gs->fields, s, tmp) {
|
||||
if (gbs.size >= gbs.capacity) {
|
||||
GroundBytecodeValue* tmp = malloc(sizeof(GroundBytecodeValue) * gbs.capacity * 2);
|
||||
if (tmp == NULL) {
|
||||
Ground.Log.Error("malloc failedd in Ground.New.BytecodeValue -> doStruct");
|
||||
Ground.Flags.error = true;
|
||||
return gbs;
|
||||
}
|
||||
gbs.values = tmp;
|
||||
gbs.capacity *= 2;
|
||||
}
|
||||
gbs.values[gbs.size] = Ground.New.BytecodeValue(s->value);
|
||||
gbs.size++;
|
||||
}
|
||||
|
||||
return gbs;
|
||||
}
|
||||
|
||||
static inline GroundBytecodeObject doObject(GroundObject* go) {
|
||||
GroundBytecodeObject gbo = {
|
||||
.values = malloc(sizeof(GroundBytecodeValue) * 16),
|
||||
.capacity = 16,
|
||||
.size = 0
|
||||
};
|
||||
|
||||
GroundObjectField *s, *tmp;
|
||||
|
||||
HASH_ITER(hh, go->fields, s, tmp) {
|
||||
if (gbo.size >= gbo.capacity) {
|
||||
GroundBytecodeValue* tmp = malloc(sizeof(GroundBytecodeValue) * gbo.capacity * 2);
|
||||
if (tmp == NULL) {
|
||||
Ground.Log.Error("malloc failedd in Ground.New.BytecodeValue -> doStruct");
|
||||
Ground.Flags.error = true;
|
||||
return gbo;
|
||||
}
|
||||
gbo.values = tmp;
|
||||
gbo.capacity *= 2;
|
||||
}
|
||||
gbo.values[gbo.size] = Ground.New.BytecodeValue(s->value);
|
||||
gbo.size++;
|
||||
}
|
||||
|
||||
return gbo;
|
||||
}
|
||||
|
||||
GroundBytecodeValue _GroundNewBytecodeValue(GroundValue value) {
|
||||
|
||||
GroundBytecodeValue bv = {
|
||||
@@ -89,11 +143,11 @@ GroundBytecodeValue _GroundNewBytecodeValue(GroundValue value) {
|
||||
break;
|
||||
}
|
||||
case GroundType_Struct: {
|
||||
// TODO - convert to bytecode struct
|
||||
bv.as.Struct = doStruct(&value.as.Struct);
|
||||
break;
|
||||
}
|
||||
case GroundType_Object: {
|
||||
// TODO - convert to bytecode object
|
||||
bv.as.Object = doObject(&value.as.Object);
|
||||
break;
|
||||
}
|
||||
case GroundType_CoreType: {
|
||||
|
||||
Reference in New Issue
Block a user