[Avida-SVN] r2455 - development/source/script

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Thu Mar 13 10:36:19 PDT 2008


Author: brysonda
Date: 2008-03-13 13:36:19 -0400 (Thu, 13 Mar 2008)
New Revision: 2455

Modified:
   development/source/script/ASTree.cc
   development/source/script/ASTree.h
   development/source/script/AvidaScript.cc
   development/source/script/AvidaScript.h
   development/source/script/cDirectInterpretASTVisitor.cc
   development/source/script/cDirectInterpretASTVisitor.h
   development/source/script/cSemanticASTVisitor.cc
   development/source/script/cSemanticASTVisitor.h
   development/source/script/cSymbolTable.cc
   development/source/script/cSymbolTable.h
Log:
AS:
Add basic support for more detailed type info, as will be necessary for object references.

Modified: development/source/script/ASTree.cc
===================================================================
--- development/source/script/ASTree.cc	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/ASTree.cc	2008-03-13 17:36:19 UTC (rev 2455)
@@ -27,6 +27,9 @@
 #include "cASTVisitor.h"
 
 
+const sASTypeInfo cASTNode::s_invalid_type(AS_TYPE_INVALID);
+
+
 void cASTAssignment::Accept(cASTVisitor& visitor) { visitor.VisitAssignment(*this); }
 void cASTArgumentList::Accept(cASTVisitor& visitor) { visitor.VisitArgumentList(*this); }
 void cASTObjectAssignment::Accept(cASTVisitor& visitor) { visitor.VisitObjectAssignment(*this); }

