Author: tchemit Date: 2011-02-02 13:16:34 +0100 (Wed, 02 Feb 2011) New Revision: 2197 Url: http://nuiton.org/repositories/revision/jaxx/2197 Log: remove JAXXUtil.assignment code on scripts it does nothing good...+ clean code Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java 2011-02-02 12:15:37 UTC (rev 2196) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/script/ScriptManager.java 2011-02-02 12:16:34 UTC (rev 2197) @@ -27,7 +27,6 @@ import jaxx.compiler.CompilerException; import jaxx.compiler.JAXXCompiler; -import jaxx.compiler.finalizers.AbstractFinalizer; import jaxx.compiler.java.parser.JavaParser; import jaxx.compiler.java.parser.JavaParserTreeConstants; import jaxx.compiler.java.parser.SimpleNode; @@ -37,7 +36,6 @@ import jaxx.runtime.JAXXUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.GeneratorUtil; import java.io.StringReader; import java.lang.reflect.Modifier; @@ -136,28 +134,31 @@ id == JavaParserTreeConstants.JJTCLASSORINTERFACETYPE) { scanCompoundSymbol(node.getText()); } - if (!staticContext) { - String lhs = null; - if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || - id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2) { - lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); - } else if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || - id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) { - lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); - } - if (lhs != null) { - FieldDescriptor[] fields = compiler.getScriptFields(); - for (FieldDescriptor field : fields) { - if (field.getName().equals(lhs)) { - //lhs.substring(lhs.lastIndexOf(".") + 1); - compiler.addImport(JAXXUtil.class); - node.firstToken.image = "JAXXUtil.assignment(" + node.firstToken.image; - String outputClassName = compiler.getOutputClassName(); - node.lastToken.image = node.lastToken.image + ", \"" + lhs + "\", " + outputClassName + ".this)"; - } - } - } - } + //tchemit 2011-02-02 I never understand this code + //Doing at each assignment a ifre with a called "dummy value" is a none sense + // Since JAXX can handle pretty well with javaBeans I remove this code +// if (!staticContext) { +// String lhs = null; +// if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || +// id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2) { +// lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); +// } else if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || +// id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) { +// lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim(); +// } +// if (lhs != null) { +// FieldDescriptor[] fields = compiler.getScriptFields(); +// for (FieldDescriptor field : fields) { +// if (field.getName().equals(lhs)) { +// //lhs.substring(lhs.lastIndexOf(".") + 1); +// String prefix = compiler.getImportManager().getType(JAXXUtil.class); +// node.firstToken.image = prefix + ".assignment(" + node.firstToken.image; +// String outputClassName = compiler.getImportManager().getType(compiler.getOutputClassName()); +// node.lastToken.image = node.lastToken.image + ", \"" + lhs + "\", " + outputClassName + ".this)"; +// } +// } +// } +// } } /** @@ -347,13 +348,11 @@ "Could not find type of " + className + " for expression " + text); } -// className = className.trim(); -// if (!AbstractFinalizer.TYPE_STRING.equals(className) && -// !GeneratorUtil.isPrimitiveType(className)) { -// log.info("[" + compiler.getJavaFile().getName() + "] : Import " + type + " from a script..."); -// compiler.getJavaFile().addImport(type); -// } - compiler.addScriptField(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); + compiler.addScriptField(new FieldDescriptor(name, + Modifier.PUBLIC, + type, + compiler.getClassLoader()) + ); // TODO: determine the actual modifiers if (equals != -1 && !isFinal && !isStatic) { @@ -368,7 +367,8 @@ @Override public void run() { - compiler.registerCompiledObject(new ScriptInitializer(finalInitializer, compiler)); + compiler.registerCompiledObject(new ScriptInitializer( + finalInitializer, compiler)); } }); } else {
participants (1)
-
tchemit@users.nuiton.org