|
From: <jom...@us...> - 2011-04-13 19:52:10
|
Revision: 1641
http://jason.svn.sourceforge.net/jason/?rev=1641&view=rev
Author: jomifred
Date: 2011-04-13 19:52:04 +0000 (Wed, 13 Apr 2011)
Log Message:
-----------
test whether a TS is set for Agent in LogCons
Modified Paths:
--------------
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/test/TSTest.java
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2011-04-12 18:47:14 UTC (rev 1640)
+++ trunk/src/jason/asSemantics/Agent.java 2011-04-13 19:52:04 UTC (rev 1641)
@@ -247,7 +247,7 @@
private void fixAgInIAandFunctions(Agent a, Literal l) throws Exception {
// if l is internal action/function
if (l instanceof InternalActionLiteral) {
- ((InternalActionLiteral)l).setIA(null);
+ ((InternalActionLiteral)l).setIA(null); // reset the IA in the literal, the IA there will be updated next getIA call
}
if (l instanceof ArithFunctionTerm) {
((ArithFunctionTerm)l).setAgent(a);
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2011-04-12 18:47:14 UTC (rev 1640)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2011-04-13 19:52:04 UTC (rev 1641)
@@ -37,7 +37,7 @@
/**
- A particular type of literal used to represent internal actions (has a "." in the functor).
+ A particular type of literal used to represent internal actions (which has a "." in the functor).
@navassoc - ia - InternalAction
@@ -47,7 +47,7 @@
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(InternalActionLiteral.class.getName());
- private InternalAction ia = null; // reference to the object that implements the internal action
+ private InternalAction ia = null; // reference to the object that implements the internal action, stored here to speed up the process of looking for the IA class inside the agent
public InternalActionLiteral(String functor) {
super(functor);
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2011-04-12 18:47:14 UTC (rev 1640)
+++ trunk/src/jason/asSyntax/Literal.java 2011-04-13 19:52:04 UTC (rev 1641)
@@ -259,7 +259,7 @@
if (il == null) // no relevant bels
return LogExpr.EMPTY_UNIF_LIST.iterator();
- final AgArch arch = (ag == null ? null : ag.getTS().getUserAgArch());
+ final AgArch arch = (ag != null && ag.getTS() != null ? ag.getTS().getUserAgArch() : null);
final int nbAnnots = (hasAnnot() && getAnnots().getTail() == null ? getAnnots().size() : 0); // if annots contains a tail (as in p[A|R]), do not backtrack on annots
return new Iterator<Unifier>() {
Modified: trunk/src/test/TSTest.java
===================================================================
--- trunk/src/test/TSTest.java 2011-04-12 18:47:14 UTC (rev 1640)
+++ trunk/src/test/TSTest.java 2011-04-13 19:52:04 UTC (rev 1641)
@@ -127,21 +127,19 @@
public void testAgentClone() throws Exception {
Agent a = new Agent();
- new TransitionSystem(a, new Circumstance(), new Settings(), new AgArch()); // just to have a default value for ts
- //a.parseAS(new File());
a.initAg("examples/auction/ag3.asl");
String p1 = a.getPL().toString();
String b1 = a.getBB().toString();
- InternalAction ia1 = ((InternalActionLiteral)a.getPL().get("prop_alliance").getBody().getBodyTerm()).getIA(null);
+ InternalAction ia1 = ((InternalActionLiteral)a.getPL().get("prop_alliance").getBody().getBodyTerm()).getIA(a);
assertTrue(ia1 != null);
// get the arith expr (B+C) from the plan
Structure send1 = (Structure)a.getPL().get("palliance").getBody().getBodyNext().getBodyNext().getBodyTerm();
ArithFunctionTerm add1 = (ArithFunctionTerm)((Structure)send1.getTerm(2)).getTerm(1);
assertEquals("(B+C)", add1.toString());
- // the agent is null here because it is a arith expr
- assertEquals(null, add1.getAgent());
+ // the agent is null here because it is an arith expr
+ //assertEquals(null, add1.getAgent());
a = a.clone(new AgArch());
assertEquals(p1, a.getPL().toString());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|