#include "tlang.h" tobject_t* __const_number_exec(node_t* n,scope_t* sc) { tobject_t* obj=tobject_create(sc->rt); obj->data.number = n->data.const_number; obj->type =tnumber; return obj; } void __const_number_free(node_t* s) { } void __const_string_free(node_t* s) { string_free(s->data.const_string); } node_t* node_const_number_create(double num) { node_t* n = (node_t*)malloc(sizeof(node_t)); n->data.const_number = num; n->type = constnumbernode; n->execute = __const_number_exec; n->free = __const_number_free; return n; } tobject_t* __const_bool_exec(node_t* n,scope_t* sc) { tobject_t* obj=tobject_create(sc->rt); obj->data.boolean = n->data.const_bool; obj->type =tbool; return obj; } tobject_t* __const_string_exec(node_t* n,scope_t* sc) { tobject_t* obj=tobject_create(sc->rt); obj->data.string = string_dups(n->data.const_string); obj->type =tstring; return obj; } tobject_t* __const_char_exec(node_t* n,scope_t* sc) { tobject_t* obj=tobject_create(sc->rt); obj->data.chr = n->data.const_char; obj->type =tchar; return obj; } node_t* node_const_string_create(string_t* s) { node_t* n = (node_t*)malloc(sizeof(node_t)); n->data.const_string = string_dups(s); n->type = conststringnode; n->execute = __const_string_exec; n->free = __const_string_free; return n; } node_t* node_const_char_create(char c) { node_t* n = (node_t*)malloc(sizeof(node_t)); n->data.const_char = c; n->type = constcharnode; n->execute = __const_char_exec; n->free = __const_number_free; return n; } tobject_t* __const_object_exec(node_t* n,scope_t* sc) { return n->data.const_obj; } node_t* node_const_object_create(tobject_t* o) { node_t* n = (node_t*)malloc(sizeof(node_t)); n->data.const_obj = o; n->type = constobjectnode; n->execute = __const_object_exec; n->free = __const_number_free; return n; } node_t* node_const_bool_create(bool c) { node_t* n = (node_t*)malloc(sizeof(node_t)); n->data.const_bool = c; n->type = constboolnode; n->execute = __const_bool_exec; n->free = __const_number_free; return n; } tobject_t* __const_undef_exec(node_t* n,scope_t* s) { return tobject_basic(s->rt,tundef); } node_t* node_const_undef_create() { node_t* n = (node_t*)malloc(sizeof(node_t)); n->type = constundefnode; n->execute = __const_undef_exec; n->free = __const_number_free; return n; } tobject_t* __const_null_exec(node_t* n,scope_t* s) { return tobject_basic(s->rt,tnull); } node_t* node_const_null_create() { node_t* n = (node_t*)malloc(sizeof(node_t)); n->type = constnullnode; n->execute = __const_null_exec; n->free = __const_number_free; return n; }