Modified: development/source/script/ASTree.h
===================================================================
--- development/source/script/ASTree.h	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/ASTree.h	2008-03-13 17:36:19 UTC (rev 2455)
@@ -70,6 +70,9 @@
 class cASTNode
 {
 private:
+  static const sASTypeInfo s_invalid_type;
+  
+  
   cASTNode(); // @not_implemented
   cASTNode(const cASTNode&); // @not_implemented
   cASTNode& operator=(const cASTNode&); // @not_implmented
@@ -81,7 +84,7 @@
 public:
   virtual ~cASTNode() { ; }
   
-  virtual ASType_t GetType() const { return AS_TYPE_INVALID; }
+  virtual const sASTypeInfo& GetType() const { return s_invalid_type; }
 
   inline const cASFilePosition& GetFilePosition() const { return m_file_pos; }
   
@@ -320,17 +323,17 @@
 class cASTFunctionDefinition : public cASTNode
 {
 private:
-  ASType_t m_type;
+  sASTypeInfo m_type;
   cString m_name;
   cASTVariableDefinitionList* m_args;
   cASTNode* m_code;
   
 public:
-  cASTFunctionDefinition(const cASFilePosition& fp, ASType_t type, const cString& name, cASTVariableDefinitionList* args)
+  cASTFunctionDefinition(const cASFilePosition& fp, const sASTypeInfo& type, const cString& name, cASTVariableDefinitionList* args)
     : cASTNode(fp), m_type(type), m_name(name), m_args(args), m_code(NULL) { ; }
   ~cASTFunctionDefinition();
   
-  inline ASType_t GetType() const { return m_type; }
+  inline const sASTypeInfo& GetType() const { return m_type; }
   inline const cString& GetName() { return m_name; }
   inline cASTVariableDefinitionList* GetArguments() { return m_args; }
   inline void ClearArguments() { m_args = NULL; }
@@ -345,18 +348,18 @@
 class cASTVariableDefinition : public cASTNode
 {
 private:
-  ASType_t m_type;
+  sASTypeInfo m_type;
   cString m_name;
   cASTNode* m_assign;
   cASTArgumentList* m_dims;
   int m_id;
   
 public:
-  cASTVariableDefinition(const cASFilePosition& fp, ASType_t type, const cString& name)
+  cASTVariableDefinition(const cASFilePosition& fp, const sASTypeInfo& type, const cString& name)
     : cASTNode(fp), m_type(type), m_name(name), m_assign(NULL), m_dims(NULL), m_id(-1) { ; }
   ~cASTVariableDefinition() { delete m_assign; delete m_dims; }
   
-  inline ASType_t GetType() const { return m_type; }
+  inline const sASTypeInfo& GetType() const { return m_type; }
   inline const cString& GetName() { return m_name; }
   inline void SetAssignmentExpression(cASTNode* assign) { delete m_assign; m_assign = assign; }
   inline cASTNode* GetAssignmentExpression() { return m_assign; }
@@ -400,8 +403,8 @@
   ASToken_t m_op;
   cASTNode* m_left;
   cASTNode* m_right;
-  ASType_t m_type;
-  ASType_t m_compare_type;
+  sASTypeInfo m_type;
+  sASTypeInfo m_compare_type;
   
 public:
   cASTExpressionBinary(const cASFilePosition& fp, ASToken_t op, cASTNode* l, cASTNode* r)
@@ -414,11 +417,11 @@
   inline void SetRight(cASTNode* right) { m_right = right; }
   inline cASTNode* GetRight() { return m_right; }
 
-  ASType_t GetType() const { return m_type; }
-  inline void SetType(ASType_t type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }
+  inline void SetType(const sASTypeInfo& type) { m_type = type; }
 
-  inline ASType_t GetCompareType() const { return m_compare_type; }
-  inline void SetCompareType(ASType_t type) { m_compare_type = type; }
+  inline const sASTypeInfo& GetCompareType() const { return m_compare_type; }
+  inline void SetCompareType(const sASTypeInfo& type) { m_compare_type = type; }
 
   void Accept(cASTVisitor& visitor);
 };
@@ -429,7 +432,7 @@
 private:
   ASToken_t m_op;
   cASTNode* m_expr;
-  ASType_t m_type;
+  sASTypeInfo m_type;
   
 public:
   cASTExpressionUnary(const cASFilePosition& fp, ASToken_t op, cASTNode* e)
@@ -440,8 +443,8 @@
   inline void SetExpression(cASTNode* expr) { m_expr = expr; }
   inline cASTNode* GetExpression() { return m_expr; }
   
-  ASType_t GetType() const { return m_type; }
-  inline void SetType(ASType_t type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }
+  inline void SetType(const sASTypeInfo& type) { m_type = type; }
   
   void Accept(cASTVisitor& visitor);
 };
@@ -454,7 +457,7 @@
 {
 private:
   cASTArgumentList* m_args;
-  ASType_t m_type;
+  sASTypeInfo m_type;
   ASBuiltIn_t m_builtin;
   cASTVariableReference* m_vr;
   
@@ -467,8 +470,8 @@
   void SetArguments(cASTArgumentList* args) { delete m_args; m_args = args; }
   cASTArgumentList* GetArguments() { return m_args; }
   
-  ASType_t GetType() const { return m_type; }
-  inline void SetType(ASType_t type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }
+  inline void SetType(const sASTypeInfo& type) { m_type = type; }
   
   cASTVariableReference* GetVariableReference() { return m_vr; }
   void SetVariableReference(cASTVariableReference* vr);
@@ -484,7 +487,7 @@
 private:
   cString m_name;
   cASTArgumentList* m_args;
-  ASType_t m_type;
+  sASTypeInfo m_type;
   int m_id;
   bool m_global;
   
@@ -498,8 +501,8 @@
   void SetArguments(cASTArgumentList* args) { delete m_args; m_args = args; }
   cASTArgumentList* GetArguments() { return m_args; }
   
-  ASType_t GetType() const { return m_type; }
-  inline void SetType(ASType_t type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }
+  inline void SetType(const sASTypeInfo& type) { m_type = type; }
   
   inline int GetFuncID() const { return m_id; }
   inline bool IsFuncGlobal() const { return m_global; }
@@ -514,13 +517,13 @@
 class cASTLiteral : public cASTNode
 {
 private:
-  ASType_t m_type;
+  sASTypeInfo m_type;
   cString m_value;
   
 public:
-  cASTLiteral(const cASFilePosition& fp, ASType_t t, const cString& v) : cASTNode(fp), m_type(t), m_value(v) { ; }
+  cASTLiteral(const cASFilePosition& fp, const sASTypeInfo& t, const cString& v) : cASTNode(fp), m_type(t), m_value(v) { ; }
   
-  ASType_t GetType() const { return m_type; }
+  const sASTypeInfo& GetType() const { return m_type; }
   inline const cString& GetValue() { return m_value; }
   
   void Accept(cASTVisitor& visitor);
@@ -532,16 +535,17 @@
 private:
   cASTArgumentList* m_values;
   bool m_is_matrix;
+  sASTypeInfo m_type;
   
 public:
   cASTLiteralArray(const cASFilePosition& fp, cASTArgumentList* v, bool is_mat)
-    : cASTNode(fp), m_values(v), m_is_matrix(is_mat) { ; }
+    : cASTNode(fp), m_values(v), m_is_matrix(is_mat), m_type(m_is_matrix ? AS_TYPE_MATRIX : AS_TYPE_ARRAY) { ; }
   ~cASTLiteralArray() { delete m_values; }  
   
   inline cASTArgumentList* GetValues() { return m_values; }
   inline bool IsMatrix() const { return m_is_matrix; }
   
-  ASType_t GetType() const { return m_is_matrix ? AS_TYPE_MATRIX : AS_TYPE_ARRAY; }
+  const sASTypeInfo& GetType() const { return m_type; }
   
   void Accept(cASTVisitor& visitor);
 };
@@ -553,7 +557,7 @@
   cASTNode* m_object;
   cString m_name;
   cASTArgumentList* m_args;
-  ASType_t m_type;
+  sASTypeInfo m_type;
   
 public:
   cASTObjectCall(const cASFilePosition& fp, cASTNode* object, const cString& name)
@@ -566,8 +570,8 @@
   void SetArguments(cASTArgumentList* args) { delete m_args; m_args = args; }
   cASTArgumentList* GetArguments() { return m_args; }
   
-  ASType_t GetType() const { return m_type; }
-  inline void SetType(ASType_t type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }
+  inline void SetType(const sASTypeInfo& type) { m_type = type; }
   
   
   bool HasArguments() const { return (m_args); }
@@ -581,16 +585,17 @@
 private:
   cASTNode* m_object;
   cString m_name;
+  sASTypeInfo m_type;
   
 public:
   cASTObjectReference(const cASFilePosition& fp, cASTNode* object, const cString& name)
-    : cASTNode(fp), m_object(object), m_name(name) { ; }
+    : cASTNode(fp), m_object(object), m_name(name), m_type(AS_TYPE_OBJECT_REF) { ; }
   ~cASTObjectReference() { delete m_object; }
   
   cASTNode* GetObject() { return m_object; }
   inline const cString& GetName() { return m_name; }
   
-  ASType_t GetType() const { return AS_TYPE_OBJECT_REF; }
+  const sASTypeInfo& GetType() const { return m_type; }
   
   void Accept(cASTVisitor& visitor);
 };
@@ -600,7 +605,7 @@
 {
 private:
   cString m_name;
-  ASType_t m_type;
+  sASTypeInfo m_type;
   int m_id;
   bool m_global;
   
@@ -610,8 +615,8 @@
   
   inline const cString& GetName() { return m_name; }
   
-  ASType_t GetType() const { return m_type; }
-  inline void SetType(ASType_t type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }
+  inline void SetType(const sASTypeInfo& type) { m_type = type; }
   
   inline int GetVarID() const { return m_id; }
   inline bool IsVarGlobal() const { return m_global; }
@@ -628,13 +633,13 @@
     cString name;
     int var_id;
     bool global;
-    ASType_t type;
+    sASTypeInfo type;
     
     inline sUnpackNode() : name(""), var_id(-1), global(false), type(AS_TYPE_INVALID) { ; }
     inline sUnpackNode(const cString& in_name) : name(in_name), var_id(-1), global(false), type(AS_TYPE_INVALID) { ; }
     inline sUnpackNode(const sUnpackNode& un) : name(un.name), var_id(un.var_id), global(un.global), type(un.type) { ; }
     
-    inline void SetVar(int in_vi, bool in_g, ASType_t in_t) { var_id = in_vi; global = in_g; type = in_t; }
+    inline void SetVar(int in_vi, bool in_g, const sASTypeInfo& in_t) { var_id = in_vi; global = in_g; type = in_t; }
   };
   tManagedPointerArray<sUnpackNode> m_nodes;
   bool m_last_wild;
@@ -650,8 +655,8 @@
   inline const cString& GetVarName(int idx) const { return m_nodes[idx].name; }
   inline int GetVarID(int idx) const { return m_nodes[idx].var_id; }
   inline bool IsVarGlobal(int idx) const { return m_nodes[idx].global; }
-  inline ASType_t GetVarType(int idx) const { return m_nodes[idx].type; }
-  inline void SetVar(int idx, int var_id, bool global, ASType_t type) { m_nodes[idx].SetVar(var_id, global, type); }
+  inline const sASTypeInfo& GetVarType(int idx) const { return m_nodes[idx].type; }
+  inline void SetVar(int idx, int var_id, bool global, const sASTypeInfo& type) { m_nodes[idx].SetVar(var_id, global, type); }
   
   inline bool IsLastNamed() const { return m_last_named; }
   inline bool IsLastWild() const { return m_last_wild; }

Modified: development/source/script/AvidaScript.cc
===================================================================
--- development/source/script/AvidaScript.cc	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/AvidaScript.cc	2008-03-13 17:36:19 UTC (rev 2455)
@@ -67,9 +67,9 @@
   }      
 }
 
