[Avida-SVN] r2794 - in branches/collect: Avida.xcodeproj documentation/notes source/actions source/cpu source/main source/script

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Thu Sep 18 08:30:27 PDT 2008


Author: blwalker
Date: 2008-09-18 11:30:20 -0400 (Thu, 18 Sep 2008)
New Revision: 2794

Added:
   branches/collect/source/script/cASCPPParameter.h
   branches/collect/source/script/cASNativeObject.h
Modified:
   branches/collect/Avida.xcodeproj/project.pbxproj
   branches/collect/documentation/notes/release-milestones.txt
   branches/collect/source/actions/EnvironmentActions.cc
   branches/collect/source/actions/LandscapeActions.cc
   branches/collect/source/cpu/cHardwareCPU.cc
   branches/collect/source/cpu/cHardwareExperimental.cc
   branches/collect/source/cpu/cHardwareExperimental.h
   branches/collect/source/main/cEventList.cc
   branches/collect/source/main/cEventList.h
   branches/collect/source/main/cStats.cc
   branches/collect/source/main/cTaskLib.cc
   branches/collect/source/script/ASTree.h
   branches/collect/source/script/AvidaScript.h
   branches/collect/source/script/cASFunction.h
   branches/collect/source/script/cDirectInterpretASTVisitor.cc
   branches/collect/source/script/cDirectInterpretASTVisitor.h
   branches/collect/source/script/cSemanticASTVisitor.cc
Log:

Porting r2760:2793 from development to collect branch.


Modified: branches/collect/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/collect/Avida.xcodeproj/project.pbxproj	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/Avida.xcodeproj/project.pbxproj	2008-09-18 15:30:20 UTC (rev 2794)
@@ -591,6 +591,8 @@
 		70A778370D69D5C200735F1E /* cDemeProbSchedule.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cDemeProbSchedule.cc; sourceTree = "<group>"; };
 		70A778380D69D5C200735F1E /* cDemeProbSchedule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cDemeProbSchedule.h; sourceTree = "<group>"; };
 		70AA941909D486AE006A24C8 /* libtcmalloc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libtcmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		70AE2D360E7DCAA100A520B5 /* cASNativeObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASNativeObject.h; sourceTree = "<group>"; };
+		70AE2D3B0E7DF6C500A520B5 /* cASCPPParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASCPPParameter.h; sourceTree = "<group>"; };
 		70B0864808F4972600FC65FE /* cLandscape.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLandscape.h; sourceTree = "<group>"; };
 		70B0864B08F4972600FC65FE /* cLocalMutations.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLocalMutations.h; sourceTree = "<group>"; };
 		70B0864C08F4972600FC65FE /* cMutation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutation.h; sourceTree = "<group>"; };
@@ -1243,6 +1245,8 @@
 				70A33CE80D8DBD1E008EF976 /* cASFunction.h */,
 				70A33CF40D8DCBB4008EF976 /* ASCoreLib.h */,
 				70A33CF50D8DCBB4008EF976 /* ASCoreLib.cc */,
+				70AE2D360E7DCAA100A520B5 /* cASNativeObject.h */,
+				70AE2D3B0E7DF6C500A520B5 /* cASCPPParameter.h */,
 			);
 			path = script;
 			sourceTree = "<group>";

Modified: branches/collect/documentation/notes/release-milestones.txt
===================================================================
--- branches/collect/documentation/notes/release-milestones.txt	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/documentation/notes/release-milestones.txt	2008-09-18 15:30:20 UTC (rev 2794)
@@ -1,67 +1,3 @@
 Avida Release Milestones
 
-Feature Key:
-- Planned feature, to be implemented
-+ Feature currently in development
-* Feature completed, ready for release
-? Planned feature, but possibly delayed to next milestone
-
-
-Visualized development/support timeline (* current):
---2.6----
-  --2.7--
-         *-2.8----
-           --2.9--
-                  --3.0----
-                    --3.1--
-                           --3.2----
-                             --3.3--
-                                    --3.4----
-                                      --3.5--
-                                             --3.6----
-                                               --3.7--
-                                                      --3.8----
-                                                        --3.9--
-                                                               --4.0----
-
-
-Version 2.6 - stable      - Status: End of Life
-Version 2.7 - development - Status: Wrapping Up
-Version 2.8 - stable      - Status: Pre-release preparation
-
-Version 2.9 - development - Target: August 2008    - Status: Soon
-
-David:
-- Completed AvidaScript
-  - Merged 'avida' and 'avida-s' functionality
-- Cleanup Landscaping tools
-+ Error reporting, input validation
-
-Dave K:
-- Topology manager
-  + environment named regions
-
-Charles:
-- Completed Viewers based on Core Viewer/GUI frameworks
-
-Bess:
-+ Consistency test coverage
-
-Unassigned:
-- New Mutation framework
-- Schedulable object framework (organism threads scheduled rather than organisms, events, etc.) 
-- Serialization
-
-All:
-- Update documentation
-- Code release cleanup
-
-
-**** NOTE: Backwards compatibility breaks at this point ****
-
-
-Version 3.0 - stable      - Target: Ongoing        - Status: Planned, pending version 2.9 completion
-
-Version 3.1 - development - Target: tbd            - Status: feature set tdb
-
-- Basic OS X native GUI
+See http://avida.devosoft.org/trac/roadmap

