Bläddra i källkod

added rawcall

albertodemichelis 9 år sedan
förälder
incheckning
2ad9683f54
3 ändrade filer med 9 tillägg och 1 borttagningar
  1. 6 1
      squirrel/sqcompiler.cpp
  2. 1 0
      squirrel/sqcompiler.h
  3. 2 0
      squirrel/sqlexer.cpp

+ 6 - 1
squirrel/sqcompiler.cpp

@@ -859,6 +859,7 @@ public:
         case TK_TYPEOF : Lex() ;UnaryOP(_OP_TYPEOF); break;
         case TK_RESUME : Lex(); UnaryOP(_OP_RESUME); break;
         case TK_CLONE : Lex(); UnaryOP(_OP_CLONE); break;
+        case TK_RAWCALL: Lex(); Expect('('); FunctionCallArgs(true); break;
         case TK_MINUSMINUS :
         case TK_PLUSPLUS :PrefixIncDec(_token); break;
         case TK_DELETE : DeleteExpr(); break;
@@ -915,7 +916,7 @@ public:
         }
         return (!_es.donot_get || ( _es.donot_get && (_token == _SC('.') || _token == _SC('['))));
     }
-    void FunctionCallArgs()
+    void FunctionCallArgs(bool rawcall = false)
     {
         SQInteger nargs = 1;//this
          while(_token != _SC(')')) {
@@ -928,6 +929,10 @@ public:
              }
          }
          Lex();
+         if (rawcall) {
+             if (nargs < 3) Error(_SC("rawcall requires at least 2 parameters (callee and this)"));
+             nargs -= 2; //removes callee and this from count
+         }
          for(SQInteger i = 0; i < (nargs - 1); i++) _fs->PopTarget();
          SQInteger stackbase = _fs->PopTarget();
          SQInteger closure = _fs->PopTarget();

+ 1 - 0
squirrel/sqcompiler.h

@@ -70,6 +70,7 @@ struct SQVM;
 #define TK_STATIC 322
 #define TK_ENUM 323
 #define TK_CONST 324
+#define TK_RAWCALL 325
 
 
 

+ 2 - 0
squirrel/sqlexer.cpp

@@ -67,6 +67,8 @@ void SQLexer::Init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,Compile
     ADD_KEYWORD(const,TK_CONST);
     ADD_KEYWORD(__LINE__,TK___LINE__);
     ADD_KEYWORD(__FILE__,TK___FILE__);
+    ADD_KEYWORD(rawcall, TK_RAWCALL);
+    
 
     _readf = rg;
     _up = up;