Added if() statement (and internal support for for,while and do{}while())
[tpg/acess2.git] / Usermode / Libraries / libspiderscript.so_src / main.c
index e5c225c..0c3cb07 100644 (file)
@@ -13,7 +13,7 @@ extern tAST_Script    *Parse_Buffer(tSpiderVariant *Variant, char *Buffer);
 extern const int       giSpiderScript_NumExports;
 extern tSpiderFunction gaSpiderScript_Exports[];
 extern tAST_Variable *Variable_Define(tAST_BlockState *Block, int Type, const char *Name);
-extern void    Variable_SetValue(tAST_BlockState *Block, const char *Name, tSpiderObject *Value);
+extern void    Variable_SetValue(tAST_BlockState *Block, const char *Name, tSpiderValue *Value);
 
 // === CODE ===
 /**
@@ -74,13 +74,13 @@ tSpiderScript *SpiderScript_ParseFile(tSpiderVariant *Variant, const char *Filen
  * \param NArguments   Number of arguments to pass
  * \param Arguments    Arguments passed
  */
-tSpiderObject *SpiderScript_ExecuteMethod(tSpiderScript *Script,
-       const char *Function, int NArguments, tSpiderObject **Arguments)
+tSpiderValue *SpiderScript_ExecuteMethod(tSpiderScript *Script,
+       const char *Function, int NArguments, tSpiderValue **Arguments)
 {
        char    *trueName = NULL;
         int    i;
         int    bFound = 0;     // Used to keep nesting levels down
-       tSpiderObject   *ret = ERRPTR;
+       tSpiderValue    *ret = ERRPTR;
        
        // Handle namespaces
        if( Function[0] == '.' ) {
@@ -107,7 +107,8 @@ tSpiderObject *SpiderScript_ExecuteMethod(tSpiderScript *Script,
                // Execute!
                if(fcn) {
                        tAST_BlockState bs;
-                       bs.FirstVar = NULL;     //< TODO: Parameters
+                       bs.FirstVar = NULL;
+                       bs.RetVal = NULL;
                        bs.Parent = NULL;
                        bs.Script = Script;
                        {
@@ -122,6 +123,8 @@ tSpiderObject *SpiderScript_ExecuteMethod(tSpiderScript *Script,
                                }
                        }
                        ret = AST_ExecuteNode(&bs, fcn->Code);
+                       //Object_Dereference(ret);
+                       ret = bs.RetVal;
                        bFound = 1;
                }
        }

UCC git Repository :: git.ucc.asn.au