extern tSpiderFunction *gpExports_First;
// === PROTOTYPES ===
+// - Values
void Object_Dereference(tSpiderValue *Object);
void Object_Reference(tSpiderValue *Object);
tSpiderValue *SpiderScript_CreateInteger(uint64_t Value);
int SpiderScript_IsValueTrue(tSpiderValue *Value);
void SpiderScript_FreeValue(tSpiderValue *Value);
char *SpiderScript_DumpValue(tSpiderValue *Value);
-
+// - Node Execution
tSpiderValue *AST_ExecuteNode(tAST_BlockState *Block, tAST_Node *Node);
tSpiderValue *AST_ExecuteNode_BinOp(tAST_BlockState *Block, tAST_Node *Node, int Operation, tSpiderValue *Left, tSpiderValue *Right);
tSpiderValue *AST_ExecuteNode_UniOp(tAST_BlockState *Block, tAST_Node *Node, int Operation, tSpiderValue *Value);
-
+// - Variables
tAST_Variable *Variable_Define(tAST_BlockState *Block, int Type, const char *Name, tSpiderValue *Value);
int Variable_SetValue(tAST_BlockState *Block, tAST_Node *VarNode, tSpiderValue *Value);
tSpiderValue *Variable_GetValue(tAST_BlockState *Block, tAST_Node *VarNode);
void Variable_Destroy(tAST_Variable *Variable);
-
+// - Errors
void AST_RuntimeMessage(tAST_Node *Node, const char *Type, const char *Format, ...);
void AST_RuntimeError(tAST_Node *Node, const char *Format, ...);
return Source;
}
+ // Debug
#if 0
{
printf("Casting %i ", Source->Type);
}
#endif
+ // Object casts
#if 0
if( Source->Type == SS_DATATYPE_OBJECT )
{
case SS_DATATYPE_UNDEF:
case SS_DATATYPE_ARRAY:
case SS_DATATYPE_OPAQUE:
+ AST_RuntimeError(NULL, "Invalid cast to %i", Type);
+ return ERRPTR;
case SS_DATATYPE_OBJECT:
+ // TODO:
AST_RuntimeError(NULL, "Invalid cast to %i", Type);
return ERRPTR;
else {
tmpobj = NULL;
}
+ // TODO: Handle arrays
ret = NULL;
if( Variable_Define(Block, Node->DefVar.DataType, Node->DefVar.Name, tmpobj) == ERRPTR )
ret = ERRPTR;
// TODO: Implement runtime constants
case NODETYPE_CONSTANT:
- // TODO: Scan namespace for function
+ // TODO: Scan namespace for constant name
AST_RuntimeError(Node, "TODO - Runtime Constants");
ret = ERRPTR;
break;
ret = Object_ExecuteMethod(Value->Object, fcnname, );
if( ret != ERRPTR )
return ret;
- // Fall through and try casting (which will usually fail)
}
}
#endif
break;
// TODO: Support python style 'i = %i' % i ?
// Might do it via a function call
+ // Implement it via % with an array, but getting past the cast will be fun
// case NODETYPE_MODULUS:
+// break;
+ // TODO: Support string repititions
+// case NODETYPE_MULTIPLY:
// break;
default: