tp_obj tp_bind(TP) { tp_obj r = TP_TYPE(TP_FNC); tp_obj self = TP_OBJ(); return tp_fnc_new(tp, r.fnc.ftype|2,r.fnc.cfnc,r.fnc.info->code, self,r.fnc.info->globals); }
int _tp_lookup_(TP,tp_obj self, tp_obj k, tp_obj *meta, int depth) { int n = _tp_dict_find(tp,self.dict.val,k); if (n != -1) { *meta = self.dict.val->items[n].val; return 1; } depth--; if (!depth) { tp_raise(0,tp_string("(tp_lookup) RuntimeError: maximum lookup depth exceeded")); } if (self.dict.dtype && self.dict.val->meta.type == TP_DICT && _tp_lookup_(tp,self.dict.val->meta,k,meta,depth)) { if (self.dict.dtype == 2 && meta->type == TP_FNC) { *meta = tp_fnc_new(tp,meta->fnc.ftype|2, meta->fnc.cfnc,meta->fnc.info->code, self,meta->fnc.info->globals); } return 1; } return 0; }
tp_obj tp_bind(TP) { tp_obj r = TP_OBJ(); tp_obj self = TP_OBJ(); return tp_fnc_new(tp,r.fnc.ftype|2,r.fnc.fval,self,r.fnc.val->globals); }
tp_obj tp_method(TP,tp_obj self,tp_obj v(TP)) { return tp_fnc_new(tp,2,v,self,tp_None); }
tp_obj tp_fnc(TP,tp_obj v(TP)) { return tp_fnc_new(tp,0,v,tp_None,tp_None); }
tp_obj tp_def(TP,void *v, tp_obj g) { return tp_fnc_new(tp,1,v,tp_None,g); }