SpiderScript - Moved header to directory, ready to remove from tree
[tpg/acess2.git] / Usermode / Libraries / libspiderscript.so_src / ast.h
index 39c23b1..a6620fc 100644 (file)
@@ -22,17 +22,21 @@ enum eAST_NodeTypes
        
        NODETYPE_BLOCK, //!< Node Block
        
+       // 2
        NODETYPE_VARIABLE,      //!< Variable
        NODETYPE_CONSTANT,      //!< Runtime Constant
        NODETYPE_STRING,        //!< String Constant
        NODETYPE_INTEGER,       //!< Integer Constant
        NODETYPE_REAL,  //!< Real Constant
+       NODETYPE_NULL,
        
+       // 8
        NODETYPE_DEFVAR,        //!< Define a variable (Variable)
        NODETYPE_SCOPE, //!< Dereference a Namespace/Class static
        NODETYPE_ELEMENT,       //!< Reference a class attribute
        NODETYPE_CAST,  //!< Cast a value to another (Uniop)
        
+       // 12
        NODETYPE_RETURN,        //!< Return from a function (reserved word)
        NODETYPE_BREAK,         //!< Break out of a loop
        NODETYPE_CONTINUE,      //!< Next loop iteration
@@ -43,17 +47,21 @@ enum eAST_NodeTypes
        NODETYPE_METHODCALL,    //!< Call a class method
        NODETYPE_CREATEOBJECT,  //!< Create an object
        
+       // 21
        NODETYPE_IF,    //!< Conditional
        NODETYPE_LOOP,  //!< Looping Construct
        
+       // 23
        NODETYPE_INDEX, //!< Index into an array
        
+       // 24
        NODETYPE_LOGICALNOT,    //!< Logical NOT operator
        NODETYPE_LOGICALAND,    //!< Logical AND operator
        NODETYPE_LOGICALOR,     //!< Logical OR operator
        NODETYPE_LOGICALXOR,    //!< Logical XOR operator
        
        NODETYPE_EQUALS,        //!< Comparison Equals
+       NODETYPE_NOTEQUALS,     //!< Comparison Not Equals
        NODETYPE_LESSTHAN,      //!< Comparison Less Than
        NODETYPE_LESSTHANEQUAL, //!< Comparison Less Than or Equal
        NODETYPE_GREATERTHAN,   //!< Comparison Greater Than
@@ -76,36 +84,11 @@ enum eAST_NodeTypes
        NODETYPE_MODULO,        //!< Modulus
 };
 
-struct sSpiderScript
-{
-       tSpiderVariant  *Variant;
-       tAST_Script     *Script;
-       char    *CurNamespace;  //!< Current namespace prefix (NULL = Root) - No trailing .
-};
-
-struct sAST_Script
-{
-       // TODO: Namespaces and Classes
-       tAST_Function   *Functions;
-       tAST_Function   *LastFunction;
-};
-
-struct sAST_Function
-{
-       tAST_Function   *Next;  //!< Next function in list
-        int    ReturnType;
-       tAST_Node       *Code;  //!< Function Code
-       tAST_Node       *Arguments;     // HACKJOB (Only NODETYPE_DEFVAR is allowed)
-       tAST_Node       *Arguments_Last;
-        int    ArgumentCount;
-       char    Name[]; //!< Function Name
-};
-
 struct sAST_Node
 {
        tAST_Node       *NextSibling;
        tAST_NodeType   Type;
-       
+
        const char      *File;
         int    Line;
        
@@ -173,8 +156,6 @@ struct sAST_Node
                
                struct {
                         int    DataType;
-                       tAST_Node       *LevelSizes;
-                       tAST_Node       *LevelSizes_Last;
                        tAST_Node       *InitialValue;
                        char    Name[];
                }       DefVar;
@@ -215,18 +196,18 @@ struct sAST_Variable
 
 // === FUNCTIONS ===
 extern tAST_Script     *AST_NewScript(void);
-extern size_t  AST_WriteScript(void *Buffer, tAST_Script *Script);
+extern size_t  AST_WriteScript(void *Buffer, tSpiderScript *Script);
 extern size_t  AST_WriteNode(void *Buffer, size_t Offset, tAST_Node *Node);
 
-extern tAST_Function   *AST_AppendFunction(tAST_Script *Script, const char *Name, int ReturnType);
-extern void    AST_AppendFunctionArg(tAST_Function *Function, tAST_Node *Arg);
-extern void    AST_SetFunctionCode(tAST_Function *Function, tAST_Node *Root);
+extern int     AST_AppendFunction(tSpiderScript *Script, const char *Name, int ReturnType, tAST_Node *FirstArg, tAST_Node *Code);
 
 extern tAST_Node       *AST_NewNop(tParser *Parser);
 
 extern tAST_Node       *AST_NewString(tParser *Parser, const char *String, int Length);
 extern tAST_Node       *AST_NewInteger(tParser *Parser, int64_t Value);
 extern tAST_Node       *AST_NewReal(tParser *Parser, double Value);
+extern tAST_Node       *AST_NewNull(tParser *Parser);
+
 extern tAST_Node       *AST_NewVariable(tParser *Parser, const char *Name);
 extern tAST_Node       *AST_NewDefineVar(tParser *Parser, int Type, const char *Name);
 extern tAST_Node       *AST_NewConstant(tParser *Parser, const char *Name);
@@ -258,5 +239,7 @@ extern void Object_Reference(tSpiderValue *Object);
 extern tSpiderValue    *AST_ExecuteNode(tAST_BlockState *Block, tAST_Node *Node);
 extern tSpiderValue    *AST_ExecuteNode_BinOp(tSpiderScript *Script, tAST_Node *Node, int Operation, tSpiderValue *Left, tSpiderValue *Right);
 extern tSpiderValue    *AST_ExecuteNode_UniOp(tSpiderScript *Script, tAST_Node *Node, int Operation, tSpiderValue *Value);
+extern tSpiderValue    *AST_ExecuteNode_Index(tSpiderScript *Script, tAST_Node *Node, tSpiderValue *Array, int Index, tSpiderValue *SaveValue);
+extern tSpiderValue    *AST_ExecuteNode_Element(tSpiderScript *Script, tAST_Node *Node, tSpiderValue *Object, const char *Element, tSpiderValue *SaveValue);
 
 #endif

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