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

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sat Mar 8 14:14:02 PST 2008


Author: brysonda
Date: 2008-03-08 17:14:02 -0500 (Sat, 08 Mar 2008)
New Revision: 2440

Modified:
   development/source/script/ASTree.cc
   development/source/script/cASTVisitor.h
   development/source/script/cDirectInterpretASTVisitor.cc
   development/source/script/cDirectInterpretASTVisitor.h
   development/source/script/cDumpASTVisitor.cc
   development/source/script/cDumpASTVisitor.h
   development/source/script/cParser.cc
   development/source/script/cSemanticASTVisitor.cc
   development/source/script/cSemanticASTVisitor.h
   development/source/script/cSymbolTable.h
Log:
AS:
Adjust visitors to use appropriate method naming convention.
Clean up class definitions some.
Begin implementing interpreter array handling.

Modified: development/source/script/ASTree.cc
===================================================================
--- development/source/script/ASTree.cc	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/ASTree.cc	2008-03-08 22:14:02 UTC (rev 2440)
@@ -27,30 +27,30 @@
 #include "cASTVisitor.h"
 
 
-void cASTAssignment::Accept(cASTVisitor& visitor) { visitor.visitAssignment(*this); }
+void cASTAssignment::Accept(cASTVisitor& visitor) { visitor.VisitAssignment(*this); }
 
-void cASTReturnStatement::Accept(cASTVisitor& visitor) { visitor.visitReturnStatement(*this); }
-void cASTStatementList::Accept(cASTVisitor& visitor) { visitor.visitStatementList(*this); }
+void cASTReturnStatement::Accept(cASTVisitor& visitor) { visitor.VisitReturnStatement(*this); }
+void cASTStatementList::Accept(cASTVisitor& visitor) { visitor.VisitStatementList(*this); }
 
-void cASTForeachBlock::Accept(cASTVisitor& visitor) { visitor.visitForeachBlock(*this); }
-void cASTIfBlock::Accept(cASTVisitor& visitor) { visitor.visitIfBlock(*this); }
-void cASTWhileBlock::Accept(cASTVisitor& visitor) { visitor.visitWhileBlock(*this); }
+void cASTForeachBlock::Accept(cASTVisitor& visitor) { visitor.VisitForeachBlock(*this); }
+void cASTIfBlock::Accept(cASTVisitor& visitor) { visitor.VisitIfBlock(*this); }
+void cASTWhileBlock::Accept(cASTVisitor& visitor) { visitor.VisitWhileBlock(*this); }
 
-void cASTFunctionDefinition::Accept(cASTVisitor& visitor) { visitor.visitFunctionDefinition(*this); }
-void cASTVariableDefinition::Accept(cASTVisitor& visitor) { visitor.visitVariableDefinition(*this); }
-void cASTVariableDefinitionList::Accept(cASTVisitor& visitor) { visitor.visitVariableDefinitionList(*this); }
+void cASTFunctionDefinition::Accept(cASTVisitor& visitor) { visitor.VisitFunctionDefinition(*this); }
+void cASTVariableDefinition::Accept(cASTVisitor& visitor) { visitor.VisitVariableDefinition(*this); }
+void cASTVariableDefinitionList::Accept(cASTVisitor& visitor) { visitor.VisitVariableDefinitionList(*this); }
 
-void cASTExpressionBinary::Accept(cASTVisitor& visitor) { visitor.visitExpressionBinary(*this); }
-void cASTExpressionUnary::Accept(cASTVisitor& visitor) { visitor.visitExpressionUnary(*this); }
+void cASTExpressionBinary::Accept(cASTVisitor& visitor) { visitor.VisitExpressionBinary(*this); }
+void cASTExpressionUnary::Accept(cASTVisitor& visitor) { visitor.VisitExpressionUnary(*this); }
 
-void cASTArgumentList::Accept(cASTVisitor& visitor) { visitor.visitArgumentList(*this); }
-void cASTFunctionCall::Accept(cASTVisitor& visitor) { visitor.visitFunctionCall(*this); }
-void cASTLiteral::Accept(cASTVisitor& visitor) { visitor.visitLiteral(*this); }
-void cASTLiteralArray::Accept(cASTVisitor& visitor) { visitor.visitLiteralArray(*this); }
-void cASTObjectCall::Accept(cASTVisitor& visitor) { visitor.visitObjectCall(*this); }
-void cASTObjectReference::Accept(cASTVisitor& visitor) { visitor.visitObjectReference(*this); }
-void cASTVariableReference::Accept(cASTVisitor& visitor) { visitor.visitVariableReference(*this); }
-void cASTUnpackTarget::Accept(cASTVisitor& visitor) { visitor.visitUnpackTarget(*this); }
+void cASTArgumentList::Accept(cASTVisitor& visitor) { visitor.VisitArgumentList(*this); }
+void cASTFunctionCall::Accept(cASTVisitor& visitor) { visitor.VisitFunctionCall(*this); }
+void cASTLiteral::Accept(cASTVisitor& visitor) { visitor.VisitLiteral(*this); }
+void cASTLiteralArray::Accept(cASTVisitor& visitor) { visitor.VisitLiteralArray(*this); }
+void cASTObjectCall::Accept(cASTVisitor& visitor) { visitor.VisitObjectCall(*this); }
+void cASTObjectReference::Accept(cASTVisitor& visitor) { visitor.VisitObjectReference(*this); }
+void cASTVariableReference::Accept(cASTVisitor& visitor) { visitor.VisitVariableReference(*this); }
+void cASTUnpackTarget::Accept(cASTVisitor& visitor) { visitor.VisitUnpackTarget(*this); }
 
 
 cASTStatementList::~cASTStatementList()

Modified: development/source/script/cASTVisitor.h
===================================================================
--- development/source/script/cASTVisitor.h	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cASTVisitor.h	2008-03-08 22:14:02 UTC (rev 2440)
@@ -35,30 +35,30 @@
   virtual ~cASTVisitor() { ; }
 
   
-  virtual void visitAssignment(cASTAssignment&) = 0;
+  virtual void VisitAssignment(cASTAssignment&) = 0;
   
-  virtual void visitReturnStatement(cASTReturnStatement&) = 0;
-  virtual void visitStatementList(cASTStatementList&) = 0;
+  virtual void VisitReturnStatement(cASTReturnStatement&) = 0;
+  virtual void VisitStatementList(cASTStatementList&) = 0;
   