Modified: branches/collect/source/actions/EnvironmentActions.cc
===================================================================
--- branches/collect/source/actions/EnvironmentActions.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/actions/EnvironmentActions.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -538,31 +538,93 @@
 /**
  Sets resource availiblity to seasonal
  */
-class cActionSetSeasonalResource : public cAction
+class cActionSetSeasonalResource : public cAction {
+private:
+	cString m_res_name;
+
+public:
+	cActionSetSeasonalResource(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
 	{
-	private:
-		cString m_res_name;
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+	}
 		
-	public:
-		cActionSetSeasonalResource(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
-		{
-			cString largs(args);
-			if (largs.GetSize()) m_res_name = largs.PopWord();
-		}
+	static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
 		
-		static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -1*(0.4*tanh((time-182500)/50000)+0.5)*(0.5*sin(time/58.091)+0.5)+1;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);
+	}
+};
+
+/**
+ Sets resource availiblity to seasonal 1 to -1 for 1K years of 365 updates
+ */
+class cActionSetSeasonalResource1Kyears_1To_1 : public cAction {
+private:
+	cString m_res_name;
+	double m_scale;
 		
-		void Process(cAvidaContext& ctx)
-		{
-			int time = m_world->GetStats().GetUpdate();
-			double m_res_count = -1*(0.4*tanh((time-182500)/50000)+0.5)*(0.5*sin(time/58.091)+0.5)+1;
-			cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
-			if (res != NULL) m_world->GetPopulation().SetResource(res->GetID(), m_res_count);
-			
-		}
-	};
+public:
+	cActionSetSeasonalResource1Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name(""), m_scale(1.0)
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+		if (largs.GetSize()) m_scale = largs.PopWord().AsDouble();
+	}
+		
+	static const cString GetDescription() { return "Arguments: <string reaction_name> <double scale>"; }
+	
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -m_scale*(tanh((time-182500)/50000)+1)*(0.5*sin(time/58.091)+0.5)+1;
+		if(m_res_count < 0.0)
+			m_res_count = 0.0;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);			
+	}
+};
 
+
 /**
+ Sets resource availiblity to seasonal 1 to -1 for 10K years of 365 updates
+ */
+class cActionSetSeasonalResource10Kyears_1To_1 : public cAction {
+private:
+	cString m_res_name;
+	double m_scale;
+	
+public:
+	cActionSetSeasonalResource10Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name(""), m_scale(1.0)
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+		if (largs.GetSize()) m_scale = largs.PopWord().AsDouble();
+
+	}
+	
+	static const cString GetDescription() { return "Arguments: <string reaction_name> <double scale>"; }
+	
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -m_scale*(tanh((time-1825000)/500000)+1)*(0.5*sin(time/58.091)+0.5)+1;
+		if(m_res_count < 0.0)
+			m_res_count = 0.0;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);			
+	}
+};
+
+
+/**
 Sets resource availiblity to periodic
  */
 class cActionSetPeriodicResource : public cAction
@@ -878,6 +940,8 @@
   action_lib->Register<cActionSetEnvironmentRandomMask>("SetEnvironmentRandomMask");
 
 	action_lib->Register<cActionSetSeasonalResource>("SetSeasonalResource");
+	action_lib->Register<cActionSetSeasonalResource1Kyears_1To_1>("SetSeasonalResource1Kyears_1To_1");
+	action_lib->Register<cActionSetSeasonalResource10Kyears_1To_1>("SetSeasonalResource10Kyears_1To_1");
   action_lib->Register<cActionSetPeriodicResource>("SetPeriodicResource");
   action_lib->Register<cActionSetNumInstBefore0Energy>("SetNumInstBefore0Energy");
 

Modified: branches/collect/source/actions/LandscapeActions.cc
===================================================================
--- branches/collect/source/actions/LandscapeActions.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/actions/LandscapeActions.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -227,6 +227,11 @@
     int update = -1;
     cLandscape* land = NULL;
     
