SQInteger SQFuncState::GetConstant(const SQObject &cons) { SQObjectPtr val; if(!_table(_literals)->Get(cons,val)) { val = _nliterals; _table(_literals)->NewSlot(cons,val); _nliterals++; if(_nliterals > MAX_LITERALS) { val.Null(); Error(_SC("internal compiler error: too many literals")); } } return _integer(val); }
static SQRESULT map_single(HSQUIRRELVM vm) { SQObjectPtr closure = vm->GetAt(vm->_top-1); if ((sq_type(closure) != OT_CLOSURE) && (sq_type(closure) != OT_NATIVECLOSURE)) { vm->Raise_ParamTypeError(1, OT_CLOSURE | OT_NATIVECLOSURE, sq_type(closure)); return 0; } SQObjectPtr result; result.Null(); sq_push(vm, -2); // push self as implicit `this` sq_push(vm, -3); // push self as parameter vm->Call(closure, 2, vm->_top-2, result, SQTrue); sq_pop(vm, 1); // pop self x2 vm->Push(result); return 1; }