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

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Sep 12 15:20:52 PDT 2008


Author: brysonda
Date: 2008-09-12 18:20:51 -0400 (Fri, 12 Sep 2008)
New Revision: 2777

Modified:
   development/source/script/ASTree.h
   development/source/script/cSemanticASTVisitor.cc
Log:
AS (#1): Implement semantic check for object references and calls.

Modified: development/source/script/ASTree.h
===================================================================
--- development/source/script/ASTree.h	2008-09-12 18:14:35 UTC (rev 2776)
+++ development/source/script/ASTree.h	2008-09-12 22:20:51 UTC (rev 2777)
@@ -600,7 +600,7 @@
   
 public:
   cASTObjectCall(const cASFilePosition& fp, cASTNode* object, const cString& name)
-    : cASTNode(fp), m_object(object), m_name(name), m_args(NULL), m_type(AS_TYPE_INVALID) { ; }
+    : cASTNode(fp), m_object(object), m_name(name), m_args(NULL), m_type(AS_TYPE_RUNTIME) { ; }
   ~cASTObjectCall() { delete m_object; delete m_args; }
   
   cASTNode* GetObject() { return m_object; }
@@ -609,10 +609,8 @@
   void SetArguments(cASTArgumentList* args) { delete m_args; m_args = args; }
   cASTArgumentList* GetArguments() { return m_args; }
   
-  const sASTypeInfo& GetType() const { return m_type; }
-  inline void SetType(const sASTypeInfo& type) { m_type = type; }
+  const sASTypeInfo& GetType() const { return m_type; }  
   
-  
   bool HasArguments() const { return (m_args); }
   
   void Accept(cASTVisitor& visitor);
@@ -628,7 +626,7 @@
   
 public:
   cASTObjectReference(const cASFilePosition& fp, cASTNode* object, const cString& name)
-    : cASTNode(fp), m_object(object), m_name(name), m_type(AS_TYPE_OBJECT_REF) { ; }
+    : cASTNode(fp), m_object(object), m_name(name), m_type(AS_TYPE_RUNTIME) { ; }
   ~cASTObjectReference() { delete m_object; }
   
   cASTNode* GetObject() { return m_object; }

Modified: development/source/script/cSemanticASTVisitor.cc
===================================================================
--- development/source/script/cSemanticASTVisitor.cc	2008-09-12 18:14:35 UTC (rev 2776)
+++ development/source/script/cSemanticASTVisitor.cc	2008-09-12 22:20:51 UTC (rev 2777)
@@ -810,15 +810,21 @@
 
 void cSemanticASTVisitor::VisitObjectCall(cASTObjectCall& node)
 {
-  // @TODO - object call
-  SEMANTIC_ERROR(INTERNAL);
+  node.GetObject()->Accept(*this);
+  checkCast(node.GetObject()->GetType(), TYPEINFO(OBJECT_REF));
+  
+  if (node.HasArguments()) { 
+    tListIterator<cASTNode> it = node.GetArguments()->Iterator();
+    cASTNode* an = NULL;
+    while((an = it.Next())) an->Accept(*this);
+  }
 }
 
 
 void cSemanticASTVisitor::VisitObjectReference(cASTObjectReference& node)
 {
-  // @TODO - object reference
-  SEMANTIC_ERROR(INTERNAL);
+  node.GetObject()->Accept(*this);
+  checkCast(node.GetObject()->GetType(), TYPEINFO(OBJECT_REF));
 }
 
 




More information about the Avida-cvs mailing list