-const char* AvidaScript::mapType(ASType_t type)
+const char* AvidaScript::mapType(const sASTypeInfo& type)
 {
-  switch (type) {
+  switch (type.type) {
     case AS_TYPE_ARRAY:       return "array";
     case AS_TYPE_BOOL:        return "bool";
     case AS_TYPE_CHAR:        return "char";
@@ -77,7 +77,7 @@
     case AS_TYPE_INT:         return "int";
     case AS_TYPE_MATRIX:      return "matrix";
     case AS_TYPE_STRING:      return "string";
-    case AS_TYPE_OBJECT_REF:  return "object";
+    case AS_TYPE_OBJECT_REF:  return type.info;
     case AS_TYPE_RUNTIME:     return "runtime";
     case AS_TYPE_VOID:        return "void";
       

Modified: development/source/script/AvidaScript.h
===================================================================
--- development/source/script/AvidaScript.h	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/AvidaScript.h	2008-03-13 17:36:19 UTC (rev 2455)
@@ -25,6 +25,8 @@
 #ifndef AvidaScript_h
 #define AvidaScript_h
 
+#include "cString.h"
+
 typedef enum eASTokens {
   AS_TOKEN_SUPPRESS = 1,
   AS_TOKEN_ENDL,
@@ -200,11 +202,21 @@
   AS_TYPE_INVALID
 } ASType_t;
 
+struct sASTypeInfo {
+  ASType_t type;
+  cString info;
+  
+  sASTypeInfo(ASType_t in_type) : type(in_type) { ; }
+  
+  bool operator==(const sASTypeInfo& ot) const { return (type == ot.type && info == ot.info); }
+  bool operator!=(const sASTypeInfo& ot) const { return (type != ot.type || info != ot.info); }
+};
 
+
 namespace AvidaScript {
   const char* mapBuiltIn(ASBuiltIn_t builtin);  
   const char* mapToken(ASToken_t token);
-  const char* mapType(ASType_t type);
+  const char* mapType(const sASTypeInfo& type);
 };
 
 #endif

Modified: development/source/script/cDirectInterpretASTVisitor.cc
===================================================================
--- development/source/script/cDirectInterpretASTVisitor.cc	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/cDirectInterpretASTVisitor.cc	2008-03-13 17:36:19 UTC (rev 2455)
@@ -45,13 +45,14 @@
 #define TOKEN(x) AS_TOKEN_ ## x
 #define TYPE(x) AS_TYPE_ ## x
 
+
 cDirectInterpretASTVisitor::cDirectInterpretASTVisitor(cSymbolTable* global_symtbl)
-  : m_global_symtbl(global_symtbl), m_cur_symtbl(global_symtbl), m_call_stack(0, 2048), m_sp(0)
+  : m_global_symtbl(global_symtbl), m_cur_symtbl(global_symtbl), m_rtype(TYPE(INVALID)), m_call_stack(0, 2048), m_sp(0)
   , m_has_returned(false), m_obj_assign(false)
 {
   m_call_stack.Resize(m_global_symtbl->GetNumVariables());
   for (int i = 0; i < m_global_symtbl->GetNumVariables(); i++) {
-    switch (m_global_symtbl->GetVariableType(i)) {
+    switch (m_global_symtbl->GetVariableType(i).type) {
       case TYPE(ARRAY):       m_call_stack[i].as_array = new cLocalArray; break;
       case TYPE(BOOL):        m_call_stack[i].as_bool = false; break;
       case TYPE(CHAR):        m_call_stack[i].as_char = 0; break;
@@ -68,7 +69,7 @@
 cDirectInterpretASTVisitor::~cDirectInterpretASTVisitor()
 {
   for (int i = 0; i < m_global_symtbl->GetNumVariables(); i++) {
-    switch (m_global_symtbl->GetVariableType(i)) {
+    switch (m_global_symtbl->GetVariableType(i).type) {
       case TYPE(ARRAY):       m_call_stack[i].as_array->RemoveReference(); break;
       case TYPE(BOOL):        break;
       case TYPE(CHAR):        break;
@@ -102,7 +103,7 @@
   
   node.GetExpression()->Accept(*this);
   
-  switch (symtbl->GetVariableType(var_id)) {
+  switch (symtbl->GetVariableType(var_id).type) {
     case TYPE(BOOL):        m_call_stack[sp + var_id].as_bool = asBool(m_rtype, m_rvalue, node); break;
     case TYPE(CHAR):        m_call_stack[sp + var_id].as_char = asChar(m_rtype, m_rvalue, node); break;
     case TYPE(FLOAT):       m_call_stack[sp + var_id].as_float = asFloat(m_rtype, m_rvalue, node); break;
@@ -144,7 +145,7 @@
   
   node.GetExpression()->Accept(*this);
   
-  if (!obj->Set(m_rtype, m_rvalue)) INTERPRET_ERROR(OBJECT_ASSIGN_FAIL);
+  if (!obj->Set(m_rtype.type, m_rvalue)) INTERPRET_ERROR(OBJECT_ASSIGN_FAIL);
 }
 
 
@@ -171,7 +172,7 @@
 void cDirectInterpretASTVisitor::VisitForeachBlock(cASTForeachBlock& node)
 {
   int var_id = node.GetVariable()->GetVarID();
-  ASType_t var_type = node.GetVariable()->GetType();
+  sASTypeInfo var_type = node.GetVariable()->GetType();
   
   node.GetValues()->Accept(*this);
   cLocalArray* arr = m_rvalue.as_array;
@@ -180,7 +181,7 @@
   for (int i = 0; i < arr->GetSize(); i++) {
     // Set the variable value for this iteration
     const sAggregateValue& val = arr->Get(i);
-    switch (var_type) {
+    switch (var_type.type) {
       case TYPE(BOOL):        m_call_stack[var_idx].as_bool = asBool(val.type, val.value, node); break;
       case TYPE(CHAR):        m_call_stack[var_idx].as_char = asChar(val.type, val.value, node); break;
       case TYPE(FLOAT):       m_call_stack[var_idx].as_float = asFloat(val.type, val.value, node); break;
@@ -260,7 +261,7 @@
     
     node.GetAssignmentExpression()->Accept(*this);
     
-    switch (node.GetType()) {
+    switch (node.GetType().type) {
       case TYPE(ARRAY):       m_call_stack[m_sp + var_id].as_array = asArray(m_rtype, m_rvalue, node); break;
       case TYPE(BOOL):        m_call_stack[m_sp + var_id].as_bool = asBool(m_rtype, m_rvalue, node); break;
       case TYPE(CHAR):        m_call_stack[m_sp + var_id].as_char = asChar(m_rtype, m_rvalue, node); break;
@@ -306,10 +307,10 @@
   // Process the left and right side expressions
   node.GetLeft()->Accept(*this);
   uAnyType lval = m_rvalue;
-  ASType_t ltype = m_rtype;
+  sASTypeInfo ltype = m_rtype;
   node.GetRight()->Accept(*this);
   uAnyType rval = m_rvalue;
-  ASType_t rtype = m_rtype;
+  sASTypeInfo rtype = m_rtype;
   
   
   switch (node.GetOperator()) {
@@ -344,7 +345,7 @@
         if (n < 0) INTERPRET_ERROR(INVALID_ARRAY_SIZE);
         
         cLocalArray* arr = new cLocalArray(n);
-        for (int i = 0; i < n; i++) arr->Set(i, ltype, lval);
+        for (int i = 0; i < n; i++) arr->Set(i, ltype.type, lval);
         
         m_rvalue.as_array = arr;
         m_rtype = TYPE(ARRAY);
@@ -364,10 +365,10 @@
     case TOKEN(OP_BIT_AND):
     case TOKEN(OP_BIT_OR):
       {
-        ASType_t rettype = node.GetType();
+        sASTypeInfo rettype = node.GetType();
         
         // Determine the operation type if it is a runtime decision
-        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype, rtype);
+        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
 
         if (rettype == TYPE(CHAR)) {
           int l = asChar(ltype, lval, node);
@@ -388,10 +389,10 @@
     case TOKEN(OP_EQ):
     case TOKEN(OP_NEQ):
       {
-        ASType_t comptype = node.GetCompareType();
+        ASType_t comptype = node.GetCompareType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (comptype == TYPE(RUNTIME)) comptype = getRuntimeType(ltype, rtype);
+        if (comptype == TYPE(RUNTIME)) comptype = getRuntimeType(ltype.type, rtype.type);
              
         switch (comptype) {
           case TYPE(BOOL):
@@ -443,10 +444,10 @@
     case TOKEN(OP_LT):
     case TOKEN(OP_GT):
       {
-        ASType_t comptype = node.GetCompareType();
+        ASType_t comptype = node.GetCompareType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (comptype == TYPE(RUNTIME)) comptype = getRuntimeType(ltype, rtype);
+        if (comptype == TYPE(RUNTIME)) comptype = getRuntimeType(ltype.type, rtype.type);
              
         switch (comptype) {
           case TYPE(CHAR):
@@ -490,10 +491,10 @@
       
     case TOKEN(OP_ADD):
       {
-        ASType_t rettype = node.GetType();
+        ASType_t rettype = node.GetType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype, rtype, true);
+        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type, true);
              
         switch (rettype) {
           case TYPE(CHAR):  m_rvalue.as_char = asChar(ltype, lval, node) + asChar(rtype, rval, node); break;
@@ -533,10 +534,10 @@
 
     case TOKEN(OP_SUB):
       {
-        ASType_t rettype = node.GetType();
+        ASType_t rettype = node.GetType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype, rtype);
+        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
              
         switch (rettype) {
           case TYPE(CHAR):  m_rvalue.as_char = asChar(ltype, lval, node) - asChar(rtype, rval, node); break;
@@ -556,10 +557,10 @@
 
     case TOKEN(OP_MUL):
       {
-        ASType_t rettype = node.GetType();
+        ASType_t rettype = node.GetType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype, rtype);
+        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
              
         switch (rettype) {
           case TYPE(CHAR):  m_rvalue.as_char = asChar(ltype, lval, node) * asChar(rtype, rval, node); break;
@@ -579,10 +580,10 @@
 
     case TOKEN(OP_DIV):
       {
-        ASType_t rettype = node.GetType();
+        ASType_t rettype = node.GetType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype, rtype);
+        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
              
         switch (rettype) {
           case TYPE(CHAR):
@@ -617,10 +618,10 @@
 
     case TOKEN(OP_MOD):
       {
-        ASType_t rettype = node.GetType();
+        ASType_t rettype = node.GetType().type;
         
         // Determine the operation type if it is a runtime decision
-        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype, rtype);
+        if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
              
         switch (rettype) {
           case TYPE(CHAR):
@@ -688,7 +689,7 @@
   
   switch (node.GetOperator()) {
     case TOKEN(OP_BIT_NOT):
-      switch (m_rtype) {
+      switch (m_rtype.type) {
         case TYPE(CHAR):
           m_rvalue.as_char = ~m_rvalue.as_char;
           break;
@@ -707,7 +708,7 @@
       break;
     
     case TOKEN(OP_SUB):
-      switch (m_rtype) {
+      switch (m_rtype.type) {
         case TYPE(CHAR):
           m_rvalue.as_char = -m_rvalue.as_char;
           break;
@@ -819,7 +820,7 @@
   int sp = m_sp + prev_symtbl->GetNumVariables();
   m_call_stack.Resize(m_call_stack.GetSize() + func_symtbl->GetNumVariables());
   for (int i = 0; i < func_symtbl->GetNumVariables(); i++) {
-    switch (func_symtbl->GetVariableType(i)) {
+    switch (func_symtbl->GetVariableType(i).type) {
       case TYPE(ARRAY):       m_call_stack[sp + i].as_array = new cLocalArray; break;
       case TYPE(BOOL):        m_call_stack[sp + i].as_bool = false; break;
       case TYPE(CHAR):        m_call_stack[sp + i].as_char = 0; break;
@@ -843,7 +844,7 @@
     
     int var_id = arg_def->GetVarID();
 
-    switch (m_cur_symtbl->GetVariableType(var_id)) {
+    switch (m_cur_symtbl->GetVariableType(var_id).type) {
       case TYPE(ARRAY):       m_call_stack[sp + var_id].as_array = asArray(m_rtype, m_rvalue, node); break;
       case TYPE(BOOL):        m_call_stack[sp + var_id].as_bool = asBool(m_rtype, m_rvalue, node); break;
       case TYPE(CHAR):        m_call_stack[sp + var_id].as_char = asChar(m_rtype, m_rvalue, node); break;
@@ -869,7 +870,7 @@
   func_src_symtbl->GetFunctionDefinition(fun_id)->Accept(*this);
   
   // Handle function return value
-  switch (node.GetType()) {
+  switch (node.GetType().type) {
     case TYPE(ARRAY):       m_rvalue.as_array = asArray(m_rtype, m_rvalue, node); break;
     case TYPE(BOOL):        m_rvalue.as_bool = asBool(m_rtype, m_rvalue, node); break;
     case TYPE(CHAR):        m_rvalue.as_char = asChar(m_rtype, m_rvalue, node); break;
@@ -887,7 +888,7 @@
 
   // Clean up variables in the current scope
   for (int i = 0; i < func_symtbl->GetNumVariables(); i++) {
-    switch (func_symtbl->GetVariableType(i)) {
+    switch (func_symtbl->GetVariableType(i).type) {
       case TYPE(ARRAY):       m_call_stack[sp + i].as_array->RemoveReference(); break;
       case TYPE(BOOL):        break;
       case TYPE(CHAR):        break;
@@ -910,7 +911,7 @@
 
 void cDirectInterpretASTVisitor::VisitLiteral(cASTLiteral& node)
 {
-  switch (node.GetType()) {
+  switch (node.GetType().type) {
     case TYPE(BOOL):
       if (node.GetValue() == "true") m_rvalue.as_bool = true;
       else m_rvalue.as_bool = false;
@@ -952,7 +953,7 @@
     int i = 0;
     while ((val = it.Next())) {
       val->Accept(*this);
-      arr->Set(i++, m_rtype, m_rvalue);
+      arr->Set(i++, m_rtype.type, m_rvalue);
     }
     
     m_rvalue.as_array = arr;    
@@ -979,7 +980,7 @@
   int sp = node.IsVarGlobal() ? 0 : m_sp;
   
   if (m_obj_assign) {
-    switch (node.GetType()) {
+    switch (node.GetType().type) {
       case TYPE(ARRAY):       m_rvalue.as_ref = new cArrayVarRef(m_call_stack[sp + var_id]); break;
       case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - assignment
       case TYPE(MATRIX):      INTERPRET_ERROR(INTERNAL); // @TODO - assignment
@@ -990,7 +991,7 @@
     }
     m_rtype = TYPE(OBJECT_REF);
   } else {
-    switch (node.GetType()) {
+    switch (node.GetType().type) {
       case TYPE(ARRAY):       m_rvalue.as_array = m_call_stack[sp + var_id].as_array->GetReference(); break;
       case TYPE(BOOL):        m_rvalue.as_bool = m_call_stack[sp + var_id].as_bool; break;
       case TYPE(CHAR):        m_rvalue.as_char = m_call_stack[sp + var_id].as_char; break;
@@ -1020,12 +1021,12 @@
   
   // Unpack the values up to the last non-wild value
   for (int i = 0; i < unpack_size; i++) {
-    ASType_t var_type = (node.IsVarGlobal(i) ? m_global_symtbl : m_cur_symtbl)->GetVariableType(node.GetVarID(i));
+    sASTypeInfo var_type = (node.IsVarGlobal(i) ? m_global_symtbl : m_cur_symtbl)->GetVariableType(node.GetVarID(i));
     int var_idx = (node.IsVarGlobal(i) ? 0 : m_sp) + node.GetVarID(i);
     
     // Set the variable value for this iteration
     const sAggregateValue& val = arr->Get(i);
-    switch (var_type) {
+    switch (var_type.type) {
       case TYPE(BOOL):        m_call_stack[var_idx].as_bool = asBool(val.type, val.value, node); break;
       case TYPE(CHAR):        m_call_stack[var_idx].as_char = asChar(val.type, val.value, node); break;
       case TYPE(FLOAT):       m_call_stack[var_idx].as_float = asFloat(val.type, val.value, node); break;
@@ -1068,9 +1069,9 @@
   arr->RemoveReference();
 }
 
-cDirectInterpretASTVisitor::cLocalArray* cDirectInterpretASTVisitor::asArray(ASType_t type, uAnyType value, cASTNode& node)
+cDirectInterpretASTVisitor::cLocalArray* cDirectInterpretASTVisitor::asArray(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
-  switch (type) {
+  switch (type.type) {
     case TYPE(ARRAY):
       return value.as_array;
 
@@ -1097,9 +1098,9 @@
   return false;
 }
 
-bool cDirectInterpretASTVisitor::asBool(ASType_t type, uAnyType value, cASTNode& node)
+bool cDirectInterpretASTVisitor::asBool(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
-  switch (type) {
+  switch (type.type) {
     case TYPE(ARRAY):
       {
         bool rval = (value.as_array->GetSize());
@@ -1137,9 +1138,9 @@
 }
 
 
-char cDirectInterpretASTVisitor::asChar(ASType_t type, uAnyType value, cASTNode& node)
+char cDirectInterpretASTVisitor::asChar(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
-  switch (type) {
+  switch (type.type) {
     case TYPE(BOOL):
       return (value.as_bool) ? 1 : 0;
     case TYPE(CHAR):
@@ -1155,9 +1156,9 @@
 }
 
 
-int cDirectInterpretASTVisitor::asInt(ASType_t type, uAnyType value, cASTNode& node)
+int cDirectInterpretASTVisitor::asInt(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
-  switch (type) {
+  switch (type.type) {
     case TYPE(BOOL):
       return (value.as_bool) ? 1 : 0;
     case TYPE(CHAR):
@@ -1181,9 +1182,9 @@
 }
 
 
-double cDirectInterpretASTVisitor::asFloat(ASType_t type, uAnyType value, cASTNode& node)
+double cDirectInterpretASTVisitor::asFloat(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
-  switch (type) {
+  switch (type.type) {
     case TYPE(BOOL):
       return (value.as_bool) ? 1.0 : 0.0;
     case TYPE(CHAR):
@@ -1207,9 +1208,9 @@
 }
 
 
-cString* cDirectInterpretASTVisitor::asString(ASType_t type, uAnyType value, cASTNode& node)
+cString* cDirectInterpretASTVisitor::asString(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
-  switch (type) {
+  switch (type.type) {
     case TYPE(BOOL):        return new cString(cStringUtil::Convert(value.as_bool));
     case TYPE(CHAR):        return new cString(value.as_char);
     case TYPE(INT):         return new cString(cStringUtil::Convert(value.as_int));
@@ -1413,9 +1414,9 @@
 }
 
 
-ASType_t cDirectInterpretASTVisitor::cObjectIndexRef::GetType(int idx)
+sASTypeInfo cDirectInterpretASTVisitor::cObjectIndexRef::GetType(int idx)
 {
-  if (m_obj->GetType(m_idx) != TYPE(ARRAY)) return TYPE(INVALID);
+  if (m_obj->GetType(m_idx).type != TYPE(ARRAY)) return TYPE(INVALID);
   
   cLocalArray* arr = m_obj->Get(m_idx).as_array;
   if (idx < 0 || idx >= arr->GetSize()) return TYPE(INVALID);

Modified: development/source/script/cDirectInterpretASTVisitor.h
===================================================================
--- development/source/script/cDirectInterpretASTVisitor.h	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/cDirectInterpretASTVisitor.h	2008-03-13 17:36:19 UTC (rev 2455)
@@ -57,7 +57,7 @@
   cSymbolTable* m_cur_symtbl;
   
   uAnyType m_rvalue;
-  ASType_t m_rtype;
+  sASTypeInfo m_rtype;
   
   tSmartArray<uAnyType> m_call_stack;
   int m_sp;
@@ -106,12 +106,12 @@
 
 private:
   // --------  Internal Utility Methods  --------
-  cLocalArray* asArray(ASType_t type, uAnyType value, cASTNode& node);
-  bool asBool(ASType_t type, uAnyType value, cASTNode& node);
-  char asChar(ASType_t type, uAnyType value, cASTNode& node);
-  int asInt(ASType_t type, uAnyType value, cASTNode& node);
-  double asFloat(ASType_t type, uAnyType value, cASTNode& node);
-  cString* asString(ASType_t type, uAnyType value, cASTNode& node);
+  cLocalArray* asArray(const sASTypeInfo& type, uAnyType value, cASTNode& node);
+  bool asBool(const sASTypeInfo& type, uAnyType value, cASTNode& node);
+  char asChar(const sASTypeInfo& type, uAnyType value, cASTNode& node);
+  int asInt(const sASTypeInfo& type, uAnyType value, cASTNode& node);
+  double asFloat(const sASTypeInfo& type, uAnyType value, cASTNode& node);
+  cString* asString(const sASTypeInfo& type, uAnyType value, cASTNode& node);
 
   ASType_t getRuntimeType(ASType_t ltype, ASType_t rtype, bool allow_str = false);
   
@@ -165,8 +165,8 @@
     virtual ~cObjectRef() { ; }
 
     virtual bool IsWritable() = 0;
-    virtual ASType_t GetType() = 0;
-    virtual ASType_t GetType(int idx) = 0;
+    virtual sASTypeInfo GetType() = 0;
+    virtual sASTypeInfo GetType(int idx) = 0;
     
     virtual uAnyType Get() = 0;
     virtual uAnyType Get(int idx) = 0;
@@ -184,9 +184,8 @@
     ~cArrayVarRef() { ; }
 
     bool IsWritable() { return true; }
-    ASType_t GetType() { return AS_TYPE_ARRAY; }
-    ASType_t GetType(int idx)
-    { if (idx < 0 || idx >= m_var.as_array->GetSize()) return AS_TYPE_INVALID; else return m_var.as_array->Get(idx).type; }
+    sASTypeInfo GetType() { return AS_TYPE_ARRAY; }
+    inline sASTypeInfo GetType(int idx);
     
     uAnyType Get() { return m_var; }
     uAnyType Get(int idx) { assert(idx > 0 && idx < m_var.as_array->GetSize()); return m_var.as_array->Get(idx).value; }
@@ -205,8 +204,8 @@
     ~cObjectIndexRef() { delete m_obj; }
     
     bool IsWritable() { return m_obj->IsWritable(); }
-    ASType_t GetType() { return m_obj->GetType(m_idx); }
-    ASType_t GetType(int idx);
+    sASTypeInfo GetType() { return m_obj->GetType(m_idx); }
+    sASTypeInfo GetType(int idx);
     
     uAnyType Get() { return m_obj->Get(m_idx); }
     uAnyType Get(int idx);
@@ -229,6 +228,15 @@
   copy(arr1->m_storage.GetSize(), arr2->m_storage);
 }
 
+inline sASTypeInfo cDirectInterpretASTVisitor::cArrayVarRef::GetType(int idx)
+{
+  if (idx < 0 || idx >= m_var.as_array->GetSize()) return AS_TYPE_INVALID;
+  else {
+    ASType_t type = m_var.as_array->Get(idx).type;
+    if (type == AS_TYPE_OBJECT_REF) return m_var.as_array->Get(idx).value.as_ref->GetType();
+    else return type;
+  }
+}
 
 
 #endif

Modified: development/source/script/cSemanticASTVisitor.cc
===================================================================
--- development/source/script/cSemanticASTVisitor.cc	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/cSemanticASTVisitor.cc	2008-03-13 17:36:19 UTC (rev 2455)
@@ -41,6 +41,7 @@
 
 #define TOKEN(x) AS_TOKEN_ ## x
 #define TYPE(x) AS_TYPE_ ## x
+#define TYPEINFO(x) sASTypeInfo(AS_TYPE_ ## x)
 
 namespace AvidaScript {
   static const bool valid_cast[11][11] = {
@@ -61,8 +62,9 @@
 
 
 #define checkCast(in_type, out_type) { \
-  if (valid_cast[in_type][out_type]) { \
-    if ((in_type == TYPE(FLOAT) && out_type == TYPE(INT)) || (in_type == TYPE(INT) && out_type == TYPE(CHAR))) \
+  if (valid_cast[in_type.type][out_type.type]) { \
+    if ((in_type.type == TYPE(FLOAT) && out_type.type == TYPE(INT)) || \
+        (in_type.type == TYPE(INT) && out_type.type == TYPE(CHAR))) \
       SEMANTIC_WARNING(LOSS_OF_PRECISION, mapType(in_type), mapType(out_type)); \
   } else { \
     SEMANTIC_ERROR(CANNOT_CAST, mapType(in_type), mapType(out_type)); \
@@ -108,7 +110,7 @@
   node.GetTarget()->Accept(*this);
   m_obj_assign = false;
   
-  if (node.GetTarget()->GetType() != TYPE(OBJECT_REF)) SEMANTIC_ERROR(INVALID_ASSIGNMENT_TARGET);
+  if (node.GetTarget()->GetType().type != TYPE(OBJECT_REF)) SEMANTIC_ERROR(INVALID_ASSIGNMENT_TARGET);
   
   node.GetExpression()->Accept(*this);
 }
@@ -161,7 +163,7 @@
 {
   // Check values and make sure we can process it as an array
   node.GetValues()->Accept(*this);
-  checkCast(node.GetValues()->GetType(), TYPE(ARRAY));
+  checkCast(node.GetValues()->GetType(), TYPEINFO(ARRAY));
   
   m_cur_symtbl->PushScope();
   
@@ -183,7 +185,7 @@
 {
   // Check main condition and code
   node.GetCondition()->Accept(*this);
-  checkCast(node.GetCondition()->GetType(), TYPE(BOOL));
+  checkCast(node.GetCondition()->GetType(), TYPEINFO(BOOL));
   
   node.GetCode()->Accept(*this);
   
@@ -192,7 +194,7 @@
   cASTIfBlock::cElseIf* ei = NULL;
   while ((ei = it.Next())) {
     ei->GetCondition()->Accept(*this);
-    checkCast(ei->GetCondition()->GetType(), TYPE(BOOL));
+    checkCast(ei->GetCondition()->GetType(), TYPEINFO(BOOL));
     ei->GetCode()->Accept(*this);
   }
   
@@ -204,7 +206,7 @@
 void cSemanticASTVisitor::VisitWhileBlock(cASTWhileBlock& node)
 {
   node.GetCondition()->Accept(*this);
-  checkCast(node.GetCondition()->GetType(), TYPE(BOOL));
+  checkCast(node.GetCondition()->GetType(), TYPEINFO(BOOL));
   node.GetCode()->Accept(*this);
 }
 
@@ -286,7 +288,7 @@
       m_top_level = true;
       node.GetCode()->Accept(*this);
       
-      if (node.GetType() != TYPE(VOID) && !m_cur_symtbl->ScopeHasReturn()) SEMANTIC_WARNING(NO_RETURN);
+      if (node.GetType().type != TYPE(VOID) && !m_cur_symtbl->ScopeHasReturn()) SEMANTIC_WARNING(NO_RETURN);
       
       // Move the code to the symbol table entry
       m_parent_scope->SetFunctionDefinition(fun_id, node.GetCode());
@@ -319,20 +321,20 @@
   // Process matrix/array dimensions
   cASTArgumentList* al = node.GetDimensions();
   if (al) {
-    if (node.GetType() == TYPE(MATRIX) || node.GetType() == TYPE(ARRAY)) {
+    if (node.GetType().type == TYPE(MATRIX) || node.GetType().type == TYPE(ARRAY)) {
       // Check individual arguments for validity
       tListIterator<cASTNode> it = al->Iterator();
       cASTNode* alnode = NULL;
       while ((alnode = it.Next())) {
         alnode->Accept(*this);
-        checkCast(alnode->GetType(), TYPE(INT));
+        checkCast(alnode->GetType(), TYPEINFO(INT));
       }
       
       // If empty, warn...
       if (al->GetSize() == 0) SEMANTIC_WARNING(NO_DIMENSIONS);
       
       // If dimensions exceed type limits
-      if ((node.GetType() == TYPE(ARRAY) && al->GetSize() > 1) || (node.GetType() == TYPE(MATRIX) && al->GetSize() > 2)) {
+      if ((node.GetType().type == TYPE(ARRAY) && al->GetSize() > 1) || (node.GetType().type == TYPE(MATRIX) && al->GetSize() > 2)) {
         SEMANTIC_ERROR(TOO_MANY_ARGUMENTS);
         SEMANTIC_ERROR(VARIABLE_DIMENSIONS_INVALID, (const char*)node.GetName(), mapType(node.GetType()));
       }
@@ -365,17 +367,17 @@
   
   switch (node.GetOperator()) {
     case TOKEN(IDX_OPEN):
-      checkCast(node.GetLeft()->GetType(), TYPE(ARRAY));
-      checkCast(node.GetRight()->GetType(), TYPE(INT));
-      node.SetType(m_obj_assign ? TYPE(OBJECT_REF) : TYPE(RUNTIME));
+      checkCast(node.GetLeft()->GetType(), TYPEINFO(ARRAY));
+      checkCast(node.GetRight()->GetType(), TYPEINFO(INT));
+      node.SetType(m_obj_assign ? TYPEINFO(OBJECT_REF) : TYPEINFO(RUNTIME));
       break;
     case TOKEN(ARR_RANGE):
-      checkCast(node.GetLeft()->GetType(), TYPE(INT));
-      checkCast(node.GetRight()->GetType(), TYPE(INT));
+      checkCast(node.GetLeft()->GetType(), TYPEINFO(INT));
+      checkCast(node.GetRight()->GetType(), TYPEINFO(INT));
       node.SetType(TYPE(ARRAY));
       break;
     case TOKEN(ARR_EXPAN):
-      checkCast(node.GetRight()->GetType(), TYPE(INT));
+      checkCast(node.GetRight()->GetType(), TYPEINFO(INT));
       node.SetType(TYPE(ARRAY));
       break;
       
@@ -398,18 +400,18 @@
       
     case TOKEN(OP_LOGIC_AND):
     case TOKEN(OP_LOGIC_OR):
-      checkCast(node.GetLeft()->GetType(), TYPE(BOOL));
-      checkCast(node.GetRight()->GetType(), TYPE(BOOL));
+      checkCast(node.GetLeft()->GetType(), TYPEINFO(BOOL));
+      checkCast(node.GetRight()->GetType(), TYPEINFO(BOOL));
       node.SetType(TYPE(BOOL));
       break;
     
     case TOKEN(OP_EQ):
     case TOKEN(OP_NEQ):
       if ((validArithmeticType(node.GetLeft()->GetType(), true) && validArithmeticType(node.GetRight()->GetType(), true)) ||
-          (node.GetLeft()->GetType() == TYPE(STRING) && node.GetRight()->GetType() == TYPE(STRING))) {
+          (node.GetLeft()->GetType().type == TYPE(STRING) && node.GetRight()->GetType().type == TYPE(STRING))) {
         node.SetCompareType(getConsensusType(node.GetLeft()->GetType(), node.GetRight()->GetType()));
         node.SetType(TYPE(BOOL));
-      } else if (node.GetLeft()->GetType() == TYPE(BOOL) || node.GetRight()->GetType() == TYPE(BOOL)) {
+      } else if (node.GetLeft()->GetType().type == TYPE(BOOL) || node.GetRight()->GetType().type == TYPE(BOOL)) {
         node.SetCompareType(TYPE(BOOL));
         node.SetType(TYPE(BOOL));
       } else {
@@ -431,8 +433,8 @@
       
     case TOKEN(OP_ADD):
       if ((validArithmeticType(node.GetLeft()->GetType(), true) && validArithmeticType(node.GetRight()->GetType(), true)) ||
-          (node.GetLeft()->GetType() == TYPE(STRING) && node.GetRight()->GetType() == TYPE(STRING)) ||
-          (node.GetLeft()->GetType() == TYPE(ARRAY) && node.GetRight()->GetType() == TYPE(ARRAY))) {
+          (node.GetLeft()->GetType().type == TYPE(STRING) && node.GetRight()->GetType().type == TYPE(STRING)) ||
+          (node.GetLeft()->GetType().type == TYPE(ARRAY) && node.GetRight()->GetType().type == TYPE(ARRAY))) {
         node.SetType(getConsensusType(node.GetLeft()->GetType(), node.GetRight()->GetType()));
       } else {
         SEMANTIC_ERROR(UNDEFINED_TYPE_OP, mapToken(node.GetOperator()), mapType(node.GetLeft()->GetType()));
@@ -465,7 +467,7 @@
       break;
   }
   
-  if (node.GetType() == TYPE(INVALID) && m_success == true) {
+  if (node.GetType().type == TYPE(INVALID) && m_success == true) {
     SEMANTIC_ERROR(INTERNAL);
   }
 }
@@ -484,11 +486,11 @@
       }
       break;
     case TOKEN(OP_LOGIC_NOT):
-      checkCast(node.GetExpression()->GetType(), TYPE(BOOL));
+      checkCast(node.GetExpression()->GetType(), TYPEINFO(BOOL));
       node.SetType(TYPE(BOOL));
       break;
     case TOKEN(OP_SUB):
-      switch (node.GetExpression()->GetType()) {
+      switch (node.GetExpression()->GetType().type) {
         case TYPE(CHAR):
         case TYPE(FLOAT):
         case TYPE(INT):
@@ -520,7 +522,7 @@
       else {
         cASTNode* argn = args->Iterator().Next();
         argn->Accept(*this);
-        checkCast(argn->GetType(), TYPE(BOOL));
+        checkCast(argn->GetType(), TYPEINFO(BOOL));
         node.SetType(TYPE(BOOL));
       }
       break;
@@ -530,7 +532,7 @@
       else {
         cASTNode* argn = args->Iterator().Next();
         argn->Accept(*this);
-        checkCast(argn->GetType(), TYPE(CHAR));
+        checkCast(argn->GetType(), TYPEINFO(CHAR));
         node.SetType(TYPE(CHAR));
       }
       break;
@@ -540,7 +542,7 @@
       else {
         cASTNode* argn = args->Iterator().Next();
         argn->Accept(*this);
-        checkCast(argn->GetType(), TYPE(INT));
+        checkCast(argn->GetType(), TYPEINFO(INT));
         node.SetType(TYPE(INT));
       }
       break;
@@ -550,7 +552,7 @@
       else {
         cASTNode* argn = args->Iterator().Next();
         argn->Accept(*this);
-        checkCast(argn->GetType(), TYPE(FLOAT));
+        checkCast(argn->GetType(), TYPEINFO(FLOAT));
         node.SetType(TYPE(FLOAT));
       }
       break;
@@ -560,7 +562,7 @@
       else {
         cASTNode* argn = args->Iterator().Next();
         argn->Accept(*this);
-        checkCast(argn->GetType(), TYPE(STRING));
+        checkCast(argn->GetType(), TYPEINFO(STRING));
         node.SetType(TYPE(STRING));
       }
       break;
@@ -570,7 +572,7 @@
       else {
         cASTNode* argn = args->Iterator().Next();
         argn->Accept(*this);
-        checkCast(argn->GetType(), TYPE(ARRAY));
+        checkCast(argn->GetType(), TYPEINFO(ARRAY));
         node.SetType(TYPE(INT));
       }
       break;
@@ -580,23 +582,23 @@
       else {
         node.GetVariableReference()->Accept(*this);
         
-        if (node.GetVariableReference()->GetType() == TYPE(ARRAY)) {
+        if (node.GetVariableReference()->GetType().type == TYPE(ARRAY)) {
           if (args->GetSize() == 1) {
             cASTNode* argn = args->Iterator().Next();
             argn->Accept(*this);
-            checkCast(argn->GetType(), TYPE(INT));
+            checkCast(argn->GetType(), TYPEINFO(INT));
           } else {
             ERR_BUILTIN_MISMATCH;
           }
-        } else if (node.GetVariableReference()->GetType() == TYPE(MATRIX)) {
+        } else if (node.GetVariableReference()->GetType().type == TYPE(MATRIX)) {
           if (args->GetSize() == 2) {
             tListIterator<cASTNode> it = args->Iterator();
             cASTNode* argn = it.Next();
             argn->Accept(*this);
-            checkCast(argn->GetType(), TYPE(INT));
+            checkCast(argn->GetType(), TYPEINFO(INT));
             argn = it.Next();
             argn->Accept(*this);
-            checkCast(argn->GetType(), TYPE(INT));
+            checkCast(argn->GetType(), TYPEINFO(INT));
           } else {
             ERR_BUILTIN_MISMATCH;
           }          
@@ -641,8 +643,8 @@
         while ((an = cit.Next())) {
           an->Accept(*this);
           
-          ASType_t in_type = an->GetType();
-          ASType_t out_type = sit.Next()->GetType();
+          ASType_t in_type = an->GetType().type;
+          ASType_t out_type = sit.Next()->GetType().type;
           if (valid_cast[in_type][out_type]) { 
             if ((in_type == TYPE(FLOAT) && out_type == TYPE(INT)) || (in_type == TYPE(INT) && out_type == TYPE(CHAR))) 
               SEMANTIC_WARNING(LOSS_OF_PRECISION, mapType(in_type), mapType(out_type)); 
@@ -736,7 +738,7 @@
   node.GetExpression()->Accept(*this);
   
   // Make sure that the expression can be used as an array
-  checkCast(node.GetExpression()->GetType(), TYPE(ARRAY));
+  checkCast(node.GetExpression()->GetType(), TYPEINFO(ARRAY));
   
   // Check each named variable and determine if it exists
   for (int var = 0; var < node.GetSize(); var++) {
@@ -768,13 +770,13 @@
 
 
 
-ASType_t cSemanticASTVisitor::getConsensusType(ASType_t left, ASType_t right)
+ASType_t cSemanticASTVisitor::getConsensusType(const sASTypeInfo& left, const sASTypeInfo& right)
 {
-  switch (left) {
+  switch (left.type) {
     case TYPE(ARRAY):
       return TYPE(ARRAY);
     case TYPE(BOOL):
-      switch (right) {
+      switch (right.type) {
         case TYPE(ARRAY):
         case TYPE(BOOL):
         case TYPE(CHAR):
@@ -791,7 +793,7 @@
       }
       break;
     case TYPE(CHAR):
-      switch (right) {
+      switch (right.type) {
         case TYPE(ARRAY):     return TYPE(ARRAY);
         case TYPE(BOOL):      return TYPE(CHAR);
         case TYPE(CHAR):      return TYPE(CHAR);
@@ -804,7 +806,7 @@
       }
       break;
     case TYPE(FLOAT):
-      switch (right) {
+      switch (right.type) {
         case TYPE(ARRAY):     return TYPE(ARRAY);
         case TYPE(BOOL):      return TYPE(FLOAT);
         case TYPE(CHAR):      return TYPE(FLOAT);
@@ -817,7 +819,7 @@
       }
       break;
     case TYPE(INT):
-      switch (right) {
+      switch (right.type) {
         case TYPE(ARRAY):     return TYPE(ARRAY);
         case TYPE(BOOL):      return TYPE(INT);
         case TYPE(CHAR):      return TYPE(INT);
@@ -843,8 +845,8 @@
   return TYPE(INVALID);
 }
 
-inline bool cSemanticASTVisitor::validArithmeticType(ASType_t type, bool allow_matrix) const {
-  switch (type) {
+inline bool cSemanticASTVisitor::validArithmeticType(const sASTypeInfo& type, bool allow_matrix) const {
+  switch (type.type) {
     case TYPE(MATRIX):
       return allow_matrix;
       
@@ -860,8 +862,8 @@
 }
 
 
-inline bool cSemanticASTVisitor::validBitwiseType(ASType_t type) const {
-  switch (type) {
+inline bool cSemanticASTVisitor::validBitwiseType(const sASTypeInfo& type) const {
+  switch (type.type) {
     case TYPE(RUNTIME):
     case TYPE(INT):
     case TYPE(CHAR):

Modified: development/source/script/cSemanticASTVisitor.h
===================================================================
--- development/source/script/cSemanticASTVisitor.h	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/cSemanticASTVisitor.h	2008-03-13 17:36:19 UTC (rev 2455)
@@ -110,9 +110,9 @@
 
 private:
   // --------  Internal Utility Methods  --------
-  ASType_t getConsensusType(ASType_t t1, ASType_t t2);
-  inline bool validArithmeticType(ASType_t type, bool allow_matrix = false) const;
-  inline bool validBitwiseType(ASType_t type) const;
+  ASType_t getConsensusType(const sASTypeInfo& t1, const sASTypeInfo& t2);
+  inline bool validArithmeticType(const sASTypeInfo& type, bool allow_matrix = false) const;
+  inline bool validBitwiseType(const sASTypeInfo& type) const;
   
   inline bool lookupVariable(const cString& name, int& var_id, bool& global) const;
   inline bool lookupFunction(const cString& name, int& fun_id, bool& global) const;

Modified: development/source/script/cSymbolTable.cc
===================================================================
--- development/source/script/cSymbolTable.cc	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/cSymbolTable.cc	2008-03-13 17:36:19 UTC (rev 2455)
@@ -31,7 +31,7 @@
   for (int i = 0; i < m_fun_tbl.GetSize(); i++) delete m_fun_tbl[i];
 }
 
-bool cSymbolTable::AddVariable(const cString& name, ASType_t type, int& var_id)
+bool cSymbolTable::AddVariable(const cString& name, const sASTypeInfo& type, int& var_id)
 {
   bool found = LookupVariable(name, var_id);
   int shadow = var_id;
@@ -50,7 +50,7 @@
   return true;
 }
 
-bool cSymbolTable::AddFunction(const cString& name, ASType_t type, int& fun_id)
+bool cSymbolTable::AddFunction(const cString& name, const sASTypeInfo& type, int& fun_id)
 {
   int shadow = fun_id;
   bool found = LookupFunction(name, fun_id);

Modified: development/source/script/cSymbolTable.h
===================================================================
--- development/source/script/cSymbolTable.h	2008-03-12 03:08:08 UTC (rev 2454)
+++ development/source/script/cSymbolTable.h	2008-03-13 17:36:19 UTC (rev 2455)
@@ -66,8 +66,8 @@
 
   
   // --------  Add/Lookup Methods  --------
-  bool AddVariable(const cString& name, ASType_t type, int& var_id);
-  bool AddFunction(const cString& name, ASType_t type, int& fun_id);
+  bool AddVariable(const cString& name, const sASTypeInfo& type, int& var_id);
+  bool AddFunction(const cString& name, const sASTypeInfo& type, int& fun_id);
   
   bool LookupVariable(const cString& name, int& var_id) { return m_sym_dict.Find(name, var_id); }
   bool LookupFunction(const cString& name, int& fun_id) { return m_fun_dict.Find(name, fun_id); }
@@ -89,12 +89,12 @@
   
 
   // --------  Variable Property Methods  --------
-  inline ASType_t GetVariableType(int var_id) const { return m_sym_tbl[var_id]->type; }
+  inline const sASTypeInfo& GetVariableType(int var_id) const { return m_sym_tbl[var_id]->type; }
 
 
   // --------  Function Property Methods  --------
   inline const cString& GetFunctionName(int fun_id) const { return m_fun_tbl[fun_id]->name; }
-  inline ASType_t GetFunctionRType(int fun_id) const { return m_fun_tbl[fun_id]->type; }
+  inline const sASTypeInfo& GetFunctionRType(int fun_id) const { return m_fun_tbl[fun_id]->type; }
   inline cSymbolTable* GetFunctionSymbolTable(int fun_id) { return m_fun_tbl[fun_id]->symtbl; }
   inline cASTVariableDefinitionList* GetFunctionSignature(int fun_id) { return m_fun_tbl[fun_id]->signature; }
   inline cASTNode* GetFunctionDefinition(int fun_id) { return m_fun_tbl[fun_id]->code; }
@@ -142,20 +142,20 @@
   struct sSymbolEntry
   {
     cString name;
-    ASType_t type;
+    sASTypeInfo type;
     
     int scope;
     int shadow;
     int deactivate;
     
-    sSymbolEntry(const cString& in_name, ASType_t in_type, int in_scope)
+    sSymbolEntry(const cString& in_name, const sASTypeInfo& in_type, int in_scope)
       : name(in_name), type(in_type), scope(in_scope), shadow(-1), deactivate(0) { ; }
   };
   
   struct sFunctionEntry
   {
     cString name;
-    ASType_t type;
+    sASTypeInfo type;
     cASTVariableDefinitionList* signature;
     cSymbolTable* symtbl;
     cASTNode* code;
@@ -164,7 +164,7 @@
     int shadow;
     int deactivate;
     
-    sFunctionEntry(const cString& in_name, ASType_t in_type, int in_scope)
+    sFunctionEntry(const cString& in_name, const sASTypeInfo& in_type, int in_scope)
       : name(in_name), type(in_type), signature(NULL), symtbl(NULL), code(NULL), scope(in_scope), shadow(-1)
       , deactivate(0) { ; }
     ~sFunctionEntry() { delete signature; delete symtbl; delete code; }




More information about the Avida-cvs mailing list