#include "tlang.h" extern void __node_single_free(node_t* n); tobject_t* __neg_node_exec(node_t* n,scope_t* sc) { bool freeleftifzero=true; node_t* left = n->data.single_node_node; tobject_t* l=left->execute(left,sc); tobject_t* out=NULL; tobject_type_t ltype=l->type; if(ltype == tdict) { if(dict_haskey(l->data.dict,"neg")) { kvp_t* kvp=dict_getkvp(l->data.dict,"neg"); if(kvp->value->type == texternalmethod || kvp->value->type == tinternalmethod) { list_tobject_t ls; list_create(sc->rt,&ls,0); out=tobject_call(sc->rt->globals,kvp->value,&ls); out->count++; //ensure i dont get deleted tobject_freeifzero(l); out->count--; //set me back bitch list_free(&ls); freeleftifzero = false; } } } if(ltype == tnumber) { out = tobject_create(sc->rt); out->type = tnumber; out->data.number = -(l->data.number); } if(freeleftifzero) { tobject_freeifzero(l); } if(out == NULL) { return tobject_basic(sc->rt,tnull); } return out; } node_t* node_negative_create(node_t* left) { node_t* node = (node_t*)malloc(sizeof(node_t)); node->type = negnode; node->data.single_node_node = left; node->execute = __neg_node_exec; node->free = __node_single_free; return node; }