-  virtual void visitForeachBlock(cASTForeachBlock&) = 0;
-  virtual void visitIfBlock(cASTIfBlock&) = 0;
-  virtual void visitWhileBlock(cASTWhileBlock&) = 0;
+  virtual void VisitForeachBlock(cASTForeachBlock&) = 0;
+  virtual void VisitIfBlock(cASTIfBlock&) = 0;
+  virtual void VisitWhileBlock(cASTWhileBlock&) = 0;
   
-  virtual void visitFunctionDefinition(cASTFunctionDefinition&) = 0;
-  virtual void visitVariableDefinition(cASTVariableDefinition&) = 0;
-  virtual void visitVariableDefinitionList(cASTVariableDefinitionList&) = 0;
+  virtual void VisitFunctionDefinition(cASTFunctionDefinition&) = 0;
+  virtual void VisitVariableDefinition(cASTVariableDefinition&) = 0;
+  virtual void VisitVariableDefinitionList(cASTVariableDefinitionList&) = 0;
 
-  virtual void visitExpressionBinary(cASTExpressionBinary&) = 0;
-  virtual void visitExpressionUnary(cASTExpressionUnary&) = 0;
+  virtual void VisitExpressionBinary(cASTExpressionBinary&) = 0;
+  virtual void VisitExpressionUnary(cASTExpressionUnary&) = 0;
 
-  virtual void visitArgumentList(cASTArgumentList&) = 0;
-  virtual void visitFunctionCall(cASTFunctionCall&) = 0;
-  virtual void visitLiteral(cASTLiteral&) = 0;
-  virtual void visitLiteralArray(cASTLiteralArray&) = 0;
-  virtual void visitObjectCall(cASTObjectCall&) = 0;
-  virtual void visitObjectReference(cASTObjectReference&) = 0;
-  virtual void visitVariableReference(cASTVariableReference&) = 0;
-  virtual void visitUnpackTarget(cASTUnpackTarget&) = 0;
+  virtual void VisitArgumentList(cASTArgumentList&) = 0;
+  virtual void VisitFunctionCall(cASTFunctionCall&) = 0;
+  virtual void VisitLiteral(cASTLiteral&) = 0;
+  virtual void VisitLiteralArray(cASTLiteralArray&) = 0;
+  virtual void VisitObjectCall(cASTObjectCall&) = 0;
+  virtual void VisitObjectReference(cASTObjectReference&) = 0;
+  virtual void VisitVariableReference(cASTVariableReference&) = 0;
+  virtual void VisitUnpackTarget(cASTUnpackTarget&) = 0;
 };
 
 #endif

