[Avida-SVN] r2383 - in development: Avida.xcodeproj source/script source/targets/avida-s
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Tue Feb 26 14:36:44 PST 2008
Author: brysonda
Date: 2008-02-26 17:36:44 -0500 (Tue, 26 Feb 2008)
New Revision: 2383
Added:
development/source/script/cDumpASTVisitor.cc
development/source/script/cDumpASTVisitor.h
Removed:
development/source/script/cASTDumpVisitor.cc
development/source/script/cASTDumpVisitor.h
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/script/cSemanticASTVisitor.h
development/source/targets/avida-s/main.cc
Log:
Rename cASTDumpVisitor to cDumpASTVisitor.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2008-02-26 22:33:02 UTC (rev 2382)
+++ development/Avida.xcodeproj/project.pbxproj 2008-02-26 22:36:44 UTC (rev 2383)
@@ -185,6 +185,7 @@
7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36F0A66AD7E00640512 /* default-transsmt.org */; };
704C21DC0C28C3980038F1A5 /* libtcmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 70AA941909D486AE006A24C8 /* libtcmalloc.a */; };
7050E6780D74C36F008B3CA0 /* AvidaScript.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7050E6770D74C36F008B3CA0 /* AvidaScript.cc */; };
+ 7050E69F0D74CFED008B3CA0 /* cDumpASTVisitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7050E69D0D74CFEB008B3CA0 /* cDumpASTVisitor.cc */; };
70658C5A085DF67D00486BED /* libncurses.5.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 70658C59085DF67D00486BED /* libncurses.5.4.dylib */; };
7073972E0D725B9F003855D3 /* cSemanticASTVisitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */; };
7076FEB00D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7076FEAE0D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc */; };
@@ -198,7 +199,6 @@
70B6514F0BEA6FCC002472ED /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 701EF27E0BEA5D2300DAE168 /* main.cc */; };
70B651B70BEA9AEC002472ED /* unit-tests in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B6514C0BEA6FAD002472ED /* unit-tests */; };
70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAC9B097AF7C0002F8733 /* primitive.cc */; };
- 70F9FC100C469DD70083B788 /* cASTDumpVisitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F9FC0F0C469DC10083B788 /* cASTDumpVisitor.cc */; };
B4FA258A0C5EB65E0086D4B5 /* cPlasticPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */; };
B4FA25A90C5EB7880086D4B5 /* cPhenPlastGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */; };
B516AF840C91E2D400023D53 /* cDemeCellEvent.cc in Sources */ = {isa = PBXBuildFile; fileRef = B516AF790C91E24600023D53 /* cDemeCellEvent.cc */; };
@@ -448,6 +448,8 @@
704ADBC40A6EEFC300666970 /* DriverActions.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DriverActions.cc; sourceTree = "<group>"; };
704D57210AA53F8600207FC1 /* code_standards.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = code_standards.html; sourceTree = "<group>"; };
7050E6770D74C36F008B3CA0 /* AvidaScript.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AvidaScript.cc; sourceTree = "<group>"; };
+ 7050E69D0D74CFEB008B3CA0 /* cDumpASTVisitor.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cDumpASTVisitor.cc; sourceTree = "<group>"; };
+ 7050E69E0D74CFEB008B3CA0 /* cDumpASTVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cDumpASTVisitor.h; sourceTree = "<group>"; };
705260BB0B87A7DB0007426F /* cInstLibEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cInstLibEntry.h; sourceTree = "<group>"; };
705261050B87AF5C0007426F /* cInstLib.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInstLib.h; sourceTree = "<group>"; };
705332480929764A006BD186 /* cSpecies.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cSpecies.cc; sourceTree = "<group>"; };
@@ -824,8 +826,6 @@
70F7DE710929678E009E311D /* cGenotype_BirthData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotype_BirthData.h; sourceTree = "<group>"; };
70F7DE730929678E009E311D /* cGenotype_TestData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotype_TestData.h; sourceTree = "<group>"; };
70F7DE76092967A8009E311D /* cGenotypeBatch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotypeBatch.h; sourceTree = "<group>"; };
- 70F9FC0E0C469DC10083B788 /* cASTDumpVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASTDumpVisitor.h; sourceTree = "<group>"; };
- 70F9FC0F0C469DC10083B788 /* cASTDumpVisitor.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cASTDumpVisitor.cc; sourceTree = "<group>"; };
70F9FD990C4E89C40083B788 /* tAutoRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tAutoRelease.h; sourceTree = "<group>"; };
70FB86A908BFAFEC00BDF589 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
B4FA25800C5EB6510086D4B5 /* cPhenPlastGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cPhenPlastGenotype.h; sourceTree = "<group>"; };
@@ -1207,6 +1207,8 @@
70DCAD1E097AF81A002F8733 /* script */ = {
isa = PBXGroup;
children = (
+ 7050E69D0D74CFEB008B3CA0 /* cDumpASTVisitor.cc */,
+ 7050E69E0D74CFEB008B3CA0 /* cDumpASTVisitor.h */,
7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */,
7073972D0D725B9D003855D3 /* cSemanticASTVisitor.h */,
704368CC0C3198F200A05ABA /* ASTree.cc */,
@@ -1223,8 +1225,6 @@
702F52DE0992FD8000B2B507 /* cScriptObject.h */,
702F52DF0992FD8000B2B507 /* cScriptObject.cc */,
70E130E30C4551E900CE9249 /* cASTVisitor.h */,
- 70F9FC0E0C469DC10083B788 /* cASTDumpVisitor.h */,
- 70F9FC0F0C469DC10083B788 /* cASTDumpVisitor.cc */,
7050E6770D74C36F008B3CA0 /* AvidaScript.cc */,
);
path = script;
@@ -2034,9 +2034,9 @@
7023ECDC0C0A44CC00362B9C /* cScriptObject.cc in Sources */,
7023ECDD0C0A44CE00362B9C /* cSymbolTable.cc in Sources */,
704368D60C31991500A05ABA /* ASTree.cc in Sources */,
- 70F9FC100C469DD70083B788 /* cASTDumpVisitor.cc in Sources */,
7073972E0D725B9F003855D3 /* cSemanticASTVisitor.cc in Sources */,
7050E6780D74C36F008B3CA0 /* AvidaScript.cc in Sources */,
+ 7050E69F0D74CFED008B3CA0 /* cDumpASTVisitor.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Deleted: development/source/script/cASTDumpVisitor.cc
===================================================================
--- development/source/script/cASTDumpVisitor.cc 2008-02-26 22:33:02 UTC (rev 2382)
+++ development/source/script/cASTDumpVisitor.cc 2008-02-26 22:36:44 UTC (rev 2383)
@@ -1,379 +0,0 @@
-/*
- * cASTDumpVisitor.cc
- * Avida
- *
- * Created by David on 7/12/07.
- * Copyright 2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cASTDumpVisitor.h"
-
-#include <iostream>
-
-using namespace std;
-using namespace AvidaScript;
-
-
-cASTDumpVisitor::cASTDumpVisitor() : m_depth(0)
-{
- cout << "main:" << endl;
- m_depth++;
-}
-
-inline void cASTDumpVisitor::indent()
-{
- for (int i = 0; i < m_depth; i++) cout << " ";
-}
-
-void cASTDumpVisitor::visitAssignment(cASTAssignment& node)
-{
- m_depth++;
- indent();
- cout << node.GetVariable() << endl;
- m_depth--;
-
- indent();
- cout << "=" << endl;
-
- m_depth++;
- node.GetExpression()->Accept(*this);
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitReturnStatement(cASTReturnStatement& node)
-{
- indent();
- cout << "return:" << endl;
-
- m_depth++;
- node.GetExpression()->Accept(*this);
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitStatementList(cASTStatementList& node)
-{
- tListIterator<cASTNode> it = node.Iterator();
-
- cASTNode* stmt = NULL;
- while ((stmt = it.Next())) {
- stmt->Accept(*this);
- }
-}
-
-
-
-void cASTDumpVisitor::visitForeachBlock(cASTForeachBlock& node)
-{
- indent();
- cout << "foreach:" << endl;
-
- m_depth++;
- node.GetVariable()->Accept(*this);
-
- indent();
- cout << "values:" << endl;
- m_depth++;
- node.GetValues()->Accept(*this);
-
- m_depth--;
- indent();
- cout << "code:" << endl;
-
- m_depth++;
- node.GetCode()->Accept(*this);
- m_depth--;
-
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitIfBlock(cASTIfBlock& node)
-{
- indent();
- cout << "if:" << endl;
-
- m_depth++;
- indent();
- cout << "condition:" << endl;
-
- m_depth++;
- node.GetCondition()->Accept(*this);
- m_depth--;
-
- indent();
- cout << "do:" << endl;
-
- m_depth++;
- node.GetCode()->Accept(*this);
- m_depth--;
-
- if (node.HasElseIfs()) {
- tListIterator<cASTIfBlock::cElseIf> it = node.ElseIfIterator();
- cASTIfBlock::cElseIf* elif = NULL;
- while ((elif = it.Next())) {
- indent();
- cout << "elseif:" << endl;
-
- m_depth++;
- indent();
- cout << "condition:" << endl;
-
- m_depth++;
- elif->GetCondition()->Accept(*this);
- m_depth--;
-
- indent();
- cout << "do:" << endl;
-
- m_depth++;
- elif->GetCode()->Accept(*this);
- m_depth--;
-
- m_depth--;
- }
- }
-
- if (node.HasElse()) {
- indent();
- cout << "else:" << endl;
-
- m_depth++;
- node.GetElseCode()->Accept(*this);
- m_depth--;
- }
-
- m_depth--;
-
-}
-
-
-void cASTDumpVisitor::visitWhileBlock(cASTWhileBlock& node)
-{
- indent();
- cout << "while:" << endl;
-
- m_depth++;
- indent();
- cout << "condition:" << endl;
-
- m_depth++;
- node.GetCondition()->Accept(*this);
- m_depth--;
-
- indent();
- cout << "do:" << endl;
-
- m_depth++;
- node.GetCode()->Accept(*this);
- m_depth--;
-
- m_depth--;
-}
-
-
-
-void cASTDumpVisitor::visitFunctionDefinition(cASTFunctionDefinition& node)
-{
- indent();
- cout << (node.IsDefinition() ? "":"@") << "function: " << mapType(node.GetType()) << " " << node.GetName() << "(";
- if (node.GetArguments()->GetSize()) {
- cout << endl;
- node.GetArguments()->Accept(*this);
- indent();
- }
- cout << ")" << endl;
-
- indent();
- cout << "{" << endl;
-
- if (node.IsDefinition()) {
- m_depth++;
- node.GetCode()->Accept(*this);
- m_depth--;
- }
-
- indent();
- cout << "}" << endl;
-}
-
-
-void cASTDumpVisitor::visitVariableDefinition(cASTVariableDefinition& node)
-{
- indent();
- cout << mapType(node.GetType()) << " " << node.GetVariable() << endl;
-
- if (node.GetAssignmentExpression()) {
- m_depth++;
- indent();
- cout << "=" << endl;
-
- m_depth++;
- node.GetAssignmentExpression()->Accept(*this);
-
- m_depth -= 2;
- }
-}
-
-
-void cASTDumpVisitor::visitVariableDefinitionList(cASTVariableDefinitionList& node)
-{
- m_depth++;
-
- tListIterator<cASTVariableDefinition> it = node.Iterator();
- cASTNode* val = NULL;
- while ((val = it.Next())) val->Accept(*this);
-
- m_depth--;
-}
-
-
-
-void cASTDumpVisitor::visitExpressionBinary(cASTExpressionBinary& node)
-{
- m_depth++;
- node.GetLeft()->Accept(*this);
- m_depth--;
-
- indent();
- cout << mapToken(node.GetOperator());
- cout << endl;
-
- m_depth++;
- node.GetRight()->Accept(*this);
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitExpressionUnary(cASTExpressionUnary& node)
-{
- indent();
- cout << mapToken(node.GetOperator());
- cout << endl;
-
- m_depth++;
- node.GetExpression()->Accept(*this);
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitArgumentList(cASTArgumentList& node)
-{
- m_depth++;
-
- tListIterator<cASTNode> it = node.Iterator();
- cASTNode* val = NULL;
- while ((val = it.Next())) val->Accept(*this);
-
- m_depth--;
-}
-
-void cASTDumpVisitor::visitFunctionCall(cASTFunctionCall& node)
-{
- indent();
- cout << "call:" << endl;
- m_depth++;
-
- indent();
- cout << "target:" << endl;
-
- m_depth++;
- node.GetTarget()->Accept(*this);
- m_depth--;
-
- if (node.HasArguments()) {
- indent();
- cout << "with:" << endl;
-
- m_depth++;
- node.GetArguments()->Accept(*this);
- m_depth--;
- }
-
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitLiteral(cASTLiteral& node)
-{
- indent();
- cout << "(" << mapType(node.GetType()) << ") " << node.GetValue() << endl;
-}
-
-
-void cASTDumpVisitor::visitLiteralArray(cASTLiteralArray& node)
-{
- indent();
- if (node.IsMatrix()) cout << "$";
- cout << "{" << endl;
- m_depth++;
-
- node.GetValue()->Accept(*this);
-
- m_depth--;
- indent();
- cout << "}" << endl;
-}
-
-
-void cASTDumpVisitor::visitVariableReference(cASTVariableReference& node)
-{
- indent();
- cout << node.GetName() << endl;
-}
-
-
-void cASTDumpVisitor::visitUnpackTarget(cASTUnpackTarget& node)
-{
- m_depth++;
-
- // Array unpack portion
- indent();
- cout << "@{";
- m_depth++;
-
- for (int i = 0; i < node.GetSize(); i++) {
- cout << endl;
- indent();
- cout << node.GetVar(i);
- }
- if (node.IsLastNamed()) {
- cout << "..";
- } else if (node.IsLastWild()) {
- cout << endl;
- indent();
- cout << "..";
- }
- cout << endl;
- m_depth--;
- indent();
- cout << "}" << endl;
-
- // Equals
- m_depth--;
- indent();
- cout << "=" << endl;
- m_depth++;
-
- // Expression portion
- node.GetExpression()->Accept(*this);
-
- m_depth--;
-}
Deleted: development/source/script/cASTDumpVisitor.h
===================================================================
--- development/source/script/cASTDumpVisitor.h 2008-02-26 22:33:02 UTC (rev 2382)
+++ development/source/script/cASTDumpVisitor.h 2008-02-26 22:36:44 UTC (rev 2383)
@@ -1,66 +0,0 @@
-/*
- * cASTDumpVisitor.h
- * Avida
- *
- * Created by David on 7/12/07.
- * Copyright 2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cASTDumpVisitor_h
-#define cASTDumpVisitor_h
-
-#include "cASTVisitor.h"
-
-
-class cASTDumpVisitor : public cASTVisitor
-{
-private:
- int m_depth;
-
-public:
- cASTDumpVisitor();
-
- void visitAssignment(cASTAssignment&);
-
- void visitReturnStatement(cASTReturnStatement&);
- void visitStatementList(cASTStatementList&);
-
- void visitForeachBlock(cASTForeachBlock&);
- void visitIfBlock(cASTIfBlock&);
- void visitWhileBlock(cASTWhileBlock&);
-
- void visitFunctionDefinition(cASTFunctionDefinition&);
- void visitVariableDefinition(cASTVariableDefinition&);
- void visitVariableDefinitionList(cASTVariableDefinitionList&);
-
- void visitExpressionBinary(cASTExpressionBinary&);
- void visitExpressionUnary(cASTExpressionUnary&);
-
- void visitArgumentList(cASTArgumentList&);
- void visitFunctionCall(cASTFunctionCall&);
- void visitLiteral(cASTLiteral&);
- void visitLiteralArray(cASTLiteralArray&);
- void visitVariableReference(cASTVariableReference&);
- void visitUnpackTarget(cASTUnpackTarget&);
-
-private:
- inline void indent();
-};
-
-#endif
Copied: development/source/script/cDumpASTVisitor.cc (from rev 2382, development/source/script/cASTDumpVisitor.cc)
===================================================================
--- development/source/script/cDumpASTVisitor.cc (rev 0)
+++ development/source/script/cDumpASTVisitor.cc 2008-02-26 22:36:44 UTC (rev 2383)
@@ -0,0 +1,379 @@
+/*
+ * cDumpASTVisitor.cc
+ * Avida
+ *
+ * Created by David on 7/12/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "cDumpASTVisitor.h"
+
+#include <iostream>
+
+using namespace std;
+using namespace AvidaScript;
+
+
+cDumpASTVisitor::cDumpASTVisitor() : m_depth(0)
+{
+ cout << "main:" << endl;
+ m_depth++;
+}
+
+inline void cDumpASTVisitor::indent()
+{
+ for (int i = 0; i < m_depth; i++) cout << " ";
+}
+
+void cDumpASTVisitor::visitAssignment(cASTAssignment& node)
+{
+ m_depth++;
+ indent();
+ cout << node.GetVariable() << endl;
+ m_depth--;
+
+ indent();
+ cout << "=" << endl;
+
+ m_depth++;
+ node.GetExpression()->Accept(*this);
+ m_depth--;
+}
+
+
+void cDumpASTVisitor::visitReturnStatement(cASTReturnStatement& node)
+{
+ indent();
+ cout << "return:" << endl;
+
+ m_depth++;
+ node.GetExpression()->Accept(*this);
+ m_depth--;
+}
+
+
+void cDumpASTVisitor::visitStatementList(cASTStatementList& node)
+{
+ tListIterator<cASTNode> it = node.Iterator();
+
+ cASTNode* stmt = NULL;
+ while ((stmt = it.Next())) {
+ stmt->Accept(*this);
+ }
+}
+
+
+
+void cDumpASTVisitor::visitForeachBlock(cASTForeachBlock& node)
+{
+ indent();
+ cout << "foreach:" << endl;
+
+ m_depth++;
+ node.GetVariable()->Accept(*this);
+
+ indent();
+ cout << "values:" << endl;
+ m_depth++;
+ node.GetValues()->Accept(*this);
+
+ m_depth--;
+ indent();
+ cout << "code:" << endl;
+
+ m_depth++;
+ node.GetCode()->Accept(*this);
+ m_depth--;
+
+ m_depth--;
+}
+
+
+void cDumpASTVisitor::visitIfBlock(cASTIfBlock& node)
+{
+ indent();
+ cout << "if:" << endl;
+
+ m_depth++;
+ indent();
+ cout << "condition:" << endl;
+
+ m_depth++;
+ node.GetCondition()->Accept(*this);
+ m_depth--;
+
+ indent();
+ cout << "do:" << endl;
+
+ m_depth++;
+ node.GetCode()->Accept(*this);
+ m_depth--;
+
+ if (node.HasElseIfs()) {
+ tListIterator<cASTIfBlock::cElseIf> it = node.ElseIfIterator();
+ cASTIfBlock::cElseIf* elif = NULL;
+ while ((elif = it.Next())) {
+ indent();
+ cout << "elseif:" << endl;
+
+ m_depth++;
+ indent();
+ cout << "condition:" << endl;
+
+ m_depth++;
+ elif->GetCondition()->Accept(*this);
+ m_depth--;
+
+ indent();
+ cout << "do:" << endl;
+
+ m_depth++;
+ elif->GetCode()->Accept(*this);
+ m_depth--;
+
+ m_depth--;
+ }
+ }
+
+ if (node.HasElse()) {
+ indent();
+ cout << "else:" << endl;
+
+ m_depth++;
+ node.GetElseCode()->Accept(*this);
+ m_depth--;
+ }
+
+ m_depth--;
+
+}
+
+
+void cDumpASTVisitor::visitWhileBlock(cASTWhileBlock& node)
+{
+ indent();
+ cout << "while:" << endl;
+
+ m_depth++;
+ indent();
+ cout << "condition:" << endl;
+
+ m_depth++;
+ node.GetCondition()->Accept(*this);
+ m_depth--;
+
+ indent();
+ cout << "do:" << endl;
+
+ m_depth++;
+ node.GetCode()->Accept(*this);
+ m_depth--;
+
+ m_depth--;
+}
+
+
+
+void cDumpASTVisitor::visitFunctionDefinition(cASTFunctionDefinition& node)
+{
+ indent();
+ cout << (node.IsDefinition() ? "":"@") << "function: " << mapType(node.GetType()) << " " << node.GetName() << "(";
+ if (node.GetArguments()->GetSize()) {
+ cout << endl;
+ node.GetArguments()->Accept(*this);
+ indent();
+ }
+ cout << ")" << endl;
+
+ indent();
+ cout << "{" << endl;
+
+ if (node.IsDefinition()) {
+ m_depth++;
+ node.GetCode()->Accept(*this);
+ m_depth--;
+ }
+
+ indent();
+ cout << "}" << endl;
+}
+
+
+void cDumpASTVisitor::visitVariableDefinition(cASTVariableDefinition& node)
+{
+ indent();
+ cout << mapType(node.GetType()) << " " << node.GetVariable() << endl;
+
+ if (node.GetAssignmentExpression()) {
+ m_depth++;
+ indent();
+ cout << "=" << endl;
+
+ m_depth++;
+ node.GetAssignmentExpression()->Accept(*this);
+
+ m_depth -= 2;
+ }
+}
+
+
+void cDumpASTVisitor::visitVariableDefinitionList(cASTVariableDefinitionList& node)
+{
+ m_depth++;
+
+ tListIterator<cASTVariableDefinition> it = node.Iterator();
+ cASTNode* val = NULL;
+ while ((val = it.Next())) val->Accept(*this);
+
+ m_depth--;
+}
+
+
+
+void cDumpASTVisitor::visitExpressionBinary(cASTExpressionBinary& node)
+{
+ m_depth++;
+ node.GetLeft()->Accept(*this);
+ m_depth--;
+
+ indent();
+ cout << mapToken(node.GetOperator());
+ cout << endl;
+
+ m_depth++;
+ node.GetRight()->Accept(*this);
+ m_depth--;
+}
+
+
+void cDumpASTVisitor::visitExpressionUnary(cASTExpressionUnary& node)
+{
+ indent();
+ cout << mapToken(node.GetOperator());
+ cout << endl;
+
+ m_depth++;
+ node.GetExpression()->Accept(*this);
+ m_depth--;
+}
+
+
+void cDumpASTVisitor::visitArgumentList(cASTArgumentList& node)
+{
+ m_depth++;
+
+ tListIterator<cASTNode> it = node.Iterator();
+ cASTNode* val = NULL;
+ while ((val = it.Next())) val->Accept(*this);
+
+ m_depth--;
+}
+
+void cDumpASTVisitor::visitFunctionCall(cASTFunctionCall& node)
+{
+ indent();
+ cout << "call:" << endl;
+ m_depth++;
+
+ indent();
+ cout << "target:" << endl;
+
+ m_depth++;
+ node.GetTarget()->Accept(*this);
+ m_depth--;
+
+ if (node.HasArguments()) {
+ indent();
+ cout << "with:" << endl;
+
+ m_depth++;
+ node.GetArguments()->Accept(*this);
+ m_depth--;
+ }
+
+ m_depth--;
+}
+
+
+void cDumpASTVisitor::visitLiteral(cASTLiteral& node)
+{
+ indent();
+ cout << "(" << mapType(node.GetType()) << ") " << node.GetValue() << endl;
+}
+
+
+void cDumpASTVisitor::visitLiteralArray(cASTLiteralArray& node)
+{
+ indent();
+ if (node.IsMatrix()) cout << "$";
+ cout << "{" << endl;
+ m_depth++;
+
+ node.GetValue()->Accept(*this);
+
+ m_depth--;
+ indent();
+ cout << "}" << endl;
+}
+
+
+void cDumpASTVisitor::visitVariableReference(cASTVariableReference& node)
+{
+ indent();
+ cout << node.GetName() << endl;
+}
+
+
+void cDumpASTVisitor::visitUnpackTarget(cASTUnpackTarget& node)
+{
+ m_depth++;
+
+ // Array unpack portion
+ indent();
+ cout << "@{";
+ m_depth++;
+
+ for (int i = 0; i < node.GetSize(); i++) {
+ cout << endl;
+ indent();
+ cout << node.GetVar(i);
+ }
+ if (node.IsLastNamed()) {
+ cout << "..";
+ } else if (node.IsLastWild()) {
+ cout << endl;
+ indent();
+ cout << "..";
+ }
+ cout << endl;
+ m_depth--;
+ indent();
+ cout << "}" << endl;
+
+ // Equals
+ m_depth--;
+ indent();
+ cout << "=" << endl;
+ m_depth++;
+
+ // Expression portion
+ node.GetExpression()->Accept(*this);
+
+ m_depth--;
+}
Copied: development/source/script/cDumpASTVisitor.h (from rev 2382, development/source/script/cASTDumpVisitor.h)
===================================================================
--- development/source/script/cDumpASTVisitor.h (rev 0)
+++ development/source/script/cDumpASTVisitor.h 2008-02-26 22:36:44 UTC (rev 2383)
@@ -0,0 +1,66 @@
+/*
+ * cDumpASTVisitor.h
+ * Avida
+ *
+ * Created by David on 7/12/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cDumpASTVisitor_h
+#define cDumpASTVisitor_h
+
+#include "cASTVisitor.h"
+
+
+class cDumpASTVisitor : public cASTVisitor
+{
+private:
+ int m_depth;
+
+public:
+ cDumpASTVisitor();
+
+ void visitAssignment(cASTAssignment&);
+
+ void visitReturnStatement(cASTReturnStatement&);
+ void visitStatementList(cASTStatementList&);
+
+ void visitForeachBlock(cASTForeachBlock&);
+ void visitIfBlock(cASTIfBlock&);
+ void visitWhileBlock(cASTWhileBlock&);
+
+ void visitFunctionDefinition(cASTFunctionDefinition&);
+ void visitVariableDefinition(cASTVariableDefinition&);
+ void visitVariableDefinitionList(cASTVariableDefinitionList&);
+
+ void visitExpressionBinary(cASTExpressionBinary&);
+ void visitExpressionUnary(cASTExpressionUnary&);
+
+ void visitArgumentList(cASTArgumentList&);
+ void visitFunctionCall(cASTFunctionCall&);
+ void visitLiteral(cASTLiteral&);
+ void visitLiteralArray(cASTLiteralArray&);
+ void visitVariableReference(cASTVariableReference&);
+ void visitUnpackTarget(cASTUnpackTarget&);
+
+private:
+ inline void indent();
+};
+
+#endif
Modified: development/source/script/cSemanticASTVisitor.h
===================================================================
--- development/source/script/cSemanticASTVisitor.h 2008-02-26 22:33:02 UTC (rev 2382)
+++ development/source/script/cSemanticASTVisitor.h 2008-02-26 22:36:44 UTC (rev 2383)
@@ -1,5 +1,5 @@
/*
- * cASTDumpVisitor.h
+ * cDumpASTVisitor.h
* Avida
*
* Created by David on 7/12/07.
Modified: development/source/targets/avida-s/main.cc
===================================================================
--- development/source/targets/avida-s/main.cc 2008-02-26 22:33:02 UTC (rev 2382)
+++ development/source/targets/avida-s/main.cc 2008-02-26 22:36:44 UTC (rev 2383)
@@ -26,7 +26,7 @@
#include "PlatformExpert.h"
#include "cASLibrary.h"
-#include "cASTDumpVisitor.h"
+#include "cDumpASTVisitor.h"
#include "cFile.h"
#include "cParser.h"
#include "cSemanticASTVisitor.h"
@@ -53,7 +53,7 @@
cSemanticASTVisitor semantic_check(lib, &global_symtbl);
tree->Accept(semantic_check);
- cASTDumpVisitor dump;
+ cDumpASTVisitor dump;
tree->Accept(dump);
std::cout << std::endl;
More information about the Avida-cvs
mailing list