Implementation for TracingHeap-Requirements for Objects
This commit is contained in:
parent
d7bfe97210
commit
43f0ed0250
5 changed files with 143 additions and 5 deletions
|
@ -33,14 +33,49 @@ const BuiltinFunction standard_builtin_functions[] = {
|
|||
BuiltinFunction_Print,
|
||||
};
|
||||
|
||||
static TracingHeapDataDestructor heap_destructors[] = {
|
||||
[HEAPDATAKIND_OBJECT] = (TracingHeapDataDestructor) Object_Destroy,
|
||||
};
|
||||
static void* heap_destructor_args[] = {
|
||||
[HEAPDATAKIND_OBJECT] = NULL,
|
||||
};
|
||||
static TracingHeapSizeQuery heap_size_queries[] = {
|
||||
[HEAPDATAKIND_OBJECT] = (TracingHeapSizeQuery) Object_SizeQuery,
|
||||
};
|
||||
static void* heap_size_queries_args[] = {
|
||||
[HEAPDATAKIND_OBJECT] = NULL,
|
||||
};
|
||||
static TracingHeapTraceData heap_trace_data[] = {
|
||||
[HEAPDATAKIND_OBJECT] = (TracingHeapTraceData) Object_ReferenceTrace,
|
||||
};
|
||||
static void* heap_trace_data_args[] = {
|
||||
[HEAPDATAKIND_OBJECT] = NULL,
|
||||
};
|
||||
|
||||
static void _Interpreter_WriteHeapConfig(TracingHeap* heap)
|
||||
{
|
||||
heap->config = (TracingHeapConfig) {
|
||||
.destructor = heap_destructors,
|
||||
.destructor_context = heap_destructor_args,
|
||||
.size_query = heap_size_queries,
|
||||
.size_query_context = heap_size_queries_args,
|
||||
.trace_data = heap_trace_data,
|
||||
.trace_context = heap_trace_data_args,
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int Interpreter_Create(Interpreter* self, DynamicArray* tokens)
|
||||
{
|
||||
if (TracingHeap_Create(&self->heap, NULL)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (DynamicArray_Create(&self->call_frames, sizeof(CallFrame), 16, NULL)) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
_Interpreter_WriteHeapConfig(&self->heap);
|
||||
if (TracingHeap_Create(&self->heap, NULL)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
self->tokens = tokens;
|
||||
|
||||
self->builtin_names = standard_builtin_names;
|
||||
|
@ -512,8 +547,8 @@ int Interpreter_ExecuteNext(Interpreter* self, size_t stop_token)
|
|||
if (construct_code) {
|
||||
return construct_code;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TOKENTYPE_PIPE:
|
||||
case TOKENTYPE_SEMICOLON:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue