Ejemplo n.º 1
0
 public Object callReporterProcedure(Activation newActivation) {
   boolean oldInReporterProcedure = inReporterProcedure;
   Command command = null;
   inReporterProcedure = true; // so use of "ask" will create an exclusive job
   activation = newActivation;
   ip = 0;
   try {
     do {
       command = activation.procedure().code()[ip];
       if ((agentBit & command.agentBits) == 0) {
         command.throwAgentClassException(this, agent.kind());
       }
       command.perform(this);
       if (command.world.comeUpForAir) {
         comeUpForAir(command);
       }
     } while (!finished && job.result == null);
   } catch (NonLocalExit$ e) {
     // do nothing
   } catch (LogoException ex) {
     EngineException.rethrow(ex, this, command);
   } finally {
     inReporterProcedure = oldInReporterProcedure;
   }
   ip = activation.returnAddress();
   activation = activation.parent();
   Object result = job.result;
   job.result = null;
   return result;
 }
Ejemplo n.º 2
0
 // this method runs until the context is finished
 void runExclusive() {
   if (agent.id == -1) // is our agent dead?
   {
     finished = true;
     return;
   }
   Command command = null;
   try {
     do {
       command = activation.procedure().code()[ip];
       if ((agentBit & command.agentBits) == 0) {
         command.throwAgentClassException(this, agent.kind());
       }
       command.perform(this);
       if (command.world.comeUpForAir) {
         comeUpForAir(command);
       }
     } while (!finished);
   } catch (LogoException ex) {
     EngineException.rethrow(ex, this, command);
   }
 }
Ejemplo n.º 3
0
 // this method runs only until a command switches
 void stepConcurrent() {
   if (agent.id == -1) // is our agent dead?
   {
     finished = true;
     return;
   }
   Command command = null;
   try {
     do {
       command = activation.procedure().code()[ip];
       if ((agentBit & command.agentBits) == 0) {
         command.throwAgentClassException(this, agent.kind());
       }
       command.perform(this);
       if (command.world.comeUpForAir) {
         comeUpForAir(command);
       }
     } while (!command.switches && !finished);
   } catch (LogoException ex) {
     EngineException.rethrow(ex, this, command);
   } catch (StackOverflowError ex) {
     throw new EngineException(this, "stack overflow (recursion too deep)");
   }
 }