|
From: <jom...@us...> - 2015-10-08 17:00:04
|
Revision: 1847
http://sourceforge.net/p/jason/svn/1847
Author: jomifred
Date: 2015-10-08 17:00:01 +0000 (Thu, 08 Oct 2015)
Log Message:
-----------
fix include
Modified Paths:
--------------
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/stdlib/include.java
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2015-10-08 08:25:34 UTC (rev 1846)
+++ trunk/src/jason/asSemantics/Agent.java 2015-10-08 17:00:01 UTC (rev 1847)
@@ -174,8 +174,6 @@
load(asSrc);
}
- private boolean initialLoadAlreadyDone = false;
-
/** parse and load the initial agent code, asSrc may be null */
public void load(String asSrc) throws JasonException {
// set the agent
@@ -203,20 +201,16 @@
if (getPL().hasMetaEventPlans())
getTS().addGoalListener(new GoalListenerForMetaEvents(getTS()));
- if (!initialLoadAlreadyDone) // to avoid loading it twice
- addInitialBelsFromProjectInBB();
+ addInitialBelsFromProjectInBB();
addInitialBelsInBB();
- if (!initialLoadAlreadyDone)
- addInitialGoalsFromProjectInBB();
+ addInitialGoalsFromProjectInBB();
addInitialGoalsInTS();
fixAgInIAandFunctions(this); // used to fix agent reference in functions used inside includes
}
- if (!initialLoadAlreadyDone) // to avoid loading it twice
- loadKqmlPlans();
+ loadKqmlPlans();
setASLSrc(asSrc);
- initialLoadAlreadyDone = true;
} catch (Exception e) {
logger.log(Level.SEVERE, "Error creating customised Agent class!", e);
throw new JasonException("Error creating customised Agent class! - " + e);
@@ -577,6 +571,7 @@
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
}
+ initialGoals.clear();
}
protected void addInitialGoalsFromProjectInBB() {
Modified: trunk/src/jason/stdlib/include.java
===================================================================
--- trunk/src/jason/stdlib/include.java 2015-10-08 08:25:34 UTC (rev 1846)
+++ trunk/src/jason/stdlib/include.java 2015-10-08 17:00:01 UTC (rev 1847)
@@ -28,7 +28,7 @@
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.StringTerm;
+import jason.asSyntax.Pred;
import jason.asSyntax.Term;
import jason.asSyntax.directives.DirectiveProcessor;
import jason.asSyntax.directives.Include;
@@ -61,17 +61,18 @@
@Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
- Agent ag = ts.getAg();
- String originalSrc = ag.getASLSrc(); // the source file that has the include directive
- String file = ((StringTerm)args[0]).getString();
-
- file = Include.checkPathAndFixWithSourcePath(
- file,
- ((Include)DirectiveProcessor.getDirective("include")).getSourcePaths(),
+ Agent ag = ts.getAg();
+ Pred inc = new Pred("include");
+ inc.addTerm(args[0]);
+
+ Agent result = ((Include)DirectiveProcessor.getDirective("include")).process(
+ inc,
+ ag,
null);
- ts.getAg().load( file );
- ts.getAg().setASLSrc(originalSrc);
+ ag.importComponents(result);
+ ag.addInitialBelsInBB();
+ ag.addInitialGoalsInTS();
return true;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|