[Avida-SVN] r2637 - in branches/collect: Avida.xcodeproj documentation source/actions source/main source/script source/targets/avida-s source/utils/make_actions_html support/config
blwalker at myxo.css.msu.edu
blwalker at myxo.css.msu.edu
Tue Jun 10 10:52:01 PDT 2008
Author: blwalker
Date: 2008-06-10 13:52:01 -0400 (Tue, 10 Jun 2008)
New Revision: 2637
Added:
branches/collect/source/script/AvidaScript.cc
branches/collect/source/script/cDumpASTVisitor.cc
branches/collect/source/script/cDumpASTVisitor.h
Removed:
branches/collect/source/script/cASTDumpVisitor.cc
branches/collect/source/script/cASTDumpVisitor.h
Modified:
branches/collect/Avida.xcodeproj/project.pbxproj
branches/collect/documentation/actions.html
branches/collect/source/actions/EnvironmentActions.cc
branches/collect/source/actions/PrintActions.cc
branches/collect/source/main/cAvidaConfig.h
branches/collect/source/main/cEnvironment.cc
branches/collect/source/main/cEnvironment.h
branches/collect/source/main/cPopulation.cc
branches/collect/source/main/cPopulationCell.h
branches/collect/source/main/cReactionProcess.h
branches/collect/source/main/cStats.cc
branches/collect/source/main/cStats.h
branches/collect/source/main/cTaskLib.cc
branches/collect/source/main/cTaskLib.h
branches/collect/source/main/nReaction.h
branches/collect/source/script/ASTree.h
branches/collect/source/script/AvidaScript.h
branches/collect/source/script/cParser.cc
branches/collect/source/script/cParser.h
branches/collect/source/script/cScriptObject.h
branches/collect/source/script/cSemanticASTVisitor.cc
branches/collect/source/script/cSemanticASTVisitor.h
branches/collect/source/script/cSymbolTable.cc
branches/collect/source/script/cSymbolTable.h
branches/collect/source/targets/avida-s/main.cc
branches/collect/source/utils/make_actions_html/actions_source_info
branches/collect/source/utils/make_actions_html/make_actions_html.pl
branches/collect/support/config/avida.cfg
Log:
Porting r2372:2383 from development to collect branch
Modified: branches/collect/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/collect/Avida.xcodeproj/project.pbxproj 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/Avida.xcodeproj/project.pbxproj 2008-06-10 17:52:01 UTC (rev 2637)
@@ -184,6 +184,8 @@
7049F3720A66AD7E00640512 /* default-smt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36E0A66AD7E00640512 /* default-smt.org */; };
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 */; };
@@ -197,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 */; };
@@ -446,6 +447,9 @@
704ADBC30A6EEFC300666970 /* DriverActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DriverActions.h; sourceTree = "<group>"; };
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>"; };
@@ -822,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>"; };
@@ -1205,6 +1207,8 @@
70DCAD1E097AF81A002F8733 /* script */ = {
isa = PBXGroup;
children = (
+ 7050E69D0D74CFEB008B3CA0 /* cDumpASTVisitor.cc */,
+ 7050E69E0D74CFEB008B3CA0 /* cDumpASTVisitor.h */,
7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */,
7073972D0D725B9D003855D3 /* cSemanticASTVisitor.h */,
704368CC0C3198F200A05ABA /* ASTree.cc */,
@@ -1221,8 +1225,7 @@
702F52DE0992FD8000B2B507 /* cScriptObject.h */,
702F52DF0992FD8000B2B507 /* cScriptObject.cc */,
70E130E30C4551E900CE9249 /* cASTVisitor.h */,
- 70F9FC0E0C469DC10083B788 /* cASTDumpVisitor.h */,
- 70F9FC0F0C469DC10083B788 /* cASTDumpVisitor.cc */,
+ 7050E6770D74C36F008B3CA0 /* AvidaScript.cc */,
);
path = script;
sourceTree = "<group>";
@@ -1756,6 +1759,7 @@
70DCAC9F097AF7CC002F8733 /* Sources */,
70DCAD07097AF7CC002F8733 /* Frameworks */,
70DCAD08097AF7CC002F8733 /* CopyFiles */,
+ 70D845480D73677E00601F5A /* ShellScript */,
);
buildRules = (
70DCAD2A097AF865002F8733 /* PBXBuildRule */,
@@ -1826,7 +1830,22 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "mkdir -p $DERIVED_FILE_DIR\nif (test -x /usr/bin/svnversion)\nthen svncmd=/usr/bin/svnversion\nelif (test -x /usr/local/bin/svnversion)\nthen svncmd=/usr/local/bin/svnversion\nelif (test -x /usr/local/svn/bin/svnversion)\nthen svncmd=/usr/local/svn/bin/svnversion\nelse\n echo \"Warning: 'svn' not found, please install subversion\"\n if [[ ! -f $DERIVED_FILE_DIR/revision.h ]]\n then\n echo \"#ifndef revision_h\" > $DERIVED_FILE_DIR/revision.h\n echo \"#define revision_h\" >> $DERIVED_FILE_DIR/revision.h\n echo \"#define REVISION \\\"???\\\"\" >> $DERIVED_FILE_DIR/revision.h\n echo \"#endif\" >> $DERIVED_FILE_DIR/revision.h\n fi\nfi\n\necho \"#ifndef revision_h\" > /tmp/newrev.tmp\necho \"#define revision_h\" >> /tmp/newrev.tmp\necho \\#define REVISION \\\"`$svncmd`\\\" >> /tmp/newrev.tmp\necho \"#endif\" >> /tmp/newrev.tmp\n\nif [[ -f $DERIVED_FILE_DIR/revision.h ]]\nthen\n revdiff=`diff $DERIVED_FILE_DIR/revision.h /tmp/newrev.tmp`\nelse\n!
revdiff=\"yes\"\nfi\n\nif [[ -n \"$revdiff\" ]]\nthen\n echo \"New revision.h Generated\"\n cp /tmp/newrev.tmp $DERIVED_FILE_DIR/revision.h\n touch $SRCROOT/source/main/avida.cc\nfi\n\nrm /tmp/newrev.tmp\n";
+ showEnvVarsInLog = 0;
};
+ 70D845480D73677E00601F5A /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "./run_tests --builddir=$BUILD_DIR/$BUILD_STYLE/ _asl*";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -2015,8 +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;
};
Modified: branches/collect/documentation/actions.html
===================================================================
--- branches/collect/documentation/actions.html 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/documentation/actions.html 2008-06-10 17:52:01 UTC (rev 2637)
@@ -9,7 +9,7 @@
<div class="revision">
Revised 2006-09-03 DMB
-<br>Generated Mon Feb 18 16:33:15 2008 by make_actions_html</div>
+<br>Generated Mon Feb 25 09:53:04 2008 by make_actions_html</div>
<p>
<a href="index.html">Return to the Index</a> |
@@ -106,8 +106,10 @@
<a href="#Exit">Exit</a><br>
<a href="#exit_if_ave_lineage_label_larger">exit_if_ave_lineage_label_larger</a><br>
<a href="#exit_if_ave_lineage_label_smaller">exit_if_ave_lineage_label_smaller</a><br>
+ <a href="#ExitAveGeneration">ExitAveGeneration</a><br>
<a href="#ExitAveLineageLabelGreater">ExitAveLineageLabelGreater</a><br>
<a href="#ExitAveLineageLabelLess">ExitAveLineageLabelLess</a><br>
+ <a href="#ExitElapsedTime">ExitElapsedTime</a><br>
<a href="#FullLandscape">FullLandscape</a><br>
<a href="#genetic_distance_pop_dump">genetic_distance_pop_dump</a><br>
<a href="#HillClimb">HillClimb</a><br>
@@ -129,6 +131,7 @@
<a href="#InjectResource">InjectResource</a><br>
<a href="#InjectScaledResource">InjectScaledResource</a><br>
<a href="#InjectSequence">InjectSequence</a><br>
+ <a href="#InjectSequenceWDivMutRate">InjectSequenceWDivMutRate</a><br>
<a href="#InsertionLandscape">InsertionLandscape</a><br>
<a href="#join_grid_col">join_grid_col</a><br>
<a href="#join_grid_row">join_grid_row</a><br>
@@ -194,11 +197,13 @@
<a href="#PrintCCladeRelativeFitnessHistogram">PrintCCladeRelativeFitnessHistogram</a><br>
<a href="#PrintCompetitionData">PrintCompetitionData</a><br>
<a href="#PrintCountData">PrintCountData</a><br>
+ <a href="#PrintCurrentReactionData">PrintCurrentReactionData</a><br>
<a href="#PrintData">PrintData</a><br>
<a href="#PrintDebug">PrintDebug</a><br>
<a href="#PrintDemeAllStats">PrintDemeAllStats</a><br>
<a href="#PrintDemeAverageData">PrintDemeAverageData</a><br>
<a href="#PrintDemeDonorStats">PrintDemeDonorStats</a><br>
+ <a href="#PrintDemeReplicationData">PrintDemeReplicationData</a><br>
<a href="#PrintDemeResourceStats">PrintDemeResourceStats</a><br>
<a href="#PrintDemeSpacialEnergyStats">PrintDemeSpacialEnergyStats</a><br>
<a href="#PrintDemeSpacialSleepStats">PrintDemeSpacialSleepStats</a><br>
@@ -215,6 +220,7 @@
<a href="#PrintGenotypeAbundanceHistogram">PrintGenotypeAbundanceHistogram</a><br>
<a href="#PrintGenotypeMap">PrintGenotypeMap</a><br>
<a href="#PrintGenotypes">PrintGenotypes</a><br>
+ <a href="#PrintGermlineData">PrintGermlineData</a><br>
<a href="#PrintInstructionAbundanceHistogram">PrintInstructionAbundanceHistogram</a><br>
<a href="#PrintInstructionData">PrintInstructionData</a><br>
<td valign="top">
@@ -267,8 +273,8 @@
<a href="#set_reaction_value_mult">set_reaction_value_mult</a><br>
<a href="#set_resource">set_resource</a><br>
<a href="#SetCellResource">SetCellResource</a><br>
- <a href="#SetEnvironmentInputMask">SetEnvironmentInputMask</a><br>
<a href="#SetEnvironmentInputs">SetEnvironmentInputs</a><br>
+ <a href="#SetEnvironmentRandomMask">SetEnvironmentRandomMask</a><br>
<a href="#SetMutProb">SetMutProb</a><br>
<a href="#SetNumInstBefore0Energy">SetNumInstBefore0Energy</a><br>
<a href="#SetOptimizeMinMax">SetOptimizeMinMax</a><br>
@@ -276,6 +282,7 @@
<a href="#SetReactionInst">SetReactionInst</a><br>
<a href="#SetReactionMaxTaskCount">SetReactionMaxTaskCount</a><br>
<a href="#SetReactionMinTaskCount">SetReactionMinTaskCount</a><br>
+ <a href="#SetReactionTask">SetReactionTask</a><br>
<a href="#SetReactionValue">SetReactionValue</a><br>
<a href="#SetReactionValueMult">SetReactionValueMult</a><br>
<a href="#SetResource">SetResource</a><br>
@@ -289,6 +296,7 @@
<a href="#sever_grid_row">sever_grid_row</a><br>
<a href="#SeverGridCol">SeverGridCol</a><br>
<a href="#SeverGridRow">SeverGridRow</a><br>
+ <a href="#StopFastForward">StopFastForward</a><br>
<a href="#swap_cells">swap_cells</a><br>
<a href="#SwapCells">SwapCells</a><br>
<a href="#task_snapshot">task_snapshot</a><br>
@@ -299,6 +307,7 @@
<a href="#VERBOSE">VERBOSE</a><br>
<a href="#zero_muts">zero_muts</a><br>
<a href="#ZeroMuts">ZeroMuts</a><br>
+ <a href="#ZeroResources">ZeroResources</a><br>
</tr>
</table>
<p> </p>
@@ -342,6 +351,14 @@
</p>
</li>
<li><p>
+ <strong><a name="ExitAveGeneration">ExitAveGeneration</a></strong>
+ <i><double generation></i>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
<strong><a name="ExitAveLineageLabelGreater">ExitAveLineageLabelGreater</a></strong>
<i><double threshold></i>
</p>
@@ -361,6 +378,22 @@
</p>
</li>
+<li><p>
+ <strong><a name="ExitElapsedTime">ExitElapsedTime</a></strong>
+ <i><int elapsed time [seconds]></i>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
+ <strong><a name="StopFastForward">StopFastForward</a></strong>
+ <i>none</i>
+ </p>
+ <p>
+
+ </p>
+</li>
</UL>
<p> </p>
<h2><a name="EnvironmentActions">Environment Actions</a></h2>
@@ -470,14 +503,6 @@
</p>
</li>
<li><p>
- <strong><a name="SetEnvironmentInputMask">SetEnvironmentInputMask</a></strong>
- <i><int mask> <int value> </i>
- </p>
- <p>
-
- </p>
-</li>
-<li><p>
<strong><a name="SetEnvironmentInputs">SetEnvironmentInputs</a></strong>
<i><int input_1> <int input_2> <int input_3> </i>
</p>
@@ -489,6 +514,14 @@
</p>
</li>
<li><p>
+ <strong><a name="SetEnvironmentRandomMask">SetEnvironmentRandomMask</a></strong>
+ <i><int mask></i>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
<strong><a name="SetNumInstBefore0Energy">SetNumInstBefore0Energy</a></strong>
<i><int new_value></i>
</p>
@@ -547,6 +580,17 @@
</p>
</li>
<li><p>
+ <strong><a name="SetReactionTask">SetReactionTask</a></strong>
+ <i><string reaction_name> <string task_name></i>
+ </p>
+ <p>
+ Set the task required to trigger a reaction to <span class="cmdarg">task_name</span>.
+ <span class="cmdarg">reaction_name</span> and <span class="cmdarg">task_name</span> must already
+ exist in the environment file.
+
+ </p>
+</li>
+<li><p>
<strong><a name="SetReactionValue">SetReactionValue</a></strong>
<i><string reaction_name> <double value></i>
</p>
@@ -627,6 +671,15 @@
</p>
</li>
+<li><p>
+ <strong><a name="ZeroResources">ZeroResources</a></strong>
+ <i>none</i>
+ </p>
+ <p>
+ Set all resurce levels to zero.
+
+ </p>
+</li>
</UL>
<p> </p>
<h2><a name="LandscapeActions">Landscape Analysis Actions</a></h2>
@@ -1025,6 +1078,14 @@
</p>
</li>
<li><p>
+ <strong><a name="InjectSequenceWDivMutRate">InjectSequenceWDivMutRate</a></strong>
+ <i><string sequence> [int cell_start=0] [int cell_end=-1] [double div_mut_rate=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]</i>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
<strong><a name="join_grid_col">join_grid_col</a></strong>
<i>[int col_id=-1] [int min_row=0] [int max_row=-1]</i>
</p>
@@ -1812,6 +1873,13 @@
</p>
</li>
<li><p>
+ <strong><a name="PrintCurrentReactionData">PrintCurrentReactionData</a></strong>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
<strong><a name="PrintData">PrintData</a></strong>
<i><cString fname> <cString format></i>
</p>
@@ -1858,6 +1926,13 @@
</p>
</li>
<li><p>
+ <strong><a name="PrintDemeReplicationData">PrintDemeReplicationData</a></strong>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
<strong><a name="PrintDemeResourceStats">PrintDemeResourceStats</a></strong>
<i>No Arguments</i>
</p>
@@ -2031,6 +2106,13 @@
</p>
</li>
<li><p>
+ <strong><a name="PrintGermlineData">PrintGermlineData</a></strong>
+ </p>
+ <p>
+
+ </p>
+</li>
+<li><p>
<strong><a name="PrintInstructionAbundanceHistogram">PrintInstructionAbundanceHistogram</a></strong>
<i>[string fname="instruction_histogram.dat"]</i>
</p>
Modified: branches/collect/source/actions/EnvironmentActions.cc
===================================================================
--- branches/collect/source/actions/EnvironmentActions.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/actions/EnvironmentActions.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -334,6 +334,29 @@
}
};
+class cActionSetReactionTask : public cAction
+{
+private:
+ cString m_name;
+ cString m_task;
+
+public:
+ cActionSetReactionTask(cWorld* world, const cString& args) : cAction(world, args), m_name(""), m_task("")
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_name = largs.PopWord();
+ if (largs.GetSize()) m_task = largs.PopWord();
+ }
+
+ static const cString GetDescription() { return "Arguments: <string reaction_name> <string task_name>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ bool success = m_world->GetEnvironment().SetReactionTask(m_name, m_task);
+ if (!success) m_world->GetDriver().RaiseFatalException(-2,"SetReactionTask action failed");
+ }
+};
+
class cActionSetResourceInflow : public cAction
{
private:
@@ -723,6 +746,7 @@
action_lib->Register<cActionSetReactionInst>("SetReactionInst");
action_lib->Register<cActionSetReactionMinTaskCount>("SetReactionMinTaskCount");
action_lib->Register<cActionSetReactionMaxTaskCount>("SetReactionMaxTaskCount");
+ action_lib->Register<cActionSetReactionTask>("SetReactionTask");
action_lib->Register<cActionSetResourceInflow>("SetResourceInflow");
action_lib->Register<cActionSetResourceOutflow>("SetResourceOutflow");
Modified: branches/collect/source/actions/PrintActions.cc
===================================================================
--- branches/collect/source/actions/PrintActions.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/actions/PrintActions.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -98,6 +98,8 @@
STATS_OUT_FILE(PrintCompetitionData, competition.dat );
STATS_OUT_FILE(PrintDemeReplicationData, deme_repl.dat );
STATS_OUT_FILE(PrintGermlineData, germline.dat );
+// @WRE: Added output event for collected visit counts
+STATS_OUT_FILE(PrintCellVisitsData, visits.dat );
#define POP_OUT_FILE(METHOD, DEFAULT) /* 1 */ \
@@ -2640,6 +2642,9 @@
action_lib->Register<cActionPrintInternalTasksQualData>("PrintInternalTasksQualData");
action_lib->Register<cActionPrintSleepData>("PrintSleepData");
action_lib->Register<cActionPrintCompetitionData>("PrintCompetitionData");
+
+ // @WRE: Added printing of visit data
+ action_lib->Register<cActionPrintCellVisitsData>("PrintCellVisitsData");
// Population Out Files
action_lib->Register<cActionPrintPhenotypeData>("PrintPhenotypeData");
Modified: branches/collect/source/main/cAvidaConfig.h
===================================================================
--- branches/collect/source/main/cAvidaConfig.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cAvidaConfig.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -516,9 +516,11 @@
CONFIG_ADD_GROUP(BIOMIMETIC_GROUP, "Biomimetic Features Settings");
CONFIG_ADD_VAR(BIOMIMETIC_REFRACTORY_PERIOD, double, 0.0, "Number of updates affected by refractory period");
CONFIG_ADD_VAR(BIOMIMETIC_MOVEMENT_STEP, int, 0, "Number of cells to move Avidian on move instruction");
+ CONFIG_ADD_VAR(BIOMIMETIC_MOVEMENT_LOG, int, 0, "Log detailed movement information (WARNING: large data file)");
+ CONFIG_ADD_VAR(BIOMIMETIC_MOVEMENT_FACTOR, double, 1.0, "Scale merit bonus due to movement (m<1.0 applies a cost)");
+ CONFIG_ADD_VAR(BIOMIMETIC_EVAL_ON_MOVEMENT, int, 0, "Force task evaluation on each movement step");
CONFIG_ADD_VAR(BIOMIMETIC_K, int, 0, "Carrying capacity in number of organisms");
-
CONFIG_ADD_CUSTOM_FORMAT(INST_SET_NEW, "Instruction Set Definition");
CONFIG_ADD_FORMAT_VAR(INST, "Instruction entry in the instruction set");
Modified: branches/collect/source/main/cEnvironment.cc
===================================================================
--- branches/collect/source/main/cEnvironment.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cEnvironment.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -162,6 +162,7 @@
else if (var_value=="lin") new_process->SetType(nReaction::PROCTYPE_LIN);
else if (var_value=="energy") new_process->SetType(nReaction::PROCTYPE_ENERGY);
else if (var_value=="enzyme") new_process->SetType(nReaction::PROCTYPE_ENZYME);
+ else if (var_value=="exp") new_process->SetType(nReaction::PROCTYPE_EXP);
else {
cerr << "Unknown reaction process type '" << var_value
<< "' found in '" << reaction->GetName() << "'." << endl;
@@ -1054,14 +1055,24 @@
result.AddEnergy(bonus);
break;
case nReaction::PROCTYPE_ENZYME: //@JEB
- {
- const int res_id = in_resource->GetID();
- assert(cur_process->GetMaxFraction() != 0);
- assert(resource_count[res_id] != 0);
- double reward = cur_process->GetValue() * resource_count[res_id] / (resource_count[res_id] + cur_process->GetMaxFraction());
- result.AddBonus( reward , reaction_id);
- }
+ {
+ const int res_id = in_resource->GetID();
+ assert(cur_process->GetMaxFraction() != 0);
+ assert(resource_count[res_id] != 0);
+ double reward = cur_process->GetValue() * resource_count[res_id] / (resource_count[res_id] + cur_process->GetMaxFraction());
+ result.AddBonus( reward , reaction_id);
break;
+ }
+ case nReaction::PROCTYPE_EXP: //@JEB
+ {
+ // Cumulative rewards are Value * integral (exp (-MaxFraction * TaskCount))
+ // Evaluate to get stepwise amount to add per task executed.
+ assert(task_count >= 1);
+ const double decay = cur_process->GetMaxFraction();
+ const double value = cur_process->GetValue();
+ result.AddBonus( value * (1.0 / decay) * ( exp((task_count-1) * decay) - exp(task_count * decay)), reaction_id );
+ break;
+ }
default:
assert(false); // Should not get here!
@@ -1178,6 +1189,49 @@
return found_reaction->SetMaxTaskCount( max_count );
}
+bool cEnvironment::SetReactionTask(const cString& name, const cString& task)
+{
+ cReaction* found_reaction = reaction_lib.GetReaction(name);
+ if (found_reaction == NULL) return false;
+
+ for(int i=0; i<m_tasklib.GetSize(); i++)
+ {
+ if (m_tasklib.GetTask(i).GetName() == task)
+ {
+ found_reaction->SetTask( m_tasklib.GetTaskReference(i) );
+ return true;
+ }
+ }
+
+ // If we didn't find the task, then we need to make a new one
+ // @JEB currently, this messes up stat tracking to add a task
+ // in the middle of a run.
+/*
+ // Finish loading in this reaction.
+ cString trigger_info = task;
+ cString trigger = trigger_info.Pop(':');
+
+ // Load the task trigger
+ cEnvReqs envreqs;
+ tList<cString> errors;
+
+ cTaskEntry* cur_task = m_tasklib.AddTask(trigger, trigger_info, envreqs, &errors);
+ if (cur_task == NULL || errors.GetSize() > 0) {
+ cString* err_str;
+ while ((err_str = errors.Pop()) != NULL) {
+ cerr << *err_str << endl;
+ delete err_str;
+ }
+ return false;
+ }
+
+ found_reaction->SetTask(cur_task); // Attack task to reaction.
+ return true;
+*/
+
+ return false;
+}
+
bool cEnvironment::SetResourceInflow(const cString& name, double _inflow )
{
cResource* found_resource = resource_lib.GetResource(name);
Modified: branches/collect/source/main/cEnvironment.h
===================================================================
--- branches/collect/source/main/cEnvironment.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cEnvironment.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -166,6 +166,7 @@
bool SetReactionInst(const cString& name, cString inst_name);
bool SetReactionMinTaskCount(const cString& name, int min_count);
bool SetReactionMaxTaskCount(const cString& name, int max_count);
+ bool SetReactionTask(const cString& name, const cString& task);
bool SetResourceInflow(const cString& name, double _inflow );
bool SetResourceOutflow(const cString& name, double _outflow );
Modified: branches/collect/source/main/cPopulation.cc
===================================================================
--- branches/collect/source/main/cPopulation.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cPopulation.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -816,30 +816,35 @@
{
// Sanity checks: Don't process if the cells are the same and
// don't bother trying to move when given a cell that isn't there
- //cout << "SwapCells: testing if cell1 and cell2 are non-null" << endl;
- //if (!(NULL != cell1) || !(NULL != cell2)) return;
if ((&cell1 == NULL) || (&cell2 == NULL)) return;
- //cout << "SwapCells: testing if cell1 and cell2 are different" << endl;
if (cell1.GetID() == cell2.GetID()) return;
// Clear current contents of cells
- //cout << "SwapCells: clearing cell contents" << endl;
cOrganism * org1 = cell1.RemoveOrganism();
cOrganism * org2 = cell2.RemoveOrganism();
- //cout << "SwapCells: organism 2 is non-null, fix up source cell" << endl;
if (org2 != NULL) {
cell1.InsertOrganism(org2);
schedule->Adjust(cell1.GetID(), org2->GetPhenotype().GetMerit(),cell1.GetDemeID());
} else {
schedule->Adjust(cell1.GetID(), cMerit(0), cell1.GetDemeID());
}
- //cout << "SwapCells: organism 1 is non-null, fix up dest cell" << endl;
if (org1 != NULL) {
cell2.InsertOrganism(org1);
+ // Increment visit count
+ cell2.IncVisits();
+ // Adjust for movement factor if needed
+ if (1.0 != m_world->GetConfig().BIOMIMETIC_MOVEMENT_FACTOR.Get()) {
+ double afterfit = org1->GetPhenotype().GetCurBonus() * m_world->GetConfig().BIOMIMETIC_MOVEMENT_FACTOR.Get();
+ org1->GetPhenotype().SetCurBonus(afterfit); //Update fitness
+ }
+ // Trigger evaluation for task completion
+ if (0 < m_world->GetConfig().BIOMIMETIC_EVAL_ON_MOVEMENT.Get()) {
+ cAvidaContext& ctx = m_world->GetDefaultContext();
+ org1->DoOutput(ctx,0);
+ }
schedule->Adjust(cell2.GetID(), org1->GetPhenotype().GetMerit(), cell2.GetDemeID());
} else {
schedule->Adjust(cell2.GetID(), cMerit(0), cell2.GetDemeID());
}
- //cout << "SwapCells: Done." << endl;
}
// CompeteDemes probabilistically copies demes into the next generation
@@ -2112,6 +2117,36 @@
const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
+ // @WRE carrying capacity handling
+ /* Pick and kill an organism here if needed
+ * and then enter choices for birth method handling.
+ */
+ if ((0 < m_world->GetConfig().BIOMIMETIC_K.Get()) &&
+ (num_organisms >= m_world->GetConfig().BIOMIMETIC_K.Get())) {
+ // Measure temporary variables
+ double max_msr = 0.0;
+ double msr = 0.0;
+ int max_msrndx = 0;
+ for (int i=0; i < cell_array.GetSize(); i++) {
+ if (cell_array[i].IsOccupied()) {
+ if (cell_array[i].GetOrganism()->GetPhenotype().OK()) {
+ // Get measurement, exclude parent
+ if (parent_cell.GetID() != cell_array[i].GetID()) {
+ msr = random();
+ } else {
+ msr = 0.0;
+ }
+
+ if (max_msr < msr) {
+ max_msr = msr;
+ max_msrndx = i;
+ }
+ }
+ }
+ }
+ KillOrganism(cell_array[max_msrndx]);
+ }
+
//@AWC -- decide wether the child will migrate to another deme -- if migrating we ignore the birth method.
if ((m_world->GetConfig().MIGRATION_RATE.Get() > 0.0) //@AWC -- Pedantic test to maintain consistancy.
&& m_world->GetRandom().P(m_world->GetConfig().MIGRATION_RATE.Get())){
@@ -2343,12 +2378,6 @@
void cPopulation::UpdateOrganismStats()
{
- // Carrying capacity @WRE 04-20-07
- // Check for positive non-zero carrying capacity and apply it
- if (0 < m_world->GetConfig().BIOMIMETIC_K.Get()) {
- SerialTransfer(m_world->GetConfig().BIOMIMETIC_K.Get(),true);
- }
-
// Loop through all the cells getting stats and doing calculations
// which must be done on a creature by creature basis.
@@ -3479,17 +3508,23 @@
{
for (int i=0; i< GetSize(); i++)
{
- if (GetCell(i).IsOccupied())
+ cPopulationCell& cell = GetCell(i);
+ if (cell.IsOccupied())
{
- cPopulationCell& cell = GetCell(i);
-
- // Correct gestation time for speculative execution
cPhenotype & p = cell.GetOrganism()->GetPhenotype();
- p.SetTrialTimeUsed(p.GetTrialTimeUsed() - cell.GetSpeculativeState());
- p.SetTimeUsed(p.GetTimeUsed() - cell.GetSpeculativeState());
- cell.GetOrganism()->NewTrial();
- cell.GetOrganism()->GetHardware().Reset();
+ // Don't continue if the time used was zero
+ if (p.GetTrialTimeUsed() != 0)
+ {
+ // Correct gestation time for speculative execution
+ p.SetTrialTimeUsed(p.GetTrialTimeUsed() - cell.GetSpeculativeState());
+ p.SetTimeUsed(p.GetTimeUsed() - cell.GetSpeculativeState());
+
+ cell.GetOrganism()->NewTrial();
+ cell.GetOrganism()->GetHardware().Reset();
+
+ cell.SetSpeculativeState(0);
+ }
}
}
@@ -3510,7 +3545,8 @@
void cPopulation::CompeteOrganisms(int competition_type, int parents_survive)
{
- if (m_world->GetVerbosity() > VERBOSE_SILENT) cout << "==Compete Organisms==" << endl;
+ NewTrial();
+
double total_fitness = 0;
int num_cells = GetSize();
tArray<double> org_fitness(num_cells);
@@ -3534,6 +3570,8 @@
if (GetCell(i).IsOccupied())
{
cPhenotype& p = GetCell(i).GetOrganism()->GetPhenotype();
+ // We trigger a lot of asserts if the copied size is zero...
+ p.SetLinesCopied(p.GetGenomeLength());
if ( (num_trials != -1) && (num_trials != p.GetTrialFitnesses().GetSize()) )
{
@@ -3545,6 +3583,12 @@
num_trials = p.GetTrialFitnesses().GetSize();
}
}
+
+ //If there weren't any trials then end here (but call new trial so things are set up for the next iteration)
+ if (num_trials == 0) return;
+
+ if (m_world->GetVerbosity() > VERBOSE_SILENT) cout << "==Compete Organisms==" << endl;
+
tArray<double> min_trial_fitnesses(num_trials);
tArray<double> max_trial_fitnesses(num_trials);
tArray<double> avg_trial_fitnesses(num_trials);
@@ -3577,9 +3621,12 @@
if (m_world->GetVerbosity() > VERBOSE_SILENT)
{
- for (int t=0; t < min_trial_fitnesses.GetSize(); t++)
+ if (min_trial_fitnesses.GetSize() > 1)
{
- cout << "Trial #" << t << " Min Fitness = " << min_trial_fitnesses[t] << ", Avg fitness = " << avg_trial_fitnesses[t] << " Max Fitness = " << max_trial_fitnesses[t] << endl;
+ for (int t=0; t < min_trial_fitnesses.GetSize(); t++)
+ {
+ cout << "Trial #" << t << " Min Fitness = " << min_trial_fitnesses[t] << ", Avg fitness = " << avg_trial_fitnesses[t] << " Max Fitness = " << max_trial_fitnesses[t] << endl;
+ }
}
}
@@ -3772,7 +3819,8 @@
// copy stats to cStats, so that these can be remembered and printed
m_world->GetStats().SetCompetitionTrialFitnesses(avg_trial_fitnesses);
- m_world->GetStats().SetCompetitionFitness(average_fitness);
+ m_world->GetStats().SetCompetitionFitnesses(average_fitness, lowest_fitness, highest_fitness, average_fitness_copied, lowest_fitness_copied, highest_fitness_copied);
m_world->GetStats().SetCompetitionOrgsReplicated(different_orgs_copied);
+ NewTrial();
}
Modified: branches/collect/source/main/cPopulationCell.h
===================================================================
--- branches/collect/source/main/cPopulationCell.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cPopulationCell.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -69,6 +69,8 @@
int m_x; //!< The x-coordinate of the position of this cell in the environment.
int m_y; //!< The y-coordinate of the position of this cell in the environment.
+ // @WRE: Statistic for movement
+ int m_visits; // The number of times Avidians move into the cell
void InsertOrganism(cOrganism* new_org);
cOrganism* RemoveOrganism();
@@ -85,7 +87,7 @@
void SetDemeID(int in_id) { m_deme_id = in_id; }
void Rotate(cPopulationCell& new_facing);
- //@AWC -- This is, admittatidly, a hack to get migration between demes working under local copy...
+ //@AWC -- This is, admittedly, a hack to get migration between demes working under local copy...
void SetMigrant() {m_migrant = true;} //@AWC -- this cell will contain a migrant genome
void UnsetMigrant() {m_migrant = false;} //@AWC -- unset the migrant flag
bool IsMigrant() {return m_migrant;} //@AWC -- does this contain a migrant genome?
@@ -96,6 +98,8 @@
inline cPopulationCell& GetCellFaced() { return *(m_connections.GetFirst()); }
int GetFacing(); // Returns the facing of this cell.
inline void GetPosition(int& x, int& y) { x = m_x; y = m_y; } // Retrieves the position (x,y) coordinates of this cell.
+ inline int GetVisits() { return m_visits; } // @WRE: Retrieves the number of visits for this cell.
+ inline void IncVisits() { m_visits++; } // @WRE: Increments the visit count for a cell
inline const cMutationRates& MutationRates() const { assert(m_mut_rates); return *m_mut_rates; }
inline cMutationRates& MutationRates() { assert(m_mut_rates); return *m_mut_rates; }
Modified: branches/collect/source/main/cReactionProcess.h
===================================================================
--- branches/collect/source/main/cReactionProcess.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cReactionProcess.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -50,7 +50,7 @@
double max_number; // Max quantity of resource usable.
double min_number; // Minimum quantity of resource needed (otherwise 0)
double max_fraction; // Max fraction of avaiable resources useable.
- cResource* product; // Output resource.
+ cResource* product; // Output resource.
double conversion; // Conversion factor.
bool lethal; // Lethality of reaction
bool sterilize; //! Whether performance of this reaction sterilizes the organism.
Modified: branches/collect/source/main/cStats.cc
===================================================================
--- branches/collect/source/main/cStats.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cStats.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -119,6 +119,11 @@
, num_own_used(0)
, sense_size(0)
, avg_competition_fitness(0)
+ , min_competition_fitness(0)
+ , max_competition_fitness(0)
+ , avg_competition_copied_fitness(0)
+ , min_competition_copied_fitness(0)
+ , max_competition_copied_fitness(0)
, num_orgs_replicated(0)
, m_spec_total(0)
, m_spec_num(0)
@@ -977,7 +982,28 @@
df.Flush();
}
+// @WRE: Added method for printing out visit data
+void cStats::PrintCellVisitsData(const cString& filename)
+{
+ // Write cell visits data to a file that can easily be read into Matlab
+ cString tmpfilename = "visits.m";
+ cDataFile& df = m_world->GetDataFile(tmpfilename);
+ cString UpdateStr = cStringUtil::Stringf( "visits%07i", GetUpdate() ) + " = [ ...";
+
+ df.WriteRaw(UpdateStr);
+
+ int xsize = m_world->GetConfig().WORLD_X.Get();
+
+ for(int i=0; i<m_world->GetPopulation().GetSize(); ++i) {
+ df.WriteBlockElement(m_world->GetPopulation().GetCell(i).GetVisits(), i, xsize);
+ }
+
+ df.WriteRaw("];");
+ df.Flush();
+}
+
+
void cStats::PrintTimeData(const cString& filename)
{
cDataFile& df = m_world->GetDataFile(filename);
@@ -1190,11 +1216,20 @@
df.WriteComment( "results of the current competitions" );
df.Write( GetUpdate(), "update" );
- df.Write( avg_competition_fitness, "overall competition fitness" );
+ df.Write( avg_competition_fitness, "average competition fitness" );
+ df.Write( min_competition_fitness, "min competition fitness" );
+ df.Write( max_competition_fitness, "max competition fitness" );
+ df.Write( avg_competition_copied_fitness, "average copied fitness" );
+ df.Write( min_competition_copied_fitness, "min copied fitness" );
+ df.Write( max_competition_copied_fitness, "max copied fitness" );
df.Write( num_orgs_replicated, "number of organisms copied" );
- for( int i=0; i < avg_trial_fitnesses.GetSize(); i++ ){
- df.Write(avg_trial_fitnesses[i], cStringUtil::Stringf("trial.%d fitness", i));
+ // Only print trial info if there were multiple trials.
+ if (avg_trial_fitnesses.GetSize() > 1)
+ {
+ for( int i=0; i < avg_trial_fitnesses.GetSize(); i++ ){
+ df.Write(avg_trial_fitnesses[i], cStringUtil::Stringf("trial.%d fitness", i));
+ }
}
df.Endl();
}
@@ -1255,6 +1290,7 @@
void cStats::DemePreReplication(cDeme& source_deme, cDeme& target_deme)
{
++m_deme_num_repls;
+ m_deme_gestation_time.Add(source_deme.GetAge());
}
@@ -1278,9 +1314,11 @@
df.WriteTimeStamp();
df.Write(m_update, "Update [update]");
df.Write(m_deme_num_repls, "Number of deme replications [numrepl]");
+ df.Write(m_deme_gestation_time.Average(), "Mean deme gestation time [gesttime]");
df.Endl();
m_deme_num_repls = 0;
+ m_deme_gestation_time.Clear();
}
Modified: branches/collect/source/main/cStats.h
===================================================================
--- branches/collect/source/main/cStats.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cStats.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -264,6 +264,11 @@
// Stats for competitions
tArray<double> avg_trial_fitnesses;
double avg_competition_fitness;
+ double min_competition_fitness;
+ double max_competition_fitness;
+ double avg_competition_copied_fitness;
+ double min_competition_copied_fitness;
+ double max_competition_copied_fitness;
int num_orgs_replicated;
tArray<int> numAsleep;
@@ -531,7 +536,9 @@
void SetResourceName(int id, const cString & name) { resource_names[id] = name; }
void SetCompetitionTrialFitnesses(tArray<double> _in) { avg_trial_fitnesses = _in; }
- void SetCompetitionFitness(double _in) { avg_competition_fitness = _in; }
+ void SetCompetitionFitnesses(double _in_avg, double _in_min, double _in_max, double _in_cp_avg, double _in_cp_min, double _in_cp_max)
+ { avg_competition_fitness = _in_avg; min_competition_fitness = _in_min; max_competition_fitness = _in_max;
+ avg_competition_copied_fitness = _in_cp_avg; min_competition_copied_fitness = _in_cp_min; max_competition_copied_fitness = _in_cp_max; }
void SetCompetitionOrgsReplicated(int _in) { num_orgs_replicated = _in; }
//market info
@@ -689,6 +696,8 @@
void PrintInternalTasksQualData(const cString& filename);
void PrintSleepData(const cString& filename);
void PrintCompetitionData(const cString& filename);
+ // @WRE: Added event for printing visit counts
+ void PrintCellVisitsData(const cString& filename);
// -------- Messaging support --------
public:
@@ -727,6 +736,7 @@
protected:
int m_deme_num_repls; //!< Number of deme replications since last PrintDemeReplicationData.
+ cDoubleSum m_deme_gestation_time; //!< Gestation time for demes - mean age at deme replication.
cDoubleSum m_germline_generation; //!< "Generation" accumulator of replicated germlines.
};
Modified: branches/collect/source/main/cTaskLib.cc
===================================================================
--- branches/collect/source/main/cTaskLib.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cTaskLib.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -79,6 +79,8 @@
else if (name == "add") NewTask(name, "Add", &cTaskLib::Task_Add);
else if (name == "add3") NewTask(name, "Add3", &cTaskLib::Task_Add3);
else if (name == "sub") NewTask(name, "Sub", &cTaskLib::Task_Sub);
+ // @WRE DontCare task always succeeds.
+ else if (name == "dontcare") NewTask(name, "DontCare", &cTaskLib::Task_DontCare);
// All 1- and 2-Input Logic Functions
if (name == "not") NewTask(name, "Not", &cTaskLib::Task_Not);
@@ -548,6 +550,12 @@
return 0.0;
}
+// @WRE DontCare task always succeeds.
+double cTaskLib::Task_DontCare(cTaskContext& ctx) const
+{
+ return 1.0;
+}
+
double cTaskLib::Task_Not(cTaskContext& ctx) const
{
const int logic_id = ctx.GetLogicId();
Modified: branches/collect/source/main/cTaskLib.h
===================================================================
--- branches/collect/source/main/cTaskLib.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/cTaskLib.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -79,7 +79,8 @@
cTaskEntry* AddTask(const cString& name, const cString& info, cEnvReqs& envreqs, tList<cString>* errors);
const cTaskEntry& GetTask(int id) const { return *(task_array[id]); }
-
+ cTaskEntry * GetTaskReference(int id) { return task_array[id]; }
+
void SetupTests(cTaskContext& ctx) const;
inline double TestOutput(cTaskContext& ctx) const { return (this->*(ctx.GetTaskEntry()->GetTestFun()))(ctx); }
@@ -97,6 +98,7 @@
double Task_Add(cTaskContext& ctx) const;
double Task_Add3(cTaskContext& ctx) const;
double Task_Sub(cTaskContext& ctx) const;
+ double Task_DontCare(cTaskContext& ctx) const;
// All 1- and 2-Input Logic Functions
double Task_Not(cTaskContext& ctx) const;
Modified: branches/collect/source/main/nReaction.h
===================================================================
--- branches/collect/source/main/nReaction.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/main/nReaction.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -32,7 +32,8 @@
PROCTYPE_POW,
PROCTYPE_LIN,
PROCTYPE_ENERGY,
- PROCTYPE_ENZYME
+ PROCTYPE_ENZYME,
+ PROCTYPE_EXP
};
}
Modified: branches/collect/source/script/ASTree.h
===================================================================
--- branches/collect/source/script/ASTree.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/ASTree.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -38,6 +38,30 @@
class cASTVisitor;
+class cASFilePosition
+{
+private:
+ cString m_filename;
+ int m_line;
+
+
+ cASFilePosition(); // @not_implemented
+ cASFilePosition& operator=(const cASFilePosition&); // @not_implemented
+
+
+public:
+ inline cASFilePosition(const cString& fn, int line) : m_filename(fn), m_line(line) { ; }
+ inline cASFilePosition(const cASFilePosition& fp) : m_filename(fp.m_filename), m_line(fp.m_line) { ; }
+
+ inline const cString& GetFilename() const { return m_filename; }
+ inline int GetLineNumber() const { return m_line; }
+
+ inline bool operator==(const cASFilePosition& fp) { return m_line == fp.m_line && m_filename == fp.m_filename; }
+ inline bool operator!=(const cASFilePosition& fp) { return m_line != fp.m_line || m_filename != fp.m_filename; }
+};
+
+
+
// -- Abstract Syntax Tree Base Class
// ---------------------------------------------------------------------------------------------------------------------
@@ -46,15 +70,21 @@
class cASTNode
{
private:
+ cASTNode(); // @not_implemented
cASTNode(const cASTNode&); // @not_implemented
cASTNode& operator=(const cASTNode&); // @not_implmented
protected:
- cASTNode() { ; }
+ cASFilePosition m_file_pos;
+ cASTNode(const cASFilePosition& fp) : m_file_pos(fp) { ; }
public:
virtual ~cASTNode() { ; }
+ virtual ASType_t GetType() const { return AS_TYPE_INVALID; }
+
+ inline const cASFilePosition& GetFilePosition() const { return m_file_pos; }
+
virtual void Accept(cASTVisitor& visitor) = 0;
};
@@ -97,7 +127,7 @@
cASTNode* m_expr;
public:
- cASTAssignment(const cString& var) : m_var(var), m_expr(NULL) { ; }
+ cASTAssignment(const cASFilePosition& fp, const cString& var) : cASTNode(fp), m_var(var), m_expr(NULL) { ; }
~cASTAssignment() { delete m_expr; }
inline const cString& GetVariable() { return m_var; }
@@ -115,7 +145,7 @@
tList<cASTNode> m_nodes;
public:
- cASTArgumentList() { ; }
+ cASTArgumentList(const cASFilePosition& fp) : cASTNode(fp) { ; }
~cASTArgumentList() { ; }
inline void AddNode(cASTNode* n) { m_nodes.PushRear(n); }
@@ -135,7 +165,7 @@
cASTNode* m_expr;
public:
- cASTReturnStatement(cASTNode* expr) : m_expr(expr) { ; }
+ cASTReturnStatement(const cASFilePosition& fp, cASTNode* expr) : cASTNode(fp), m_expr(expr) { ; }
~cASTReturnStatement() { delete m_expr; }
inline cASTNode* GetExpression() { return m_expr; }
@@ -150,7 +180,7 @@
tList<cASTNode> m_nodes;
public:
- cASTStatementList() { ; }
+ cASTStatementList(const cASFilePosition& fp) : cASTNode(fp) { ; }
~cASTStatementList();
inline void AddNode(cASTNode* n) { m_nodes.PushRear(n); }
@@ -172,7 +202,8 @@
cASTNode* m_code;
public:
- cASTForeachBlock(cASTVariableDefinition* v, cASTNode* e, cASTNode* c) : m_var(v), m_expr(e), m_code(c) { ; }
+ cASTForeachBlock(const cASFilePosition& fp, cASTVariableDefinition* v, cASTNode* e, cASTNode* c)
+ : cASTNode(fp), m_var(v), m_expr(e), m_code(c) { ; }
inline cASTVariableDefinition* GetVariable() { return m_var; }
inline cASTNode* GetValues() { return m_expr; }
@@ -195,7 +226,7 @@
cElseIf(cASTNode* expr, cASTNode* code) : m_expr(expr), m_code(code) { ; }
public:
- cASTNode* GetCondition() { return m_expr; }
+ cASTNode* GetCondition() { return m_expr; }
cASTNode* GetCode() { return m_code; }
};
@@ -207,7 +238,8 @@
tList<cElseIf> m_elifs;
public:
- cASTIfBlock(cASTNode* expr, cASTNode* code) : m_expr(expr), m_code(code), m_else(NULL) { ; }
+ cASTIfBlock(const cASFilePosition& fp, cASTNode* expr, cASTNode* code)
+ : cASTNode(fp), m_expr(expr), m_code(code), m_else(NULL) { ; }
~cASTIfBlock()
{
delete m_expr;
@@ -239,7 +271,7 @@
cASTNode* m_code;
public:
- cASTWhileBlock(cASTNode* expr, cASTNode* code) : m_expr(expr), m_code(code) { ; }
+ cASTWhileBlock(const cASFilePosition& fp, cASTNode* expr, cASTNode* code) : cASTNode(fp), m_expr(expr), m_code(code) { ; }
~cASTWhileBlock() { delete m_expr; delete m_code; }
inline cASTNode* GetCondition() { return m_expr; }
@@ -262,8 +294,8 @@
cASTNode* m_code;
public:
- cASTFunctionDefinition(ASType_t type, const cString& name, cASTVariableDefinitionList* args)
- : m_type(type), m_name(name), m_args(args), m_code(NULL) { ; }
+ cASTFunctionDefinition(const cASFilePosition& fp, ASType_t type, const cString& name, cASTVariableDefinitionList* args)
+ : cASTNode(fp), m_type(type), m_name(name), m_args(args), m_code(NULL) { ; }
inline ASType_t GetType() { return m_type; }
inline const cString& GetName() { return m_name; }
@@ -287,7 +319,8 @@
cASTArgumentList* m_dims;
public:
- cASTVariableDefinition(ASType_t type, const cString& var) : m_type(type), m_var(var), m_assign(NULL), m_dims(NULL) { ; }
+ cASTVariableDefinition(const cASFilePosition& fp, ASType_t type, const cString& var)
+ : cASTNode(fp), m_type(type), m_var(var), m_assign(NULL), m_dims(NULL) { ; }
~cASTVariableDefinition() { delete m_assign; delete m_dims; }
inline ASType_t GetType() { return m_type; }
@@ -307,7 +340,7 @@
tList<cASTVariableDefinition> m_nodes;
public:
- cASTVariableDefinitionList() { ; }
+ cASTVariableDefinitionList(const cASFilePosition& fp) : cASTNode(fp) { ; }
~cASTVariableDefinitionList() { ; }
inline void AddNode(cASTVariableDefinition* n) { m_nodes.PushRear(n); }
@@ -332,7 +365,8 @@
cASTNode* m_right;
public:
- cASTExpressionBinary(ASToken_t op, cASTNode* l, cASTNode* r) : m_op(op), m_left(l), m_right(r) { ; }
+ cASTExpressionBinary(const cASFilePosition& fp, ASToken_t op, cASTNode* l, cASTNode* r)
+ : cASTNode(fp), m_op(op), m_left(l), m_right(r) { ; }
~cASTExpressionBinary() { delete m_left; delete m_right; }
inline ASToken_t GetOperator() { return m_op; }
@@ -350,15 +384,20 @@
private:
ASToken_t m_op;
cASTNode* m_expr;
+ ASType_t m_type;
public:
- cASTExpressionUnary(ASToken_t op, cASTNode* e) : m_op(op), m_expr(e) { ; }
+ cASTExpressionUnary(const cASFilePosition& fp, ASToken_t op, cASTNode* e)
+ : cASTNode(fp), m_op(op), m_expr(e), m_type(AS_TYPE_INVALID) { ; }
~cASTExpressionUnary() { delete m_expr; }
inline ASToken_t GetOperator() { return m_op; }
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; }
+
void Accept(cASTVisitor& visitor);
};
@@ -373,7 +412,7 @@
cASTArgumentList* m_args;
public:
- cASTFunctionCall(cASTNode* target) : m_target(target), m_args(NULL) { ; }
+ cASTFunctionCall(const cASFilePosition& fp, cASTNode* target) : cASTNode(fp), m_target(target), m_args(NULL) { ; }
~cASTFunctionCall() { delete m_args; }
cASTNode* GetTarget() { return m_target; }
@@ -393,7 +432,7 @@
cString m_value;
public:
- cASTLiteral(ASType_t t, const cString& v) : m_type(t), m_value(v) { ; }
+ cASTLiteral(const cASFilePosition& fp, ASType_t t, const cString& v) : cASTNode(fp), m_type(t), m_value(v) { ; }
inline ASType_t GetType() { return m_type; }
inline const cString& GetValue() { return m_value; }
@@ -409,7 +448,7 @@
bool m_is_matrix;
public:
- cASTLiteralArray(cASTNode* v, bool is_mat) : m_value(v), m_is_matrix(is_mat) { ; }
+ cASTLiteralArray(const cASFilePosition& fp, cASTNode* v, bool is_mat) : cASTNode(fp), m_value(v), m_is_matrix(is_mat) { ; }
~cASTLiteralArray() { delete m_value; }
inline cASTNode* GetValue() { return m_value; }
@@ -425,7 +464,7 @@
cString m_name;
public:
- cASTVariableReference(const cString& name) : m_name(name) { ; }
+ cASTVariableReference(const cASFilePosition& fp, const cString& name) : cASTNode(fp), m_name(name) { ; }
inline const cString& GetName() { return m_name; }
@@ -442,7 +481,7 @@
cASTNode* m_expr;
public:
- cASTUnpackTarget() : m_last_wild(false), m_last_named(false), m_expr(NULL) { ; }
+ cASTUnpackTarget(const cASFilePosition& fp) : cASTNode(fp), m_last_wild(false), m_last_named(false), m_expr(NULL) { ; }
~cASTUnpackTarget() { delete m_expr; }
inline void AddVar(const cString& name) { m_nodes.Push(name); }
Copied: branches/collect/source/script/AvidaScript.cc (from rev 2383, development/source/script/AvidaScript.cc)
===================================================================
--- branches/collect/source/script/AvidaScript.cc (rev 0)
+++ branches/collect/source/script/AvidaScript.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -0,0 +1,74 @@
+/*
+ * AvidaScript.cc
+ * Avida
+ *
+ * Created by David on 2/26/08.
+ * Copyright 2008 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 "AvidaScript.h"
+
+
+const char* AvidaScript::mapToken(ASToken_t token)
+{
+ switch (token) {
+ case AS_TOKEN_OP_BIT_NOT: return "~";
+ case AS_TOKEN_OP_BIT_AND: return "&";
+ case AS_TOKEN_OP_BIT_OR: return "|";
+ case AS_TOKEN_OP_LOGIC_NOT: return "!";
+ case AS_TOKEN_OP_LOGIC_AND: return "&&";
+ case AS_TOKEN_OP_LOGIC_OR: return "||";
+ case AS_TOKEN_OP_ADD: return "+";
+ case AS_TOKEN_OP_SUB: return "-";
+ case AS_TOKEN_OP_MUL: return "*";
+ case AS_TOKEN_OP_DIV: return "/";
+ case AS_TOKEN_OP_MOD: return "%";
+ case AS_TOKEN_DOT: return ".";
+ case AS_TOKEN_OP_EQ: return "==";
+ case AS_TOKEN_OP_LE: return "<=";
+ case AS_TOKEN_OP_GE: return ">=";
+ case AS_TOKEN_OP_LT: return "<";
+ case AS_TOKEN_OP_GT: return ">";
+ case AS_TOKEN_OP_NEQ: return "!=";
+ case AS_TOKEN_ARR_RANGE: return ":";
+ case AS_TOKEN_ARR_EXPAN: return "^";
+ case AS_TOKEN_IDX_OPEN: return "[]";
+ default: return "?";
+ }
+}
+
+const char* AvidaScript::mapType(ASType_t type)
+{
+ switch (type) {
+ case AS_TYPE_ARRAY: return "array";
+ case AS_TYPE_CHAR: return "char";
+ case AS_TYPE_FLOAT: return "float";
+ case AS_TYPE_INT: return "int";
+ case AS_TYPE_MATRIX: return "matrix";
+ case AS_TYPE_STRING: return "string";
+ case AS_TYPE_VOID: return "void";
+ case AS_TYPE_OBJECT_REF: return "object";
+
+ case AS_TYPE_INVALID:
+ default:
+ return "*INVALID*";
+ }
+}
+
+
Modified: branches/collect/source/script/AvidaScript.h
===================================================================
--- branches/collect/source/script/AvidaScript.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/AvidaScript.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -110,6 +110,19 @@
} ASParseError_t;
+typedef enum eASSemanticErrors {
+ AS_SEMANTIC_WARN_UNREACHABLE,
+ AS_SEMANTIC_WARN__LAST,
+
+ AS_SEMANTIC_ERR_UNDEFINED_TYPE_OP,
+ AS_SEMANTIC_ERR_VARIABLE_UNDEFINED,
+ AS_SEMANTIC_ERR_VARIABLE_REDEFINITION,
+ AS_SEMANTIC_ERR_INTERNAL,
+
+ AS_SEMANTIC_ERR_UNKNOWN
+} ASSemanticError_t;
+
+
typedef enum eASTypes {
AS_TYPE_ARRAY = 0,
AS_TYPE_CHAR,
@@ -123,4 +136,10 @@
AS_TYPE_INVALID
} ASType_t;
+
+namespace AvidaScript {
+ const char* mapToken(ASToken_t type);
+ const char* mapType(ASType_t type);
+};
+
#endif
Deleted: branches/collect/source/script/cASTDumpVisitor.cc
===================================================================
--- branches/collect/source/script/cASTDumpVisitor.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cASTDumpVisitor.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -1,425 +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;
-
-
-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::printToken(ASToken_t token)
-{
- switch (token) {
- case AS_TOKEN_OP_BIT_NOT: cout << '~'; break;
- case AS_TOKEN_OP_BIT_AND: cout << '&'; break;
- case AS_TOKEN_OP_BIT_OR: cout << '|'; break;
- case AS_TOKEN_OP_LOGIC_NOT: cout << '!'; break;
- case AS_TOKEN_OP_LOGIC_AND: cout << "&&"; break;
- case AS_TOKEN_OP_LOGIC_OR: cout << "||"; break;
- case AS_TOKEN_OP_ADD: cout << '+'; break;
- case AS_TOKEN_OP_SUB: cout << '-'; break;
- case AS_TOKEN_OP_MUL: cout << '*'; break;
- case AS_TOKEN_OP_DIV: cout << '/'; break;
- case AS_TOKEN_OP_MOD: cout << '%'; break;
- case AS_TOKEN_DOT: cout << '.'; break;
- case AS_TOKEN_OP_EQ: cout << "=="; break;
- case AS_TOKEN_OP_LE: cout << "<="; break;
- case AS_TOKEN_OP_GE: cout << ">="; break;
- case AS_TOKEN_OP_LT: cout << '<'; break;
- case AS_TOKEN_OP_GT: cout << '>'; break;
- case AS_TOKEN_OP_NEQ: cout << "!="; break;
- case AS_TOKEN_ARR_RANGE: cout << ':'; break;
- case AS_TOKEN_ARR_EXPAN: cout << '^'; break;
- case AS_TOKEN_IDX_OPEN: cout << "[]"; break;
- default: cout << '?'; break;
- }
-}
-
-const char* cASTDumpVisitor::mapType(ASType_t type)
-{
- switch (type) {
- case AS_TYPE_ARRAY: return "array";
- case AS_TYPE_CHAR: return "char";
- case AS_TYPE_FLOAT: return "float";
- case AS_TYPE_INT: return "int";
- case AS_TYPE_MATRIX: return "matrix";
- case AS_TYPE_STRING: return "string";
- case AS_TYPE_VOID: return "void";
- case AS_TYPE_OBJECT_REF: return "object";
-
- case AS_TYPE_INVALID:
- default:
- return "*INVALID*";
- }
-}
-
-
-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();
- printToken(node.GetOperator());
- cout << endl;
-
- m_depth++;
- node.GetRight()->Accept(*this);
- m_depth--;
-}
-
-
-void cASTDumpVisitor::visitExpressionUnary(cASTExpressionUnary& node)
-{
- indent();
- printToken(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: branches/collect/source/script/cASTDumpVisitor.h
===================================================================
--- branches/collect/source/script/cASTDumpVisitor.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cASTDumpVisitor.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -1,68 +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();
- void printToken(ASToken_t token);
- const char* mapType(ASType_t type);
-};
-
-#endif
Copied: branches/collect/source/script/cDumpASTVisitor.cc (from rev 2383, development/source/script/cDumpASTVisitor.cc)
===================================================================
--- branches/collect/source/script/cDumpASTVisitor.cc (rev 0)
+++ branches/collect/source/script/cDumpASTVisitor.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -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: branches/collect/source/script/cDumpASTVisitor.h (from rev 2383, development/source/script/cDumpASTVisitor.h)
===================================================================
--- branches/collect/source/script/cDumpASTVisitor.h (rev 0)
+++ branches/collect/source/script/cDumpASTVisitor.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -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: branches/collect/source/script/cParser.cc
===================================================================
--- branches/collect/source/script/cParser.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cParser.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -28,6 +28,8 @@
#include "cFile.h"
#include "tAutoRelease.h"
+using namespace AvidaScript;
+
/*
The following represents the grammar for AvidaScript in BNF, adjusted so that it is compatible with recursive descent
parsing (to be) implemented by cParser.
@@ -192,6 +194,8 @@
#define PARSE_ERROR(x) reportError(AS_PARSE_ERR_ ## x, __LINE__)
#define PARSE_UNEXPECT() { if (currentToken()) { PARSE_ERROR(UNEXPECTED_TOKEN); } else { PARSE_ERROR(EOF); } return NULL; }
+#define FILEPOS cASFilePosition(m_filename, m_lexer ? m_lexer->lineno() : 0)
+
#define TOKEN(x) AS_TOKEN_ ## x
@@ -267,7 +271,7 @@
if (nextToken() != TOKEN(ID)) PARSE_UNEXPECT();
- tAutoRelease<cASTUnpackTarget> ut(new cASTUnpackTarget());
+ tAutoRelease<cASTUnpackTarget> ut(new cASTUnpackTarget(FILEPOS));
(*ut).AddVar(currentText());
while (nextToken()) {
@@ -303,7 +307,7 @@
cASTArgumentList* cParser::parseArgumentList()
{
PARSE_TRACE("parseArgumentList");
- cASTArgumentList* al = new cASTArgumentList();
+ cASTArgumentList* al = new cASTArgumentList(FILEPOS);
al->AddNode(parseExpression());
while (currentToken() == TOKEN(COMMA)) {
@@ -317,7 +321,7 @@
cASTNode* cParser::parseAssignment()
{
PARSE_TRACE("parseAssignment");
- cASTAssignment* an = new cASTAssignment(currentText());
+ cASTAssignment* an = new cASTAssignment(FILEPOS, currentText());
nextToken(); // consume '='
@@ -338,11 +342,11 @@
switch (currentToken()) {
case TOKEN(DOT):
if (nextToken() != TOKEN(ID)) PARSE_UNEXPECT();
- ce.Set(new cASTExpressionBinary(TOKEN(DOT), ce.Release(), new cASTVariableReference(currentText())));
+ ce.Set(new cASTExpressionBinary(FILEPOS, TOKEN(DOT), ce.Release(), new cASTVariableReference(FILEPOS, currentText())));
nextToken(); // consume id
break;
case TOKEN(PREC_OPEN):
- cASTFunctionCall* fc = new cASTFunctionCall(ce.Release());
+ cASTFunctionCall* fc = new cASTFunctionCall(FILEPOS, ce.Release());
ce.Set(fc);
if (nextToken() != TOKEN(PREC_CLOSE)) fc->SetArguments(parseArgumentList());
if (currentToken() != TOKEN(PREC_CLOSE)) PARSE_UNEXPECT();
@@ -354,7 +358,7 @@
case TOKEN(IDX_OPEN):
do {
nextToken(); // consume '['
- ce.Set(new cASTExpressionBinary(TOKEN(IDX_OPEN), ce.Release(), parseExpression()));
+ ce.Set(new cASTExpressionBinary(FILEPOS, TOKEN(IDX_OPEN), ce.Release(), parseExpression()));
if (currentToken() != TOKEN(IDX_CLOSE)) PARSE_UNEXPECT();
} while (nextToken() == TOKEN(IDX_OPEN));
break;
@@ -409,7 +413,7 @@
nextToken();
r = parseExprP1();
if (!r) PARSE_ERROR(NULL_EXPR);
- l = new cASTExpressionBinary(op, l, r);
+ l = new cASTExpressionBinary(FILEPOS, op, l, r);
break;
default:
@@ -434,7 +438,7 @@
nextToken();
r = parseExprP2();
if (!r) PARSE_ERROR(NULL_EXPR);
- l = new cASTExpressionBinary(op, l, r);
+ l = new cASTExpressionBinary(FILEPOS, op, l, r);
break;
default:
@@ -459,7 +463,7 @@
nextToken();
r = parseExprP3();
if (!r) PARSE_ERROR(NULL_EXPR);
- l = new cASTExpressionBinary(op, l, r);
+ l = new cASTExpressionBinary(FILEPOS, op, l, r);
break;
default:
@@ -488,7 +492,7 @@
nextToken();
r = parseExprP4();
if (!r) PARSE_ERROR(NULL_EXPR);
- l = new cASTExpressionBinary(op, l, r);
+ l = new cASTExpressionBinary(FILEPOS, op, l, r);
break;
default:
@@ -513,7 +517,7 @@
nextToken();
r = parseExprP5();
if (!r) PARSE_ERROR(NULL_EXPR);
- l = new cASTExpressionBinary(op, l, r);
+ l = new cASTExpressionBinary(FILEPOS, op, l, r);
break;
default:
@@ -539,7 +543,7 @@
nextToken();
r = parseExprP6();
if (!r) PARSE_ERROR(NULL_EXPR);
- l = new cASTExpressionBinary(op, l, r);
+ l = new cASTExpressionBinary(FILEPOS, op, l, r);
break;
default:
@@ -559,27 +563,27 @@
switch (currentToken()) {
case TOKEN(FLOAT):
- expr.Set(new cASTLiteral(AS_TYPE_FLOAT, currentText()));
+ expr.Set(new cASTLiteral(FILEPOS, AS_TYPE_FLOAT, currentText()));
break;
case TOKEN(INT):
- expr.Set(new cASTLiteral(AS_TYPE_INT, currentText()));
+ expr.Set(new cASTLiteral(FILEPOS, AS_TYPE_INT, currentText()));
break;
case TOKEN(CHAR):
- expr.Set(new cASTLiteral(AS_TYPE_CHAR, currentText()));
+ expr.Set(new cASTLiteral(FILEPOS, AS_TYPE_CHAR, currentText()));
break;
case TOKEN(STRING):
- expr.Set(new cASTLiteral(AS_TYPE_STRING, currentText()));
+ expr.Set(new cASTLiteral(FILEPOS, AS_TYPE_STRING, currentText()));
break;
case TOKEN(ID):
if (peekToken() == TOKEN(PREC_OPEN)) {
- cASTNode* vr = new cASTVariableReference(currentText());
+ cASTNode* vr = new cASTVariableReference(FILEPOS, currentText());
nextToken(); // consume id token
- cASTFunctionCall* fc = new cASTFunctionCall(vr);
+ cASTFunctionCall* fc = new cASTFunctionCall(FILEPOS, vr);
expr.Set(fc);
if (nextToken() != TOKEN(PREC_CLOSE)) fc->SetArguments(parseArgumentList());
if (currentToken() != TOKEN(PREC_CLOSE)) PARSE_UNEXPECT();
} else {
- expr = new cASTVariableReference(currentText());
+ expr = new cASTVariableReference(FILEPOS, currentText());
}
break;
case TOKEN(PREC_OPEN):
@@ -594,7 +598,7 @@
case TOKEN(ARR_OPEN):
if (nextToken() != TOKEN(ARR_CLOSE)) expr.Set(parseArgumentList());
if (currentToken() != TOKEN(ARR_CLOSE)) PARSE_UNEXPECT();
- expr.Set(new cASTLiteralArray(expr.Release(), is_matrix));
+ expr.Set(new cASTLiteralArray(FILEPOS, expr.Release(), is_matrix));
break;
case TOKEN(OP_BIT_NOT):
@@ -606,7 +610,7 @@
PARSE_ERROR(NULL_EXPR);
return NULL;
}
- expr.Set(new cASTExpressionUnary(op, r));
+ expr.Set(new cASTExpressionUnary(FILEPOS, op, r));
nextToken();
return expr.Release();
@@ -653,7 +657,7 @@
return NULL;
}
- tAutoRelease<cASTVariableDefinition> var(new cASTVariableDefinition(type, currentText()));
+ tAutoRelease<cASTVariableDefinition> var(new cASTVariableDefinition(FILEPOS, type, currentText()));
if (nextToken() != TOKEN(PREC_OPEN)) {
PARSE_UNEXPECT();
@@ -671,7 +675,7 @@
cASTNode* code = parseCodeBlock();
- return new cASTForeachBlock(var.Release(), expr.Release(), code);
+ return new cASTForeachBlock(FILEPOS, var.Release(), expr.Release(), code);
}
cASTNode* cParser::parseFunctionDefine()
@@ -719,7 +723,7 @@
if (currentToken() != TOKEN(PREC_CLOSE)) PARSE_UNEXPECT();
nextToken(); // consume ')'
- return new cASTFunctionDefinition(type, name, args.Release());
+ return new cASTFunctionDefinition(FILEPOS, type, name, args.Release());
}
cASTNode* cParser::parseIDStatement()
@@ -733,7 +737,7 @@
case TOKEN(DOT):
case TOKEN(IDX_OPEN):
case TOKEN(PREC_OPEN):
- cASTNode* target = new cASTVariableReference(currentText());
+ cASTNode* target = new cASTVariableReference(FILEPOS, currentText());
nextToken(); // consume id
return parseCallExpression(target, true);
break;
@@ -757,7 +761,7 @@
if (currentToken() != TOKEN(PREC_CLOSE)) PARSE_UNEXPECT();
nextToken();
- tAutoRelease<cASTIfBlock> is(new cASTIfBlock(cond.Release(), parseCodeBlock()));
+ tAutoRelease<cASTIfBlock> is(new cASTIfBlock(FILEPOS, cond.Release(), parseCodeBlock()));
while (currentToken() == TOKEN(CMD_ELSEIF)) {
@@ -813,7 +817,7 @@
PARSE_TRACE("parseReturnStatement");
nextToken(); // consume 'return'
- cASTNode* rs = new cASTReturnStatement(parseExpression());
+ cASTNode* rs = new cASTReturnStatement(FILEPOS, parseExpression());
return rs;
}
@@ -822,7 +826,7 @@
cASTNode* cParser::parseStatementList()
{
PARSE_TRACE("parseStatementList");
- tAutoRelease<cASTStatementList> sl(new cASTStatementList());
+ tAutoRelease<cASTStatementList> sl(new cASTStatementList(FILEPOS));
tAutoRelease<cASTNode> node;
@@ -912,7 +916,7 @@
if (nextToken() != TOKEN(ID)) PARSE_UNEXPECT();
- tAutoRelease<cASTVariableDefinition> vd(new cASTVariableDefinition(vtype, currentText()));
+ tAutoRelease<cASTVariableDefinition> vd(new cASTVariableDefinition(FILEPOS, vtype, currentText()));
switch (nextToken()) {
case TOKEN(ASSIGN):
@@ -936,7 +940,7 @@
cASTVariableDefinitionList* cParser::parseVariableDefinitionList()
{
PARSE_TRACE("parseVariableDefinitionList");
- tAutoRelease<cASTVariableDefinitionList> vl(new cASTVariableDefinitionList());
+ tAutoRelease<cASTVariableDefinitionList> vl(new cASTVariableDefinitionList(FILEPOS));
cASTVariableDefinition* vd = parseVariableDefinition();
if (!vd) return NULL;
@@ -964,7 +968,7 @@
nextToken();
cASTNode* code = parseCodeBlock();
- return new cASTWhileBlock(cond.Release(), code);
+ return new cASTWhileBlock(FILEPOS, cond.Release(), code);
}
@@ -1018,4 +1022,6 @@
#undef PARSE_ERROR()
#undef PARSE_UNEXPECT()
+#undef FILEPOS
+
#undef TOKEN()
Modified: branches/collect/source/script/cParser.h
===================================================================
--- branches/collect/source/script/cParser.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cParser.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -32,7 +32,6 @@
#include "cASLibrary.h"
#include "cLexer.h"
-#include "cScriptObject.h"
class cFile;
Modified: branches/collect/source/script/cScriptObject.h
===================================================================
--- branches/collect/source/script/cScriptObject.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cScriptObject.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -34,6 +34,7 @@
public:
cScriptObject() { ; }
+ virtual ~cScriptObject() { ; }
virtual void Run() = 0;
};
Modified: branches/collect/source/script/cSemanticASTVisitor.cc
===================================================================
--- branches/collect/source/script/cSemanticASTVisitor.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cSemanticASTVisitor.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -27,19 +27,44 @@
#include "cASLibrary.h"
#include "cSymbolTable.h"
+#include <cstdarg>
+using namespace AvidaScript;
+
+
+#define SEMANTIC_ERROR(code, ...) reportError(true, AS_SEMANTIC_ERR_ ## code, node.GetFilePosition(), __LINE__, ##__VA_ARGS__)
+#define SEMANTIC_WARNING(code, ...) reportError(false, AS_SEMANTIC_WARN_ ## code, node.GetFilePosition(), __LINE__, ##__VA_ARGS__)
+
+#define TOKEN(x) AS_TOKEN_ ## x
+#define TYPE(x) AS_TYPE_ ## x
+
+
cSemanticASTVisitor::cSemanticASTVisitor(cASLibrary* lib, cSymbolTable* global_symtbl)
- : m_library(lib), m_global_symtbl(global_symtbl), m_cur_symtbl(NULL)
+ : m_library(lib), m_global_symtbl(global_symtbl), m_parent_scope(global_symtbl), m_fun_id(0), m_cur_symtbl(global_symtbl)
{
+ // Add internal definition of the global function
+ m_global_symtbl->AddFunction("__asmain", TYPE(INT));
}
void cSemanticASTVisitor::visitAssignment(cASTAssignment& node)
{
+ node.GetExpression()->Accept(*this);
+ int var_id = -1;
+ if (m_cur_symtbl->LookupVariable(node.GetVariable(), var_id)) {
+ checkCast(node.GetExpression()->GetType(), m_cur_symtbl->GetVariableType(var_id));
+ } else if (m_cur_symtbl != m_global_symtbl && m_global_symtbl->LookupVariable(node.GetVariable(), var_id)) {
+ checkCast(node.GetExpression()->GetType(), m_global_symtbl->GetVariableType(var_id));
+ } else {
+ SEMANTIC_ERROR(VARIABLE_UNDEFINED, (const char*)node.GetVariable());
+ }
}
void cSemanticASTVisitor::visitReturnStatement(cASTReturnStatement& node)
{
+ node.GetExpression()->Accept(*this);
+ checkCast(m_parent_scope->GetFunctionRType(m_fun_id), node.GetExpression()->GetType());
+ // @TODO - mark scope as containing return
}
@@ -50,6 +75,7 @@
cASTNode* stmt = NULL;
while ((stmt = it.Next())) {
stmt->Accept(*this);
+ // @TODO - check for unreachable statements
}
}
@@ -77,6 +103,9 @@
void cSemanticASTVisitor::visitVariableDefinition(cASTVariableDefinition& node)
{
+ if (!m_cur_symtbl->AddVariable(node.GetVariable(), node.GetType())) {
+ SEMANTIC_ERROR(VARIABLE_REDEFINITION, (const char*)node.GetVariable());
+ }
}
@@ -93,6 +122,51 @@
void cSemanticASTVisitor::visitExpressionUnary(cASTExpressionUnary& node)
{
+ node.GetExpression()->Accept(*this);
+
+ switch (node.GetOperator()) {
+ case TOKEN(OP_BIT_NOT):
+ switch (node.GetExpression()->GetType()) {
+ case TYPE(ARRAY):
+ case TYPE(MATRIX):
+ // Array and Matrix meta-op, validity must be determined at runtime
+ case TYPE(INT):
+ case TYPE(CHAR):
+ // Char and Int Okay
+
+ node.SetType(node.GetExpression()->GetType());
+ break;
+
+ default:
+ SEMANTIC_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_BIT_NOT)), mapType(node.GetExpression()->GetType()));
+ break;
+ }
+ break;
+ case TOKEN(OP_LOGIC_NOT):
+ // All types support boolean usage
+ break;
+ case TOKEN(OP_SUB):
+ switch (node.GetExpression()->GetType()) {
+ case TYPE(ARRAY):
+ case TYPE(MATRIX):
+ // Array and Matrix meta-op, validity must be determined at runtime
+ case TYPE(CHAR):
+ case TYPE(FLOAT):
+ case TYPE(INT):
+ // Char, Float and Int Okay
+
+ node.SetType(node.GetExpression()->GetType());
+ break;
+ default:
+ SEMANTIC_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_SUB)), mapType(node.GetExpression()->GetType()));
+ break;
+ };
+
+ break;
+ default:
+ SEMANTIC_ERROR(INTERNAL);
+ break;
+ }
}
@@ -123,3 +197,60 @@
void cSemanticASTVisitor::visitUnpackTarget(cASTUnpackTarget& node)
{
}
+
+
+
+void cSemanticASTVisitor::checkCast(ASType_t in_type, ASType_t out_type)
+{
+
+}
+
+
+void cSemanticASTVisitor::reportError(bool fail, ASSemanticError_t err, const cASFilePosition& fp, const int line, ...)
+{
+#define ERR_ENDL " (cSemanticASTVisitor.cc:" << line << ")" << std::endl
+
+ if (fail) m_success = false;
+
+ std::cerr << fp.GetFilename() << ":" << fp.GetLineNumber();
+ if (err < AS_SEMANTIC_WARN__LAST) std::cerr << ": warning: ";
+ else std::cerr << ": error: ";
+
+ va_list vargs;
+ va_start(vargs, line);
+ switch (err) {
+ case AS_SEMANTIC_WARN_UNREACHABLE:
+ std::cerr << "unreachable statement(s)" << ERR_ENDL;
+ break;
+ case AS_SEMANTIC_ERR_VARIABLE_UNDEFINED:
+ {
+ cString varname = va_arg(vargs, const char*);
+ std::cerr << "'" << varname << "' undefined";
+ cString nearmatch = m_cur_symtbl->VariableNearMatch(varname);
+ if (nearmatch != "") std::cerr << " - possible match '" << nearmatch << "'";
+ std::cerr << ERR_ENDL;
+ }
+ break;
+ case AS_SEMANTIC_ERR_UNDEFINED_TYPE_OP:
+ std::cerr << "'" << va_arg(vargs, const char*) << "' operation undefined for type '"
+ << va_arg(vargs, const char*) << "'" << ERR_ENDL;
+ break;
+ case AS_SEMANTIC_ERR_VARIABLE_REDEFINITION:
+ std::cerr << "redefining variable '" << va_arg(vargs, const char*) << "'" << ERR_ENDL;
+ break;
+ case AS_SEMANTIC_ERR_INTERNAL:
+ std::cerr << "internal semantic analysis error at cSemanticASTVisitor.cc:" << line << std::endl;
+ break;
+ case AS_SEMANTIC_ERR_UNKNOWN:
+ default:
+ std::cerr << "unknown error" << std::endl;
+ }
+ va_end(vargs);
+
+#undef ERR_ENDL
+}
+
+#undef SEMANTIC_ERROR()
+#undef SEMANTIC_WARNING()
+#undef TOKEN()
+#undef TYPE()
Modified: branches/collect/source/script/cSemanticASTVisitor.h
===================================================================
--- branches/collect/source/script/cSemanticASTVisitor.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cSemanticASTVisitor.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -1,5 +1,5 @@
/*
- * cASTDumpVisitor.h
+ * cDumpASTVisitor.h
* Avida
*
* Created by David on 7/12/07.
@@ -27,6 +27,7 @@
#include "cASTVisitor.h"
+#include "tArray.h"
#include "tSmartArray.h"
class cASLibrary;
@@ -38,9 +39,30 @@
private:
cASLibrary* m_library;
cSymbolTable* m_global_symtbl;
+ cSymbolTable* m_parent_scope;
+ int m_fun_id;
cSymbolTable* m_cur_symtbl;
- tSmartArray<cSymbolTable*> m_symtbl_stack;
+ struct sFunctionEntry
+ {
+ cSymbolTable* scope;
+ int fun_id;
+
+ cSymbolTable* fun_symtbl;
+
+ sFunctionEntry() : scope(NULL), fun_id(-1) { ; }
+ };
+ tSmartArray<sFunctionEntry> m_fun_stack;
+
+
+ bool m_success;
+
+
+ cSemanticASTVisitor(); // @not_implemented
+ cSemanticASTVisitor(const cSemanticASTVisitor&); // @not_implemented
+ cSemanticASTVisitor& operator=(const cSemanticASTVisitor&); // @not_implemented
+
+
public:
cSemanticASTVisitor(cASLibrary* lib, cSymbolTable* global_symtbl);
@@ -68,7 +90,7 @@
void visitUnpackTarget(cASTUnpackTarget&);
private:
-
+ void checkCast(ASType_t in_type, ASType_t out_type);
+ void reportError(bool fail, ASSemanticError_t err, const cASFilePosition& fp, const int line, ...);
};
-
#endif
Modified: branches/collect/source/script/cSymbolTable.cc
===================================================================
--- branches/collect/source/script/cSymbolTable.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cSymbolTable.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -24,3 +24,31 @@
#include "cSymbolTable.h"
+
+cSymbolTable::~cSymbolTable()
+{
+ for (int i = 0; i < m_sym_tbl.GetSize(); i++) delete m_sym_tbl[i];
+ for (int i = 0; i < m_fun_tbl.GetSize(); i++) delete m_fun_tbl[i];
+}
+
+bool cSymbolTable::AddVariable(const cString& name, ASType_t type)
+{
+ if (HasSymbol(name)) return false;
+
+ m_sym_tbl.Push(new sSymbolEntry(name, type));
+ m_sym_dict.Add(name, m_sym_tbl.GetSize() - 1);
+
+ return true;
+}
+
+bool cSymbolTable::AddFunction(const cString& name, ASType_t type)
+{
+ if (HasSymbol(name)) return false;
+
+ m_fun_tbl.Push(new sFunctionEntry(name, type));
+ m_fun_dict.Add(name, m_fun_tbl.GetSize() - 1);
+
+ return true;
+}
+
+
Modified: branches/collect/source/script/cSymbolTable.h
===================================================================
--- branches/collect/source/script/cSymbolTable.h 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/script/cSymbolTable.h 2008-06-10 17:52:01 UTC (rev 2637)
@@ -67,10 +67,22 @@
public:
cSymbolTable() { ; }
+ ~cSymbolTable();
+
- bool AddSymbol(const cString& name);
+ bool AddVariable(const cString& name, ASType_t type);
+ bool AddFunction(const cString& name, ASType_t type);
- bool Lookup(const cString& name) const;
+ ASType_t GetVariableType(int var_id) const { return m_sym_tbl[var_id]->type; }
+ ASType_t GetFunctionRType(int fun_id) const { return m_fun_tbl[fun_id]->type; }
+
+ 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); }
+
+ inline bool HasSymbol(const cString& name) const { return m_sym_dict.HasEntry(name) || m_fun_dict.HasEntry(name); }
+
+ 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); }
};
Modified: branches/collect/source/targets/avida-s/main.cc
===================================================================
--- branches/collect/source/targets/avida-s/main.cc 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/targets/avida-s/main.cc 2008-06-10 17:52:01 UTC (rev 2637)
@@ -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;
Modified: branches/collect/source/utils/make_actions_html/actions_source_info
===================================================================
--- branches/collect/source/utils/make_actions_html/actions_source_info 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/utils/make_actions_html/actions_source_info 2008-06-10 17:52:01 UTC (rev 2637)
@@ -376,6 +376,10 @@
Set the max task count required to trigger a reaction to <span class="cmdarg">task_count</span>.
<span class="cmdarg">reaction_name</span> must already
exist in the environment file.
+=== Action SetReactionTask ===
+ Set the task required to trigger a reaction to <span class="cmdarg">task_name</span>.
+ <span class="cmdarg">reaction_name</span> and <span class="cmdarg">task_name</span> must already
+ exist in the environment file.
=== Action SetReactionValueMult ===
Multiply the reaction value by the <span class="cmdarg">value</span>.
<span class="cmdarg">reaction_name</span> must already
@@ -386,6 +390,8 @@
<span class="cmdarg">reaction_name</span> must already
exist in the environment file.
<span class="cmdarg">inst</span> must be in the instruction set.
+=== Action ZeroResources ===
+ Set all resurce levels to zero.
=== head ===
<html>
<!-- This HTML was generated by the make_actions_html routine please modify --->
Modified: branches/collect/source/utils/make_actions_html/make_actions_html.pl
===================================================================
--- branches/collect/source/utils/make_actions_html/make_actions_html.pl 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/source/utils/make_actions_html/make_actions_html.pl 2008-06-10 17:52:01 UTC (rev 2637)
@@ -135,8 +135,16 @@
s/ ?action_lib->Register<//;
s/>\(//;
my @tmp = split/\"/;
- $tmp[0] =~ s/^ ?//;
+ $tmp[0] =~ s/^ *//;
$action_to_class_h{$tmp[1]} = $tmp[0];
+
+ # Handle special cases in PrintActions.cc where a number of actions
+ # are defined using macro expension
+
+ } elsif (/^ *STATS_OUT_FILE/ or /^ *POP_OUT_FILE/) {
+ s/ //g;
+ my @tmp = split/[(,)]/;
+ $class_to_command_line_h{"cAction$tmp[1]"} = "[string fname=\"$tmp[2]\"]";
}
}
close (SOURCE);
Modified: branches/collect/support/config/avida.cfg
===================================================================
--- branches/collect/support/config/avida.cfg 2008-06-10 17:42:21 UTC (rev 2636)
+++ branches/collect/support/config/avida.cfg 2008-06-10 17:52:01 UTC (rev 2637)
@@ -388,4 +388,6 @@
# Biomimetic Features Settings
BIOMIMETIC_REFRACTORY_PERIOD 0.0 # Number of updates affected by refractory period
BIOMIMETIC_MOVEMENT_STEP 0 # Number of cells to move Avidian on move instruction
+BIOMIMETIC_MOVEMENT_FACTOR 1.0 # Scale merit bonus due to movement (m<1.0 applies a cost)
+BIOMIMETIC_EVAL_ON_MOVEMENT 0 # Force task evaluation on each movement step
BIOMIMETIC_K 0 # Carrying capacity in number of organisms
More information about the Avida-cvs
mailing list