|
From: <jom...@us...> - 2013-03-27 15:42:13
|
Revision: 1725
http://sourceforge.net/p/jason/svn/1725
Author: jomifred
Date: 2013-03-27 15:42:10 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
include the method "destroy" in the internal action interface
Modified Paths:
--------------
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/DefaultInternalAction.java
trunk/src/jason/asSemantics/InternalAction.java
Added Paths:
-----------
trunk/src/jason/stdlib/copy_term.java
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2013-03-26 16:56:17 UTC (rev 1724)
+++ trunk/src/jason/asSemantics/Agent.java 2013-03-27 15:42:10 UTC (rev 1725)
@@ -246,6 +246,13 @@
if (scheduler != null)
scheduler.shutdownNow();
+
+ for (InternalAction ia: internalActions.values())
+ try {
+ ia.destroy();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
/**
Modified: trunk/src/jason/asSemantics/DefaultInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/DefaultInternalAction.java 2013-03-26 16:56:17 UTC (rev 1724)
+++ trunk/src/jason/asSemantics/DefaultInternalAction.java 2013-03-27 15:42:10 UTC (rev 1725)
@@ -41,4 +41,8 @@
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
return false;
}
+
+ public void destroy() throws Exception {
+
+ }
}
Modified: trunk/src/jason/asSemantics/InternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/InternalAction.java 2013-03-26 16:56:17 UTC (rev 1724)
+++ trunk/src/jason/asSemantics/InternalAction.java 2013-03-27 15:42:10 UTC (rev 1725)
@@ -48,4 +48,6 @@
* successfully executed. An Iterator result means that there is
* more than one answer for this IA (e.g. see member internal action). */
Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception;
+
+ public void destroy() throws Exception;
}
Added: trunk/src/jason/stdlib/copy_term.java
===================================================================
--- trunk/src/jason/stdlib/copy_term.java (rev 0)
+++ trunk/src/jason/stdlib/copy_term.java 2013-03-27 15:42:10 UTC (rev 1725)
@@ -0,0 +1,25 @@
+package jason.stdlib;
+
+import jason.JasonException;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+
+public class copy_term extends DefaultInternalAction {
+
+ @Override public int getMinArgs() { return 2; }
+ @Override public int getMaxArgs() { return 2; }
+
+ @Override protected void checkArguments(Term[] args) throws JasonException {
+ super.checkArguments(args); // check number of arguments
+ if (!args[0].isLiteral())
+ throw JasonException.createWrongArgument(this,"first argument must be a literal");
+ }
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ return un.unifies(args[1], ((Literal)args[0]).makeVarsAnnon());
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|