2 see copyright notice in squirrel.h
\r
4 #include "sqpcheader.h"
\r
7 #include "sqfuncproto.h"
\r
8 #include "sqclosure.h"
\r
9 #include "sqstring.h"
\r
11 SQRESULT sq_stackinfos(HSQUIRRELVM v, int level, SQStackInfos *si)
\r
13 int cssize = v->_callsstack.size();
\r
14 if (cssize > level) {
\r
15 memset(si, 0, sizeof(SQStackInfos));
\r
16 SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
\r
17 switch (type(ci._closure)) {
\r
19 SQFunctionProto *func = _funcproto(_closure(ci._closure)->_function);
\r
20 if (type(func->_name) == OT_STRING)
\r
21 si->funcname = _stringval(func->_name);
\r
22 if (type(func->_sourcename) == OT_STRING)
\r
23 si->source = _stringval(func->_sourcename);
\r
24 si->line = func->GetLine(ci._ip);
\r
27 case OT_NATIVECLOSURE:
\r
28 si->source = _SC("NATIVE");
\r
29 si->funcname = _SC("unknown");
\r
30 if(type(_nativeclosure(ci._closure)->_name) == OT_STRING)
\r
31 si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
\r
40 void SQVM::Raise_Error(const SQChar *s, ...)
\r
44 scvsprintf(_sp(rsl(scstrlen(s)+(NUMBER_MAX_CHAR*2))), s, vl);
\r
46 _lasterror = SQString::Create(_ss(this),_spval,-1);
\r
49 void SQVM::Raise_Error(SQObjectPtr &desc)
\r
54 SQString *SQVM::PrintObjVal(const SQObject &o)
\r
57 case OT_STRING: return _string(o);
\r
59 scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%d"), _integer(o));
\r
60 return SQString::Create(_ss(this), _spval);
\r
63 scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%.14g"), _float(o));
\r
64 return SQString::Create(_ss(this), _spval);
\r
67 return SQString::Create(_ss(this), GetTypeName(o));
\r
71 void SQVM::Raise_IdxError(SQObject &o)
\r
73 SQObjectPtr oval = PrintObjVal(o);
\r
74 Raise_Error(_SC("the index '%.50s' does not exist"), _stringval(oval));
\r
77 void SQVM::Raise_CompareError(const SQObject &o1, const SQObject &o2)
\r
79 SQObjectPtr oval1 = PrintObjVal(o1), oval2 = PrintObjVal(o2);
\r
80 Raise_Error(_SC("comparsion between '%.50s' and '%.50s'"), _stringval(oval1), _stringval(oval2));
\r
84 void SQVM::Raise_ParamTypeError(int nparam,int typemask,int type)
\r
86 SQObjectPtr exptypes = SQString::Create(_ss(this), _SC(""), -1);
\r
88 for(int i=0; i<16; i++)
\r
90 int mask = 0x00000001 << i;
\r
91 if(typemask & (mask)) {
\r
92 if(found>0) StringCat(exptypes,SQString::Create(_ss(this), _SC("|"), -1), exptypes);
\r
94 StringCat(exptypes,SQString::Create(_ss(this), IdType2Name((SQObjectType)mask), -1), exptypes);
\r
97 Raise_Error(_SC("parameter %d has an invalid type '%s' ; expected: '%s'"), nparam, IdType2Name((SQObjectType)type), _stringval(exptypes));
\r