Modified: development/source/script/cDirectInterpretASTVisitor.cc
===================================================================
--- development/source/script/cDirectInterpretASTVisitor.cc	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cDirectInterpretASTVisitor.cc	2008-03-08 22:14:02 UTC (rev 2440)
@@ -62,7 +62,7 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitAssignment(cASTAssignment& node)
+void cDirectInterpretASTVisitor::VisitAssignment(cASTAssignment& node)
 {
   cSymbolTable* symtbl = node.IsVarGlobal() ? m_global_symtbl : m_cur_symtbl;
   int sp = node.IsVarGlobal() ? 0 : m_sp;
@@ -89,14 +89,14 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitReturnStatement(cASTReturnStatement& node)
+void cDirectInterpretASTVisitor::VisitReturnStatement(cASTReturnStatement& node)
 {
   node.GetExpression()->Accept(*this);
   m_has_returned = true;
 }
 
 
-void cDirectInterpretASTVisitor::visitStatementList(cASTStatementList& node)
+void cDirectInterpretASTVisitor::VisitStatementList(cASTStatementList& node)
 {
   tListIterator<cASTNode> it = node.Iterator();
   
@@ -108,7 +108,7 @@
 
 
 
-void cDirectInterpretASTVisitor::visitForeachBlock(cASTForeachBlock& node)
+void cDirectInterpretASTVisitor::VisitForeachBlock(cASTForeachBlock& node)
 {
   //int var_id = node.GetVariable()->GetVarID();
   
@@ -116,7 +116,7 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitIfBlock(cASTIfBlock& node)
+void cDirectInterpretASTVisitor::VisitIfBlock(cASTIfBlock& node)
 {
   node.GetCondition()->Accept(*this);
   
@@ -140,7 +140,7 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitWhileBlock(cASTWhileBlock& node)
+void cDirectInterpretASTVisitor::VisitWhileBlock(cASTWhileBlock& node)
 {
   node.GetCondition()->Accept(*this);
   while (asBool(m_rtype, m_rvalue, node)) {
@@ -151,13 +151,13 @@
 
 
 
-void cDirectInterpretASTVisitor::visitFunctionDefinition(cASTFunctionDefinition& node)
+void cDirectInterpretASTVisitor::VisitFunctionDefinition(cASTFunctionDefinition& node)
 {
   // Nothing to do here
 }
 
 
-void cDirectInterpretASTVisitor::visitVariableDefinition(cASTVariableDefinition& node)
+void cDirectInterpretASTVisitor::VisitVariableDefinition(cASTVariableDefinition& node)
 {
   if (node.GetAssignmentExpression()) {
     int var_id = node.GetVarID();
@@ -165,7 +165,7 @@
     node.GetAssignmentExpression()->Accept(*this);
     
     switch (m_cur_symtbl->GetVariableType(var_id)) {
-      case TYPE(ARRAY):       INTERPRET_ERROR(INTERNAL); // @TODO - assignment
+      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;
       case TYPE(FLOAT):       m_call_stack[m_sp + var_id].as_float = asFloat(m_rtype, m_rvalue, node); break;
@@ -186,7 +186,7 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitVariableDefinitionList(cASTVariableDefinitionList& node)
+void cDirectInterpretASTVisitor::VisitVariableDefinitionList(cASTVariableDefinitionList& node)
 {
   // Should never recurse into here.  Variable definition lists are processed by function definitions.
   INTERPRET_ERROR(INTERNAL);
@@ -194,7 +194,7 @@
 
 
 
-void cDirectInterpretASTVisitor::visitExpressionBinary(cASTExpressionBinary& node)
+void cDirectInterpretASTVisitor::VisitExpressionBinary(cASTExpressionBinary& node)
 {
   // Process the left and right side expressions
   node.GetLeft()->Accept(*this);
@@ -486,7 +486,7 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitExpressionUnary(cASTExpressionUnary& node)
+void cDirectInterpretASTVisitor::VisitExpressionUnary(cASTExpressionUnary& node)
 {
   node.GetExpression()->Accept(*this);
   
@@ -543,13 +543,13 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitArgumentList(cASTArgumentList& node)
+void cDirectInterpretASTVisitor::VisitArgumentList(cASTArgumentList& node)
 {
   // Should never recurse into here.  Argument lists are processed by their owners as needed.
   INTERPRET_ERROR(INTERNAL);
 }
 
-void cDirectInterpretASTVisitor::visitFunctionCall(cASTFunctionCall& node)
+void cDirectInterpretASTVisitor::VisitFunctionCall(cASTFunctionCall& node)
 {
   // Save previous scope information
   cSymbolTable* prev_symtbl = m_cur_symtbl;
@@ -577,7 +577,7 @@
     int var_id = arg_def->GetVarID();
 
     switch (m_cur_symtbl->GetVariableType(var_id)) {
-      case TYPE(ARRAY):       INTERPRET_ERROR(INTERNAL); // @TODO - assignment
+      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;
       case TYPE(FLOAT):       m_call_stack[sp + var_id].as_float = asFloat(m_rtype, m_rvalue, node); break;
@@ -604,7 +604,7 @@
   
   // Handle function return value
   switch (node.GetType()) {
-    case TYPE(ARRAY):       INTERPRET_ERROR(INTERNAL); // @TODO - return
+    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;
     case TYPE(FLOAT):       m_rvalue.as_float = asFloat(m_rtype, m_rvalue, node); break;
@@ -630,7 +630,7 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitLiteral(cASTLiteral& node)
+void cDirectInterpretASTVisitor::VisitLiteral(cASTLiteral& node)
 {
   switch (node.GetType()) {
     case TYPE(BOOL):
@@ -660,32 +660,32 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitLiteralArray(cASTLiteralArray& node)
+void cDirectInterpretASTVisitor::VisitLiteralArray(cASTLiteralArray& node)
 {
   // @TODO - handle literal array
   INTERPRET_ERROR(INTERNAL);
 }
 
 
-void cDirectInterpretASTVisitor::visitObjectCall(cASTObjectCall& node)
+void cDirectInterpretASTVisitor::VisitObjectCall(cASTObjectCall& node)
 {
   // @TODO - handle object call
   INTERPRET_ERROR(INTERNAL);
 }
 
-void cDirectInterpretASTVisitor::visitObjectReference(cASTObjectReference& node)
+void cDirectInterpretASTVisitor::VisitObjectReference(cASTObjectReference& node)
 {
   // @TODO - handle object reference
   INTERPRET_ERROR(INTERNAL);
 }
 
-void cDirectInterpretASTVisitor::visitVariableReference(cASTVariableReference& node)
+void cDirectInterpretASTVisitor::VisitVariableReference(cASTVariableReference& node)
 {
   int var_id = node.GetVarID();
   int sp = node.IsVarGlobal() ? 0 : m_sp;
   
   switch (node.GetType()) {
-    case TYPE(ARRAY):       INTERPRET_ERROR(INTERNAL); // @TODO - assignment
+    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;
     case TYPE(FLOAT):       m_rvalue.as_float = m_call_stack[sp + var_id].as_float; break;
@@ -701,18 +701,40 @@
 }
 
 
-void cDirectInterpretASTVisitor::visitUnpackTarget(cASTUnpackTarget& node)
+void cDirectInterpretASTVisitor::VisitUnpackTarget(cASTUnpackTarget& node)
 {
   // @TODO - handle unpack target
 }
 
+cDirectInterpretASTVisitor::cLocalArray* cDirectInterpretASTVisitor::asArray(ASType_t type, uAnyType value, cASTNode& node)
+{
+  switch (type) {
+    case TYPE(ARRAY):
+      return value.as_array;
+    case TYPE(MATRIX):
+      INTERPRET_ERROR(INTERNAL); // @TODO - matrix as array 
+    case TYPE(STRING):
+      INTERPRET_ERROR(INTERNAL); // @TODO - string as array 
+      
+    default:
+      INTERPRET_ERROR(TYPE_CAST, mapType(type), mapType(TYPE(CHAR)));
+  }
+  
+  return false;
+}
 
 bool cDirectInterpretASTVisitor::asBool(ASType_t type, uAnyType value, cASTNode& node)
 {
   switch (type) {
     case TYPE(ARRAY):
+      {
+        bool rval = (value.as_array->GetSize());
+        value.as_array->RemoveReference();
+        return rval;
+      }
+      
     case TYPE(MATRIX):
-      // @TODO - implement asBool for array/matrix
+      // @TODO - implement asBool for matrix
       INTERPRET_ERROR(INTERNAL);
       
     case TYPE(BOOL):
@@ -909,7 +931,59 @@
 }
 
 
+void cDirectInterpretASTVisitor::cLocalArray::copy(int offset, tArray<sAggregateValue>& in_storage)
+{
+  for (int i = 0; i < in_storage.GetSize(); i++) {
+    (*m_storage)[i + offset].type = in_storage[i].type;
+    switch (in_storage[i].type) {
+      case TYPE(BOOL):    (*m_storage)[i + offset].value.as_bool = in_storage[i].value.as_bool; break;
+      case TYPE(CHAR):    (*m_storage)[i + offset].value.as_char = in_storage[i].value.as_char; break;
+      case TYPE(INT):     (*m_storage)[i + offset].value.as_int = in_storage[i].value.as_int; break;
+      case TYPE(FLOAT):   (*m_storage)[i + offset].value.as_float = in_storage[i].value.as_float; break;
+      case TYPE(STRING):  (*m_storage)[i + offset].value.as_string = new cString(*in_storage[i].value.as_string); break;
+      case TYPE(ARRAY):   (*m_storage)[i + offset].value.as_array = in_storage[i].value.as_array->GetReference(); break;
+      case TYPE(MATRIX):
+        // @TODO - matrix types
+        break;
+        
+      default: break;
+    }
+  }
+}
 
+
+void cDirectInterpretASTVisitor::cLocalArray::Resize(int sz)
+{
+  int o_sz = m_storage->GetSize();
+  
+  m_storage->Resize(sz);
+  
+  for (int i = o_sz; i < sz; i++) {
+    (*m_storage)[i].value.as_int = 0;
+    (*m_storage)[i].type = TYPE(INT);
+  }  
+}
+
+cDirectInterpretASTVisitor::cLocalArray::~cLocalArray()
+{
+  int sz = m_storage->GetSize();
+  
+  // Cleanup values stored in the array
+  for (int i = 0; i < sz; i++) {
+    sAggregateValue& cell = (*m_storage)[i];
+    switch (cell.type) {
+      case TYPE(STRING):  delete cell.value.as_string; break;
+      case TYPE(ARRAY):   cell.value.as_array->RemoveReference(); break;
+      case TYPE(MATRIX):  delete cell.value.as_matrix; break;
+      default: break;
+    }
+  }
+  
+  delete m_storage;
+}
+
+
+
 void cDirectInterpretASTVisitor::reportError(ASDirectInterpretError_t err, const cASFilePosition& fp, const int line, ...)
 {
 #if DEBUG_AS_DIRECT_INTERPRET

Modified: development/source/script/cDirectInterpretASTVisitor.h
===================================================================
--- development/source/script/cDirectInterpretASTVisitor.h	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cDirectInterpretASTVisitor.h	2008-03-08 22:14:02 UTC (rev 2440)
@@ -35,8 +35,9 @@
 class cDirectInterpretASTVisitor : public cASTVisitor
 {
 private:
-  cSymbolTable* m_global_symtbl;
-  cSymbolTable* m_cur_symtbl;
+  // --------  Internal Type Declarations  --------
+  class cLocalArray;
+  class cLocalMatrix;
   
   typedef union {
     bool as_bool;
@@ -44,8 +45,15 @@
     int as_int;
     double as_float;
     cString* as_string;
+    cLocalArray* as_array;
+    cLocalMatrix* as_matrix;
   } uAnyType;
   
+
+  // --------  Internal Variables  --------
+  cSymbolTable* m_global_symtbl;
+  cSymbolTable* m_cur_symtbl;
+  
   uAnyType m_rvalue;
   ASType_t m_rtype;
   
@@ -54,6 +62,7 @@
   bool m_has_returned;
   
   
+  // --------  Private Constructors  --------
   cDirectInterpretASTVisitor(const cDirectInterpretASTVisitor&); // @not_implemented
   cDirectInterpretASTVisitor& operator=(const cDirectInterpretASTVisitor&); // @not_implemented
   
@@ -63,32 +72,35 @@
   
   int Interpret(cASTNode* node);
   
-  void visitAssignment(cASTAssignment&);
+  void VisitAssignment(cASTAssignment&);
   
-  void visitReturnStatement(cASTReturnStatement&);
-  void visitStatementList(cASTStatementList&);
+  void VisitReturnStatement(cASTReturnStatement&);
+  void VisitStatementList(cASTStatementList&);
   
-  void visitForeachBlock(cASTForeachBlock&);
-  void visitIfBlock(cASTIfBlock&);
-  void visitWhileBlock(cASTWhileBlock&);
+  void VisitForeachBlock(cASTForeachBlock&);
+  void VisitIfBlock(cASTIfBlock&);
+  void VisitWhileBlock(cASTWhileBlock&);
   
-  void visitFunctionDefinition(cASTFunctionDefinition&);
-  void visitVariableDefinition(cASTVariableDefinition&);
-  void visitVariableDefinitionList(cASTVariableDefinitionList&);
+  void VisitFunctionDefinition(cASTFunctionDefinition&);
+  void VisitVariableDefinition(cASTVariableDefinition&);
+  void VisitVariableDefinitionList(cASTVariableDefinitionList&);
   
-  void visitExpressionBinary(cASTExpressionBinary&);
-  void visitExpressionUnary(cASTExpressionUnary&);
+  void VisitExpressionBinary(cASTExpressionBinary&);
+  void VisitExpressionUnary(cASTExpressionUnary&);
   
-  void visitArgumentList(cASTArgumentList&);
-  void visitFunctionCall(cASTFunctionCall&);
-  void visitLiteral(cASTLiteral&);
-  void visitLiteralArray(cASTLiteralArray&);
-  void visitObjectCall(cASTObjectCall&);
-  void visitObjectReference(cASTObjectReference&);
-  void visitVariableReference(cASTVariableReference&);
-  void visitUnpackTarget(cASTUnpackTarget&);
+  void VisitArgumentList(cASTArgumentList&);
+  void VisitFunctionCall(cASTFunctionCall&);
+  void VisitLiteral(cASTLiteral&);
+  void VisitLiteralArray(cASTLiteralArray&);
+  void VisitObjectCall(cASTObjectCall&);
+  void VisitObjectReference(cASTObjectReference&);
+  void VisitVariableReference(cASTVariableReference&);
+  void VisitUnpackTarget(cASTUnpackTarget&);
 
+
 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);
@@ -98,7 +110,65 @@
   ASType_t getRuntimeType(ASType_t ltype, ASType_t rtype, bool allow_str = false);
   
   void reportError(ASDirectInterpretError_t err, const cASFilePosition& fp, const int line, ...);
+  
+
+  // --------  Internal Type Definitions  --------
+  struct sAggregateValue {
+    uAnyType value;
+    ASType_t type;
+  };
+  
+  class cLocalArray
+  {
+  private:
+    tArray<sAggregateValue>* m_storage;
+    int m_ref_count;
+    
+    
+  public:
+    inline cLocalArray() : m_storage(new tArray<sAggregateValue>), m_ref_count(1) { ; }
+    inline explicit cLocalArray(cLocalArray* in_array); // Create a copy
+    inline cLocalArray(cLocalArray* arr1, cLocalArray* arr2); // Concat two arrays
+    ~cLocalArray();
+    
+    inline cLocalArray* GetReference() { m_ref_count++; return this; }
+    inline void RemoveReference() { m_ref_count--;  if (m_ref_count == 0) delete this; }
+    inline bool IsShared() const { return (m_ref_count > 1); }
+    
+    inline int GetSize() const { return m_storage->GetSize(); }
+    void Resize(int sz);
+    
+    inline const sAggregateValue& Get(int i) const { return (*m_storage)[i]; }    
+    void Set(int i, ASType_t type, uAnyType value);
+    
+    
+  private:
+    void copy(int offset, tArray<sAggregateValue>& in_storage);
+  };
+  
+  
+  class cLocalMatrix
+  {
+    
+  };
 };
 
 
+inline cDirectInterpretASTVisitor::cLocalArray::cLocalArray(cLocalArray* in_array) : m_ref_count(1)
+{
+  m_storage = new tArray<sAggregateValue>(in_array->m_storage->GetSize());
+  copy(0, *in_array->m_storage);
+}
+
+inline cDirectInterpretASTVisitor::cLocalArray::cLocalArray(cLocalArray* arr1, cLocalArray* arr2) : m_ref_count(1)
+{
+  int sz1 = arr1->m_storage->GetSize();
+  m_storage = new tArray<sAggregateValue>(sz1 + arr2->m_storage->GetSize());
+  
+  copy(0, *arr1->m_storage);
+  copy(sz1, *arr2->m_storage);
+}
+
+
+
 #endif

Modified: development/source/script/cDumpASTVisitor.cc
===================================================================
--- development/source/script/cDumpASTVisitor.cc	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cDumpASTVisitor.cc	2008-03-08 22:14:02 UTC (rev 2440)
@@ -41,7 +41,7 @@
   for (int i = 0; i < m_depth; i++) cout << "  ";
 }
 
-void cDumpASTVisitor::visitAssignment(cASTAssignment& node)
+void cDumpASTVisitor::VisitAssignment(cASTAssignment& node)
 {
   m_depth++;
   indent();
@@ -57,7 +57,7 @@
 }
 
 
-void cDumpASTVisitor::visitReturnStatement(cASTReturnStatement& node)
+void cDumpASTVisitor::VisitReturnStatement(cASTReturnStatement& node)
 {
   indent();
   cout << "return:" << endl;
@@ -68,7 +68,7 @@
 }
 
 
-void cDumpASTVisitor::visitStatementList(cASTStatementList& node)
+void cDumpASTVisitor::VisitStatementList(cASTStatementList& node)
 {
   tListIterator<cASTNode> it = node.Iterator();
   
@@ -80,7 +80,7 @@
 
 
 
-void cDumpASTVisitor::visitForeachBlock(cASTForeachBlock& node)
+void cDumpASTVisitor::VisitForeachBlock(cASTForeachBlock& node)
 {
   indent();
   cout << "foreach:" << endl;
@@ -105,7 +105,7 @@
 }
 
 
-void cDumpASTVisitor::visitIfBlock(cASTIfBlock& node)
+void cDumpASTVisitor::VisitIfBlock(cASTIfBlock& node)
 {
   indent();
   cout << "if:" << endl;
@@ -165,7 +165,7 @@
 }
 
 
-void cDumpASTVisitor::visitWhileBlock(cASTWhileBlock& node)
+void cDumpASTVisitor::VisitWhileBlock(cASTWhileBlock& node)
 {
   indent();
   cout << "while:" << endl;
@@ -190,7 +190,7 @@
 
 
 
-void cDumpASTVisitor::visitFunctionDefinition(cASTFunctionDefinition& node)
+void cDumpASTVisitor::VisitFunctionDefinition(cASTFunctionDefinition& node)
 {
   indent();
   cout << (node.GetCode() ? "":"@") << "function: " << mapType(node.GetType()) << " " << node.GetName() << "(";
@@ -215,7 +215,7 @@
 }
 
 
-void cDumpASTVisitor::visitVariableDefinition(cASTVariableDefinition& node)
+void cDumpASTVisitor::VisitVariableDefinition(cASTVariableDefinition& node)
 {
   indent();
   cout << mapType(node.GetType()) << " " << node.GetName() << endl;
@@ -244,7 +244,7 @@
 }
 
 
-void cDumpASTVisitor::visitVariableDefinitionList(cASTVariableDefinitionList& node)
+void cDumpASTVisitor::VisitVariableDefinitionList(cASTVariableDefinitionList& node)
 {
   m_depth++;
   
@@ -257,7 +257,7 @@
 
 
 
-void cDumpASTVisitor::visitExpressionBinary(cASTExpressionBinary& node)
+void cDumpASTVisitor::VisitExpressionBinary(cASTExpressionBinary& node)
 {
   m_depth++;
   node.GetLeft()->Accept(*this);
@@ -273,7 +273,7 @@
 }
 
 
-void cDumpASTVisitor::visitExpressionUnary(cASTExpressionUnary& node)
+void cDumpASTVisitor::VisitExpressionUnary(cASTExpressionUnary& node)
 {
   indent();
   cout << mapToken(node.GetOperator());
@@ -285,7 +285,7 @@
 }
 
 
-void cDumpASTVisitor::visitArgumentList(cASTArgumentList& node)
+void cDumpASTVisitor::VisitArgumentList(cASTArgumentList& node)
 {
   m_depth++;
   
@@ -296,7 +296,7 @@
   m_depth--;
 }
 
-void cDumpASTVisitor::visitFunctionCall(cASTFunctionCall& node)
+void cDumpASTVisitor::VisitFunctionCall(cASTFunctionCall& node)
 {
   indent();
   cout << "call:" << endl;
@@ -323,14 +323,14 @@
 }
 
 
-void cDumpASTVisitor::visitLiteral(cASTLiteral& node)
+void cDumpASTVisitor::VisitLiteral(cASTLiteral& node)
 {
   indent();
   cout << "(" << mapType(node.GetType()) << ") " << node.GetValue() << endl;
 }
 
 
-void cDumpASTVisitor::visitLiteralArray(cASTLiteralArray& node)
+void cDumpASTVisitor::VisitLiteralArray(cASTLiteralArray& node)
 {
   indent();
   if (node.IsMatrix()) cout << "$";
@@ -345,7 +345,7 @@
 }
 
 
-void cDumpASTVisitor::visitObjectCall(cASTObjectCall& node)
+void cDumpASTVisitor::VisitObjectCall(cASTObjectCall& node)
 {
   indent();
   cout << "call:" << endl;
@@ -371,7 +371,7 @@
 
 }
 
-void cDumpASTVisitor::visitObjectReference(cASTObjectReference& node)
+void cDumpASTVisitor::VisitObjectReference(cASTObjectReference& node)
 {
   m_depth++;
   node.GetObject()->Accept(*this);
@@ -386,14 +386,14 @@
   m_depth--;  
 }
 
-void cDumpASTVisitor::visitVariableReference(cASTVariableReference& node)
+void cDumpASTVisitor::VisitVariableReference(cASTVariableReference& node)
 {
   indent();
   cout << node.GetName() << endl;
 }
 
 
-void cDumpASTVisitor::visitUnpackTarget(cASTUnpackTarget& node)
+void cDumpASTVisitor::VisitUnpackTarget(cASTUnpackTarget& node)
 {
   m_depth++;
   

Modified: development/source/script/cDumpASTVisitor.h
===================================================================
--- development/source/script/cDumpASTVisitor.h	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cDumpASTVisitor.h	2008-03-08 22:14:02 UTC (rev 2440)
@@ -36,30 +36,30 @@
 public:
   cDumpASTVisitor();
   
-  void visitAssignment(cASTAssignment&);
+  void VisitAssignment(cASTAssignment&);
   
-  void visitReturnStatement(cASTReturnStatement&);
-  void visitStatementList(cASTStatementList&);
+  void VisitReturnStatement(cASTReturnStatement&);
+  void VisitStatementList(cASTStatementList&);
   
-  void visitForeachBlock(cASTForeachBlock&);
-  void visitIfBlock(cASTIfBlock&);
-  void visitWhileBlock(cASTWhileBlock&);
+  void VisitForeachBlock(cASTForeachBlock&);
+  void VisitIfBlock(cASTIfBlock&);
+  void VisitWhileBlock(cASTWhileBlock&);
   
-  void visitFunctionDefinition(cASTFunctionDefinition&);
-  void visitVariableDefinition(cASTVariableDefinition&);
-  void visitVariableDefinitionList(cASTVariableDefinitionList&);
+  void VisitFunctionDefinition(cASTFunctionDefinition&);
+  void VisitVariableDefinition(cASTVariableDefinition&);
+  void VisitVariableDefinitionList(cASTVariableDefinitionList&);
   
-  void visitExpressionBinary(cASTExpressionBinary&);
-  void visitExpressionUnary(cASTExpressionUnary&);
+  void VisitExpressionBinary(cASTExpressionBinary&);
+  void VisitExpressionUnary(cASTExpressionUnary&);
   
-  void visitArgumentList(cASTArgumentList&);
-  void visitFunctionCall(cASTFunctionCall&);
-  void visitLiteral(cASTLiteral&);
-  void visitLiteralArray(cASTLiteralArray&);
-  void visitObjectCall(cASTObjectCall&);
-  void visitObjectReference(cASTObjectReference&);
-  void visitVariableReference(cASTVariableReference&);
-  void visitUnpackTarget(cASTUnpackTarget&);
+  void VisitArgumentList(cASTArgumentList&);
+  void VisitFunctionCall(cASTFunctionCall&);
+  void VisitLiteral(cASTLiteral&);
+  void VisitLiteralArray(cASTLiteralArray&);
+  void VisitObjectCall(cASTObjectCall&);
+  void VisitObjectReference(cASTObjectReference&);
+  void VisitVariableReference(cASTVariableReference&);
+  void VisitUnpackTarget(cASTUnpackTarget&);
 
 private:
   inline void indent();

Modified: development/source/script/cParser.cc
===================================================================
--- development/source/script/cParser.cc	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cParser.cc	2008-03-08 22:14:02 UTC (rev 2440)
@@ -769,6 +769,7 @@
     case TOKEN(IDX_OPEN):
       cASTNode* target = new cASTVariableReference(FILEPOS, currentText());
       nextToken(); // consume id
+      // @TODO - handle call expression assignments
       return parseCallExpression(target, true);
       break;
     case TOKEN(REF):

Modified: development/source/script/cSemanticASTVisitor.cc
===================================================================
--- development/source/script/cSemanticASTVisitor.cc	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cSemanticASTVisitor.cc	2008-03-08 22:14:02 UTC (rev 2440)
@@ -46,11 +46,11 @@
   static const bool valid_cast[11][11] = {
   // ARRAY, BOOL , CHAR , FLOAT, INT  , @OBJ , MATRX, STRNG, RUNTM, VOID , INVLD
     {true , true , false, false, false, false, false, true , true , false, false}, // TYPE(ARRAY)
-    {true , true , true , true , true , false, true , true , true , false, false}, // TYPE(BOOL)
-    {true , true , true , true , true , false, true , true , true , false, false}, // TYPE(CHAR)
-    {true , true , false, true , true , false, true , true , true , false, false}, // TYPE(FLOAT)
-    {true , true , true , true , true , false, true , true , true , false, false}, // TYPE(INT)
-    {true , true , false, false, false, true , false, true , false, false, false}, // TYPE(OBJECT_REF)
+    {false, true , true , true , true , false, true , true , true , false, false}, // TYPE(BOOL)
+    {false, true , true , true , true , false, true , true , true , false, false}, // TYPE(CHAR)
+    {false, true , false, true , true , false, true , true , true , false, false}, // TYPE(FLOAT)
+    {false, true , true , true , true , false, true , true , true , false, false}, // TYPE(INT)
+    {false, true , false, false, false, true , false, true , false, false, false}, // TYPE(OBJECT_REF)
     {true , true , false, false, false, false, true , true , true , false, false}, // TYPE(MATRIX)
     {true , true , false, true , true , false, false, true , true , false, false}, // TYPE(STRNG)
     {true , true , true , true , true , true , true , true , true , false, false}, // TYPE(RUNTIME)
@@ -81,7 +81,7 @@
 }
 
 
-void cSemanticASTVisitor::visitAssignment(cASTAssignment& node)
+void cSemanticASTVisitor::VisitAssignment(cASTAssignment& node)
 {
   node.GetExpression()->Accept(*this);
   int var_id = -1;
@@ -95,7 +95,7 @@
 }
 
 
-void cSemanticASTVisitor::visitReturnStatement(cASTReturnStatement& node)
+void cSemanticASTVisitor::VisitReturnStatement(cASTReturnStatement& node)
 {
   node.GetExpression()->Accept(*this);
   checkCast(m_parent_scope->GetFunctionRType(m_fun_id), node.GetExpression()->GetType());
@@ -103,7 +103,7 @@
 }
 
 
-void cSemanticASTVisitor::visitStatementList(cASTStatementList& node)
+void cSemanticASTVisitor::VisitStatementList(cASTStatementList& node)
 {
   tListIterator<cASTNode> it = node.Iterator();
   
@@ -137,7 +137,7 @@
 }
 
 
-void cSemanticASTVisitor::visitForeachBlock(cASTForeachBlock& node)
+void cSemanticASTVisitor::VisitForeachBlock(cASTForeachBlock& node)
 {
   // Check values and make sure we can process it as an array
   node.GetValues()->Accept(*this);
@@ -159,7 +159,7 @@
 }
 
 
-void cSemanticASTVisitor::visitIfBlock(cASTIfBlock& node)
+void cSemanticASTVisitor::VisitIfBlock(cASTIfBlock& node)
 {
   // Check main condition and code
   node.GetCondition()->Accept(*this);
@@ -181,7 +181,7 @@
 }
 
 
-void cSemanticASTVisitor::visitWhileBlock(cASTWhileBlock& node)
+void cSemanticASTVisitor::VisitWhileBlock(cASTWhileBlock& node)
 {
   node.GetCondition()->Accept(*this);
   checkCast(node.GetCondition()->GetType(), TYPE(BOOL));
@@ -190,7 +190,7 @@
 
 
 
-void cSemanticASTVisitor::visitFunctionDefinition(cASTFunctionDefinition& node)
+void cSemanticASTVisitor::VisitFunctionDefinition(cASTFunctionDefinition& node)
 {
   int fun_id = -1;
   bool added = m_cur_symtbl->AddFunction(node.GetName(), node.GetType(), fun_id);
@@ -285,7 +285,7 @@
 }
 
 
-void cSemanticASTVisitor::visitVariableDefinition(cASTVariableDefinition& node)
+void cSemanticASTVisitor::VisitVariableDefinition(cASTVariableDefinition& node)
 {
   int var_id = -1;
   if (m_cur_symtbl->AddVariable(node.GetName(), node.GetType(), var_id)) node.SetVar(var_id);
@@ -325,7 +325,7 @@
 }
 
 
-void cSemanticASTVisitor::visitVariableDefinitionList(cASTVariableDefinitionList& node)
+void cSemanticASTVisitor::VisitVariableDefinitionList(cASTVariableDefinitionList& node)
 {
   // Should never recurse into here.  Variable definition lists are processed by function definitions.
   SEMANTIC_ERROR(INTERNAL);
@@ -333,7 +333,7 @@
 
 
 
-void cSemanticASTVisitor::visitExpressionBinary(cASTExpressionBinary& node)
+void cSemanticASTVisitor::VisitExpressionBinary(cASTExpressionBinary& node)
 {
   node.GetLeft()->Accept(*this);
   node.GetRight()->Accept(*this);
@@ -446,7 +446,7 @@
 }
 
 
-void cSemanticASTVisitor::visitExpressionUnary(cASTExpressionUnary& node)
+void cSemanticASTVisitor::VisitExpressionUnary(cASTExpressionUnary& node)
 {
   node.GetExpression()->Accept(*this);
   
@@ -487,13 +487,13 @@
 }
 
 
-void cSemanticASTVisitor::visitArgumentList(cASTArgumentList& node)
+void cSemanticASTVisitor::VisitArgumentList(cASTArgumentList& node)
 {
   // Should never recurse into here.  Argument lists are processed by their owners as needed.
   SEMANTIC_ERROR(INTERNAL);
 }
 
-void cSemanticASTVisitor::visitFunctionCall(cASTFunctionCall& node)
+void cSemanticASTVisitor::VisitFunctionCall(cASTFunctionCall& node)
 {
   // @TODO - somewhere in here, make sure that default value expressions are valid for this context if used
   
@@ -553,13 +553,13 @@
 }
 
 
-void cSemanticASTVisitor::visitLiteral(cASTLiteral& node)
+void cSemanticASTVisitor::VisitLiteral(cASTLiteral& node)
 {
   // Nothing to do here...   type already determined by the parser
 }
 
 
-void cSemanticASTVisitor::visitLiteralArray(cASTLiteralArray& node)
+void cSemanticASTVisitor::VisitLiteralArray(cASTLiteralArray& node)
 {
   cASTArgumentList* al = node.GetValues();
   if (al) {
@@ -572,21 +572,21 @@
 }
 
 
-void cSemanticASTVisitor::visitObjectCall(cASTObjectCall& node)
+void cSemanticASTVisitor::VisitObjectCall(cASTObjectCall& node)
 {
   // @TODO - object call
   SEMANTIC_ERROR(INTERNAL);
 }
 
 
-void cSemanticASTVisitor::visitObjectReference(cASTObjectReference& node)
+void cSemanticASTVisitor::VisitObjectReference(cASTObjectReference& node)
 {
   // @TODO - object reference
   SEMANTIC_ERROR(INTERNAL);
 }
 
 
-void cSemanticASTVisitor::visitVariableReference(cASTVariableReference& node)
+void cSemanticASTVisitor::VisitVariableReference(cASTVariableReference& node)
 {
   int var_id = -1;
   bool global = false;
@@ -599,7 +599,7 @@
 }
 
 
-void cSemanticASTVisitor::visitUnpackTarget(cASTUnpackTarget& node)
+void cSemanticASTVisitor::VisitUnpackTarget(cASTUnpackTarget& node)
 {
   node.GetExpression()->Accept(*this);
   

Modified: development/source/script/cSemanticASTVisitor.h
===================================================================
--- development/source/script/cSemanticASTVisitor.h	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cSemanticASTVisitor.h	2008-03-08 22:14:02 UTC (rev 2440)
@@ -37,30 +37,34 @@
 class cSemanticASTVisitor : public cASTVisitor
 {
 private:
-  cASLibrary* m_library;
-  cSymbolTable* m_global_symtbl;
-  cSymbolTable* m_parent_scope;
-  int m_fun_id;
-  cSymbolTable* m_cur_symtbl;
-  
+  // --------  Internal Type Declarations  --------
   struct sFunctionEntry
   {
     cSymbolTable* parent_scope;
     int fun_id;
-
+    
     cSymbolTable* fun_symtbl;
     
     sFunctionEntry() : parent_scope(NULL), fun_id(-1) { ; }
     sFunctionEntry(cSymbolTable* ps, int in_fun_id) : parent_scope(ps), fun_id(in_fun_id) { ; }
   };
+  
+  
+  // --------  Internal Variables  --------
+  cASLibrary* m_library;
+  cSymbolTable* m_global_symtbl;
+  cSymbolTable* m_parent_scope;
+  int m_fun_id;
+  cSymbolTable* m_cur_symtbl;
+  
   tSmartArray<sFunctionEntry> m_fun_stack;
-
   
   bool m_success;
   bool m_fun_def;
   bool m_top_level;
 
   
+  // --------  Private Constructors  --------
   cSemanticASTVisitor(); // @not_implemented
   cSemanticASTVisitor(const cSemanticASTVisitor&); // @not_implemented
   cSemanticASTVisitor& operator=(const cSemanticASTVisitor&); // @not_implemented
@@ -72,35 +76,36 @@
   inline bool WasSuccessful() { return m_success; }
   
   
-  void visitAssignment(cASTAssignment&);
+  void VisitAssignment(cASTAssignment&);
   
-  void visitReturnStatement(cASTReturnStatement&);
-  void visitStatementList(cASTStatementList&);
+  void VisitReturnStatement(cASTReturnStatement&);
+  void VisitStatementList(cASTStatementList&);
   
-  void visitForeachBlock(cASTForeachBlock&);
-  void visitIfBlock(cASTIfBlock&);
-  void visitWhileBlock(cASTWhileBlock&);
+  void VisitForeachBlock(cASTForeachBlock&);
+  void VisitIfBlock(cASTIfBlock&);
+  void VisitWhileBlock(cASTWhileBlock&);
   
-  void visitFunctionDefinition(cASTFunctionDefinition&);
-  void visitVariableDefinition(cASTVariableDefinition&);
-  void visitVariableDefinitionList(cASTVariableDefinitionList&);
+  void VisitFunctionDefinition(cASTFunctionDefinition&);
+  void VisitVariableDefinition(cASTVariableDefinition&);
+  void VisitVariableDefinitionList(cASTVariableDefinitionList&);
   
-  void visitExpressionBinary(cASTExpressionBinary&);
-  void visitExpressionUnary(cASTExpressionUnary&);
+  void VisitExpressionBinary(cASTExpressionBinary&);
+  void VisitExpressionUnary(cASTExpressionUnary&);
   
-  void visitArgumentList(cASTArgumentList&);
-  void visitFunctionCall(cASTFunctionCall&);
-  void visitLiteral(cASTLiteral&);
-  void visitLiteralArray(cASTLiteralArray&);
-  void visitObjectCall(cASTObjectCall&);
-  void visitObjectReference(cASTObjectReference&);
-  void visitVariableReference(cASTVariableReference&);
-  void visitUnpackTarget(cASTUnpackTarget&);
+  void VisitArgumentList(cASTArgumentList&);
+  void VisitFunctionCall(cASTFunctionCall&);
+  void VisitLiteral(cASTLiteral&);
+  void VisitLiteralArray(cASTLiteralArray&);
+  void VisitObjectCall(cASTObjectCall&);
+  void VisitObjectReference(cASTObjectReference&);
+  void VisitVariableReference(cASTVariableReference&);
+  void VisitUnpackTarget(cASTUnpackTarget&);
 
   void PostCheck();
 
 
 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;
@@ -110,4 +115,5 @@
   
   void reportError(ASSemanticError_t err, const cASFilePosition& fp, const int line, ...);
 };
+
 #endif

Modified: development/source/script/cSymbolTable.h
===================================================================
--- development/source/script/cSymbolTable.h	2008-03-08 20:14:43 UTC (rev 2439)
+++ development/source/script/cSymbolTable.h	2008-03-08 22:14:02 UTC (rev 2440)
@@ -38,38 +38,14 @@
 class cSymbolTable
 {
 private:
-  struct sSymbolEntry
-  {
-    cString name;
-    ASType_t type;
+  // --------  Internal Type Declarations  --------
+  struct sSymbolEntry;
+  struct sFunctionEntry;
 
-    int scope;
-    int shadow;
-    int deactivate;
-    
-    sSymbolEntry(const cString& in_name, ASType_t in_type, int in_scope)
-      : name(in_name), type(in_type), scope(in_scope), shadow(-1), deactivate(0) { ; }
-  };
+  
+  // --------  Internal Variables  --------
   tArray<sSymbolEntry*> m_sym_tbl;
   tDictionary<int> m_sym_dict;
-  
-  struct sFunctionEntry
-  {
-    cString name;
-    ASType_t type;
-    cASTVariableDefinitionList* signature;
-    cSymbolTable* symtbl;
-    cASTNode* code;
-    
-    int scope;
-    int shadow;
-    int deactivate;
-    
-    sFunctionEntry(const cString& in_name, ASType_t 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; }
-  };
   tArray<sFunctionEntry*> m_fun_tbl;
   tDictionary<int> m_fun_dict;
 
@@ -79,6 +55,7 @@
   bool m_return;
   
   
+  // --------  Private Constructors  --------
   cSymbolTable(const cSymbolTable&); // @not_implemented
   cSymbolTable& operator=(const cSymbolTable&); // @not_implemented
   
@@ -88,6 +65,7 @@
   ~cSymbolTable();
 
   
+  // --------  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);
   
@@ -97,6 +75,11 @@
   inline int GetNumVariables() const { return m_sym_tbl.GetSize(); }
   inline int GetNumFunctions() const { return m_fun_tbl.GetSize(); }
   
+  inline cString VariableNearMatch(const cString& name) const { return m_sym_dict.NearMatch(name); }
+  inline cString FunctionNearMatch(const cString& name) const { return m_fun_dict.NearMatch(name); }
+
+
+  // --------  Scope Methods  --------
   inline void PushScope() { m_scope++; }
   void PopScope();
   inline int GetScope() const { return m_scope; }
@@ -104,8 +87,12 @@
   inline void SetScopeReturn() { m_return = true; }
   inline bool ScopeHasReturn() const { return m_return; }
   
+
+  // --------  Variable Property Methods  --------
   inline ASType_t 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 cSymbolTable* GetFunctionSymbolTable(int fun_id) { return m_fun_tbl[fun_id]->symtbl; }
@@ -118,10 +105,8 @@
   inline void SetFunctionSignature(int fun_id, cASTVariableDefinitionList* vdl) { m_fun_tbl[fun_id]->signature = vdl; }
   inline void SetFunctionDefinition(int fun_id, cASTNode* code) { m_fun_tbl[fun_id]->code = code; }
   
-  inline cString VariableNearMatch(const cString& name) const { return m_sym_dict.NearMatch(name); }
-  inline cString FunctionNearMatch(const cString& name) const { return m_fun_dict.NearMatch(name); }
-
   
+  // --------  Externally Visible Type Declarations  --------
   class cFunctionIterator
   {
     friend class cSymbolTable;
@@ -148,7 +133,42 @@
   };
 
 
+  // --------  Externally Visible Type Dependent Methods  --------
   inline cFunctionIterator ActiveFunctionIterator() { return cFunctionIterator(this); }  
+  
+
+private:
+  // --------  Internal Type Definitions  --------
+  struct sSymbolEntry
+  {
+    cString name;
+    ASType_t type;
+    
+    int scope;
+    int shadow;
+    int deactivate;
+    
+    sSymbolEntry(const cString& in_name, ASType_t 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;
+    cASTVariableDefinitionList* signature;
+    cSymbolTable* symtbl;
+    cASTNode* code;
+    
+    int scope;
+    int shadow;
+    int deactivate;
+    
+    sFunctionEntry(const cString& in_name, ASType_t 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