+    if (m_dist < 1) {
+      m_world->GetDriver().RaiseException("landscape distance must be >= 1");
+      return;
+    }
+    
     if (ctx.GetAnalyzeMode()) {
       if (m_world->GetVerbosity() >= VERBOSE_ON) {
         cString msg("Full Landscaping batch ");

Modified: branches/collect/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/collect/source/cpu/cHardwareCPU.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/cpu/cHardwareCPU.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -4233,6 +4233,12 @@
   // Declarations
   int fromcellID, destcellID; //, actualNeighborhoodSize, fromFacing, destFacing, currentFacing;
 
+  fromcellID = organism->GetCellID(); //absolute id of current cell
+	
+  if(fromcellID == -1) {
+    return false;
+  }
+	
   // Get population
   cPopulation& pop = m_world->GetPopulation();
   cDeme &deme = pop.GetDeme(pop.GetCell(organism->GetCellID()).GetDemeID());
@@ -4248,7 +4254,7 @@
   // Code
   if (0 < stepsize) {
     // Current cell
-    fromcellID = organism->GetCellID();
+    //fromcellID = organism->GetCellID();
     // With sanity check
     if (-1  == fromcellID) return false;
     // Destination cell
@@ -5439,9 +5445,15 @@
 // Sense if the organism is on a target -- put 1 in reg is so, 0 otherwise
 bool cHardwareCPU::Inst_SenseTarget(cAvidaContext& ctx) {
   int reg_to_set = FindModifiedRegister(REG_CX);
-  int cell_data = m_world->GetPopulation().GetCell(organism->GetCellID()).GetCellData();
+  int cellid = organism->GetCellID();
+
+  if(cellid == -1) {
+    return false;
+  }
+	
+  int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
   int val = 0;
-
+	
   if(cell_data > 0) {
     val = 1;
   }
@@ -5455,11 +5467,17 @@
   int reg_to_set = FindModifiedRegister(REG_CX);
 
   cPopulation& pop = m_world->GetPopulation();
-  cPopulationCell& mycell = pop.GetCell(organism->GetCellID());
-
+  int cellid = organism->GetCellID();
+	
+  if(cellid == -1) {
+    return true;
+  }
+	
+  cPopulationCell& mycell = pop.GetCell(cellid);
+	
   int cell_data = mycell.GetCellFaced().GetCellData(); //absolute id of faced cell
   int val = 0;
-
+	
   if(cell_data > 0) {
     val = 1;
   }
@@ -5474,6 +5492,10 @@
 {
   int reg_to_set = FindModifiedRegister(REG_BX);
 
+  if(cellid == -1) {
+    return false;
+  }
+
   cPopulation& pop = m_world->GetPopulation();
   cDeme &deme = pop.GetDeme(pop.GetCell(cellid).GetDemeID());
   int relative_cell_id = deme.GetRelativeCellID(cellid);
@@ -6581,7 +6603,13 @@
 
 bool cHardwareCPU::Inst_IfTarget(cAvidaContext& ctx)
 {
-  int cell_data = m_world->GetPopulation().GetCell(organism->GetCellID()).GetCellData();
+  int cellid = organism->GetCellID(); //absolute id of current cell
+	
+  if(cellid == -1) {
+	return true;
+  }		
+	
+  int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
 
   if(cell_data == -1) {
     IP().Advance();
@@ -6593,7 +6621,13 @@
 
 bool cHardwareCPU::Inst_IfNotTarget(cAvidaContext& ctx)
 {
-  int cell_data = m_world->GetPopulation().GetCell(organism->GetCellID()).GetCellData();
+  int cellid = organism->GetCellID(); //absolute id of current cell
+	
+  if(cellid == -1) {
+    return true;
+  }	
+	
+  int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
 
   if(cell_data > 0) {
     IP().Advance();

Modified: branches/collect/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/collect/source/cpu/cHardwareExperimental.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/cpu/cHardwareExperimental.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -147,6 +147,7 @@
     // Replication Instructions
     tInstLibEntry<tMethod>("h-alloc", &cHardwareExperimental::Inst_HeadAlloc, nInstFlag::DEFAULT, "Allocate maximum allowed space"),
     tInstLibEntry<tMethod>("h-divide", &cHardwareExperimental::Inst_HeadDivide, (nInstFlag::DEFAULT | nInstFlag::STALL), "Divide code between read and write heads."),
+    tInstLibEntry<tMethod>("h-divide-sex", &cHardwareExperimental::Inst_HeadDivideSex, (nInstFlag::DEFAULT | nInstFlag::STALL), "Divide code between read and write heads."),
     tInstLibEntry<tMethod>("h-copy", &cHardwareExperimental::Inst_HeadCopy, nInstFlag::DEFAULT, "Copy from read-head to write-head; advance both"),
     tInstLibEntry<tMethod>("if-label", &cHardwareExperimental::Inst_IfLabel, nInstFlag::DEFAULT, "Execute next if we copied complement of attached label"),
 
@@ -1341,8 +1342,12 @@
   return true;
 }
 
+
 bool cHardwareExperimental::Inst_HeadDivide(cAvidaContext& ctx)
 {
+  organism->GetPhenotype().SetDivideSex(false);
+  organism->GetPhenotype().SetCrossNum(0);
+
   AdjustHeads();
   const int divide_pos = GetHead(nHardware::HEAD_READ).GetPosition();
   int child_end =  GetHead(nHardware::HEAD_WRITE).GetPosition();
@@ -1355,6 +1360,23 @@
 }
 
 
+bool cHardwareExperimental::Inst_HeadDivideSex(cAvidaContext& ctx)  
+{ 
+  organism->GetPhenotype().SetDivideSex(true);
+  organism->GetPhenotype().SetCrossNum(1);
+  
+  AdjustHeads();
+  const int divide_pos = GetHead(nHardware::HEAD_READ).GetPosition();
+  int child_end =  GetHead(nHardware::HEAD_WRITE).GetPosition();
+  if (child_end == 0) child_end = m_memory.GetSize();
+  const int extra_lines = m_memory.GetSize() - child_end;
+  bool ret_val = Divide_Main(ctx, divide_pos, extra_lines, 1.0);
+  // Re-adjust heads.
+  AdjustHeads();
+  return ret_val; 
+}
+
+
 bool cHardwareExperimental::Inst_HeadRead(cAvidaContext& ctx)
 {
   const int dst = FindModifiedRegister(REG_BX);

Modified: branches/collect/source/cpu/cHardwareExperimental.h
===================================================================
--- branches/collect/source/cpu/cHardwareExperimental.h	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/cpu/cHardwareExperimental.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -400,6 +400,7 @@
   bool Inst_GetHead(cAvidaContext& ctx);
   bool Inst_IfLabel(cAvidaContext& ctx);
   bool Inst_HeadDivide(cAvidaContext& ctx);
+  bool Inst_HeadDivideSex(cAvidaContext& ctx);
   bool Inst_HeadRead(cAvidaContext& ctx);
   bool Inst_HeadWrite(cAvidaContext& ctx);
   bool Inst_HeadCopy(cAvidaContext& ctx);

Modified: branches/collect/source/main/cEventList.cc
===================================================================
--- branches/collect/source/main/cEventList.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/main/cEventList.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -133,6 +133,9 @@
   case GENERATION:
     t_val = m_world->GetStats().SumGeneration().Average();
     break;
+  case BIRTHS:
+    t_val = m_world->GetStats().GetTotCreatures();
+    break;
   case UNDEFINED:
     break;
   }
@@ -251,6 +254,9 @@
       case IMMEDIATE:
         os << "immediate ";
         break;
+      case BIRTHS:
+        os << "births ";
+        break;
       default:
         os << "undefined ";
     }
@@ -306,6 +312,9 @@
   } else if( cur_word == "g" || cur_word == "generation") {
     trigger = GENERATION;
     cur_word = cur_line.PopWord();
+  } else if (cur_word == "b" || cur_word == "births") {
+    trigger = BIRTHS;
+    cur_word = cur_line.PopWord();
   } else {
     // If Trigger is skipped so assume IMMEDIATE
     trigger = IMMEDIATE;

Modified: branches/collect/source/main/cEventList.h
===================================================================
--- branches/collect/source/main/cEventList.h	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/main/cEventList.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -52,7 +52,7 @@
   tMemTrack<cEventList> mt;
 #endif
 public:
-  enum eTriggerType { UPDATE, GENERATION, IMMEDIATE, UNDEFINED };
+  enum eTriggerType { UPDATE, GENERATION, IMMEDIATE, BIRTHS, UNDEFINED };
   
   static const double TRIGGER_BEGIN;
   static const double TRIGGER_END;

Modified: branches/collect/source/main/cStats.cc
===================================================================
--- branches/collect/source/main/cStats.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/main/cStats.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -184,6 +184,9 @@
   resource_count.Resize( m_world->GetNumResources() );
   resource_count.SetAll(0);
 
+  resource_geometry.Resize( m_world->GetNumResources() );
+  resource_geometry.SetAll(nGeometry::GLOBAL);
+
   task_names.Resize(num_tasks);
   for (int i = 0; i < num_tasks; i++)
     task_names[i] = env.GetTask(i).GetDesc();

Modified: branches/collect/source/main/cTaskLib.cc
===================================================================
--- branches/collect/source/main/cTaskLib.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/main/cTaskLib.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -2898,7 +2898,7 @@
   return 1.0;
 }
 
-double cTaskLib::Task_MoveToRightSide(cTaskContext& ctx) const {
+double cTaskLib::Task_MoveToRightSide(cTaskContext& ctx) const {	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   std::pair<int, int> location = deme.GetCellPosition(ctx.GetOrgInterface()->GetCellID());
   
@@ -2931,6 +2931,11 @@
 //Note - a generic version of this is now at - Task_MoveToMovementEvent
 {
   cOrgInterface* iface = ctx.GetOrgInterface();
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }
+	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   int celldata = m_world->GetPopulation().GetCell(iface->GetCellID()).GetCellData();
 
@@ -2958,6 +2963,11 @@
 } //End cTaskLib::TaskMoveToTarget()
 
 double cTaskLib::Task_MoveToMovementEvent(cTaskContext& ctx) const {
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }	
+	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   int cell_data = m_world->GetPopulation().GetCell(ctx.GetOrgInterface()->GetCellID()).GetCellData();
   cOrgInterface* iface = ctx.GetOrgInterface();
@@ -2977,6 +2987,11 @@
 
 
 double cTaskLib::Task_MoveBetweenMovementEvent(cTaskContext& ctx) const {
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }	
+	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   int cell_data = m_world->GetPopulation().GetCell(ctx.GetOrgInterface()->GetCellID()).GetCellData();
   cOrgInterface* iface = ctx.GetOrgInterface();
@@ -3019,6 +3034,11 @@
 }
 
 double cTaskLib::Task_MoveToEvent(cTaskContext& ctx) const {
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }	
+	
   cDeme* deme = ctx.GetOrganism()->GetOrgInterface().GetDeme();
   int cell_data = ctx.GetOrganism()->GetOrgInterface().GetCellData();
   if(cell_data <= 0)

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

Modified: branches/collect/source/script/AvidaScript.h
===================================================================
--- branches/collect/source/script/AvidaScript.h	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/script/AvidaScript.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -164,6 +164,7 @@
   AS_DIRECT_INTERPRET_ERR_KEY_NOT_FOUND,
   AS_DIRECT_INTERPRET_ERR_MATRIX_OP_TYPE_MISMATCH,
   AS_DIRECT_INTERPRET_ERR_MATRIX_SIZE_MISMATCH,
+  AS_DIRECT_INTERPRET_ERR_NATIVE_OBJECT_TYPE_MISMATCH,
   AS_DIRECT_INTERPRET_ERR_OBJECT_ASSIGN_FAIL,
   AS_DIRECT_INTERPRET_ERR_TYPE_CAST,
   AS_DIRECT_INTERPRET_ERR_UNDEFINED_TYPE_OP,
@@ -242,7 +243,11 @@
   bool operator!=(const sASTypeInfo& ot) const { return (type != ot.type || info != ot.info); }
 };
 
+enum eASMethodReturnValues {
+  AS_NOT_FOUND = -1
+};
 
+
 namespace AvidaScript {
   const char* mapBuiltIn(ASBuiltIn_t builtin);  
   const char* mapToken(ASToken_t token);

Copied: branches/collect/source/script/cASCPPParameter.h (from rev 2793, development/source/script/cASCPPParameter.h)
===================================================================
--- branches/collect/source/script/cASCPPParameter.h	                        (rev 0)
+++ branches/collect/source/script/cASCPPParameter.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -0,0 +1,66 @@
+/*
+ *  cASCPPParameter.h
+ *  Avida
+ *
+ *  Created by David Bryson on 9/14/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.
+ *
+ */
+
+#ifndef cASCPPParameter_h
+#define cASCPPParameter_h
+
+#include "avida.h"
+#include "AvidaScript.h"
+
+#include "cString.h"
+
+
+class cASCPPParameter
+{
+private:
+  union {
+    bool m_bool;
+    char m_char;
+    int m_int;
+    double m_float;
+    cString* m_string;
+  };
+  
+public:
+  cASCPPParameter() { ; }
+  
+  void Set(bool val) { m_bool = val; }
+  void Set(char val) { m_char = val; }
+  void Set(int val) { m_int = val; }
+  void Set(double val) { m_float = val; }
+  void Set(cString* val) { m_string = val; }
+  void Set(const cString& val) { m_string = new cString(val); }
+  
+  template<typename T> inline T Get() const { Avida::Exit(AS_EXIT_INTERNAL_ERROR); return m_int; }
+};
+
+template<> inline bool cASCPPParameter::Get<bool>() const { return m_bool; }
+template<> inline char cASCPPParameter::Get<char>() const { return m_char; }
+template<> inline int cASCPPParameter::Get<int>() const { return m_int; }
+template<> inline double cASCPPParameter::Get<double>() const { return m_float; }
+template<> inline const cString& cASCPPParameter::Get<const cString&>() const { return *m_string; }
+template<> inline const cString* cASCPPParameter::Get<const cString*>() const { return m_string; }
+template<> inline cString* cASCPPParameter::Get<cString*>() const { return m_string; }
+
+#endif

Modified: branches/collect/source/script/cASFunction.h
===================================================================
--- branches/collect/source/script/cASFunction.h	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/script/cASFunction.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -25,40 +25,14 @@
 #ifndef cASFunction_h
 #define cASFunction_h
 
-#include "avida.h"
 #include "AvidaScript.h"
 
+#include "cASCPPParameter.h"
 #include "cString.h"
 
 
 class cASFunction
 {
-public:
-  class cParameter
-  {
-  private:
-    union {
-      bool m_bool;
-      char m_char;
-      int m_int;
-      double m_float;
-      cString* m_string;
-    };
-    
-  public:
-    cParameter() { ; }
-    
-    void Set(bool val) { m_bool = val; }
-    void Set(char val) { m_char = val; }
-    void Set(int val) { m_int = val; }
-    void Set(double val) { m_float = val; }
-    void Set(cString* val) { m_string = val; }
-    void Set(const cString& val) { m_string = new cString(val); }
-    
-    template<typename T> inline T Get() const { Avida::Exit(AS_EXIT_INTERNAL_ERROR); return m_int; }
-  };
-  
-  
 protected:
   cString m_name;
   sASTypeInfo m_rtype;
@@ -74,19 +48,10 @@
   const sASTypeInfo& GetReturnType() const { return m_rtype; }
   virtual const sASTypeInfo& GetArgumentType(int arg) const = 0;
   
-  virtual cParameter Call(cParameter args[]) const = 0;
+  virtual cASCPPParameter Call(cASCPPParameter args[]) const = 0;
 };
 
 
-template<> inline bool cASFunction::cParameter::Get<bool>() const { return m_bool; }
-template<> inline char cASFunction::cParameter::Get<char>() const { return m_char; }
-template<> inline int cASFunction::cParameter::Get<int>() const { return m_int; }
-template<> inline double cASFunction::cParameter::Get<double>() const { return m_float; }
-template<> inline const cString& cASFunction::cParameter::Get<const cString&>() const { return *m_string; }
-template<> inline const cString* cASFunction::cParameter::Get<const cString*>() const { return m_string; }
-template<> inline cString* cASFunction::cParameter::Get<cString*>() const { return m_string; }
-
-
 template<typename FunctionType> class tASFunction;
 
 
@@ -110,9 +75,9 @@
   int GetArity() const { return 1; }
   const sASTypeInfo& GetArgumentType(int arg) const { return m_signature; }
   
-  cParameter Call(cParameter args[]) const
+  cASCPPParameter Call(cASCPPParameter args[]) const
   {
-    cParameter rvalue;
+    cASCPPParameter rvalue;
     rvalue.Set((*m_func)(args[0].Get<Arg1Type>()));
     return rvalue;
   }
@@ -139,11 +104,11 @@
   int GetArity() const { return 1; }
   const sASTypeInfo& GetArgumentType(int arg) const { return m_signature; }
   
-  cParameter Call(cParameter args[]) const
+  cASCPPParameter Call(cASCPPParameter args[]) const
   {
     (*m_func)(args[0].Get<Arg1Type>());
     
-    return cParameter();
+    return cASCPPParameter();
   }
 };
 

Copied: branches/collect/source/script/cASNativeObject.h (from rev 2793, development/source/script/cASNativeObject.h)
===================================================================
--- branches/collect/source/script/cASNativeObject.h	                        (rev 0)
+++ branches/collect/source/script/cASNativeObject.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -0,0 +1,72 @@
+/*
+ *  cASNativeObject.h
+ *  Avida
+ *
+ *  Created by David Bryson on 9/14/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.
+ *
+ */
+
+#ifndef cASNativeObject_h
+#define cASNativeObject_h
+
+#include "AvidaScript.h"
+
+#include "cASCPPParameter.h"
+
+class cString;
+
+class cASNativeObject 
+{
+private:
+  int m_ref_count;
+  
+public:
+  cASNativeObject() : m_ref_count(1) { ; }
+  virtual ~cASNativeObject() { ; }
+  
+  virtual const char* GetType() = 0;
+  
+  virtual bool CallMethod(int mid, int argc, cASCPPParameter args[]) = 0;
+  
+  int LookupValue(const cString& val_name) { return AS_NOT_FOUND; } // @TODO
+  int LookupMethod(const cString& meth_name) { return AS_NOT_FOUND; } // @TODO
+  
+  inline cASNativeObject* GetReference() { m_ref_count++; return this; }
+  inline void RemoveReference() { m_ref_count--; if (m_ref_count == 0) delete this; }
+  inline bool IsShared() { return (m_ref_count > 1); }
+};
+
+
+template<class NativeClass, const char* TypeName>
+class tASNativeObject : public cASNativeObject
+{
+private:
+  NativeClass* m_object;
+  
+public:
+  tASNativeObject(NativeClass* obj) : m_object(obj) { ; }
+  ~tASNativeObject() { delete m_object; }
+
+  const char* GetType() { return TypeName; }
+  
+  bool CallMethod(int mid, int argc, cASCPPParameter args[]) { return false; } // @TODO;  
+};
+  
+
+#endif

Modified: branches/collect/source/script/cDirectInterpretASTVisitor.cc
===================================================================
--- branches/collect/source/script/cDirectInterpretASTVisitor.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/script/cDirectInterpretASTVisitor.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -116,7 +116,10 @@
     case TYPE(CHAR):        m_call_stack[sp + var_id].value.as_char = asChar(m_rtype, m_rvalue, node); break;
     case TYPE(FLOAT):       m_call_stack[sp + var_id].value.as_float = asFloat(m_rtype, m_rvalue, node); break;
     case TYPE(INT):         m_call_stack[sp + var_id].value.as_int = asInt(m_rtype, m_rvalue, node); break;
-    case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - assignment
+    
+    case TYPE(OBJECT_REF):
+      m_call_stack[sp + var_id].value.as_nobj->RemoveReference();
+      m_call_stack[sp + var_id].value.as_nobj = asNativeObject(symtbl->GetVariableType(var_id).info, m_rtype, m_rvalue, node);
 
     case TYPE(VAR):
       m_call_stack[sp + var_id].value = m_rvalue;
@@ -212,7 +215,10 @@
       case TYPE(CHAR):        m_call_stack[var_idx].value.as_char = asChar(val.type, val.value, node); break;
       case TYPE(FLOAT):       m_call_stack[var_idx].value.as_float = asFloat(val.type, val.value, node); break;
       case TYPE(INT):         m_call_stack[var_idx].value.as_int = asInt(val.type, val.value, node); break;
-      case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - foreach assignment
+      case TYPE(OBJECT_REF):
+        m_call_stack[var_idx].value.as_nobj->RemoveReference();
+        m_call_stack[var_idx].value.as_nobj = asNativeObject(var_type.info, val.type, val.value, node);
+        break;
         
       case TYPE(ARRAY):
         m_call_stack[var_idx].value.as_array->RemoveReference();
@@ -306,7 +312,7 @@
       case TYPE(DICT):        m_call_stack[m_sp + var_id].value.as_dict = asDict(m_rtype, m_rvalue, node); break;
       case TYPE(FLOAT):       m_call_stack[m_sp + var_id].value.as_float = asFloat(m_rtype, m_rvalue, node); break;
       case TYPE(INT):         m_call_stack[m_sp + var_id].value.as_int = asInt(m_rtype, m_rvalue, node); break;
-      case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - var def assignment
+      case TYPE(OBJECT_REF):  m_call_stack[m_sp + var_id].value.as_nobj = asNativeObject(node.GetType().info, m_rtype, m_rvalue, node); break;
       case TYPE(MATRIX):      m_call_stack[m_sp + var_id].value.as_matrix = asMatrix(m_rtype, m_rvalue, node); break;
       case TYPE(STRING):
         delete m_call_stack[m_sp + var_id].value.as_string;
@@ -342,6 +348,8 @@
     } else {
       INTERPRET_ERROR(INTERNAL);
     }
+  } else if (node.GetType().type == TYPE(OBJECT_REF)) {
+    // @TODO - set native object ref to special NULL value
   }
 }
 
@@ -1145,7 +1153,7 @@
     const cASFunction* func = node.GetASFunction();
     
     // Setup arguments
-    cASFunction::cParameter* args = new cASFunction::cParameter[func->GetArity()];
+    cASCPPParameter* args = new cASCPPParameter[func->GetArity()];
     tListIterator<cASTNode> cit = node.GetArguments()->Iterator();
     cASTNode* an = NULL;
     for (int i = 0; i < func->GetArity(); i++) {
@@ -1165,7 +1173,7 @@
     }
     
     // Call the function
-    cASFunction::cParameter rvalue = func->Call(args);
+    cASCPPParameter rvalue = func->Call(args);
 
     // Handle the return value
     switch (node.GetType().type) {
@@ -1243,7 +1251,7 @@
         case TYPE(DICT):        m_call_stack[sp + var_id].value.as_dict = asDict(m_rtype, m_rvalue, node); break;
         case TYPE(FLOAT):       m_call_stack[sp + var_id].value.as_float = asFloat(m_rtype, m_rvalue, node); break;
         case TYPE(INT):         m_call_stack[sp + var_id].value.as_int = asInt(m_rtype, m_rvalue, node); break;
-        case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - func call arg assignment
+        case TYPE(OBJECT_REF):  m_call_stack[sp + var_id].value.as_nobj = asNativeObject(func_symtbl->GetVariableType(var_id).info, m_rtype, m_rvalue, node); break;
         case TYPE(MATRIX):      m_call_stack[sp + var_id].value.as_matrix = asMatrix(m_rtype, m_rvalue, node); break;
         case TYPE(STRING):
           {
@@ -1275,7 +1283,7 @@
       case TYPE(DICT):        m_rvalue.as_dict = asDict(m_rtype, m_rvalue, node); break;
       case TYPE(FLOAT):       m_rvalue.as_float = asFloat(m_rtype, m_rvalue, node); break;
       case TYPE(INT):         m_rvalue.as_int = asInt(m_rtype, m_rvalue, node); break;
-      case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - return
+      case TYPE(OBJECT_REF):  m_rvalue.as_nobj = asNativeObject(node.GetType().info, m_rtype, m_rvalue, node); break;
       case TYPE(MATRIX):      m_rvalue.as_matrix = asMatrix(m_rtype, m_rvalue, node); break;
       case TYPE(STRING):      m_rvalue.as_string = asString(m_rtype, m_rvalue, node); break;
       case TYPE(VAR):         break;
@@ -1434,7 +1442,7 @@
     switch (node.GetType().type) {
       case TYPE(ARRAY):       m_rvalue.as_ref = new cArrayVarRef(m_call_stack[sp + var_id].value); break;
       case TYPE(DICT):        m_rvalue.as_ref = new cDictVarRef(m_call_stack[sp + var_id].value); break;
-      case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - var ref object assignment
+      case TYPE(OBJECT_REF):  m_rvalue.as_ref = new cNativeObjectVarRef(m_call_stack[sp + var_id].value); break;
       case TYPE(MATRIX):      m_rvalue.as_ref = new cMatrixVarRef(m_call_stack[sp + var_id].value); break;
       case TYPE(STRING):      m_rvalue.as_ref = new cStringVarRef(m_call_stack[sp + var_id].value); break;
         
@@ -1459,7 +1467,7 @@
       case TYPE(STRING):      m_rvalue.as_string = new cString(*m_call_stack[sp + var_id].value.as_string); break;
 
       
-      case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - var ref assignment
+      case TYPE(OBJECT_REF):  m_rvalue.as_nobj = m_call_stack[sp + var_id].value.as_nobj->GetReference(); break;
         
       default:
         INTERPRET_ERROR(INTERNAL);
@@ -1490,7 +1498,10 @@
       case TYPE(CHAR):        m_call_stack[var_idx].value.as_char = asChar(val.type, val.value, node); break;
       case TYPE(FLOAT):       m_call_stack[var_idx].value.as_float = asFloat(val.type, val.value, node); break;
       case TYPE(INT):         m_call_stack[var_idx].value.as_int = asInt(val.type, val.value, node); break;
-      case TYPE(OBJECT_REF):  INTERPRET_ERROR(INTERNAL); // @TODO - assignment
+      case TYPE(OBJECT_REF):
+        m_call_stack[var_idx].value.as_nobj->RemoveReference();
+        m_call_stack[var_idx].value.as_nobj = asNativeObject(var_type.info, val.type, val.value, node);
+        break;
         
       case TYPE(VAR):
         m_call_stack[var_idx].value = val.value;
@@ -1757,6 +1768,22 @@
 }
 
 
+cASNativeObject* cDirectInterpretASTVisitor::asNativeObject(const cString& info, const sASTypeInfo& type, uAnyType value,
+                                                            cASTNode& node)                                                           
+{
+  switch (type.type) {
+    case TYPE(OBJECT_REF):
+      if (type.info != info) INTERPRET_ERROR(NATIVE_OBJECT_TYPE_MISMATCH, *info, *type.info);
+      return value.as_nobj;
+      
+    default:
+      INTERPRET_ERROR(TYPE_CAST, mapType(type), mapType(TYPE(OBJECT_REF)));
+  }
+  
+  return NULL;
+}
+
+
 cString* cDirectInterpretASTVisitor::asString(const sASTypeInfo& type, uAnyType value, cASTNode& node)
 {
   switch (type.type) {
@@ -1786,9 +1813,9 @@
         return str;
       }
 
-    case TYPE(OBJECT_REF): // @TODO - as string
+    case TYPE(OBJECT_REF):
     {
-      cString* str = new cString(cStringUtil::Stringf("< object >"));
+      cString* str = new cString(cStringUtil::Stringf("< %s object @ %p >", value.as_nobj->GetType(), value.as_nobj));
       return str;
     }
       
@@ -2196,9 +2223,7 @@
       case TYPE(ARRAY):   return value.as_array == lval.value.as_array;
       case TYPE(DICT):    return value.as_dict == lval.value.as_dict;
       case TYPE(MATRIX):  return value.as_matrix == lval.value.as_matrix;
-        
-      case TYPE(OBJECT_REF): // @TODO - aggregate value compare
-        return value.as_void == lval.value.as_void;
+      case TYPE(OBJECT_REF): return value.as_nobj == lval.value.as_nobj;
       
       default:
         break;
@@ -2497,8 +2522,21 @@
 }
 
 
+bool cDirectInterpretASTVisitor::cNativeObjectVarRef::Get(const sAggregateValue& idx, sAggregateValue& val)
+{
+  // @TODO - get indexed native var
+  return false;
+}
 
+bool cDirectInterpretASTVisitor::cNativeObjectVarRef::Set(sAggregateValue& idx, sAggregateValue& val)
+{
+  // @TODO - set indexed native var
+  return false;
+}
 
+
+
+
 bool cDirectInterpretASTVisitor::cObjectIndexRef::Get(const sAggregateValue& idx, sAggregateValue& val)
 {
   sAggregateValue o_val;
@@ -2721,6 +2759,13 @@
     case AS_DIRECT_INTERPRET_ERR_MATRIX_SIZE_MISMATCH:
       std::cerr << "matrix size mismatch for '" << VA_ARG_STR << "' operation" << ERR_ENDL;
       break;
+    case AS_DIRECT_INTERPRET_ERR_NATIVE_OBJECT_TYPE_MISMATCH:
+      {
+        const char* otype = VA_ARG_STR;
+        const char* itype = VA_ARG_STR;
+        std::cerr << "expected object of type '" << otype << "', received '" << itype << "'" << ERR_ENDL;
+      }
+      break;
     case AS_DIRECT_INTERPRET_ERR_OBJECT_ASSIGN_FAIL:
       std::cerr << "aggregate assignment failed" << ERR_ENDL;
       break;

Modified: branches/collect/source/script/cDirectInterpretASTVisitor.h
===================================================================
--- branches/collect/source/script/cDirectInterpretASTVisitor.h	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/script/cDirectInterpretASTVisitor.h	2008-09-18 15:30:20 UTC (rev 2794)
@@ -25,6 +25,7 @@
 #ifndef cDirectInterpretASTVisitor_h
 #define cDirectInterpretASTVisitor_h
 
+#include "cASNativeObject.h"
 #include "cASTVisitor.h"
 
 #include "tHashTable.h"
@@ -53,6 +54,7 @@
     cLocalDict* as_dict;
     cLocalMatrix* as_matrix;
     cObjectRef* as_ref;
+    cASNativeObject* as_nobj;
     void* as_void;
   } uAnyType;
   
@@ -132,6 +134,7 @@
   int asInt(const sASTypeInfo& type, uAnyType value, cASTNode& node);
   double asFloat(const sASTypeInfo& type, uAnyType value, cASTNode& node);
   cLocalMatrix* asMatrix(const sASTypeInfo& type, uAnyType value, cASTNode& node);
+  cASNativeObject* asNativeObject(const cString& info, const sASTypeInfo& type, uAnyType value, cASTNode& node);
   cString* asString(const sASTypeInfo& type, uAnyType value, cASTNode& node);
   
   ASType_t getRuntimeType(ASType_t ltype, ASType_t rtype, bool allow_str = false);
@@ -306,6 +309,22 @@
     bool Set(sAggregateValue& idx, sAggregateValue& val);
   };
   
+  class cNativeObjectVarRef : public cObjectRef
+  {
+  private:
+    uAnyType& m_var;
+    
+  public:
+    cNativeObjectVarRef(uAnyType& var) : m_var(var) { ; }
+    ~cNativeObjectVarRef() { ; }
+    
+    bool IsWritable() { return false; } 
+    bool Get(sAggregateValue& val) { val.value = m_var; val.type = AS_TYPE_OBJECT_REF; return false; }
+    bool Get(const sAggregateValue& idx, sAggregateValue& val);
+    bool Set(sAggregateValue& val) { return false; }
+    bool Set(sAggregateValue& idx, sAggregateValue& val);
+  };
+  
   class cObjectIndexRef : public cObjectRef
   {
   private:

Modified: branches/collect/source/script/cSemanticASTVisitor.cc
===================================================================
--- branches/collect/source/script/cSemanticASTVisitor.cc	2008-09-18 03:47:37 UTC (rev 2793)
+++ branches/collect/source/script/cSemanticASTVisitor.cc	2008-09-18 15:30:20 UTC (rev 2794)
@@ -810,15 +810,21 @@
 
 void cSemanticASTVisitor::VisitObjectCall(cASTObjectCall& node)
 {
-  // @TODO - object call
-  SEMANTIC_ERROR(INTERNAL);
+  node.GetObject()->Accept(*this);
+  checkCast(node.GetObject()->GetType(), TYPEINFO(OBJECT_REF));
+  
+  if (node.HasArguments()) { 
+    tListIterator<cASTNode> it = node.GetArguments()->Iterator();
+    cASTNode* an = NULL;
+    while((an = it.Next())) an->Accept(*this);
+  }
 }
 
 
 void cSemanticASTVisitor::VisitObjectReference(cASTObjectReference& node)
 {
-  // @TODO - object reference
-  SEMANTIC_ERROR(INTERNAL);
+  node.GetObject()->Accept(*this);
+  checkCast(node.GetObject()->GetType(), TYPEINFO(OBJECT_REF));
 }
 
 




More information about the Avida-cvs mailing list