diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..b3295c5
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5d86774..115b840 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,7 +7,21 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -20,7 +34,6 @@
-
@@ -68,35 +81,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Id
+
+
@@ -121,13 +115,6 @@
@@ -192,20 +186,12 @@
-
-
-
-
+
+
+
-
-
-
-
-
-
-
@@ -225,161 +211,38 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -389,7 +252,7 @@
-
+
@@ -409,7 +272,7 @@
-
+
@@ -436,8 +299,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
@@ -458,13 +341,98 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -503,33 +471,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -682,27 +623,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -773,48 +693,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -843,6 +727,10 @@
+
+ localhost
+ 5050
+
project
@@ -866,21 +754,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -890,10 +763,6 @@
-
- localhost
- 5050
-
@@ -1163,42 +1032,41 @@
-
-
+
+
-
+
-
-
+
-
-
-
+
+
+
+
+
-
+
-
+
-
-
@@ -1256,305 +1124,379 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
-
+
-
+
+
-
+
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
-
+
-
+
-
+
-
-
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
+
-
+
-
+
-
+
+
-
+
+
-
+
-
+
-
+
+
+
+
-
-
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
-
-
+
-
-
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1632,7 +1574,7 @@
- 1.7
+ 1.8
diff --git a/src/com/devbaltasarq/pooi/core/AppInfo.java b/src/com/devbaltasarq/pooi/core/AppInfo.java
index ea22e3a..0031305 100644
--- a/src/com/devbaltasarq/pooi/core/AppInfo.java
+++ b/src/com/devbaltasarq/pooi/core/AppInfo.java
@@ -13,7 +13,7 @@ public class AppInfo {
public static final String Name = "Pooi";
public static final String Email = "jbgarcia@uvigo.es";
public static final String Author = "Baltasar GarcĂa Perez-Schofield";
- public static final String Version = "1.9 20160629";
+ public static final String Version = "2.0 20180116";
public static final String License = "MIT License: https://opensource.org/licenses/MIT";
public static final String SessionFileExt = ".txt";
public static final String ScriptFileExt = ".poi";
diff --git a/src/com/devbaltasarq/pooi/core/ObjectBag.java b/src/com/devbaltasarq/pooi/core/ObjectBag.java
index 3690fdc..0820fa6 100644
--- a/src/com/devbaltasarq/pooi/core/ObjectBag.java
+++ b/src/com/devbaltasarq/pooi/core/ObjectBag.java
@@ -22,15 +22,18 @@ public class ObjectBag {
* Its objective is to wrap a method in the list of available methods in this object.
*/
public static class Slot {
- public Slot(Method mth) {
+ public Slot(Method mth)
+ {
this.mth = mth;
}
- public Method getMethod() {
+ public Method getMethod()
+ {
return mth;
}
- public void setMethod(Method mth) {
+ public void setMethod(Method mth)
+ {
this.mth = mth;
}
@@ -582,7 +585,7 @@ public void set(String name, ObjectBag obj) throws InterpretError
obj.setName( name );
}
- // Change the container of the pointed object, if apropriated
+ // Change the container of the pointed object, if appropriated
if ( !isParent
&& obj instanceof ValueObject )
{
@@ -612,26 +615,23 @@ public void embed(String name, ObjectBag obj) throws InterpretError
*/
public void set(String name, Method mth) throws InterpretError
{
- this.chkIdentifierForMemberName( name );
- this.setMethod( name, mth );
+ this.set( name, mth, Check );
}
-
- /**
- * Returns a member, local to this object, given a name.
- * @param id A String containing the name.
- * @return The member corresponding to that id, or null.
+ /** Adds a new method to the list of methods of this object
+ * @param name The name of this new method
+ * @param mth The Method itself
+ * @throws com.devbaltasarq.pooi.core.Interpreter.InterpretError if name is not valid
*/
- public Member localLookUpMember(String id) {
- Member toret = localLookUpAttribute( id );
-
- if ( toret == null ) {
- toret = localLookUpMethod( id );
+ public void set(String name, Method mth, boolean check) throws InterpretError
+ {
+ if ( check ) {
+ this.chkIdentifierForMemberName(name);
}
- return toret;
+ this.setMethod( name, mth );
}
- protected final void setMethod(String name, Method mth) throws InterpretError
+ protected final void setMethod(String name, Method mth)
{
final Slot slot = this.lookUpSlot( name );
@@ -648,7 +648,6 @@ protected final void setMethod(String name, Method mth) throws InterpretError
protected final void setAttribute(String name, ObjectBag obj) throws InterpretError
{
boolean isParent = name.equals( ParentAttribute.ParentAttributeName );
- final Runtime rt = this.getRuntime();
Attribute atr = localLookUpAttribute( name );
// Chk cycles in parent graph
@@ -721,7 +720,8 @@ public void renameMember(String oldName, String newName) throws InterpretError
return;
}
- public void renameMethod(String oldName, String newName) throws InterpretError {
+ public void renameMethod(String oldName, String newName) throws InterpretError
+ {
final Slot slot = this.lookUpSlot( oldName );
if ( slot != null ) {
@@ -750,7 +750,8 @@ public void renameMethod(String oldName, String newName) throws InterpretError {
return;
}
- public void renameAttribute(String oldName, String newName) throws InterpretError {
+ public void renameAttribute(String oldName, String newName) throws InterpretError
+ {
final Attribute attr = this.localLookUpAttribute( oldName );
ObjectBag ref = null;
@@ -846,7 +847,8 @@ public Method localLookUpMethod(String mthName)
* @param mthName The name of the method.
* @return A Slot object pointing to the method, null otherwise.
*/
- public Slot lookUpSlot(String mthName) {
+ public Slot lookUpSlot(String mthName)
+ {
return this.methods.get( mthName );
}
diff --git a/src/com/devbaltasarq/pooi/core/Parser.java b/src/com/devbaltasarq/pooi/core/Parser.java
index 5d1f4fd..16d4ee0 100644
--- a/src/com/devbaltasarq/pooi/core/Parser.java
+++ b/src/com/devbaltasarq/pooi/core/Parser.java
@@ -145,7 +145,6 @@ private static String getMessageId(Lexer lex)
{
char ch;
String toret = "";
- Lexer.TokenType tokenType;
// Decide which kind of message, native: *,+,-... or average
lex.skipSpaces();
diff --git a/src/com/devbaltasarq/pooi/core/Reserved.java b/src/com/devbaltasarq/pooi/core/Reserved.java
index 354327f..a3e8122 100644
--- a/src/com/devbaltasarq/pooi/core/Reserved.java
+++ b/src/com/devbaltasarq/pooi/core/Reserved.java
@@ -8,6 +8,8 @@
public class Reserved {
public static final String ParentAttribute = "parent";
+ public static final String SetMethod = "set";
+
public static final String RootObject = "Root";
public static final String LibObject = "Lib";
@@ -17,6 +19,7 @@ public class Reserved {
public static final String BoolObject = "Bool";
public static final String RealObject = "Real";
public static final String StrObject = "Str";
+ public static final String DateTimeObject = "DateTime";
public static final String SelfRef = "self";
public static final String AssignmentOperator = "=";
public static final String AllowedSymbolsInMethodName = "!<>+-*/=?^";
@@ -31,6 +34,8 @@ public class Reserved {
+ ' ' + RealObject + ' '
+ ' ' + StrObject + ' '
+ ' ' + AssignmentOperator + ' '
+ + ' ' + DateTimeObject + ' '
+ + ' ' + SetMethod + ' '
;
public static boolean isReservedForObjects(String id)
diff --git a/src/com/devbaltasarq/pooi/core/Runtime.java b/src/com/devbaltasarq/pooi/core/Runtime.java
index 2e9a61a..84ef9fc 100644
--- a/src/com/devbaltasarq/pooi/core/Runtime.java
+++ b/src/com/devbaltasarq/pooi/core/Runtime.java
@@ -81,7 +81,7 @@ private Runtime() throws InterpretError
this.getLiteralsContainer().clear( false );
}
- public void addMethodsToRuntimeObjects() throws InterpretError
+ private void addMethodsToRuntimeObjects() throws InterpretError
{
// Int
this.integer.set( NativeMethodIntSum.EtqMthIntSum, new NativeMethodIntSum( this ) );
@@ -116,6 +116,10 @@ public void addMethodsToRuntimeObjects() throws InterpretError
this.real.set( NativeMethodRealInt.EtqMthInt, new NativeMethodRealInt( this ) );
this.real.set( NativeMethodRealRound.EtqMthRound, new NativeMethodRealRound( this ) );
+ // Bool
+ this.bool.set( NativeMethodBoolNot.EtqMthBoolNot, new NativeMethodBoolNot( this ) );
+ this.bool.set( NativeMethodBoolIsTrue.EtqMthBoolIsTrue, new NativeMethodBoolIsTrue( this ) );
+
// Str
this.str.set( NativeMethodStrConcat.EtqMthStrConcat, new NativeMethodStrConcat( this ) );
this.str.set( NativeMethodStrConcatAssign.EtqMthStrConcatAssign, new NativeMethodStrConcatAssign( this ) );
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/Method.java b/src/com/devbaltasarq/pooi/core/evaluables/Method.java
index cd8dfef..927f6ca 100644
--- a/src/com/devbaltasarq/pooi/core/evaluables/Method.java
+++ b/src/com/devbaltasarq/pooi/core/evaluables/Method.java
@@ -83,7 +83,10 @@ public String getFormalParametersAsString() {
return toret.toString().trim();
}
- /** @return Gets the body of the method as a representation in text */
+ /** @return Gets the body of the method as a representation in text
+ * Native methods return with something like "{: }", which is enough.
+ * Interpreted methods must be represented accurately.
+ */
public abstract String getMethodBodyAsString();
/**
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/methods/InterpretedMethod.java b/src/com/devbaltasarq/pooi/core/evaluables/methods/InterpretedMethod.java
index 18a05b0..d40db18 100644
--- a/src/com/devbaltasarq/pooi/core/evaluables/methods/InterpretedMethod.java
+++ b/src/com/devbaltasarq/pooi/core/evaluables/methods/InterpretedMethod.java
@@ -12,11 +12,7 @@
import java.util.HashMap;
import java.util.Stack;
-/**
- * Method holding interpreted code.
- * User: baltasarq
- * Date: 11/19/12
- */
+/** Method holding interpreted code. */
public class InterpretedMethod extends Method {
public static final String DefaultMethodId = "__mth_";
@@ -113,6 +109,7 @@ public void addCmds(String cmd) throws InterpretError
this.stackCmds.addAll( Arrays.asList( Parser.parseOrder( this.getRuntime(), cmd ) ) );
}
+ @Override
public InterpretedMethod copy()
{
InterpretedMethod toret = new InterpretedMethod( this.getRuntime(), this.getName() );
@@ -120,7 +117,7 @@ public InterpretedMethod copy()
// Commands
toret.stackCmds.addAll( Arrays.asList( this.getCmds() ) );
- // Formal paramenters
+ // Formal parameters
toret.formalParams = this.formalParams.clone();
// Slots for real parameters
@@ -153,60 +150,68 @@ public String[] getFormalParameters()
}
@Override
- public String getMethodBodyAsString() {
- Stack stack = new Stack<>();
+ public String getMethodBodyAsString()
+ {
StringBuilder toret = new StringBuilder();
-
- toret.append( "{" );
+ Stack stack = new Stack<>();
+ ArrayList positions = new ArrayList<>();
// Add params
- for(String param: this.getFormalParameters()) {
- toret.append( param );
- toret.append( ' ' );
- }
-
+ toret.append( "{ " );
+ toret.append( this.getFormalParametersAsString() );
toret.append( ": " );
// Add commands
for(Command cmd: this.getCmds()) {
- String replaceCmd = "";
+ toret.append( cmd.toString() );
+ toret.append( "; " );
+ }
+/*
+ // Add commands
+ for(Command cmd: this.getCmds()) {
+ String replaceCmd;
String cmdAsStr = cmd.toString();
- int pos = cmdAsStr.indexOf( Parser.PopTask );
- if ( pos >= 0 ) {
- // Process the reference
- if ( cmd.getReference().toString().equals( Parser.PopTask ) ) {
- replaceCmd = stack.pop();
- cmdAsStr = cmdAsStr.substring( 0, pos )
- + replaceCmd
- + cmdAsStr.substring( pos + Parser.PopTask.length(), cmdAsStr.length() );
+ // Find all POP occurrences
+ positions.clear();
+ int popPos = cmdAsStr.lastIndexOf( Parser.PopTask );
+ do {
+ while( popPos > -1 ) {
+ positions.add( popPos );
+ cmdAsStr.lastIndexOf( Parser.PopTask, popPos - Parser.PopTask.length() );
}
- // Process possible targets
- pos += replaceCmd.length();
- pos = cmdAsStr.indexOf( Parser.PopTask, pos );
- while( pos >= 0 ) {
+ for(int pos: positions) {
+ // Process possible targets
+ // pos += replaceCmd.length();
+ // pos = cmdAsStr.indexOf( Parser.PopTask, pos );
replaceCmd = stack.pop();
cmdAsStr = cmdAsStr.substring( 0, pos )
+ replaceCmd
+ cmdAsStr.substring( pos + Parser.PopTask.length(), cmdAsStr.length() );
-
- // Next?
- pos += replaceCmd.length();
- pos = cmdAsStr.indexOf( Parser.PopTask, pos );
}
- }
+ popPos = cmdAsStr.lastIndexOf( Parser.PopTask );
+ } while( popPos > -1 );
+/*
+ // Process the reference
+ if ( cmd.getReference().toString().equals( Parser.PopTask ) ) {
+ replaceCmd = stack.pop();
+ cmdAsStr = cmdAsStr.substring( 0, popPos )
+ + replaceCmd
+ + cmdAsStr.substring( popPos + Parser.PopTask.length(), cmdAsStr.length() );
+ }
+*/
+/*
// Push command
stack.push( cmdAsStr );
}
- // Dump the remaining
+ // Dump the remaining in natural order (nearly never executed)
for(String strCmd: stack) {
toret.append( strCmd );
- toret.append( "; " );
}
-
+*/
toret.append( "}" );
return toret.toString();
}
@@ -221,6 +226,7 @@ public static String createNewMethodId()
return toret;
}
+ @Override
public int getNumParams() {
return this.formalParams.length;
}
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/methods/NativeMethod.java b/src/com/devbaltasarq/pooi/core/evaluables/methods/NativeMethod.java
index aab9918..51ae9bb 100644
--- a/src/com/devbaltasarq/pooi/core/evaluables/methods/NativeMethod.java
+++ b/src/com/devbaltasarq/pooi/core/evaluables/methods/NativeMethod.java
@@ -8,9 +8,8 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-/**
- * Representing available methods in the interpreter
- * @author baltasarq
+/** Representing available methods in the interpreter
+ * @author baltasarq
*/
public abstract class NativeMethod extends Method {
@@ -26,9 +25,8 @@ public NativeMethod(com.devbaltasarq.pooi.core.Runtime rt, String name)
public abstract ObjectBag doIt(ObjectBag ref, Evaluable[] params, StringBuilder msg)
throws InterpretError;
- /**
- * Copy the needed NativeMethod by means of reflection
- * @return The copied method, as a Method object.
+ /** Copy the needed NativeMethod by means of reflection
+ * @return The copied method, as a Method object.
*/
@Override
public NativeMethod copy()
@@ -48,8 +46,12 @@ public NativeMethod copy()
return toret;
}
+ /** Return A textual representation of the method
+ * @return A string describing the method.
+ */
@Override
- public String getMethodBodyAsString() {
- return "{: }";
+ public String getMethodBodyAsString()
+ {
+ return "{ " + this.getFormalParametersAsString() + ": }";
}
}
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodBoolIsTrue.java b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodBoolIsTrue.java
new file mode 100644
index 0000000..f4fb7b0
--- /dev/null
+++ b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodBoolIsTrue.java
@@ -0,0 +1,48 @@
+package com.devbaltasarq.pooi.core.evaluables.methods.nativemethods;
+
+import com.devbaltasarq.pooi.core.Evaluable;
+import com.devbaltasarq.pooi.core.Interpreter;
+import com.devbaltasarq.pooi.core.ObjectBag;
+import com.devbaltasarq.pooi.core.evaluables.methods.NativeMethod;
+import com.devbaltasarq.pooi.core.objs.ObjectBool;
+
+public class NativeMethodBoolIsTrue extends NativeMethod {
+ public static final String EtqMthBoolIsTrue = "true?";
+
+ public NativeMethodBoolIsTrue(com.devbaltasarq.pooi.core.Runtime rt)
+ {
+ super( rt, EtqMthBoolIsTrue );
+ }
+
+ @Override
+ public ObjectBag doIt(ObjectBag ref, Evaluable[] params, StringBuilder msg)
+ throws Interpreter.InterpretError
+ {
+ final com.devbaltasarq.pooi.core.Runtime rt = ref.getRuntime();
+
+ chkParametersNumber( 0, params );
+
+ if ( !( ref instanceof ObjectBool) ) {
+ throw new Interpreter.InterpretError(
+ "Semantic error: expected Bool in '"
+ + ref.getName()
+ + '\''
+ );
+ }
+
+ final boolean result = ( ( (ObjectBool) ref ).getValue() );
+
+ msg.append( Boolean.toString( result ) );
+ return rt.createBool( result );
+ }
+
+ @Override
+ public int getNumParams() {
+ return 0;
+ }
+
+ @Override
+ public String[] getFormalParameters() {
+ return new String[ 0 ];
+ }
+}
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodBoolNot.java b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodBoolNot.java
new file mode 100644
index 0000000..b6b818f
--- /dev/null
+++ b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodBoolNot.java
@@ -0,0 +1,48 @@
+package com.devbaltasarq.pooi.core.evaluables.methods.nativemethods;
+
+import com.devbaltasarq.pooi.core.Evaluable;
+import com.devbaltasarq.pooi.core.Interpreter;
+import com.devbaltasarq.pooi.core.ObjectBag;
+import com.devbaltasarq.pooi.core.evaluables.methods.NativeMethod;
+import com.devbaltasarq.pooi.core.objs.ObjectBool;
+
+public class NativeMethodBoolNot extends NativeMethod {
+ public static final String EtqMthBoolNot= "not";
+
+ public NativeMethodBoolNot(com.devbaltasarq.pooi.core.Runtime rt)
+ {
+ super( rt, EtqMthBoolNot );
+ }
+
+ @Override
+ public ObjectBag doIt(ObjectBag ref, Evaluable[] params, StringBuilder msg)
+ throws Interpreter.InterpretError
+ {
+ final com.devbaltasarq.pooi.core.Runtime rt = ref.getRuntime();
+
+ chkParametersNumber( 0, params );
+
+ if ( !( ref instanceof ObjectBool) ) {
+ throw new Interpreter.InterpretError(
+ "Semantic error: expected Bool in '"
+ + ref.getName()
+ + '\''
+ );
+ }
+
+ final boolean result = !( ( (ObjectBool) ref ).getValue() );
+
+ msg.append( Boolean.toString( result ) );
+ return rt.createBool( result );
+ }
+
+ @Override
+ public int getNumParams() {
+ return 0;
+ }
+
+ @Override
+ public String[] getFormalParameters() {
+ return new String[ 0 ];
+ }
+}
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodCopy.java b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodCopy.java
index db1731b..a662f65 100644
--- a/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodCopy.java
+++ b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodCopy.java
@@ -38,6 +38,7 @@ public ObjectBag doIt(ObjectBag ref, Evaluable[] params, StringBuilder msg)
return toret;
}
+ @Override
public int getNumParams() {
return 0;
}
diff --git a/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodIntAbs.java b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodIntAbs.java
index 0ddf78c..a23ca24 100644
--- a/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodIntAbs.java
+++ b/src/com/devbaltasarq/pooi/core/evaluables/methods/nativemethods/NativeMethodIntAbs.java
@@ -41,6 +41,7 @@ public ObjectBag doIt(ObjectBag ref, Evaluable[] params, StringBuilder msg)
return rt.createInt( result );
}
+ @Override
public int getNumParams() {
return 0;
}
diff --git a/src/com/devbaltasarq/pooi/core/objs/ObjectParent.java b/src/com/devbaltasarq/pooi/core/objs/ObjectParent.java
index 31feb2e..9e52295 100644
--- a/src/com/devbaltasarq/pooi/core/objs/ObjectParent.java
+++ b/src/com/devbaltasarq/pooi/core/objs/ObjectParent.java
@@ -59,7 +59,7 @@ public void registerCommonMethods() throws InterpretError
this.set( NativeMethodGetPath.EtqMthPath, new NativeMethodGetPath( this.getRuntime() ) );
this.set( NativeMethodErase.EtqMthErase, new NativeMethodErase( this.getRuntime() ) );
this.set( NativeMethodGetName.EtqMthGetName, new NativeMethodGetName( this.getRuntime() ) );
- this.set( NativeMethodSet.EtqMthSet, new NativeMethodSet( this.getRuntime() ) );
+ this.set( NativeMethodSet.EtqMthSet, new NativeMethodSet( this.getRuntime() ), DontCheck );
this.set( NativeMethodCopy.EtqMthCopy, new NativeMethodCopy( this.getRuntime() ) );
this.set( NativeMethodCreateChild.EtqMthCreateChild, new NativeMethodCreateChild( this.getRuntime() ) );
this.set( NativeMethodSetName.EtqMthSetName, new NativeMethodSetName( this.getRuntime() ) );
diff --git a/src/com/devbaltasarq/pooi/ui/VisualEngine.java b/src/com/devbaltasarq/pooi/ui/VisualEngine.java
index 4a3e145..168269e 100644
--- a/src/com/devbaltasarq/pooi/ui/VisualEngine.java
+++ b/src/com/devbaltasarq/pooi/ui/VisualEngine.java
@@ -41,11 +41,11 @@
* @author baltasarq
*/
public class VisualEngine extends JFrame {
- public static final int MinFontSize = 10;
- public static final int MaxFontSize = 32;
- public static final String EtqIconApp = "icons/pooiIcon.png";
- public static final String EtqIconReset = "icons/reset.png";
- public static final String EtqIconNew = "icons/new.png";
+ private static final int MinFontSize = 10;
+ private static final int MaxFontSize = 32;
+ private static final String EtqIconApp = "icons/pooiIcon.png";
+ private static final String EtqIconReset = "icons/reset.png";
+ private static final String EtqIconNew = "icons/new.png";
/** Creates new form VisualEngine */
public VisualEngine(Interpreter interpreter)
@@ -305,7 +305,7 @@ private void buildOutput()
this.output.setBackground( new java.awt.Color( 0, 0, 0 ) );
this.output.setColumns( 20 );
this.output.setEditable( false );
- this.output.setFont( new java.awt.Font( "Courier New", 0, 14 ) );
+ this.output.setFont( new java.awt.Font( "Courier New", Font.PLAIN, 14 ) );
this.output.setForeground( new java.awt.Color( 255, 255, 255 ) );
this.output.setRows( 5 );
this.output.setCursor(new java.awt.Cursor( java.awt.Cursor.DEFAULT_CURSOR ) );
@@ -347,7 +347,7 @@ private void buildTreeView()
trObjectsTree = new JTree();
trObjectsTree.addTreeSelectionListener( new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent evt) {
- onSelectedItemChanged( evt.getNewLeadSelectionPath() );
+ onSelectedItemChanged();
}
} );
trObjectsTree.addMouseListener( new MouseListener() {
@@ -699,50 +699,51 @@ private void onAbout()
private void onInputEntered()
{
String msg = (String) this.input.getSelectedItem();
- msg = msg.trim();
- try {
- if ( this.input.isEnabled()
- && !msg.isEmpty() )
- {
- this.input.setEnabled( false );
- this.input.setSelectedItem( "" );
-
- // Show the order in the output panel
- this.output.append( "> " + msg + "\n" ) ;
-
- // Interpret the order
- this.output.append( interpreter.interpret( msg ) );
- this.output.append( "\n\n" );
- this.output.setCaretPosition( output.getText().length() );
+ if ( msg != null ) {
+ msg = msg.trim();
- // Check for the root existing -- if not, end
- if ( this.interpreter.getRuntime().getRoot() == null ) {
- this.close();
- }
+ try {
+ if (this.input.isEnabled()
+ && !msg.isEmpty()) {
+ this.input.setEnabled(false);
+ this.input.setSelectedItem("");
+
+ // Show the order in the output panel
+ this.output.append("> " + msg + "\n");
+
+ // Interpret the order
+ this.output.append(interpreter.interpret(msg));
+ this.output.append("\n\n");
+ this.output.setCaretPosition(output.getText().length());
+
+ // Check for the root existing -- if not, end
+ if (this.interpreter.getRuntime().getRoot() == null) {
+ this.close();
+ }
- // Set it to the order history
- this.input.insertItemAt( msg, 0 );
+ // Set it to the order history
+ this.input.insertItemAt(msg, 0);
- if ( this.input.getItemCount() >= 10 ) {
- this.input.removeItemAt( 9 );
+ if (this.input.getItemCount() >= 10) {
+ this.input.removeItemAt(9);
+ }
}
+ } catch (StackOverflowError exc) {
+ this.output.append("\n\n*** INTERNAL ERROR: stack overflow\n\n");
+ } catch (NullPointerException exc) {
+ this.output.append("\n\n*** INTERNAL ERROR: rogue null pointer\n\n");
+ } catch (Exception exc) {
+ this.output.append("\n\n*** INTERNAL ERROR: " + exc.getMessage() + "\n\n");
+ } finally {
+ this.updateTree();
+ this.updateDiagram();
+ this.input.setEnabled(true);
+ this.input.requestFocus();
}
- } catch(StackOverflowError exc) {
- this.output.append( "\n\n*** INTERNAL ERROR: stack overflow\n\n" );
- }
- catch(NullPointerException exc) {
- this.output.append( "\n\n*** INTERNAL ERROR: rogue null pointer\n\n" );
- }
- catch(Exception exc) {
- this.output.append( "\n\n*** INTERNAL ERROR: " + exc.getMessage() + "\n\n" );
- }
- finally {
- this.updateTree();
- this.updateDiagram();
- this.input.setEnabled( true );
- this.input.requestFocus();
}
+
+ return;
}
private void setSelectedObject(ObjectBag obj)
@@ -794,14 +795,14 @@ private String getSelectedObjectPath() {
return toret.toString();
}
- private void onSelectedItemChanged(TreePath treePath)
+ private void onSelectedItemChanged()
{
if ( !rebuildingTree ) {
rebuildingTree = true;
String path = this.getSelectedObjectPath();
if ( !path.isEmpty() ) {
- this.input.setSelectedItem(path.toString());
+ this.input.setSelectedItem( path.toString() );
}
this.input.requestFocusInWindow();
@@ -996,8 +997,8 @@ public void updateDiagram()
Dimension dimChild = box.getMeasuredDimension();
Dimension dimParent = parentBox.getMeasuredDimension();
- int childPosX = box.getX() + ( (int) ( dimChild.width / 2 ) );
- int parentPosX = parentBox.getX() + ( (int) ( dimParent.width / 2 ) );
+ int childPosX = box.getX() + ( dimChild.width / 2 );
+ int parentPosX = parentBox.getX() + ( dimParent.width / 2 );
this.pnlCanvas.drawLine( childPosX, box.getY(), parentPosX, parentBox.getY() + dimParent.height );
}
@@ -1088,7 +1089,7 @@ private void addNodes(DefaultMutableTreeNode node, ObjectBag obj, HashSet