Beispiel #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;
 }
Beispiel #2
0
  @Test
  public void test7() {
    Graph g1 = createGraph(true);
    Load load1 = Load.create(g1);
    load1.load(root + "sdk/sdk.rdf");

    String init = "load <" + root + "rule/server.rul> into graph kg:rule";
    String query = "select * where {?x a ?class}";
    QueryProcess exec = QueryProcess.create(g1);

    try {
      exec.query(init);
      Mappings map = exec.query(query);
      // System.out.println(map);
      assertEquals("Result", 6, map.size());
    } catch (EngineException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Beispiel #3
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);
   }
 }
Beispiel #4
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)");
   }
 }