*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
public class Addition implements IExpression {\r
\r
public IExpression exp1;\r
\r
@Override\r
public Object evaluate(IEnvironment environment) {\r
- Double d1 = (Double)exp1.evaluate(environment);\r
- Double d2 = (Double)exp2.evaluate(environment);\r
- return d1 + d2;\r
+ Object o1 = exp1.evaluate(environment);\r
+ Object o2 = exp2.evaluate(environment);\r
+ if(o1 instanceof Double && o2 instanceof Double) {\r
+ return (Double)o1 + (Double)o2;\r
+ }\r
+ if(o1 instanceof Array && o2 instanceof Array) {\r
+ Array la = (Array)o1;\r
+ Array ra = (Array)o2;\r
+ return la.add(ra);\r
+ }\r
+ throw new IllegalStateException();\r
+ }\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Addition(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
}\r
\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
package fi.semantum.sysdyn.solver;\r
\r
import java.util.ArrayList;\r
+import java.util.Map;\r
\r
public class And implements IExpression {\r
\r
- public ArrayList<IExpression> exps;\r
+ public IExpression[] exps;\r
\r
public And(ArrayList<IExpression> exps) {\r
- this.exps = exps;\r
+ this.exps = exps.toArray(new IExpression[exps.size()]);\r
}\r
\r
@Override\r
public String toString() {\r
StringBuilder b = new StringBuilder();\r
- b.append(exps.get(0));\r
- for(int i=1;i<exps.size();i++) {\r
+ b.append(exps[0]);\r
+ for(int i=1;i<exps.length;i++) {\r
b.append(" and ");\r
- b.append(exps.get(i));\r
+ b.append(exps[i]);\r
}\r
return b.toString();\r
}\r
for(IExpression e : exps) \r
if(!(Boolean)e.evaluate(environment)) return false;\r
return true;\r
- } \r
+ }\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ ArrayList<IExpression> ne = new ArrayList<IExpression>();\r
+ for(IExpression e : exps) ne.add(e.withBase(frame, prefix));\r
+ return new And(ne);\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ for(int i=0;i<exps.length;i++) {\r
+ exps[i] = exps[i].rewrite(frame, copies);\r
+ }\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Application implements IExpression {\r
\r
public String name;\r
return environment.getSystem().evaluateFunction(environment, name, args);\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Application(name, args.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ args = args.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Argument implements IExpression {\r
\r
public String name;\r
throw new UnsupportedOperationException();\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Argument(prefix+name, modification.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ public Argument rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ modification = modification.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
package fi.semantum.sysdyn.solver;\r
\r
import java.util.ArrayList;\r
+import java.util.Map;\r
\r
public class ArgumentList {\r
\r
- public ArrayList<Argument> args;\r
+ public Argument[] args;\r
+ public String op;\r
\r
public ArgumentList(ArrayList<Argument> args) {\r
- this.args = args;\r
+ this.args = args.toArray(new Argument[args.size()]);\r
+ this.op = "";\r
}\r
\r
- public ArgumentList() {\r
- this.args = new ArrayList<Argument>();\r
+ public ArgumentList(ArrayList<Argument> args, String op) {\r
+ this.args = args.toArray(new Argument[args.size()]);\r
+ this.op = op;\r
+ }\r
+\r
+ public ArgumentList(String op) {\r
+ this.args = new Argument[0];\r
+ this.op = op;\r
}\r
\r
@Override\r
public String toString() {\r
- if(args.size() == 0) return "()";\r
+ if(args.length == 0) return "()";\r
StringBuilder b = new StringBuilder();\r
- b.append("(" + args.get(0));\r
- for(int i=1;i<args.size();i++) {\r
+ b.append("(" + args[0]);\r
+ for(int i=1;i<args.length;i++) {\r
b.append(", ");\r
- b.append(args.get(i));\r
+ b.append(args[i]);\r
}\r
b.append(")");\r
return b.toString();\r
}\r
\r
+ public ArgumentList withBase(IFrame frame, String prefix) {\r
+ ArrayList<Argument> a2 = new ArrayList<Argument>();\r
+ for(Argument a : args) a2.add((Argument)a.withBase(frame, prefix));\r
+ return new ArgumentList(a2, op);\r
+ }\r
+ \r
+ public ArgumentList rewrite(IFrame frame, Map<String,VariableBase> copies) {\r
+ for(int i=0;i<args.length;i++)\r
+ args[i] = args[i].rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
\r
import java.util.ArrayList;\r
import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import fi.semantum.sysdyn.solver.SolverUtils.Slice;\r
\r
public class Array implements IExpression {\r
\r
\r
}\r
\r
- public void addElement(Object element) {\r
+ public Array addElement(Object element) {\r
if(element instanceof Constant) addElement(((Constant)element).value);\r
else elements.add(element);\r
+ return this;\r
}\r
\r
public void setElement(int index, Object element) {\r
for(int i=0;i<needed;i++) addElement(subArray ? new Array() : null);\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ Array result = new Array();\r
+ for(Object o : elements) {\r
+ if(o instanceof Array) {\r
+ result.addElement(((Array)o).withBase(frame, prefix));\r
+ } else {\r
+ if(o instanceof IExpression) {\r
+ IExpression exp = (IExpression)o;\r
+ result.addElement(exp.withBase(frame, prefix));\r
+ } else {\r
+ result.addElement(o);\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ for(int i=0;i<elements.size();i++) {\r
+ Object element = elements.get(i);\r
+ if(element instanceof IExpression) {\r
+ elements.set(i, ((IExpression)element).rewrite(frame, copies));\r
+ }\r
+ }\r
+ return this;\r
+ }\r
+ \r
+ public int dimension() {\r
+ int result = 0;\r
+ for(int i=0;i<elements.size();i++) {\r
+ Object element = elements.get(i);\r
+ if(element instanceof Array) {\r
+ result += ((Array)element).dimension();\r
+ } else {\r
+ result++;\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ public Array mul(double d) {\r
+ Array result = new Array();\r
+ for(Object o : elements) {\r
+ if(o instanceof Double) {\r
+ result.addElement((Double)o*d);\r
+ } else if (o instanceof Array) {\r
+ result.addElement(((Array)o).mul(d));\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ public boolean validateDimensions(int[] dimensions, int index) {\r
+ if(elements.size() != dimensions[index]) return false;\r
+ if(index < dimensions.length-1) {\r
+ for(Object o : elements) {\r
+ if(!(o instanceof Array)) return false;\r
+ Array arr = (Array)o;\r
+ if(!arr.validateDimensions(dimensions, index+1)) return false;\r
+ }\r
+ } else {\r
+ for(Object o : elements) {\r
+ if((o instanceof Array)) return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+\r
+ public Array slice(Slice[] indices) {\r
+ \r
+ if(indices.length == 1) {\r
+ Array result = new Array();\r
+ for(int i=indices[0].start;i<=indices[0].end;i++) {\r
+ result.addElement(element(i));\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ if(indices.length != 2) throw new IllegalStateException();\r
+ \r
+ if(indices[1] == Slice.FULL) {\r
+ return (Array)elements.get(indices[0].start);\r
+ } else {\r
+ Array result = new Array();\r
+ for(Object o : elements) {\r
+ Array a = (Array)o;\r
+ result.addElement(a.element(indices[1].start));\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ }\r
+ \r
+ public Array add(Array other) {\r
+ Array result = new Array();\r
+ Collection<Object> lae = elements();\r
+ Collection<Object> rae = other.elements();\r
+ if(lae.size() != rae.size()) throw new IllegalStateException();\r
+ Iterator<Object> li = lae.iterator();\r
+ Iterator<Object> ri = rae.iterator();\r
+ for(int i=0;i<lae.size();i++) {\r
+ Object l = li.next();\r
+ Object r = ri.next();\r
+ if(l instanceof Double && r instanceof Double) {\r
+ result.addElement(((Double)l)+((Double)r));\r
+ } else if (l instanceof Array && r instanceof Array) {\r
+ Array arr = (Array)l;\r
+ Array otherArr = (Array)r;\r
+ result.addElement(arr.add(otherArr));\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ public Array mul(Array other) {\r
+ Array result = new Array();\r
+ Collection<Object> lae = elements();\r
+ Collection<Object> rae = other.elements();\r
+ if(lae.size() != rae.size()) throw new IllegalStateException();\r
+ Iterator<Object> li = lae.iterator();\r
+ Iterator<Object> ri = rae.iterator();\r
+ for(int i=0;i<lae.size();i++) {\r
+ Object l = li.next();\r
+ Object r = ri.next();\r
+ if(l instanceof Double && r instanceof Double) {\r
+ result.addElement(((Double)l)*((Double)r));\r
+ } else if (l instanceof Array && r instanceof Array) {\r
+ Array arr = (Array)l;\r
+ Array otherArr = (Array)r;\r
+ result.addElement(arr.add(otherArr));\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class ArraySliceExpression implements IExpression {\r
\r
- final public IExpression start;\r
- final public IExpression end;\r
+ public IExpression start;\r
+ public IExpression end;\r
\r
public ArraySliceExpression(IExpression start, IExpression end) {\r
this.start = start;\r
return result;\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new ArraySliceExpression(start.withBase(frame, prefix), end.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ start = start.rewrite(frame, copies);\r
+ end = end.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import org.omg.PortableInterceptor.SUCCESSFUL;\r
+\r
public class Assignment {\r
\r
public Variable target;\r
+ public IExpression[] subscripts;\r
public IExpression expression;\r
public boolean assigned = false;\r
\r
- public Assignment(Variable target, IExpression expression) {\r
+ public Assignment(Variable target, IExpression[] subscripts, IExpression expression) {\r
this.target = target;\r
+ this.subscripts = subscripts;\r
this.expression = expression;\r
}\r
\r
return target + " = " + expression;\r
}\r
\r
+ public Assignment withBase(IFrame frame, String prefix) {\r
+ if(subscripts != null) {\r
+ IExpression[] subscripts2 = new IExpression[subscripts.length];\r
+ for(int i=0;i<subscripts.length;i++)\r
+ subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
+ return new Assignment(target.withBase(frame, prefix), subscripts2, expression.withBase(frame, prefix));\r
+ } else {\r
+ return new Assignment(target.withBase(frame, prefix), null, expression.withBase(frame, prefix));\r
+ }\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Constant implements IExpression {\r
\r
public Object value;\r
return value;\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return this;\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ return this;\r
+ }\r
+ \r
}\r
+\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Declaration implements IExpression {\r
\r
public Variable variable;\r
throw new UnsupportedOperationException();\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Derivate implements IExpression {\r
\r
private Variable variable;\r
+ private IExpression[] subscripts;\r
private IExpression e;\r
\r
- public Derivate(Variable variable, IExpression e) {\r
+ public Derivate(Variable variable, IExpression[] subscripts, IExpression e) {\r
this.variable = variable;\r
+ this.subscripts = subscripts;\r
this.e = e;\r
}\r
\r
public Object evaluate(IEnvironment _environment) {\r
Environment environment = (Environment)_environment;\r
// Double old = (Double)environment.getValue(variable.name + variable.subscriptKey());\r
- Double old = (Double)environment.getValue(variable.index(_environment));\r
+ Double old = (Double)environment.getValue(variable.base.index(_environment, subscripts));\r
return old+environment.step*(Double)e.evaluate(environment);\r
}\r
\r
public String toString() {\r
return e.toString();\r
} \r
+\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ if(subscripts != null) {\r
+ IExpression[] subscripts2 = new IExpression[subscripts.length];\r
+ for(int i=0;i<subscripts.length;i++)\r
+ subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
+ return new Derivate((Variable)variable.withBase(frame, prefix), subscripts2, e.withBase(frame, prefix));\r
+ } else {\r
+ return new Derivate((Variable)variable.withBase(frame, prefix), null, e.withBase(frame, prefix));\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ if(subscripts != null) {\r
+ for(int i=0;i<subscripts.length;i++)\r
+ subscripts[i] = subscripts[i].rewrite(frame, copies);\r
+ }\r
+ e = e.rewrite(frame, copies);\r
+ return this;\r
+ }\r
\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
-public class Derivative {\r
+import java.util.Map;\r
+\r
+public class Derivative implements IExpression {\r
\r
Variable variable;\r
\r
public String toString() {\r
return "der(" + variable.toString() + ")";\r
}\r
+\r
+ @Override\r
+ public Object evaluate(IEnvironment environment) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Division implements IExpression {\r
\r
public IExpression exp1;\r
}\r
\r
private Array arrayDiv(Array a, Double d) {\r
- return a;\r
+ Array result = new Array();\r
+ for(Object o : a.elements()) {\r
+ if(o instanceof Double) {\r
+ result.addElement((Double)o/d);\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ return result;\r
}\r
\r
@Override\r
else throw new UnsupportedOperationException();\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Division(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+public class ElementwiseProduct implements IExpression {\r
+ \r
+ public IExpression exp1;\r
+ public IExpression exp2;\r
+ \r
+ public ElementwiseProduct(IExpression exp1, IExpression exp2) {\r
+ this.exp1 = exp1;\r
+ this.exp2 = exp2;\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return exp1 + " * " + exp2;\r
+ }\r
+ \r
+ @Override\r
+ public Object evaluate(IEnvironment environment) {\r
+ Object left = exp1.evaluate(environment);\r
+ Object right = exp2.evaluate(environment);\r
+ if(left instanceof Array && right instanceof Array) {\r
+ Array la = (Array)left;\r
+ Array ra = (Array)right;\r
+ Collection<Object> lae = la.elements();\r
+ Collection<Object> rae = ra.elements();\r
+ if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
+ Iterator<Object> li = lae.iterator();\r
+ Iterator<Object> ri = rae.iterator();\r
+ Array result = new Array();\r
+ for(int i=0;i<lae.size();i++) {\r
+ double ld = (Double)li.next();\r
+ double rd = (Double)ri.next();\r
+ result.addElement(ld*rd);\r
+ }\r
+ return result;\r
+ } else throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new ElementwiseProduct(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+public class EnumElementsVariableBase extends VariableBase {\r
+\r
+ private Array result;\r
+ \r
+ public EnumElementsVariableBase(Model clazz) {\r
+ super("elements");\r
+ result = new Array();\r
+ for(VariableDeclaration vd : clazz.variables) {\r
+ Constant c = (Constant)vd.modification.args[0].modification;\r
+ result.addElement(c.value);\r
+ }\r
+ }\r
+\r
+ public EnumElementsVariableBase(String name, Array result) {\r
+ super(name);\r
+ this.result = result;\r
+ }\r
+\r
+ @Override\r
+ public Object evaluate(IEnvironment environment, IExpression[] subscripts) {\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ VariableBase withBase(String prefix) {\r
+ return new EnumElementsVariableBase(prefix+name, result);\r
+ }\r
+ \r
+ @Override\r
+ public IExpression getPossibleConstant() {\r
+ return result;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+public class EnumSizeVariableBase extends VariableBase {\r
+\r
+ private Double value;\r
+ \r
+ public EnumSizeVariableBase(Model clazz) {\r
+ super("size");\r
+ value = (double)clazz.variables.size();\r
+ }\r
+\r
+ public EnumSizeVariableBase(String name, double value) {\r
+ super(name);\r
+ this.value = value;\r
+ }\r
+\r
+ @Override\r
+ public Object evaluate(IEnvironment environment, IExpression[] subscripts) {\r
+ return value;\r
+ } \r
+\r
+ @Override\r
+ VariableBase withBase(String prefix) {\r
+ return new EnumSizeVariableBase(prefix+name, value);\r
+ }\r
+ \r
+ @Override\r
+ public IExpression getPossibleConstant() {\r
+ return new Constant(value.toString());\r
+ }\r
+ \r
+}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
import java.util.TreeMap;\r
\r
interface Fn {\r
public Object evaluate(IEnvironment environment, int argc);\r
+ public Object evaluateInput(IEnvironment environment, int argPosition);\r
public void setLocals(IEnvironment environment);\r
public int offset();\r
public Variable[] parameters();\r
}\r
\r
abstract class Fn1 implements Fn {\r
+\r
+ Variable[] parameters;\r
\r
- static Variable[] parameters;\r
- \r
- static {\r
- parameters = new Variable[5];\r
- parameters[0] = new Variable(new VariableBase("", 0));\r
- parameters[1] = new Variable(new VariableBase("", 1));\r
- parameters[2] = new Variable(new VariableBase("", 2));\r
- parameters[3] = new Variable(new VariableBase("", 3));\r
- parameters[4] = new Variable(new VariableBase("", 4));\r
+ public Fn1(int pCount) {\r
+ parameters = new Variable[pCount];\r
+ for(int i=0;i<pCount;i++)\r
+ parameters[i] = new Variable(new VariableBase("", i));\r
}\r
\r
public int offset() {\r
public void setLocals(IEnvironment environment) {\r
}\r
\r
+ @Override\r
+ public Object evaluateInput(IEnvironment environment, int argPosition) {\r
+ // Function frame size is constant - this is called when padding is needed\r
+ return null;\r
+ }\r
+ \r
}\r
\r
-public class Environment implements IEnvironment, ISystem {\r
+final public class Environment implements IEnvironment, ISystem {\r
\r
+ final Map<String,Object> named = new HashMap<String,Object>();\r
+\r
public Model model;\r
public final double step;\r
public double time;\r
public boolean initial = true;\r
+ public int size;\r
\r
public Object[] valueTable;\r
\r
this.step = step;\r
this.time = start;\r
\r
- model.functions.put("size", new Fn1() {\r
+ model.functions.put("size", new Fn1(2) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("zidz", new Fn1() {\r
+ model.functions.put("zidz", new Fn1(2) {\r
\r
- @Override\r
- public Object evaluate(IEnvironment environment, int argc) {\r
- Double p1 = (Double)environment.getValue(0);\r
- Double p2 = (Double)environment.getValue(1);\r
+ private Object evaluate(Double p1, Double p2) {\r
if(Math.abs(p2) < 1e-12) return 0.0;\r
else return p1 / p2;\r
}\r
\r
+ @Override\r
+ public Object evaluate(IEnvironment environment, int argc) {\r
+ Object o1 = environment.getValue(0);\r
+ Object o2 = environment.getValue(1);\r
+ \r
+ if(o1 instanceof Double && o2 instanceof Double) {\r
+ return evaluate((Double)o1, (Double)o2);\r
+ }\r
+ if(o1 instanceof Array && o2 instanceof Array) {\r
+ Array la = (Array)o1;\r
+ Array ra = (Array)o2;\r
+ Collection<Object> lae = la.elements();\r
+ Collection<Object> rae = ra.elements();\r
+ if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
+ Iterator<Object> li = lae.iterator();\r
+ Iterator<Object> ri = rae.iterator();\r
+ Array result = new Array();\r
+ for(int i=0;i<lae.size();i++) {\r
+ double ld = (Double)li.next();\r
+ double rd = (Double)ri.next();\r
+ result.addElement(evaluate(ld,rd));\r
+ }\r
+ return result;\r
+ }\r
+ throw new IllegalStateException();\r
+ \r
+ \r
+ }\r
+ \r
});\r
- model.functions.put("xidz", new Fn1() {\r
+ model.functions.put("xidz", new Fn1(3) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("availabilityExternal", new Fn1() {\r
+ model.functions.put("availabilityExternal", new Fn1(4) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("pre", new Fn1() {\r
+ model.functions.put("pre", new Fn1(1) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("fill", new Fn1() {\r
+ model.functions.put("fill", new Fn1(3) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("randomNumber", new Fn1() {\r
+ model.functions.put("randomNumber", new Fn1(2) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("initial", new Fn1() {\r
+ model.functions.put("initial", new Fn1(0) {\r
\r
@Override\r
public Object evaluate(IEnvironment _environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("noEvent", new Fn1() {\r
+ model.functions.put("noEvent", new Fn1(1) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("min", new Fn1() {\r
+ model.functions.put("min", new Fn1(5) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("max", new Fn1() {\r
+ model.functions.put("max", new Fn1(5) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("integer", new Fn1() {\r
+ model.functions.put("integer", new Fn1(1) {\r
\r
@Override\r
public Object evaluate(IEnvironment environment, int argc) {\r
}\r
\r
});\r
- model.functions.put("delay", new Fn1() {\r
+ model.functions.put("sum", new Fn1(1) {\r
+\r
+ @Override\r
+ public Object evaluate(IEnvironment environment, int argc) {\r
+ Object value = environment.getValue(0);\r
+ Array arr = (Array)value;\r
+ double res = 0;\r
+ for(Object o : arr.elements())\r
+ res += (Double)o;\r
+ return res;\r
+ }\r
+ \r
+ });\r
+ model.functions.put("delay", new Fn1(4) {\r
\r
@Override\r
public Object evaluate(IEnvironment _environment, int argc) {\r
}\r
\r
}); \r
+ model.functions.put("cat", new Fn1(10) {\r
+ \r
+ @Override\r
+ public Object evaluate(IEnvironment _environment, int argc) {\r
+ \r
+ Double dim = (Double)_environment.getValue(0);\r
+ \r
+ Array array = new Array();\r
+ for(int i=1;i<argc;i++) {\r
+ Object ar = _environment.getValue(i);\r
+ if (ar instanceof Array) {\r
+ Array a = (Array)ar;\r
+ for(Object o : a.elements())\r
+ array.addElement(o);\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ \r
+ return array;\r
+ \r
+ }\r
+ \r
+ }); \r
}\r
\r
public TreeMap<Double,Double> getHistory(String ident) {\r
valueTable[key] = value;\r
}\r
\r
+ public void put(String key, Object value) {\r
+ named.put(key, value);\r
+ }\r
+\r
+ public void setSize(int size) {\r
+ this.size = size;\r
+ }\r
+ \r
@Override\r
public int offset() {\r
- return model.names.size();\r
+ return size;\r
}\r
\r
@Override\r
public double time() {\r
return time;\r
}\r
+\r
+ double[] valueArray;\r
+ \r
+ public void addIndexed(int dimensions[], ArrayList<String> keys, String prefix, int d) {\r
+\r
+ if(d == dimensions.length) {\r
+ keys.add(prefix);\r
+ return;\r
+ }\r
+\r
+ for(int i=0;i<dimensions[d];i++) {\r
+ String prefix2 = prefix + "[" + i + "]";\r
+ addIndexed(dimensions, keys, prefix2, d+1);\r
+ }\r
+ \r
+ }\r
\r
+ public void addVariable(String name, int[] dimensions, ArrayList<String> keys) {\r
+\r
+// int dimensions[] = base.dimensions;\r
+ if(dimensions == null) {\r
+ keys.add(name);\r
+ } else {\r
+ addIndexed(dimensions, keys, name, 0);\r
+ }\r
+\r
+ }\r
+ \r
+ public void addVariable(Variable var, ArrayList<String> keys) {\r
+ addVariable(var.base.name, var.base.dimensions, keys);\r
+ }\r
+\r
+ public String[] getValueKeyArray() {\r
+ \r
+ ArrayList<String> keys = new ArrayList<String>();\r
+ \r
+ for (int i = 0; i < model.assignmentArray.length; i++) {\r
+ addVariable(model.assignmentArray[i].target, keys);\r
+ }\r
+ \r
+ for (int i = 0; i < model.derivativeArray.length; i++) {\r
+ addVariable(model.derivativeArray[i].target, keys);\r
+ }\r
+ \r
+ // NOTE: there is room for optimization as parameter values that do not\r
+ // change should only be obtained once (and parameter values that do\r
+ // change are (possibly) included in assignments or derivatives)\r
+ for(int i = 0; i < model.parameterArray.length; i++) {\r
+ addVariable(model.parameterArray[i].variable, keys);\r
+ }\r
+ \r
+ for(Map.Entry<String,VariableBase> entry : model.copies.entrySet()) {\r
+ addVariable(entry.getKey(), entry.getValue().dimensions, keys);\r
+ }\r
+\r
+ valueArray = new double[keys.size()];\r
+ \r
+ return keys.toArray(new String[keys.size()]);\r
+ \r
+ }\r
+\r
// TODO: this is probably not smart at all, figure out a better way to obtain results\r
- public HashMap<String, Double> getValueMap() {\r
- HashMap<String, Double> values = new HashMap<String, Double>();\r
+ public double[] getValueArray() {\r
+ \r
+ int offset = 0;\r
\r
for (int i = 0; i < model.assignmentArray.length; i++) {\r
Variable v = model.assignmentArray[i].target;\r
- values.put(v.toString(), (Double)getValue(v.index(this)));\r
+ for(int index=0;index<v.base.dimension();index++)\r
+ valueArray[offset++] = (Double)getValue(v.base.index(this, null)+index);\r
}\r
\r
for (int i = 0; i < model.derivativeArray.length; i++) {\r
Variable v = model.derivativeArray[i].target;\r
- values.put(v.toString(), (Double)getValue(v.index(this)));\r
+ for(int index=0;index<v.base.dimension();index++)\r
+ valueArray[offset++] = (Double)getValue(v.base.index(this, null)+index);\r
}\r
\r
// NOTE: there is room for optimization as parameter values that do not\r
// change should only be obtained once (and parameter values that do\r
// change are (possibly) included in assignments or derivatives)\r
- for (ParameterDeclaration p : model.parameters) {\r
- Variable v = p.variable;\r
- values.put(v.toString(), (Double)getValue(v.index(this)));\r
+ for(int i = 0; i < model.parameterArray.length; i++) {\r
+ Variable v = model.parameterArray[i].variable;\r
+ for(int index=0;index<v.base.dimension();index++)\r
+ valueArray[offset++] = (Double)getValue(v.base.index(this, null)+index);\r
}\r
+\r
+ for(Map.Entry<String,VariableBase> entry : model.copies.entrySet()) {\r
+ VariableBase base = entry.getValue();\r
+ for(int index=0;index<base.dimension();index++)\r
+ valueArray[offset++] = (Double)getValue(base.index(this, null)+index);\r
+ }\r
+ \r
+ return valueArray;\r
\r
- return values;\r
+ }\r
+\r
+ @Override\r
+ public Object getNamedValue(String key) {\r
+ return named.get(key);\r
}\r
\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Equals implements IExpression {\r
\r
public IExpression exp1;\r
\r
@Override\r
public Object evaluate(IEnvironment environment) {\r
- return ((Double)exp1.evaluate(environment)) == ((Double)exp2.evaluate(environment));\r
+ Object v1 = exp1.evaluate(environment);\r
+ Object v2 = exp2.evaluate(environment);\r
+ if(!(v1 instanceof Double))\r
+ throw new IllegalStateException();\r
+ if(!(v2 instanceof Double))\r
+ throw new IllegalStateException();\r
+ return (v1.equals(v2));\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Equals(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+public class ForArray implements IExpression {\r
+\r
+ private ArrayList<Object> elements = new ArrayList<Object>();\r
+\r
+ public ForArray() {\r
+ \r
+ }\r
+\r
+ public ForArray(ArrayList<Object> elements) {\r
+ this.elements = elements;\r
+ }\r
+\r
+ public void addElement(Object element) {\r
+ if(element instanceof Constant) addElement(((Constant)element).value);\r
+ else elements.add(element);\r
+ }\r
+ \r
+ public void setElement(int index, Object element) {\r
+ elements.set(index, element);\r
+ }\r
+\r
+ @Override\r
+ public Object evaluate(IEnvironment environment) {\r
+ return evaluated(environment);\r
+ }\r
+ \r
+ public Array evaluated(IEnvironment environment) {\r
+ \r
+ Array result = new Array();\r
+ \r
+ IExpression exp = (IExpression)elements.get(0);\r
+ Argument arg = (Argument)elements.get(1);\r
+ \r
+ Array indices = (Array)arg.modification.evaluate(environment);\r
+ for(Object o : indices.elements()) {\r
+ environment.put(arg.name, o);\r
+// Frame f = new Frame(environment, 1);\r
+// f.put(arg.name, o);\r
+ result.addElement(exp.evaluate(environment));\r
+ }\r
+ \r
+ return result;\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return elements.toString();\r
+ }\r
+ \r
+ public int size(int col) {\r
+ return elements.size();\r
+ }\r
+ \r
+ public Object element(int index) {\r
+ return elements.get(index);\r
+ }\r
+ \r
+ public Collection<Object> elements() {\r
+ return elements;\r
+ }\r
+ \r
+ public void ensureIndex(int index, boolean subArray) {\r
+ int needed = (index+1-elements.size());\r
+ for(int i=0;i<needed;i++) addElement(subArray ? new ForArray() : null);\r
+ }\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ ArrayList<Object> e = new ArrayList<Object>();\r
+ for(Object o : elements) {\r
+ if(o instanceof IExpression) {\r
+ e.add(((IExpression)o).withBase(frame, prefix));\r
+ } else {\r
+ e.add(o);\r
+ }\r
+ }\r
+ return new ForArray(e);\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ for(int i=0;i<elements.size();i++) {\r
+ Object o = elements.get(i);\r
+ if(o instanceof IExpression) {\r
+ elements.set(i, ((IExpression)o).rewrite(frame, copies));\r
+ }\r
+ }\r
+ return this;\r
+ }\r
+ \r
+}\r
\r
public class ForIndex {\r
\r
+ public String name;\r
public VariableBase base;\r
public IExpression expression;\r
\r
public ForIndex(Function function, String name, IExpression expression) {\r
this.expression = expression;\r
- this.base = function.addIndex(name, this);\r
+ this.name = name;\r
+ if(function != null)\r
+ this.base = function.addIndex(name, this);\r
}\r
\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
public class Frame implements IEnvironment {\r
\r
final public IEnvironment parent;\r
final private int offset;\r
+ Map<String,Object> named;\r
\r
public Frame(IEnvironment parent, int offset) {\r
this.parent = parent;\r
public void put(int index, Object value) {\r
parent.put(parent.offset() + index, value);\r
}\r
+\r
+ public void put(String key, Object value) {\r
+ if(named == null) named = new HashMap<String,Object>();\r
+ named.put(key, value);\r
+ }\r
\r
@Override\r
public Object getValue(int index) {\r
return parent.getValue(parent.offset() + index);\r
}\r
+\r
+ @Override\r
+ public Object getNamedValue(String key) {\r
+ if(named == null) return null;\r
+ return named.get(key);\r
+ }\r
\r
@Override\r
public ISystem getSystem() {\r
package fi.semantum.sysdyn.solver;\r
\r
import java.util.ArrayList;\r
-import java.util.Arrays;\r
import java.util.HashMap;\r
import java.util.Map;\r
\r
-public class Function implements Fn, IFrame {\r
+final public class Function implements Fn, IFrame {\r
\r
public static final boolean PRINT = false;\r
\r
return base;\r
}\r
\r
+ @Override\r
+ public VariableBase getBase(VariableBase base, String prefix) {\r
+ throw new IllegalStateException();\r
+ }\r
+ \r
public void prepare() {\r
int nextIndex = 0;\r
if(PRINT)\r
for(int i=0;i<inputs.size();i++) {\r
VariableDeclaration decl = inputs.get(i);\r
parameters[i] = decl.variable;\r
- decl.variable.base.tellSubscripts(decl.variable.subscripts);\r
+ decl.variable.base.tellSubscripts(decl.variable.subscripts, null);\r
}\r
for(int i=0;i<outputs.size();i++) {\r
VariableDeclaration decl = outputs.get(i);\r
- decl.variable.base.tellSubscripts(decl.variable.subscripts);\r
+ decl.variable.base.tellSubscripts(decl.variable.subscripts, null);\r
}\r
for(int i=0;i<internals.size();i++) {\r
VariableDeclaration decl = internals.get(i);\r
- decl.variable.base.tellSubscripts(decl.variable.subscripts);\r
+ decl.variable.base.tellSubscripts(decl.variable.subscripts, null);\r
}\r
}\r
\r
return parameters;\r
}\r
\r
+ @Override\r
+ public Object evaluateInput(IEnvironment environment, int argPosition) {\r
+ VariableDeclaration decl = inputs.get(argPosition);\r
+ return decl.modification.args[0].modification.evaluate(environment);\r
+ }\r
+ \r
+ @Override\r
+ public Model getClass(String name) {\r
+ return null;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class GreaterOrEqualThan implements IExpression {\r
\r
public IExpression exp1;\r
return ((Double)exp1.evaluate(environment)) >= ((Double)exp2.evaluate(environment));\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new GreaterOrEqualThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class GreaterThan implements IExpression {\r
\r
public IExpression exp1;\r
return ((Double)exp1.evaluate(environment)) > ((Double)exp2.evaluate(environment));\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new GreaterThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
public interface IEnvironment {\r
\r
// Object getValue(String key);\r
+ Object getNamedValue(String key);\r
Object getValue(int index);\r
-// void put(String key, Object value);\r
+ void put(String key, Object value);\r
void put(int index, Object value);\r
// Object evaluateFunction(IEnvironment parent, String name, ArgumentList args);\r
\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public interface IExpression {\r
\r
public Object evaluate(IEnvironment environment);\r
+ public IExpression withBase(IFrame frame, String prefix);\r
+ public Object getPossibleConstant();\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies);\r
\r
}\r
\r
public interface IFrame {\r
public VariableBase getBase(String name);\r
+ public VariableBase getBase(VariableBase base, String prefix);\r
+ public Model getClass(String name);\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class IfThenElse implements IExpression {\r
\r
public IExpression exp;\r
}\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new IfThenElse(exp.withBase(frame, prefix), t.withBase(frame, prefix), e.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp = exp.rewrite(frame, copies);\r
+ t = t.rewrite(frame, copies);\r
+ e = e.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class LessOrEqualThan implements IExpression {\r
\r
public IExpression exp1;\r
return d1 <= d2;\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new LessOrEqualThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class LessThan implements IExpression {\r
\r
public IExpression exp1;\r
return ((Double)left) < ((Double)right);\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new LessThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
\r
import java.io.StringReader;\r
\r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
import fi.semantum.sysdyn.solver.parser.ModelParser;\r
import fi.semantum.sysdyn.solver.parser.Node;\r
import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
public LineReader(String input, NodeCache cache) {\r
chars = input.toCharArray();\r
this.cache = cache;\r
- model = new Model();\r
+ model = new Model(new Globals(), "", false);\r
parser = new Parser();\r
}\r
\r
cache.store(line, (SimpleNode)node);\r
} \r
\r
- parser.currentFrame = model;\r
parser.walk((SimpleNode)node, 0, model);\r
\r
}\r
cache.store(line, (SimpleNode)node);\r
} \r
\r
- parser.currentFrame = model;\r
parser.walk((SimpleNode)node, 0, model);\r
\r
}\r
cache.store(line, (SimpleNode)node);\r
} \r
\r
- parser.currentFrame = model;\r
parser.walk((SimpleNode)node, 0, model);\r
\r
}\r
import java.util.Arrays;\r
import java.util.HashMap;\r
import java.util.Map;\r
+import java.util.TreeMap;\r
\r
class Model implements IFrame {\r
\r
+ static class Globals {\r
+ public Map<String,Model> classes = new HashMap<String,Model>();\r
+ }\r
+ \r
final public static boolean PRINT = false;\r
\r
public boolean initial = false;\r
public ArrayList<ParameterDeclaration> parameters = new ArrayList<ParameterDeclaration>();\r
public ArrayList<VariableDeclaration> variables = new ArrayList<VariableDeclaration>();\r
public Map<String,Fn> functions = new HashMap<String,Fn>();\r
+ public Map<String,VariableBase> copies;\r
\r
public Assignment[] assignmentArray;\r
public Assignment[] derivativeArray;\r
+ public ParameterDeclaration[] parameterArray;\r
+ \r
+ public final Globals globals;\r
+ \r
+ public String name;\r
+ public boolean isEnumClass;\r
+ \r
+ public Model(Globals globals, String name, boolean isEnumClass) {\r
+ this.globals = globals;\r
+ this.name = name;\r
+ this.isEnumClass = isEnumClass;\r
+ }\r
+ \r
+ public void addVariable(VariableDeclaration vd) {\r
+ this.variables.add(vd);\r
+ }\r
\r
public Fn getFunction(String name) {\r
return functions.get(name);\r
\r
public HashMap<String,VariableBase> names = new HashMap<String,VariableBase>();\r
\r
+ public VariableBase getBase(VariableBase original, String prefix) {\r
+ VariableBase base = names.get(prefix+original.name);\r
+ if(base != null) return base;\r
+ base = original.withBase(prefix);\r
+ names.put(base.name, base);\r
+ return base;\r
+ }\r
+ \r
public VariableBase getBase(String name) {\r
VariableBase base = names.get(name);\r
if(base == null) {\r
- base = new VariableBase(name);\r
+ \r
+ if(isEnumClass) {\r
+ if("size".equals(name)) base = new EnumSizeVariableBase(this);\r
+ else if("elements".equals(name)) base = new EnumElementsVariableBase(this);\r
+ } \r
+ \r
+ if(base == null) base = new VariableBase(name);\r
names.put(name, base);\r
}\r
return base;\r
Frame frame = new Frame(environment, fn.offset());\r
\r
ArrayList<Object> argh = new ArrayList<Object>();\r
- argh.add(args.args.get(0).modification.toString());\r
- for(int i=0;i<args.args.size();i++) {\r
- argh.add(args.args.get(i).modification.evaluate(environment));\r
+ argh.add(args.args[0].modification.toString());\r
+ for(int i=0;i<args.args.length;i++) {\r
+ argh.add(args.args[1].modification.evaluate(environment));\r
}\r
\r
Variable[] parameters = fn.parameters();\r
\r
- for(int i=0;i<args.args.size()+1;i++) {\r
+ for(int i=0;i<args.args.length+1;i++) {\r
Variable var = parameters[i];\r
Object value = argh.get(i);\r
var.assignPlain(frame, value);\r
\r
fn.setLocals(frame);\r
\r
- return fn.evaluate(frame, args.args.size()+1);\r
+ return fn.evaluate(frame, args.args.length+1);\r
\r
} else {\r
\r
Frame frame = new Frame(environment, fn.offset());\r
\r
ArrayList<Object> argh = new ArrayList<Object>();\r
- for(int i=0;i<args.args.size();i++) {\r
- Object arg = args.args.get(i).modification.evaluate(environment);\r
+ for(int i=0;i<args.args.length;i++) {\r
+ Object arg = args.args[i].modification.evaluate(environment);\r
+ if(arg == null) throw new IllegalStateException("No value for " + args.args[i].modification);\r
argh.add(arg);\r
}\r
\r
Variable[] parameters = fn.parameters();\r
\r
- for(int i=0;i<args.args.size();i++) {\r
+ for(int i=0;i<parameters.length;i++) {\r
Variable var = parameters[i];\r
- Object value = argh.get(i);\r
- var.assignPlain(frame, value);\r
+ if(i < argh.size()) {\r
+ Object value = argh.get(i);\r
+ var.assignPlain(frame, value);\r
+ } else {\r
+ Object value = fn.evaluateInput(environment, i);\r
+ var.assignPlain(frame, value);\r
+ }\r
}\r
\r
fn.setLocals(frame);\r
\r
- return fn.evaluate(frame, args.args.size());\r
+ return fn.evaluate(frame, args.args.length);\r
\r
}\r
\r
}\r
\r
+ private VariableBase resolveCopy(Map<String,VariableBase> work, VariableBase target) {\r
+ VariableBase deep = work.get(target.name);\r
+ if(deep == null) return target;\r
+ return resolveCopy(work, target);\r
+ }\r
+ \r
+ private void rewrite() {\r
+\r
+ ArrayList<ParameterDeclaration> parameterCopies = new ArrayList<ParameterDeclaration>();\r
+ ArrayList<Assignment> variableCopies = new ArrayList<Assignment>();\r
+\r
+ HashMap<String,VariableBase> work = new HashMap<String,VariableBase>();\r
+ \r
+ for(ParameterDeclaration pd : parameters) {\r
+ if(pd.modification instanceof Variable) {\r
+ Variable var = (Variable)pd.modification;\r
+ if(!SolverUtils.isFullSubscript(var.subscripts)) continue;\r
+ if(!SolverUtils.isFullSubscript(pd.variable.subscripts)) continue;\r
+ parameterCopies.add(pd);\r
+ work.put(pd.variable.base.name, var.base);\r
+ }\r
+ }\r
+ for(Assignment ass : assignments) {\r
+ if(ass.expression instanceof Variable) {\r
+ Variable var = (Variable)ass.expression;\r
+ if(!SolverUtils.isFullSubscript(var.subscripts)) continue;\r
+ if(!SolverUtils.isFullSubscript(ass.target.subscripts)) continue;\r
+ variableCopies.add(ass);\r
+ work.put(ass.target.base.name, var.base);\r
+ }\r
+ }\r
+\r
+ parameters.removeAll(parameterCopies);\r
+ assignments.removeAll(variableCopies);\r
+\r
+ copies = new TreeMap<String,VariableBase>();\r
+ for(String key : work.keySet()) {\r
+ VariableBase b = resolveCopy(work, work.get(key));\r
+ copies.put(key, b);\r
+ }\r
+\r
+ for(VariableDeclaration vd : variables) {\r
+ vd.modification = vd.modification.rewrite(this, copies);\r
+ vd.variable = (Variable)vd.variable.rewrite(this, copies);\r
+ }\r
+ for(ParameterDeclaration pd : parameters) {\r
+ pd.modification = pd.modification.rewrite(this, copies);\r
+ }\r
+ for(Assignment ass : assignments) {\r
+ ass.expression = ass.expression.rewrite(this, copies);\r
+ }\r
+ for(Assignment ass : derivatives) {\r
+ ass.expression = ass.expression.rewrite(this, copies);\r
+ }\r
+ for(Assignment ass : initials) {\r
+ ass.expression = ass.expression.rewrite(this, copies);\r
+ }\r
+ \r
+ }\r
+ \r
public int prepare() {\r
\r
if(PRINT) {\r
System.err.println("==================");\r
}\r
\r
- for(VariableDeclaration vd : variables) {\r
- vd.variable.base.tellSubscripts(vd.variable.subscripts);\r
- }\r
- for(ParameterDeclaration pd : parameters) {\r
- pd.variable.base.tellSubscripts(pd.variable.subscripts);\r
+ rewrite();\r
+ \r
+ boolean done = true;\r
+ \r
+ for(int i=0;i<50;i++) {\r
+ done = true;\r
+ for(VariableDeclaration vd : variables) {\r
+ done &= vd.variable.base.tellSubscripts(vd.variable.subscripts, null);\r
+ }\r
+ for(ParameterDeclaration pd : parameters) {\r
+ done &= pd.variable.base.tellSubscripts(pd.variable.subscripts, pd.modification);\r
+ }\r
+ if(done) break;\r
}\r
+ \r
+ if(!done) throw new IllegalStateException();\r
+ \r
int nextIndex = 0;\r
for(Map.Entry<String, VariableBase> entry : names.entrySet()) {\r
VariableBase base = entry.getValue();\r
base.index = nextIndex;\r
if(PRINT)\r
System.err.println("Variable: " + entry.getKey() + " " + base.index + " " + Arrays.toString(base.dimensions));\r
- nextIndex += base.dimension();\r
+ int dim = base.dimension();\r
+ if(dim == -1) dim = 1;\r
+ nextIndex += dim;\r
}\r
\r
if(PRINT)\r
\r
}\r
\r
+ public void prettyPrint() {\r
+\r
+ System.err.println("initials");\r
+ for(Assignment a : initials) {\r
+ System.err.println("-"+a);\r
+ }\r
+ System.err.println("assignments");\r
+ for(Assignment a : assignments) {\r
+ System.err.println("-"+a);\r
+ }\r
+ System.err.println("derivatives");\r
+ for(Assignment a : derivatives) {\r
+ System.err.println("-"+a);\r
+ }\r
+ System.err.println("parameters");\r
+ for(ParameterDeclaration a : parameters) {\r
+ System.err.println("-"+a);\r
+ }\r
+ System.err.println("variables");\r
+ for(VariableDeclaration a : variables) {\r
+ System.err.println("-"+a);\r
+ }\r
+ System.err.println("functions");\r
+ for(Map.Entry<String, Fn> a : functions.entrySet()) {\r
+ System.err.println("-"+a.getKey() + " " + a.getValue());\r
+ }\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public Model getClass(String name) {\r
+ return globals.classes.get(name);\r
+ }\r
+ \r
+ public boolean instantiateClass(String type_specifier, Declaration decl, IFrame currentFrame) {\r
+ \r
+ Model clazz = globals.classes.get(type_specifier);\r
+ if(clazz == null) return false;\r
+\r
+ Map<String,IExpression> modifications = new HashMap<String,IExpression>();\r
+ if(decl.modification instanceof ArgumentList) {\r
+ ArgumentList args = (ArgumentList)decl.modification;\r
+ for(Argument a : args.args) {\r
+ modifications.put(a.name, a.modification);\r
+ }\r
+ }\r
+ \r
+ for(VariableDeclaration vd : clazz.variables) {\r
+ String base = decl.variable.base.name + ".";\r
+ Variable var2 = vd.variable.withBase(currentFrame, base);\r
+ VariableDeclaration vd2 = new VariableDeclaration(var2, vd.direction, vd.type, vd.modification.withBase(currentFrame, base));\r
+ variables.add(vd2);\r
+ }\r
+ for(ParameterDeclaration pd : clazz.parameters) {\r
+ IExpression modi = modifications.get(pd.variable.base.name);\r
+ if(modi != null) {\r
+ String base = decl.variable.base.name + ".";\r
+ Variable var2 = pd.variable.withBase(currentFrame, base);\r
+ var2.subscripts = null;\r
+ ParameterDeclaration pd2 = new ParameterDeclaration(var2, modi);\r
+ parameters.add(pd2);\r
+ modifications.remove(pd.variable.base.name);\r
+ } else {\r
+ String base = decl.variable.base.name + ".";\r
+ Variable var2 = pd.variable.withBase(currentFrame, base);\r
+ ParameterDeclaration pd2 = new ParameterDeclaration(var2, pd.modification.withBase(currentFrame, base));\r
+ parameters.add(pd2);\r
+ }\r
+ }\r
+ \r
+ if(!modifications.isEmpty())\r
+ throw new IllegalStateException();\r
+ \r
+ for(Assignment ass : clazz.assignments) {\r
+ Assignment ass2 = ass.withBase(currentFrame, decl.variable.base.name + ".");\r
+ assignments.add(ass2);\r
+ }\r
+ for(Assignment ass : clazz.initials) {\r
+ Assignment ass2 = ass.withBase(currentFrame, decl.variable.base.name + ".");\r
+ initials.add(ass2);\r
+ }\r
+ for(Assignment ass : clazz.derivatives) {\r
+ Assignment ass2 = ass.withBase(currentFrame, decl.variable.base.name + ".");\r
+ derivatives.add(ass2);\r
+ }\r
+ \r
+ return true;\r
+ \r
+ }\r
+ \r
}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.ArrayList;\r
+\r
+public class MultiStatement implements IStatement {\r
+ \r
+ public ArrayList<Variable> targets;\r
+ public Variable fn;\r
+ public ArgumentList args;\r
+ \r
+ public MultiStatement(ArrayList<Variable> targets, Variable fn, ArgumentList args) {\r
+ this.targets = targets;\r
+ this.fn = fn;\r
+ this.args = args;\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return targets + " := " + fn + " " + args;\r
+ }\r
+ \r
+ @Override\r
+ public void evaluate(IEnvironment environment) {\r
+ ArrayList<Object> values = (ArrayList<Object>)environment.getSystem().evaluateFunction(environment, fn.base.name, args);\r
+ for(int i=0;i<targets.size();i++) {\r
+ targets.get(i).assignPlain(environment, values.get(i));\r
+ }\r
+ }\r
+ \r
+}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Multiplication implements IExpression {\r
\r
public IExpression exp1;\r
public String toString() {\r
return exp1 + " * " + exp2;\r
}\r
-\r
- private Array arrayMul(Array a, Double d) {\r
- return a;\r
- }\r
\r
@Override\r
public Object evaluate(IEnvironment environment) {\r
Object left = exp1.evaluate(environment);\r
Object right = exp2.evaluate(environment);\r
- if(left instanceof Double && right instanceof Double) return ((Double)left)*((Double)right);\r
- else if (left instanceof Array && right instanceof Double) return arrayMul((Array)left, (Double)right);\r
- else if (left instanceof Double && right instanceof Array) return arrayMul((Array)right, (Double)left);\r
- else throw new UnsupportedOperationException();\r
+ if(left instanceof Double && right instanceof Double) {\r
+ return ((Double)left)*((Double)right);\r
+ } \r
+ else if(left instanceof Array && right instanceof Array) {\r
+ Array la = (Array)left;\r
+ Array ra = (Array)right;\r
+ return la.mul(ra);\r
+ }\r
+ else if (left instanceof Array && right instanceof Double) return ((Array)left).mul((Double)right);\r
+ else if (left instanceof Double && right instanceof Array) return ((Array)right).mul((Double)left);\r
+ throw new IllegalStateException();\r
+ \r
}\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Multiplication(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Negation implements IExpression {\r
\r
public IExpression exp;\r
return -((Double)exp.evaluate(environment));\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Negation(exp.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp = exp.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
while_statement,\r
statement,\r
name,\r
+ element,\r
element_list,\r
element_modification,\r
function_arguments,\r
add_op,\r
mul_op,\r
rel_op,\r
- der_initial;\r
+ der_initial,\r
+ output_expression_list,\r
+ extends_clause;\r
\r
private NodeClass() {\r
Parser.nodeNameMap.put(toString(), this);\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class NotEquals implements IExpression {\r
\r
public IExpression exp1;\r
return ((Double)exp1.evaluate(environment)) != ((Double)exp2.evaluate(environment));\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new NotEquals(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
--- /dev/null
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.Map;\r
+\r
+public class NullModification implements IExpression {\r
+\r
+ @Override\r
+ public Object evaluate(IEnvironment environment) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return this;\r
+ }\r
+\r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return this;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ return this;\r
+ }\r
+\r
+}\r
package fi.semantum.sysdyn.solver;\r
\r
import java.util.ArrayList;\r
+import java.util.Map;\r
\r
public class Or implements IExpression {\r
\r
- public ArrayList<IExpression> exps;\r
+ public IExpression[] exps;\r
\r
public Or(ArrayList<IExpression> exps) {\r
- this.exps = exps;\r
+ this.exps = exps.toArray(new IExpression[exps.size()]);\r
}\r
\r
@Override\r
public String toString() {\r
StringBuilder b = new StringBuilder();\r
- b.append(exps.get(0));\r
- for(int i=1;i<exps.size();i++) {\r
+ b.append(exps[0]);\r
+ for(int i=1;i<exps.length;i++) {\r
b.append(" or ");\r
- b.append(exps.get(i));\r
+ b.append(exps[i]);\r
}\r
return b.toString();\r
}\r
for(IExpression e : exps) \r
if((Boolean)e.evaluate(environment)) return true;\r
return false;\r
- } \r
+ }\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ ArrayList<IExpression> ne = new ArrayList<IExpression>();\r
+ for(IExpression e : exps) ne.add(e.withBase(frame, prefix));\r
+ return new Or(ne);\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ for(int i=0;i<exps.length;i++) {\r
+ exps[i] = exps[i].rewrite(frame, copies);\r
+ }\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
\r
public class ParameterDeclaration implements IExpression {\r
\r
throw new UnsupportedOperationException();\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.io.File;\r
+import java.io.StringReader;\r
import java.util.ArrayList;\r
import java.util.HashMap;\r
import java.util.Map;\r
\r
+import org.simantics.utils.FileUtils;\r
+\r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
+import fi.semantum.sysdyn.solver.parser.ModelParser;\r
import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
\r
public class Parser {\r
\r
- public IFrame currentFrame;\r
+// public IFrame currentFrame;\r
\r
private int PRINT = 0;\r
\r
- public Object walk(SimpleNode n, int indent, Model model) {\r
+ public Object walk(SimpleNode n, int indent, IFrame model) {\r
Object result = walk_(n, indent, model);\r
if(PRINT > 0) {\r
for(int i=0;i<indent;i++) System.err.print(" ");\r
\r
static Map<String, NodeClass> nodeNameMap = new HashMap<String, NodeClass>();\r
\r
- public Object walk_(SimpleNode n, int indent, Model model) {\r
+ public Object walk_(SimpleNode n, int indent, IFrame frame) {\r
\r
+ Model model = frame instanceof Model ? (Model)frame : null;\r
+ \r
// TODO: most of this should probably be implemented in the parser\r
\r
NodeClass nc = NodeClass.of(n.toString());\r
\r
if (nc == null) {\r
- if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
// not sure if this is ever called\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- walk((SimpleNode)n.jjtGetChild(i),indent+2, model);\r
+ walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
}\r
return null;\r
}\r
\r
switch(nc) {\r
case assignment:\r
- Object v = (Object)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- IExpression exp = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+ Object v = (Object)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ IExpression exp = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
if(v instanceof Derivative) {\r
Derivative der = (Derivative)v;\r
- Assignment eq = new Assignment(der.variable,new Derivate(der.variable, exp));\r
+ Assignment eq = new Assignment(der.variable, der.variable.subscripts, new Derivate(der.variable, der.variable.subscripts, exp));\r
model.derivatives.add(eq);\r
return eq;\r
} else {\r
- Assignment eq = new Assignment((Variable)v,exp);\r
+ Variable var = (Variable)v;\r
+ Assignment eq = new Assignment(var, var.subscripts, exp);\r
if(model.initial)\r
model.initials.add(eq);\r
else\r
case equation_section:\r
if("initial".equals(n.op)) {\r
model.initial = true;\r
+ for(int i=0;i<n.jjtGetNumChildren();i++) {\r
+ walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
+ }\r
} else {\r
model.initial = false;\r
+ for(int i=0;i<n.jjtGetNumChildren();i++) {\r
+ walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
+ }\r
}\r
- break;\r
+ return null;\r
case composition:\r
- if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0),indent+2, model);\r
+ if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0),indent+2, frame);\r
ArrayList<Object> comps = new ArrayList<Object>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- comps.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ comps.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return comps;\r
case for_index:\r
- return new ForIndex((Function)currentFrame, n.op, (IExpression)walk((SimpleNode)n.jjtGetChild(0),indent+2, model));\r
+ if(frame instanceof Function)\r
+ return new ForIndex((Function)frame, n.op, (IExpression)walk((SimpleNode)n.jjtGetChild(0),indent+2, frame));\r
+ else\r
+ return new ForIndex(null, n.op, (IExpression)walk((SimpleNode)n.jjtGetChild(0),indent+2, frame));\r
case for_indices:\r
ArrayList<ForIndex> indices = new ArrayList<ForIndex>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- indices.add((ForIndex)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ indices.add((ForIndex)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return indices;\r
case for_statement:\r
- ArrayList<ForIndex> indices2 = (ArrayList<ForIndex>)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ ArrayList<ForIndex> indices2 = (ArrayList<ForIndex>)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
ArrayList<IStatement> stms = new ArrayList<IStatement>();\r
for(int i=1;i<n.jjtGetNumChildren();i++) {\r
- stms.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ stms.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return new ForStatement(indices2, new StatementList(stms));\r
case if_statement:\r
- IExpression condition = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ IExpression condition = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
ArrayList<IStatement> thens = new ArrayList<IStatement>();\r
ArrayList<IStatement> elses = new ArrayList<IStatement>();\r
for(int i=1;i<n.jjtGetNumChildren();i++) {\r
SimpleNode child = (SimpleNode)n.jjtGetChild(i);\r
- if("then_statement".equals(child.toString())) thens.add((IStatement)walk(child, indent+2, model));\r
- else if("else_statement".equals(child.toString())) elses.add((IStatement)walk(child, indent+2, model));\r
+ if("then_statement".equals(child.toString())) thens.add((IStatement)walk(child, indent+2, frame));\r
+ else if("else_statement".equals(child.toString())) elses.add((IStatement)walk(child, indent+2, frame));\r
}\r
return new IfStatement(condition, new StatementList(thens), new StatementList(elses));\r
case while_statement:\r
- IExpression expression = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ IExpression expression = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
ArrayList<IStatement> whiles = new ArrayList<IStatement>();\r
for(int i=1;i<n.jjtGetNumChildren();i++) {\r
- whiles.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ whiles.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return new While(expression, new StatementList(whiles));\r
case statement:\r
- if(n.jjtGetNumChildren() == 1) return (IStatement)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- Variable variable = (Variable)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- IExpression expression2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
- return new Statement(variable, expression2);\r
+ \r
+// ( component_reference() ( ":=" expression() | function_call_args() )\r
+// | "(" output_expression_list() ")" ":=" component_reference() function_call_args()\r
+// | "break"\r
+// | "return"\r
+// | if_statement()\r
+// | for_statement()\r
+// | while_statement()\r
+// | when_statement() )\r
+// comment() \r
+ \r
+ if(n.jjtGetNumChildren() == 1) {\r
+ return (IStatement)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ } else if (n.jjtGetNumChildren() == 2) {\r
+ SimpleNode n0 = (SimpleNode)n.jjtGetChild(1);\r
+ if(n0.toString().equals("expression")) {\r
+ Variable variable = (Variable)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ IExpression expression2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ return new Statement(variable, variable.subscripts, expression2);\r
+ } else if (n0.toString().equals("function_call_args")) {\r
+ throw new IllegalStateException();\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ } else if (n.jjtGetNumChildren() == 3) {\r
+ ArrayList<Variable> vars = (ArrayList<Variable>)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ Variable fn = (Variable)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ ArgumentList args = (ArgumentList)walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
+ return new MultiStatement(vars, fn, args);\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ case output_expression_list:\r
+ ArrayList<Variable> vars = new ArrayList<Variable>();\r
+ for(int i=0;i<n.jjtGetNumChildren();i++) {\r
+ vars.add((Variable)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
+ }\r
+ return vars;\r
case name:\r
return n.op;\r
case element_list:\r
ArrayList<Object> elements = new ArrayList<Object>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- elements.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ elements.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return elements;\r
+ case element:\r
+// if("inner".equals(n.op)) {\r
+// return null;\r
+// } else {\r
+ return walk((SimpleNode)n.jjtGetChild(0),indent+2, frame);\r
+// }\r
case element_modification:\r
if(n.jjtGetNumChildren() == 2) {\r
- String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- IExpression modification = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+ String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ IExpression modification = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
return new Argument(name, modification);\r
}\r
break;\r
case function_arguments:\r
- ArgumentList arguments = new ArgumentList();\r
+ //ArgumentList arguments = new ArgumentList(n.op);\r
+ \r
+ ArrayList<Argument> arguments = new ArrayList<Argument>();\r
+ \r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- Object o = walk((SimpleNode)n.jjtGetChild(i),indent+2, model);\r
+ Object o = walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
if(o instanceof ArgumentList) {\r
- arguments.args.addAll(((ArgumentList)o).args);\r
+ for(Argument a : ((ArgumentList)o).args)\r
+ arguments.add(a);\r
} else if (o instanceof IExpression) {\r
- arguments.args.add(new Argument("", (IExpression)o));\r
+ arguments.add(new Argument("", (IExpression)o));\r
+ } else if (o instanceof ArrayList) {\r
+ ArrayList list = (ArrayList)o;\r
+ for(Object o2 : list) {\r
+ if(o2 instanceof Argument) {\r
+ arguments.add((Argument)o2);\r
+ } else if (o2 instanceof ForIndex) {\r
+ ForIndex fi = (ForIndex)o2;\r
+ arguments.add(new Argument(fi.name, fi.expression));\r
+ }\r
+ }\r
} else {\r
return null;\r
}\r
}\r
- return arguments;\r
+ return new ArgumentList(arguments, n.op);\r
case argument_list:\r
ArrayList<Argument> args = new ArrayList<Argument>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- args.add((Argument)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ args.add((Argument)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return new ArgumentList(args);\r
case type_prefix:\r
case algorithm_section:\r
ArrayList<IStatement> statements = new ArrayList<IStatement>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- statements.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ statements.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return new StatementList(statements);\r
case subscript:\r
if(n.jjtGetNumChildren() == 0)\r
return new Constant("-1.0");\r
if(n.jjtGetNumChildren() == 1)\r
- return walk((SimpleNode)n.jjtGetChild(0),indent+2, model);\r
+ return walk((SimpleNode)n.jjtGetChild(0),indent+2, frame);\r
throw new IllegalStateException();\r
case subscript_2:\r
throw new IllegalStateException();\r
case component_clause:\r
- String type_prefix = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- String type_specifier = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
- Object third = walk((SimpleNode)n.jjtGetChild(2), indent+2, model);\r
+ String type_prefix = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ String type_specifier = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ Object third = walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
IExpression[] subscripts = (third instanceof IExpression[])? (IExpression[])third : null;\r
int declarationStart = (third instanceof IExpression[]) ? 3 : 2;\r
ArrayList<Object> clauses = new ArrayList<Object>();\r
for(int i=declarationStart;i<n.jjtGetNumChildren();i++) {\r
- Declaration decl = (Declaration)walk((SimpleNode)n.jjtGetChild(i), indent+2, model);\r
+ \r
+ Declaration decl = (Declaration)walk((SimpleNode)n.jjtGetChild(i), indent+2, frame);\r
if(subscripts != null)\r
decl.variable.subscripts = subscripts;\r
+ \r
if("parameter".equals(type_prefix)) {\r
+ \r
ParameterDeclaration pd = new ParameterDeclaration(decl.variable, (IExpression)decl.modification);\r
model.parameters.add(pd);\r
clauses.add(pd);\r
+ \r
} else {\r
- if(decl.modification instanceof ArgumentList) {\r
- VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, (ArgumentList)decl.modification);\r
- if(currentFrame == model) model.variables.add(vd);\r
- clauses.add(vd);\r
- } else {\r
- VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, new ArgumentList(new ArrayList<Argument>()));\r
- if(currentFrame == model) model.variables.add(vd);\r
- clauses.add(vd);\r
+ \r
+ boolean wasClass = model == null ? false : model.instantiateClass(type_specifier, decl, frame);\r
+ if(!wasClass) {\r
+ \r
+ if(decl.modification instanceof ArgumentList) {\r
+ VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, (ArgumentList)decl.modification);\r
+ if(model != null)\r
+ model.addVariable(vd);\r
+ clauses.add(vd);\r
+ } else if (decl.modification instanceof IExpression) {\r
+ ArrayList<Argument> as = new ArrayList<Argument>();\r
+ as.add(new Argument("", (IExpression)decl.modification));\r
+ ArgumentList al = new ArgumentList(as);\r
+ VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, al);\r
+ if(model != null)\r
+ model.addVariable(vd);\r
+ clauses.add(vd);\r
+ } else {\r
+ VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, new ArgumentList(new ArrayList<Argument>()));\r
+ if(model != null)\r
+ model.addVariable(vd);\r
+ clauses.add(vd);\r
+ }\r
+ \r
}\r
+ \r
}\r
}\r
return clauses;\r
case component_declaration:\r
- return (Declaration)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ return (Declaration)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
case array_subscripts:\r
IExpression[] subs = new IExpression[n.jjtGetNumChildren()];\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- subs[i] = (IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, model);\r
+ subs[i] = (IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
}\r
return subs;\r
case declaration:\r
if(n.jjtGetNumChildren() == 0) {\r
- return new Declaration(new Variable(currentFrame, n.op, null), null);\r
+ return new Declaration(new Variable(frame, n.op, null), null);\r
} else if(n.jjtGetNumChildren() == 1) {\r
- Object o = walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ Object o = walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
if(o instanceof IExpression[]) {\r
- return new Declaration(new Variable(currentFrame, n.op, (IExpression[])o), null);\r
+ return new Declaration(new Variable(frame, n.op, (IExpression[])o), null);\r
} else {\r
- return new Declaration(new Variable(currentFrame, n.op, null), o);\r
+ return new Declaration(new Variable(frame, n.op, null), o);\r
}\r
} else if(n.jjtGetNumChildren() == 2) {\r
- IExpression[] subscripts2 = (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- Object modification = walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
- return new Declaration(new Variable(currentFrame, n.op,subscripts2), modification);\r
+ IExpression[] subscripts2 = (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ Object modification = walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ return new Declaration(new Variable(frame, n.op,subscripts2), modification);\r
} else {\r
StringBuilder b = new StringBuilder();\r
b.append("declaration: ");\r
String functionName = child.op;\r
ArrayList<IStatement> stms2 = new ArrayList<IStatement>();\r
Function function = new Function(functionName, new StatementList(stms2));\r
- currentFrame = function;\r
- ArrayList<Object> composition = (ArrayList<Object>)walk(child, indent+2, model);\r
+ ArrayList<Object> composition = (ArrayList<Object>)walk(child, indent+2, function);\r
for(int i=1;i<composition.size();i++) {\r
Object comp = composition.get(i);\r
if(comp instanceof IStatement) {\r
} else if(comp instanceof ArrayList) {\r
ArrayList<Object> declarations = (ArrayList<Object>)composition.get(i);\r
for(Object os_ : declarations) {\r
- ArrayList<Object> os = (ArrayList<Object>)os_;\r
- for(Object o : os) {\r
- VariableDeclaration decl = (VariableDeclaration)o;\r
- function.internals.add(decl);\r
+ if(os_ instanceof VariableDeclaration) {\r
+ VariableDeclaration decl = (VariableDeclaration)os_;\r
+ if("input".equals(decl.direction)) function.inputs.add(decl);\r
+ else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
+ else throw new IllegalStateException();\r
+ } else {\r
+ ArrayList<Object> os = (ArrayList<Object>)os_;\r
+ for(Object o : os) {\r
+ VariableDeclaration decl = (VariableDeclaration)o;\r
+ function.internals.add(decl);\r
+ }\r
}\r
}\r
}\r
}\r
ArrayList<Object> declarations = (ArrayList<Object>)composition.get(0);\r
for(Object os_ : declarations) {\r
- ArrayList<Object> os = (ArrayList<Object>)os_;\r
- for(Object o : os) {\r
- VariableDeclaration decl = (VariableDeclaration)o;\r
+ if(os_ instanceof VariableDeclaration) {\r
+ VariableDeclaration decl = (VariableDeclaration)os_;\r
if("input".equals(decl.direction)) function.inputs.add(decl);\r
else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
else throw new IllegalStateException();\r
+ } else {\r
+ ArrayList<Object> os = (ArrayList<Object>)os_;\r
+ for(Object o : os) {\r
+ VariableDeclaration decl = (VariableDeclaration)o;\r
+ if("input".equals(decl.direction)) function.inputs.add(decl);\r
+ else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
+ else throw new IllegalStateException();\r
+ }\r
}\r
}\r
model.functions.put(functionName, function);\r
- currentFrame = model;\r
return function;\r
+ \r
+ } else if("model".equals(n.op)) {\r
+\r
+ if(n.jjtGetNumChildren() == 1) {\r
+ return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ } else {\r
+ System.err.println("undefined children for class_definition model"); \r
+ }\r
+ return null;\r
+ \r
+ } else if("class".equals(n.op)) {\r
+ \r
+ SimpleNode specifier = (SimpleNode)n.jjtGetChild(0); \r
+ Model clazz = new Model(model.globals, specifier.op, false);\r
+ model.globals.classes.put(specifier.op, clazz);\r
+ walk(specifier, indent+2, clazz);\r
+ \r
+ if(clazz.isEnumClass) {\r
+ Variable sizeVariable = new Variable(clazz, "size", null);\r
+ Variable elementsVariable = new Variable(clazz, "elements", new IExpression[] { new Constant(""+clazz.variables.size()) });\r
+ clazz.parameters.add(new ParameterDeclaration(sizeVariable, sizeVariable.getPossibleConstant()));\r
+ clazz.parameters.add(new ParameterDeclaration(elementsVariable, elementsVariable.getPossibleConstant()));\r
+ }\r
+ \r
+ return null;\r
+ \r
+ } else {\r
+ System.err.println("class_definition " + n.op);\r
}\r
break;\r
case array:\r
- Array array = new Array();\r
if(n.jjtGetNumChildren() == 1) {\r
- ArgumentList al = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- for(Argument arg : al.args) array.addElement(arg.modification);\r
+ ArgumentList al = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ if("for".equals(al.op)) {\r
+ ForArray array = new ForArray();\r
+ array.addElement(al.args[0].modification);\r
+ array.addElement(al.args[1]);\r
+ return array;\r
+ } else {\r
+ Array array = new Array();\r
+ for(Argument arg : al.args) array.addElement(arg.modification);\r
+ return array;\r
+ }\r
}\r
- return array;\r
case primary:\r
if(n.op != null) {\r
return Utils.parsePrimitive(n.op);\r
} else {\r
- return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
}\r
case component_reference:\r
if(n.jjtGetNumChildren() == 1) {\r
- return new Variable(currentFrame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, model));\r
+ return Variable.make(frame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame));\r
} else {\r
if ("time".equals(n.op)) {\r
return new TimeVariable();\r
}\r
- return new Variable(currentFrame, n.op, null);\r
+ return Variable.make(frame, n.op, null);\r
}\r
case relation:\r
if(n.jjtGetNumChildren() == 3) {\r
- IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- String op = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
- IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, model);\r
+ IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ String op = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
String trimmed = op != null ? op.trim() : null;\r
if("<".equals(trimmed)) {\r
return new LessThan(exp1, exp2);\r
}\r
else return null;\r
} else {\r
- return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
}\r
case simple_expression:\r
- if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
else if(n.jjtGetNumChildren() == 2) {\r
- IExpression start = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model); \r
- IExpression end = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+ IExpression start = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame); \r
+ IExpression end = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
return new ArraySliceExpression(start, end);\r
} else {\r
throw new UnsupportedOperationException();\r
if(n.jjtGetNumChildren() > 1) {\r
ArrayList<IExpression> logs = new ArrayList<IExpression>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- logs.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ logs.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return new Or(logs);\r
} else {\r
- return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
}\r
case logical_term:\r
if(n.jjtGetNumChildren() > 1) {\r
ArrayList<IExpression> terms = new ArrayList<IExpression>();\r
for(int i=0;i<n.jjtGetNumChildren();i++) {\r
- terms.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+ terms.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
}\r
return new And(terms);\r
} else {\r
- return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
}\r
case arithmetic_expression:\r
- if(n.jjtGetNumChildren() == 2) {\r
+ {\r
+ int i=0;\r
+ IExpression left;\r
+ if(n.jjtGetNumChildren() % 2 == 0) {\r
String op = ((String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model)).trim();\r
- if("-".equals(op)) return new Negation((IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model));\r
- }\r
- if(n.jjtGetNumChildren() > 1) {\r
- IExpression left = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- for(int i=1;i<n.jjtGetNumChildren();i+=2) {\r
- String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
- IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, model);\r
- if("+".equals(op)) left = new Addition(left, exp2);\r
- else if("-".equals(op)) left = new Subtraction(left, exp2);\r
+ left = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ if("-".equals(op)) {\r
+ left = new Negation(left);\r
}\r
- return left;\r
+ i=2;\r
} else {\r
- return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ left = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ i=1;\r
+ }\r
+\r
+ for(;i<n.jjtGetNumChildren();i+=2) {\r
+ String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
+ IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, frame);\r
+ if("+".equals(op)) left = new Addition(left, exp2);\r
+ else if("-".equals(op)) left = new Subtraction(left, exp2);\r
}\r
+\r
+ return left;\r
+ }\r
+ \r
case term:\r
if(n.jjtGetNumChildren() > 1) {\r
- IExpression term = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ IExpression term = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
for(int i=1;i<n.jjtGetNumChildren();i+=2) {\r
String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
- IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, model);\r
+ IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, frame);\r
if("*".equals(op)) term = new Multiplication(term, exp2);\r
+ else if(".*".equals(op)) term = new ElementwiseProduct(term, exp2);\r
else if("/".equals(op)) term = new Division(term, exp2);\r
}\r
return term;\r
} else {\r
- return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+ return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
}\r
case if_expression:\r
if(n.jjtGetNumChildren() == 3) {\r
- IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
- IExpression exp3 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, model);\r
+ IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ IExpression exp3 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
return new IfThenElse(exp1, exp2, exp3);\r
}\r
case add_op:\r
return n.op;\r
case der_initial:\r
if("der".equals(n.op)) {\r
- ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- if(args2.args.size() == 1) {\r
- return new Derivative((Variable)args2.args.get(0).modification);\r
+ ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ if(args2.args.length == 1) {\r
+ return new Derivative((Variable)args2.args[0].modification);\r
}\r
} else if("initial".equals(n.op)) {\r
- return new Application("initial", new ArgumentList());\r
+ return new Application("initial", new ArgumentList(""));\r
} else if("application".equals(n.op)) {\r
- String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
- ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+ String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
return new Application(name, args2);\r
}\r
+ case extends_clause:\r
+ String extendsName = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+ walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+ model.isEnumClass = extendsName.equals("Enumeration_class");\r
+ return null;\r
}\r
\r
+ System.err.println("fall-through " + n);\r
+ \r
// should not get this far\r
return null;\r
}\r
\r
+ public static final boolean WAIT = false;\r
+ \r
+ public static void main(String[] args) throws Exception {\r
+ \r
+ if(WAIT) {\r
+ for(int i=0;i<1e12;i++) {\r
+ int k = System.in.read();\r
+ if(k==13) break;\r
+ Thread.sleep(10);\r
+ }\r
+ }\r
+ \r
+// NodeCache cache = new NodeCache();\r
+//\r
+//// long start = System.nanoTime();\r
+//\r
+// File f = new File("C:/Users/Antti Villberg/Downloads/isomalli.txt");\r
+// String contents = FileUtils.getContents(f);\r
+// LineReader reader = new LineReader(contents, cache);\r
+// reader.parse();\r
+//\r
+//// long duration = System.nanoTime()-start;\r
+//// System.err.println("complete parse file in " + 1e-9*duration + "s.");\r
+//\r
+//// start = System.nanoTime();\r
+//\r
+// if(WAIT) {\r
+// for(int i=0;i<1e12;i++) {\r
+// int k = System.in.read();\r
+// if(k==13) break;\r
+// Thread.sleep(10);\r
+// }\r
+// }\r
+\r
+ \r
+\r
+ \r
+ File f1 = new File("d:/sysdynfn.txt");\r
+ String contents1 = FileUtils.getContents(f1);\r
+ File f2 = new File("d:/sysdyntest.txt");\r
+ String contents2 = contents1 + FileUtils.getContents(f2);\r
+ \r
+ StringReader reader = new StringReader(contents2);\r
+ ModelParser modelParser = new ModelParser(reader);\r
+ SimpleNode n = (SimpleNode)modelParser.stored_definition();\r
+ Parser parser = new Parser();\r
+ Model m = new Model(new Globals(), "", false);\r
+ parser.walk(n, 0, m);\r
+ \r
+ m.prettyPrint();\r
+ \r
+ Solver solver = new Solver();\r
+ solver.prepare(contents2);\r
+ \r
+//\r
+// if(WAIT) {\r
+// for(int i=0;i<1e12;i++) {\r
+// int k = System.in.read();\r
+// if(k==13) break;\r
+// Thread.sleep(10);\r
+// }\r
+// }\r
+//\r
+// long start = System.nanoTime();\r
+ for(int i=0;i<50;i++) {\r
+ solver.step();\r
+ solver.printEnvironment();\r
+ }\r
+// long duration = System.nanoTime()-start;\r
+// System.err.println("stepped simulation in " + 1e-9*duration + "s.");\r
+ \r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.io.StringReader;\r
import java.util.ArrayList;\r
-import java.util.HashMap;\r
+\r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
+import fi.semantum.sysdyn.solver.parser.ModelParser;\r
+import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
\r
public class Solver {\r
\r
}\r
\r
public void prepare(String input) throws Exception {\r
- LineReader reader = new LineReader(input, cache);\r
- reader.parse();\r
\r
- model = reader.model;\r
+ long startNanos = System.nanoTime();\r
+ \r
+// LineReader reader = new LineReader(input, cache);\r
+// reader.parse();\r
+// \r
+// model = reader.model;\r
+ \r
+ StringReader reader = new StringReader(input);\r
+ ModelParser modelParser = new ModelParser(reader);\r
+ SimpleNode n = (SimpleNode)modelParser.stored_definition();\r
+ Parser parser = new Parser();\r
+ model = new Model(new Globals(), "", false);\r
+ parser.walk(n, 0, model);\r
+ \r
env = new Environment(model, step, start);\r
\r
int size = model.prepare();\r
+ env.setSize(size);\r
\r
for(Fn fn : model.functions.values()) {\r
if(fn instanceof Function)\r
\r
model.assignmentArray = model.assignments.toArray(new Assignment[model.assignments.size()]);\r
model.derivativeArray = model.derivatives.toArray(new Assignment[model.derivatives.size()]);\r
+ model.parameterArray = model.parameters.toArray(new ParameterDeclaration[model.parameters.size()]);\r
\r
newValues = new Object[Math.max(model.assignments.size(),model.derivatives.size())];\r
\r
- int koss = 1;\r
+ int condition = 1;\r
+ int loops = 0;\r
\r
- while(koss > 0) {\r
+ while(condition > 0 && loops++ < 50) {\r
\r
- koss = 0;\r
+// System.err.println("== LOOP " + loops + " ==");\r
+ \r
+ condition = 0;\r
\r
for(ParameterDeclaration pd : model.parameters) {\r
try {\r
if(!pd.assigned) {\r
- pd.variable.assign(env, pd.modification.evaluate(env));\r
+ pd.variable.assign(env, null, pd.modification.evaluate(env));\r
pd.assigned = true;\r
}\r
} catch (Exception e) {\r
- koss++;\r
+ condition++;\r
if(PRINT_EXCEPTIONS) {\r
e.printStackTrace();\r
System.err.println("failed to assign " + pd.variable.toString());\r
try {\r
if(!vd.assigned) {\r
for(Argument arg : vd.modification.args) {\r
- if("start".equals(arg.name)) {\r
+ if(arg.name.endsWith("start")) {\r
Object value = arg.modification.evaluate(env);\r
- vd.variable.assign(env, value);\r
+ if(vd.variable.base.dimension() == 1) {\r
+ vd.variable.assign(env, null, value);\r
+ } else {\r
+ if(value instanceof Double) {\r
+ Array array = new Array();\r
+ for(int i=0;i<vd.variable.base.dimension();i++) array.addElement(value);\r
+ vd.variable.assign(env, null, array);\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
// make sure the variable is not initialized \r
// twice, this is probably not the most \r
// efficient way\r
}\r
}\r
}\r
- vd.assigned = true;\r
}\r
} catch (Exception e) {\r
- koss++;\r
+ condition++;\r
if(PRINT_EXCEPTIONS) {\r
e.printStackTrace();\r
System.err.println("failed to assign " + vd.variable.toString());\r
try {\r
if(!ass.assigned) {\r
Object value = ass.expression.evaluate(env);\r
- ass.target.assign(env, value);\r
+ ass.target.assign(env, ass.subscripts, value);\r
ass.assigned = true;\r
}\r
} catch (Exception e) {\r
- koss++;\r
+ condition++;\r
if(PRINT_EXCEPTIONS) {\r
e.printStackTrace();\r
System.err.println("failed to assign " + ass.target.toString());\r
env.initial = false;\r
\r
ready = true;\r
+ \r
+ long endNanos = System.nanoTime();\r
+ \r
+ System.err.println("Prepared model in " + 1e-6*(endNanos-startNanos) + "ms.");\r
+ \r
+ }\r
+ \r
+ public String[] keys() {\r
+ return env.getValueKeyArray();\r
}\r
\r
- public HashMap<String, Double> values() {\r
- return env.getValueMap();\r
+ public double[] values() {\r
+ return env.getValueArray();\r
}\r
\r
public void step() {\r
newValues[i] = assignments[i].expression.evaluate(env);\r
}\r
for(int i=0;i<model.assignments.size();i++) {\r
- assignments[i].target.assign(env, newValues[i]);\r
+ assignments[i].target.assign(env, assignments[i].subscripts, newValues[i]);\r
}\r
\r
// Solve derivatives\r
newValues[i] = derivatives[i].expression.evaluate(env);\r
}\r
for(int i=0;i<model.derivatives.size();i++) {\r
- derivatives[i].target.assign(env, newValues[i]);\r
+ derivatives[i].target.assign(env, assignments[i].subscripts, newValues[i]);\r
}\r
}\r
\r
// TODO: implement some on the fly parameter change stuff for different experiment types\r
\r
+ public void printEnvironment() {\r
+ String[] keys = keys();\r
+ double[] values = values();\r
+ System.err.println("Environment " + keys.length + " " + values.length);\r
+ for(int i=0;i<keys.length;i++) {\r
+ System.err.println(keys[i] + " = " + values[i]);\r
+ }\r
+ }\r
+ \r
}\r
--- /dev/null
+package fi.semantum.sysdyn.solver;\r
+\r
+public class SolverUtils {\r
+\r
+ public static class Slice {\r
+ public static final Slice FULL = new Slice(-2,-1);\r
+ public int start;\r
+ public int end;\r
+ public Slice(int start, int end) {\r
+ this.start = start;\r
+ this.end = end;\r
+ }\r
+ }\r
+ \r
+ public static boolean isFullSubscript(IExpression[] subscripts) {\r
+ if(subscripts == null) return true;\r
+ for(int i=0;i<subscripts.length;i++) {\r
+ if(subscripts[i] instanceof Constant) {\r
+ Constant c = (Constant)subscripts[i];\r
+ if(c.value instanceof Double) {\r
+ Double d = (Double)c.value;\r
+ if(d == -1.0) continue;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ public static boolean isArray(int[] dimensions) {\r
+ return dimensions != null && dimensions != VariableBase.UNINIT;\r
+ }\r
+ \r
+ public static Slice[] parseSubscripts(IEnvironment env, IExpression[] subscripts) {\r
+ Slice[] result = new Slice[subscripts.length];\r
+ for(int i=0;i<subscripts.length;i++) {\r
+ IExpression e = subscripts[i];\r
+ if(e instanceof ArraySliceExpression) {\r
+ ArraySliceExpression ase = (ArraySliceExpression)e;\r
+ Double start = (Double)ase.start.evaluate(env);\r
+ Double end = (Double)ase.end.evaluate(env);\r
+ result[i] = new Slice(start.intValue(), end.intValue());\r
+ } else {\r
+ Double v = (Double)e.evaluate(env);\r
+ int index = v.intValue()-1;\r
+ if(index == -2) result[i] = Slice.FULL;\r
+ else result[i] = new Slice(index,index);\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ public static boolean isSlice(Slice[] subs) {\r
+ for(Slice s : subs) {\r
+ if(s.start != s.end) return true;\r
+ }\r
+ return false;\r
+ }\r
+ \r
+}\r
public class Statement implements IStatement {\r
\r
public Variable target;\r
+ public IExpression[] subscripts;\r
public IExpression expression;\r
\r
- public Statement(Variable target, IExpression expression) {\r
+ public Statement(Variable target, IExpression[] subscripts, IExpression expression) {\r
this.target = target;\r
+ this.subscripts = subscripts;\r
this.expression = expression;\r
}\r
\r
@Override\r
public void evaluate(IEnvironment environment) {\r
Object value = expression.evaluate(environment);\r
- target.assign(environment, value);\r
+ target.assign(environment, subscripts, value);\r
}\r
\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class Subtraction implements IExpression {\r
\r
public IExpression exp1;\r
public IExpression exp2;\r
\r
public Subtraction(IExpression exp1, IExpression exp2) {\r
+ if(exp1 == null) exp1 = new Constant("0");\r
this.exp1 = exp1;\r
this.exp2 = exp2;\r
}\r
public Object evaluate(IEnvironment environment) {\r
return ((Double)exp1.evaluate(environment)) - ((Double)exp2.evaluate(environment));\r
}\r
+ \r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return new Subtraction(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
\r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ exp1 = exp1.rewrite(frame, copies);\r
+ exp2 = exp2.rewrite(frame, copies);\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
public class TimeVariable implements IExpression {\r
\r
@Override\r
return "time";\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ return this;\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ return this;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
+\r
+\r
public class Variable implements IExpression {\r
\r
public VariableBase base;\r
this.subscripts = subscripts;\r
}\r
\r
+ public static Object make(IFrame frame, String name, IExpression[] subscripts) {\r
+// Array enumElements = enumerationElements(frame, name);\r
+// if(enumElements != null) return enumElements;\r
+// Constant enumSize = enumerationSize(frame, name);\r
+// if(enumSize != null) return enumSize;\r
+ return new Variable(frame, name, subscripts);\r
+ }\r
+ \r
public Variable(VariableBase base) {\r
this.base = base;\r
}\r
\r
- private int makeSubscriptIndex(IEnvironment env) {\r
- if(base.dimensions == null) return 0;\r
- int result = 0;\r
- for(int i=0;i<subscripts.length;i++) {\r
- int factor = 1;\r
- for(int j=i+1;j<subscripts.length;j++) factor *= base.dimensions[j];\r
- IExpression e = subscripts[i];\r
- Double v = (Double)e.evaluate(env);\r
- int index = v.intValue()-1;\r
- if(index == -2) return 0;\r
- result += factor*index;\r
- }\r
- if(result == -1) throw new IllegalStateException();\r
- return result;\r
-\r
- }\r
- \r
- public int subscriptIndex(IEnvironment env) {\r
- if(subscripts == null) return 0;\r
- return makeSubscriptIndex(env);\r
+ public Variable(VariableBase base, IExpression[] subscripts) {\r
+ this.base = base;\r
+ this.subscripts = subscripts;\r
}\r
\r
@Override\r
str.append(", ");\r
}\r
// is the expression inside subscript always a constant?\r
- str.append(((Double)((Constant)subscripts[i]).value).intValue());\r
+ Object sub = subscripts[i];\r
+ if(sub instanceof Constant) {\r
+ str.append(((Double)((Constant)sub).value).intValue());\r
+ } else if (sub instanceof Variable) {\r
+ str.append(((Variable)sub).base.name);\r
+ }\r
}\r
str.append(']');\r
return str.toString();\r
\r
public int assignArray(IEnvironment env, int index, Array value, int asd) {\r
for(int i=0;i<value.elements().size();i++) {\r
-// String s = name + "_" + (i+1);\r
Object element = value.element(i);\r
if(element instanceof Double) {\r
env.put(index+asd++, (Double)element);\r
return asd;\r
}\r
\r
- public int index(IEnvironment env) {\r
- return base.index + subscriptIndex(env);\r
- }\r
- \r
public void setArrayIndex(IEnvironment environment, Array array, Object value) {\r
\r
for(int i=0;i<subscripts.length-1;i++) {\r
\r
}\r
\r
- public Object getArrayIndex(IEnvironment environment, Array array) {\r
- Object result = array;\r
- for(IExpression e : subscripts) {\r
- int index = Utils.getIndex(e.evaluate(environment));\r
- result = ((Array)result).element(index);\r
- }\r
- if(result instanceof IExpression) {\r
- IExpression exp = (IExpression)result;\r
- return exp.evaluate(environment);\r
- }\r
- return result;\r
- }\r
-\r
public void assignPlain(IEnvironment env, Object value) {\r
env.put(base.index, value);\r
}\r
\r
- public void assign(IEnvironment env, Object value) {\r
+ private void validateSize(IEnvironment env, IExpression[] subscripts, Object value) {\r
+ \r
+ if(base.isStoredAsArray()) return;\r
+ \r
+ int fullDimension = base.dimension();\r
+ if(fullDimension == 1) {\r
+ if(!(value instanceof Double)) {\r
+ Array arr = (Array)value;\r
+ if(arr.size(0) != 1)\r
+ throw new IllegalStateException();\r
+ }\r
+ } else {\r
+ if(subscripts == null) {\r
+ if(!(value instanceof Array))\r
+ throw new IllegalStateException();\r
+ Array arr = (Array)value;\r
+ int arrDim = arr.dimension();\r
+ if(arrDim != fullDimension)\r
+ throw new IllegalStateException();\r
+ } else {\r
+ if(value instanceof Array) {\r
+ Array arr = (Array)value;\r
+ if(!arr.validateDimensions(base.dimensions, 0))\r
+ throw new IllegalStateException();\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ }\r
+ \r
+ \r
+ }\r
+ \r
+ public void assign(IEnvironment env, IExpression[] subscripts, Object value) {\r
+ \r
+ validateSize(env, subscripts, value);\r
+ \r
if(value instanceof Array) {\r
if(base.isStoredAsArray()) {\r
- env.put(index(env), value);\r
+ env.put(base.index(env, subscripts), value);\r
} else {\r
- assignArray(env, index(env), (Array)value, 0);\r
+ assignArray(env, base.index(env, subscripts), (Array)value, 0);\r
}\r
} else {\r
if(base.isStoredAsArray()) {\r
}\r
setArrayIndex(env, existing, value);\r
} else {\r
- env.put(index(env), value);\r
+ env.put(base.index(env, subscripts), value);\r
}\r
}\r
}\r
\r
@Override\r
public Object evaluate(IEnvironment environment) {\r
- if(base.isStoredAsArray()) {\r
- Array array = (Array)environment.getValue(base.index);\r
- if(hasScalarSubscript()) {\r
- Object o = getArrayIndex(environment, array);\r
- if(o instanceof Variable) throw new IllegalStateException();\r
- return o;\r
- }\r
- else return array;\r
+ return base.evaluate(environment, subscripts);\r
+ }\r
+\r
+ \r
+// static Array enumerationElements(IFrame frame, String name) {\r
+// if(!name.endsWith(".elements")) return null;\r
+// String prefix = name.replace(".elements", "");\r
+// Model m = frame.getClass(prefix + "_class");\r
+// if(m == null) return null;\r
+// Array result = new Array();\r
+// for(VariableDeclaration vd : m.variables) {\r
+// Constant c = (Constant)vd.modification.args.get(0).modification;\r
+// result.addElement(c.value);\r
+// }\r
+// return result;\r
+// }\r
+// \r
+// static Constant enumerationSize(IFrame frame, String name) {\r
+// if(!name.endsWith(".size")) return null;\r
+// String prefix = name.replace(".size", "");\r
+// Model m = frame.getClass(prefix + "_class");\r
+// if(m == null) return null;\r
+// return new Constant("" + m.variables.size());\r
+// }\r
+\r
+ public Variable withBase(IFrame frame, String prefix) {\r
+ \r
+ if(subscripts != null) {\r
+ IExpression[] subscripts2 = new IExpression[subscripts.length];\r
+ for(int i=0;i<subscripts.length;i++)\r
+ subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
+ return new Variable(frame.getBase(base, prefix), subscripts2);\r
} else {\r
- Object result = environment.getValue(index(environment)); \r
- if(result == null) throw new UnassignedVariableException("No value for " + base.name);\r
- return result;\r
+ return new Variable(frame.getBase(base, prefix), null);\r
}\r
}\r
+ \r
+ @Override\r
+ public IExpression getPossibleConstant() {\r
+ return base.getPossibleConstant();\r
+ }\r
\r
- private boolean hasScalarSubscript() {\r
- if(subscripts == null) return false;\r
- else return true;\r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ VariableBase copy = copies.get(base.name);\r
+ if(copy == null) {\r
+ if(subscripts != null) {\r
+ for(int i=0;i<subscripts.length;i++)\r
+ subscripts[i] = subscripts[i].rewrite(frame, copies);\r
+ }\r
+ return this;\r
+ }\r
+\r
+ return new Variable(frame.getBase(copy.name), subscripts).rewrite(frame, copies);\r
+ \r
}\r
\r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Arrays;\r
+\r
+import fi.semantum.sysdyn.solver.SolverUtils.Slice;\r
+\r
public class VariableBase {\r
+\r
+ static final int[] UNINIT = new int[0];\r
\r
public String name;\r
public int index;\r
- public int[] dimensions;\r
+ public int[] dimensions = UNINIT;\r
public VariableBase(String name) {\r
this.name = name;\r
}\r
this.name = name;\r
this.index = index;\r
}\r
- public void tellSubscripts(IExpression[] e) {\r
- if(e == null) return;\r
- if(dimensions == null) \r
- dimensions = new int[e.length];\r
- for(int i=0;i<e.length;i++) {\r
- if(!(e[i] instanceof Constant)) {\r
- dimensions[i] = -1;\r
- } else {\r
- Constant c = (Constant)e[i];\r
- int index = ((Double)c.value).intValue();\r
- if(index == -1) dimensions[i] = -1;\r
- else if(index > dimensions[i]) dimensions[i] = index;\r
+ public VariableBase(String name, int index, int[] dimensions) {\r
+ this.name = name;\r
+ this.index = index;\r
+ this.dimensions = dimensions;\r
+ }\r
+ public boolean tellSubscripts(IExpression[] e, IExpression modification) {\r
+ \r
+ if(dimensions != UNINIT) return true;\r
+ \r
+ if(e != null) {\r
+ \r
+ if(dimensions == UNINIT) \r
+ dimensions = new int[e.length];\r
+ \r
+ if(e.length == 0)\r
+ throw new IllegalStateException();\r
+ \r
+ for(int i=0;i<e.length;i++) {\r
+ \r
+ IExpression exp = e[i];\r
+ Object constant = exp.getPossibleConstant();\r
+ if(constant != null) exp = (IExpression)constant;\r
+ \r
+ if(!(exp instanceof Constant)) {\r
+ dimensions[i] = -1;\r
+ } else {\r
+ Constant c = (Constant)exp;\r
+ int index = ((Double)c.value).intValue();\r
+ if(index == -1) {\r
+ if(modification instanceof Array) {\r
+ Array array = (Array)modification;\r
+ dimensions[i] = array.size(i);\r
+ } else {\r
+ dimensions[i] = -1;\r
+ }\r
+ }\r
+ else if(index > dimensions[i]) dimensions[i] = index;\r
+ }\r
}\r
+ \r
+ } else {\r
+ \r
+ dimensions = null;\r
+ \r
}\r
+ \r
+ return dimensions != UNINIT;\r
+ \r
}\r
public int dimension() {\r
if(dimensions == null) return 1;\r
for(int d : dimensions) if(d == -1) return true;\r
return false;\r
}\r
+ \r
+ VariableBase withBase(String prefix) {\r
+ return new VariableBase(prefix+name, index, dimensions);\r
+ }\r
+\r
+ private int makeSubscriptIndex(IEnvironment env, IExpression[] subscripts) {\r
+ if(dimensions == null) return 0;\r
+ int result = 0;\r
+ for(int i=0;i<subscripts.length;i++) {\r
+ int factor = 1;\r
+ for(int j=i+1;j<subscripts.length;j++) factor *= dimensions[j];\r
+ IExpression e = subscripts[i];\r
+ Double v = (Double)e.evaluate(env);\r
+ int index = v.intValue()-1;\r
+ if(index == -2) return 0;\r
+ result += factor*index;\r
+ }\r
+ if(result == -1) throw new IllegalStateException();\r
+ return result;\r
+ }\r
+ \r
+ public int subscriptIndex(IEnvironment env, IExpression[] subscripts) {\r
+ if(subscripts == null) return 0;\r
+ return makeSubscriptIndex(env, subscripts);\r
+ }\r
+ \r
+ public int index(IEnvironment env, IExpression[] subscripts) {\r
+ return index + subscriptIndex(env, subscripts);\r
+ }\r
+ \r
+ public Object getArrayIndex(IEnvironment environment, IExpression[] subscripts, Array array) {\r
+ Object result = array;\r
+ for(IExpression e : subscripts) {\r
+ int index = Utils.getIndex(e.evaluate(environment));\r
+ result = ((Array)result).element(index);\r
+ }\r
+ if(result instanceof IExpression) {\r
+ IExpression exp = (IExpression)result;\r
+ return exp.evaluate(environment);\r
+ }\r
+ if(result instanceof Array)\r
+ throw new IllegalStateException();\r
+ return result;\r
+ }\r
+ \r
+ private boolean hasScalarSubscript(IExpression[] subscripts) {\r
+ if(subscripts == null) return false;\r
+ else return true;\r
+ }\r
+ \r
+ public int intoArray(IEnvironment env, int index, int d, Array target) {\r
+\r
+ if(d == dimensions.length-1) {\r
+ for(int i=0;i<dimensions[d];i++) {\r
+ Object value = env.getValue(index);\r
+ if(value == null) {\r
+ throw new UnassignedVariableException("No value for " + name);\r
+ }\r
+ target.addElement(value);\r
+ index++;\r
+ }\r
+ return index;\r
+ }\r
+ \r
+ for(int i=0;i<dimensions[d];i++) {\r
+ Array array = new Array();\r
+ index = intoArray(env, index, d+1, array);\r
+ target.addElement(array);\r
+ }\r
+ \r
+ return index;\r
+ \r
+ }\r
+ \r
+ public Object evaluate(IEnvironment environment, IExpression[] subscripts) {\r
+ \r
+ if(isStoredAsArray()) {\r
+ \r
+ Array array = (Array)environment.getValue(index);\r
+ if(hasScalarSubscript(subscripts)) {\r
+ Object o = getArrayIndex(environment, subscripts, array);\r
+ if(o instanceof Variable) throw new IllegalStateException();\r
+ if(o instanceof Array)\r
+ throw new IllegalStateException();\r
+ return o;\r
+ }\r
+ else return array;\r
+ \r
+ } else {\r
+ \r
+ if(dimension() > 1) {\r
+ if(subscripts != null) {\r
+ \r
+ Slice[] sub = SolverUtils.parseSubscripts(environment, subscripts);\r
+ if(SolverUtils.isSlice(sub)) {\r
+ Array arr = new Array();\r
+ intoArray(environment, index, 0, arr);\r
+ return arr.slice(sub);\r
+ } else { \r
+ return environment.getValue(index(environment, subscripts));\r
+ }\r
+ \r
+ } else {\r
+ Array array = new Array();\r
+ intoArray(environment, index, 0, array);\r
+ return array;\r
+ }\r
+ }\r
+ \r
+ Object result = environment.getNamedValue(name);\r
+ if(result == null) result = environment.getValue(index(environment, subscripts));\r
+ if(result == null) throw new UnassignedVariableException("No value for " + name);\r
+\r
+ if(SolverUtils.isArray(dimensions) && subscripts == null) {\r
+ return new Array().addElement(result);\r
+ } else {\r
+ return result;\r
+ }\r
+ \r
+ }\r
+ }\r
+ \r
+ public IExpression getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
}\r
*******************************************************************************/\r
package fi.semantum.sysdyn.solver;\r
\r
+import java.util.Map;\r
+\r
\r
public class VariableDeclaration implements IExpression {\r
\r
throw new UnsupportedOperationException();\r
}\r
\r
+ @Override\r
+ public IExpression withBase(IFrame frame, String prefix) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public Object getPossibleConstant() {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
case 34:\r
jj_consume_token(34);\r
+ jjtn000.op = "class";\r
break;\r
case 7:\r
jj_consume_token(7);\r
+ jjtn000.op = "model";\r
break;\r
case 61:\r
jj_consume_token(61);\r
}\r
comment();\r
} else if (jj_2_3(3)) {\r
- jj_consume_token(IDENT);\r
- jj_consume_token(88);\r
- jj_consume_token(40);\r
- jj_consume_token(62);\r
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
- case IDENT:\r
- enum_list();\r
- break;\r
- default:\r
- jj_la1[10] = jj_gen;\r
- ;\r
- }\r
- jj_consume_token(63);\r
- comment();\r
- } else if (jj_2_4(3)) {\r
jj_consume_token(IDENT);\r
jj_consume_token(88);\r
jj_consume_token(58);\r
;\r
break;\r
default:\r
- jj_la1[11] = jj_gen;\r
+ jj_la1[10] = jj_gen;\r
break label_2;\r
}\r
jj_consume_token(71);\r
}\r
jj_consume_token(63);\r
comment();\r
- } else {\r
+ } else if (jj_2_4(3)) {\r
+ jj_consume_token(IDENT);\r
+ jj_consume_token(88);\r
+ jj_consume_token(40);\r
+ jj_consume_token(62);\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
- case 55:\r
- jj_consume_token(55);\r
- jj_consume_token(IDENT);\r
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
- case 62:\r
- class_modification();\r
- break;\r
- default:\r
- jj_la1[12] = jj_gen;\r
- ;\r
- }\r
- string_comment();\r
- composition();\r
- jj_consume_token(35);\r
- jj_consume_token(IDENT);\r
+ case IDENT:\r
+ enum_list();\r
break;\r
default:\r
- jj_la1[13] = jj_gen;\r
- jj_consume_token(-1);\r
- throw new ParseException();\r
+ jj_la1[11] = jj_gen;\r
+ ;\r
}\r
+ jj_consume_token(63);\r
+ comment();\r
+ } else {\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
}\r
} catch (Throwable jjte000) {\r
if (jjtc000) {\r
;\r
break;\r
default:\r
- jj_la1[14] = jj_gen;\r
+ jj_la1[12] = jj_gen;\r
break label_3;\r
}\r
jj_consume_token(71);\r
;\r
break;\r
default:\r
- jj_la1[15] = jj_gen;\r
+ jj_la1[13] = jj_gen;\r
break label_4;\r
}\r
if (jj_2_5(2)) {\r
algorithm_section();\r
break;\r
default:\r
- jj_la1[16] = jj_gen;\r
+ jj_la1[14] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
language_specification();\r
break;\r
default:\r
- jj_la1[17] = jj_gen;\r
+ jj_la1[15] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
external_function_call();\r
break;\r
default:\r
- jj_la1[18] = jj_gen;\r
+ jj_la1[16] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
annotation();\r
break;\r
default:\r
- jj_la1[19] = jj_gen;\r
+ jj_la1[17] = jj_gen;\r
;\r
}\r
jj_consume_token(70);\r
break;\r
default:\r
- jj_la1[20] = jj_gen;\r
+ jj_la1[18] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
jj_consume_token(70);\r
break;\r
default:\r
- jj_la1[21] = jj_gen;\r
+ jj_la1[19] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
jj_consume_token(88);\r
break;\r
default:\r
- jj_la1[22] = jj_gen;\r
+ jj_la1[20] = jj_gen;\r
;\r
}\r
jj_consume_token(IDENT);\r
expression_list();\r
break;\r
default:\r
- jj_la1[23] = jj_gen;\r
+ jj_la1[21] = jj_gen;\r
;\r
}\r
jj_consume_token(63);\r
;\r
break;\r
default:\r
- jj_la1[24] = jj_gen;\r
+ jj_la1[22] = jj_gen;\r
break label_5;\r
}\r
element();\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
case 36:\r
import_clause();\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ {if (true) return jjtn000;}\r
break;\r
case 55:\r
extends_clause();\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ {if (true) return jjtn000;}\r
break;\r
case 5:\r
case 7:\r
jj_consume_token(8);\r
break;\r
default:\r
- jj_la1[25] = jj_gen;\r
+ jj_la1[23] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
jj_consume_token(11);\r
break;\r
default:\r
- jj_la1[26] = jj_gen;\r
+ jj_la1[24] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
case 51:\r
jj_consume_token(51);\r
+ jjtn000.op = "inner";\r
break;\r
default:\r
- jj_la1[27] = jj_gen;\r
+ jj_la1[25] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
case 27:\r
jj_consume_token(27);\r
+ jjtn000.op = "outer";\r
break;\r
default:\r
- jj_la1[28] = jj_gen;\r
+ jj_la1[26] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
component_clause();\r
break;\r
default:\r
- jj_la1[29] = jj_gen;\r
+ jj_la1[27] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
component_clause();\r
break;\r
default:\r
- jj_la1[30] = jj_gen;\r
+ jj_la1[28] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
comment();\r
break;\r
default:\r
- jj_la1[31] = jj_gen;\r
+ jj_la1[29] = jj_gen;\r
;\r
}\r
break;\r
default:\r
- jj_la1[32] = jj_gen;\r
+ jj_la1[30] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
{if (true) return jjtn000;}\r
break;\r
default:\r
- jj_la1[33] = jj_gen;\r
+ jj_la1[31] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
jj_consume_token(82);\r
break;\r
default:\r
- jj_la1[34] = jj_gen;\r
+ jj_la1[32] = jj_gen;\r
;\r
}\r
break;\r
default:\r
- jj_la1[35] = jj_gen;\r
+ jj_la1[33] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
class_modification();\r
break;\r
default:\r
- jj_la1[36] = jj_gen;\r
+ jj_la1[34] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
annotation();\r
break;\r
default:\r
- jj_la1[37] = jj_gen;\r
+ jj_la1[35] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
class_modification();\r
break;\r
default:\r
- jj_la1[38] = jj_gen;\r
+ jj_la1[36] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
array_subscripts();\r
break;\r
default:\r
- jj_la1[39] = jj_gen;\r
+ jj_la1[37] = jj_gen;\r
;\r
}\r
componentList = component_list();\r
jj_consume_token(23);\r
break;\r
default:\r
- jj_la1[40] = jj_gen;\r
+ jj_la1[38] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
break;\r
default:\r
- jj_la1[41] = jj_gen;\r
+ jj_la1[39] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
jjtn000.op = "constant";\r
break;\r
default:\r
- jj_la1[42] = jj_gen;\r
+ jj_la1[40] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
break;\r
default:\r
- jj_la1[43] = jj_gen;\r
+ jj_la1[41] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
type = InterfaceVariableType.INPUT; jjtn000.op = "input";\r
break;\r
default:\r
- jj_la1[44] = jj_gen;\r
+ jj_la1[42] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
break;\r
default:\r
- jj_la1[45] = jj_gen;\r
+ jj_la1[43] = jj_gen;\r
;\r
}\r
jjtree.closeNodeScope(jjtn000, true);\r
;\r
break;\r
default:\r
- jj_la1[46] = jj_gen;\r
+ jj_la1[44] = jj_gen;\r
break label_6;\r
}\r
jj_consume_token(71);\r
conditional_attribute();\r
break;\r
default:\r
- jj_la1[47] = jj_gen;\r
+ jj_la1[45] = jj_gen;\r
;\r
}\r
ret.description = comment();\r
array_subscripts();\r
break;\r
default:\r
- jj_la1[48] = jj_gen;\r
+ jj_la1[46] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
ret.optional = modification();\r
break;\r
default:\r
- jj_la1[49] = jj_gen;\r
+ jj_la1[47] = jj_gen;\r
;\r
}\r
jjtree.closeNodeScope(jjtn000, true);\r
expression();\r
break;\r
default:\r
- jj_la1[50] = jj_gen;\r
+ jj_la1[48] = jj_gen;\r
;\r
}\r
break;\r
optional = true;\r
break;\r
default:\r
- jj_la1[51] = jj_gen;\r
+ jj_la1[49] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
argument_list();\r
break;\r
default:\r
- jj_la1[52] = jj_gen;\r
+ jj_la1[50] = jj_gen;\r
;\r
}\r
jj_consume_token(63);\r
;\r
break;\r
default:\r
- jj_la1[53] = jj_gen;\r
+ jj_la1[51] = jj_gen;\r
break label_7;\r
}\r
jj_consume_token(71);\r
element_redeclaration();\r
break;\r
default:\r
- jj_la1[54] = jj_gen;\r
+ jj_la1[52] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
jj_consume_token(10);\r
break;\r
default:\r
- jj_la1[55] = jj_gen;\r
+ jj_la1[53] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
jj_consume_token(11);\r
break;\r
default:\r
- jj_la1[56] = jj_gen;\r
+ jj_la1[54] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
element_replaceable();\r
break;\r
default:\r
- jj_la1[57] = jj_gen;\r
+ jj_la1[55] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
modification();\r
break;\r
default:\r
- jj_la1[58] = jj_gen;\r
+ jj_la1[56] = jj_gen;\r
;\r
}\r
string_comment();\r
jj_consume_token(10);\r
break;\r
default:\r
- jj_la1[59] = jj_gen;\r
+ jj_la1[57] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
jj_consume_token(11);\r
break;\r
default:\r
- jj_la1[60] = jj_gen;\r
+ jj_la1[58] = jj_gen;\r
;\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
component_clause1();\r
break;\r
default:\r
- jj_la1[61] = jj_gen;\r
+ jj_la1[59] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
element_replaceable();\r
break;\r
default:\r
- jj_la1[62] = jj_gen;\r
+ jj_la1[60] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
component_clause1();\r
break;\r
default:\r
- jj_la1[63] = jj_gen;\r
+ jj_la1[61] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
constraining_clause();\r
break;\r
default:\r
- jj_la1[64] = jj_gen;\r
+ jj_la1[62] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
jjtn000.op = "initial";\r
break;\r
default:\r
- jj_la1[65] = jj_gen;\r
+ jj_la1[63] = jj_gen;\r
;\r
}\r
jj_consume_token(45);\r
jj_consume_token(46);\r
break;\r
default:\r
- jj_la1[66] = jj_gen;\r
+ jj_la1[64] = jj_gen;\r
;\r
}\r
jj_consume_token(4);\r
;\r
break;\r
default:\r
- jj_la1[67] = jj_gen;\r
+ jj_la1[65] = jj_gen;\r
break label_9;\r
}\r
statement();\r
function_call_args();\r
break;\r
default:\r
- jj_la1[68] = jj_gen;\r
+ jj_la1[66] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
function_call_args();\r
break;\r
default:\r
- jj_la1[69] = jj_gen;\r
+ jj_la1[67] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
when_statement();\r
break;\r
default:\r
- jj_la1[70] = jj_gen;\r
+ jj_la1[68] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
;\r
break;\r
default:\r
- jj_la1[71] = jj_gen;\r
+ jj_la1[69] = jj_gen;\r
break label_10;\r
}\r
equation();\r
;\r
break;\r
default:\r
- jj_la1[72] = jj_gen;\r
+ jj_la1[70] = jj_gen;\r
break label_11;\r
}\r
jj_consume_token(20);\r
;\r
break;\r
default:\r
- jj_la1[73] = jj_gen;\r
+ jj_la1[71] = jj_gen;\r
break label_12;\r
}\r
equation();\r
;\r
break;\r
default:\r
- jj_la1[74] = jj_gen;\r
+ jj_la1[72] = jj_gen;\r
break label_13;\r
}\r
equation();\r
}\r
break;\r
default:\r
- jj_la1[75] = jj_gen;\r
+ jj_la1[73] = jj_gen;\r
;\r
}\r
jj_consume_token(35);\r
;\r
break;\r
default:\r
- jj_la1[76] = jj_gen;\r
+ jj_la1[74] = jj_gen;\r
break label_14;\r
}\r
then_statement();\r
;\r
break;\r
default:\r
- jj_la1[77] = jj_gen;\r
+ jj_la1[75] = jj_gen;\r
break label_15;\r
}\r
jj_consume_token(20);\r
;\r
break;\r
default:\r
- jj_la1[78] = jj_gen;\r
+ jj_la1[76] = jj_gen;\r
break label_16;\r
}\r
elseif_statement();\r
;\r
break;\r
default:\r
- jj_la1[79] = jj_gen;\r
+ jj_la1[77] = jj_gen;\r
break label_17;\r
}\r
else_statement();\r
}\r
break;\r
default:\r
- jj_la1[80] = jj_gen;\r
+ jj_la1[78] = jj_gen;\r
;\r
}\r
jj_consume_token(35);\r
;\r
break;\r
default:\r
- jj_la1[81] = jj_gen;\r
+ jj_la1[79] = jj_gen;\r
break label_18;\r
}\r
equation();\r
;\r
break;\r
default:\r
- jj_la1[82] = jj_gen;\r
+ jj_la1[80] = jj_gen;\r
break label_19;\r
}\r
statement();\r
;\r
break;\r
default:\r
- jj_la1[83] = jj_gen;\r
+ jj_la1[81] = jj_gen;\r
break label_20;\r
}\r
jj_consume_token(71);\r
expression();\r
break;\r
default:\r
- jj_la1[84] = jj_gen;\r
+ jj_la1[82] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
;\r
break;\r
default:\r
- jj_la1[85] = jj_gen;\r
+ jj_la1[83] = jj_gen;\r
break label_21;\r
}\r
statement();\r
;\r
break;\r
default:\r
- jj_la1[86] = jj_gen;\r
+ jj_la1[84] = jj_gen;\r
break label_22;\r
}\r
equation();\r
;\r
break;\r
default:\r
- jj_la1[87] = jj_gen;\r
+ jj_la1[85] = jj_gen;\r
break label_23;\r
}\r
jj_consume_token(25);\r
;\r
break;\r
default:\r
- jj_la1[88] = jj_gen;\r
+ jj_la1[86] = jj_gen;\r
break label_24;\r
}\r
equation();\r
;\r
break;\r
default:\r
- jj_la1[89] = jj_gen;\r
+ jj_la1[87] = jj_gen;\r
break label_25;\r
}\r
statement();\r
;\r
break;\r
default:\r
- jj_la1[90] = jj_gen;\r
+ jj_la1[88] = jj_gen;\r
break label_26;\r
}\r
jj_consume_token(25);\r
;\r
break;\r
default:\r
- jj_la1[91] = jj_gen;\r
+ jj_la1[89] = jj_gen;\r
break label_27;\r
}\r
statement();\r
;\r
break;\r
default:\r
- jj_la1[92] = jj_gen;\r
+ jj_la1[90] = jj_gen;\r
break label_28;\r
}\r
jj_consume_token(20);\r
jj_consume_token(0);\r
break;\r
default:\r
- jj_la1[93] = jj_gen;\r
+ jj_la1[91] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
;\r
break;\r
default:\r
- jj_la1[94] = jj_gen;\r
+ jj_la1[92] = jj_gen;\r
break label_29;\r
}\r
jj_consume_token(20);\r
if_expression();\r
break;\r
default:\r
- jj_la1[95] = jj_gen;\r
+ jj_la1[93] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
logical_expression();\r
break;\r
default:\r
- jj_la1[96] = jj_gen;\r
+ jj_la1[94] = jj_gen;\r
;\r
}\r
break;\r
default:\r
- jj_la1[97] = jj_gen;\r
+ jj_la1[95] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
;\r
break;\r
default:\r
- jj_la1[98] = jj_gen;\r
+ jj_la1[96] = jj_gen;\r
break label_30;\r
}\r
jj_consume_token(22);\r
;\r
break;\r
default:\r
- jj_la1[99] = jj_gen;\r
+ jj_la1[97] = jj_gen;\r
break label_31;\r
}\r
jj_consume_token(9);\r
jj_consume_token(12);\r
break;\r
default:\r
- jj_la1[100] = jj_gen;\r
+ jj_la1[98] = jj_gen;\r
;\r
}\r
relation();\r
arithmetic_expression();\r
break;\r
default:\r
- jj_la1[101] = jj_gen;\r
+ jj_la1[99] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
jjtn000.op = "<>";\r
break;\r
default:\r
- jj_la1[102] = jj_gen;\r
+ jj_la1[100] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
add_op();\r
break;\r
default:\r
- jj_la1[103] = jj_gen;\r
+ jj_la1[101] = jj_gen;\r
;\r
}\r
term();\r
;\r
break;\r
default:\r
- jj_la1[104] = jj_gen;\r
+ jj_la1[102] = jj_gen;\r
break label_32;\r
}\r
add_op();\r
jj_consume_token(81);\r
break;\r
default:\r
- jj_la1[105] = jj_gen;\r
+ jj_la1[103] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
;\r
break;\r
default:\r
- jj_la1[106] = jj_gen;\r
+ jj_la1[104] = jj_gen;\r
break label_33;\r
}\r
mul_op();\r
break;\r
case 84:\r
jj_consume_token(84);\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ jjtn000.op = ".*";\r
break;\r
case 85:\r
jj_consume_token(85);\r
break;\r
default:\r
- jj_la1[107] = jj_gen;\r
+ jj_la1[105] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
case 86:\r
case 87:\r
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
- case 86:\r
- jj_consume_token(86);\r
- break;\r
- case 87:\r
- jj_consume_token(87);\r
- primary();\r
- break;\r
- default:\r
- jj_la1[108] = jj_gen;\r
- jj_consume_token(-1);\r
- throw new ParseException();\r
- }\r
+ factor_op();\r
+ primary();\r
break;\r
default:\r
- jj_la1[109] = jj_gen;\r
+ jj_la1[106] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
}\r
}\r
\r
+ final public void factor_op() throws ParseException {\r
+ /*@bgen(jjtree) factor_op */\r
+ SimpleNode jjtn000 = new SimpleNode(JJTFACTOR_OP);\r
+ boolean jjtc000 = true;\r
+ jjtree.openNodeScope(jjtn000);\r
+ try {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 86:\r
+ jj_consume_token(86);\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ jjtn000.op = "^";\r
+ break;\r
+ case 87:\r
+ jj_consume_token(87);\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ jjtn000.op = ".^";\r
+ break;\r
+ default:\r
+ jj_la1[107] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ } finally {\r
+ if (jjtc000) {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ }\r
+ }\r
+ }\r
+\r
final public void der_initial() throws ParseException {\r
/*@bgen(jjtree) der_initial */\r
SimpleNode jjtn000 = new SimpleNode(JJTDER_INITIAL);\r
jjtn000.op = "initial";\r
break;\r
default:\r
- jj_la1[110] = jj_gen;\r
+ jj_la1[108] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
;\r
break;\r
default:\r
- jj_la1[111] = jj_gen;\r
+ jj_la1[109] = jj_gen;\r
break label_34;\r
}\r
jj_consume_token(70);\r
jjtn000.op = token.image;\r
break;\r
default:\r
- jj_la1[112] = jj_gen;\r
+ jj_la1[110] = jj_gen;\r
if (jj_2_9(2147483647)) {\r
der_initial();\r
} else {\r
jj_consume_token(35);\r
break;\r
default:\r
- jj_la1[113] = jj_gen;\r
+ jj_la1[111] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
ret += ".";\r
break;\r
default:\r
- jj_la1[114] = jj_gen;\r
+ jj_la1[112] = jj_gen;\r
;\r
}\r
jj_consume_token(IDENT);\r
;\r
break;\r
default:\r
- jj_la1[115] = jj_gen;\r
+ jj_la1[113] = jj_gen;\r
break label_35;\r
}\r
jj_consume_token(68);\r
jj_consume_token(68);\r
break;\r
default:\r
- jj_la1[116] = jj_gen;\r
+ jj_la1[114] = jj_gen;\r
;\r
}\r
t = jj_consume_token(IDENT);\r
array_subscripts();\r
break;\r
default:\r
- jj_la1[117] = jj_gen;\r
+ jj_la1[115] = jj_gen;\r
;\r
}\r
label_36:\r
;\r
break;\r
default:\r
- jj_la1[118] = jj_gen;\r
+ jj_la1[116] = jj_gen;\r
break label_36;\r
}\r
jj_consume_token(68);\r
array_subscripts();\r
break;\r
default:\r
- jj_la1[119] = jj_gen;\r
+ jj_la1[117] = jj_gen;\r
;\r
}\r
}\r
function_arguments();\r
break;\r
default:\r
- jj_la1[120] = jj_gen;\r
+ jj_la1[118] = jj_gen;\r
;\r
}\r
jj_consume_token(63);\r
case 21:\r
jj_consume_token(21);\r
for_indices();\r
+ jjtn000.op = "for";\r
break;\r
default:\r
- jj_la1[121] = jj_gen;\r
+ jj_la1[119] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
break;\r
default:\r
- jj_la1[122] = jj_gen;\r
+ jj_la1[120] = jj_gen;\r
;\r
}\r
} else {\r
named_arguments();\r
break;\r
default:\r
- jj_la1[123] = jj_gen;\r
+ jj_la1[121] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
named_arguments();\r
break;\r
default:\r
- jj_la1[124] = jj_gen;\r
+ jj_la1[122] = jj_gen;\r
;\r
}\r
} catch (Throwable jjte000) {\r
expression();\r
break;\r
default:\r
- jj_la1[125] = jj_gen;\r
+ jj_la1[123] = jj_gen;\r
;\r
}\r
label_37:\r
;\r
break;\r
default:\r
- jj_la1[126] = jj_gen;\r
+ jj_la1[124] = jj_gen;\r
break label_37;\r
}\r
jj_consume_token(71);\r
expression();\r
break;\r
default:\r
- jj_la1[127] = jj_gen;\r
+ jj_la1[125] = jj_gen;\r
;\r
}\r
}\r
;\r
break;\r
default:\r
- jj_la1[128] = jj_gen;\r
+ jj_la1[126] = jj_gen;\r
break label_38;\r
}\r
jj_consume_token(71);\r
;\r
break;\r
default:\r
- jj_la1[129] = jj_gen;\r
+ jj_la1[127] = jj_gen;\r
break label_39;\r
}\r
jj_consume_token(71);\r
expression();\r
break;\r
default:\r
- jj_la1[130] = jj_gen;\r
+ jj_la1[128] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
annotation();\r
break;\r
default:\r
- jj_la1[131] = jj_gen;\r
+ jj_la1[129] = jj_gen;\r
;\r
}\r
{if (true) return ret;}\r
;\r
break;\r
default:\r
- jj_la1[132] = jj_gen;\r
+ jj_la1[130] = jj_gen;\r
break label_40;\r
}\r
jj_consume_token(78);\r
}\r
break;\r
default:\r
- jj_la1[133] = jj_gen;\r
+ jj_la1[131] = jj_gen;\r
;\r
}\r
{if (true) return ret;}\r
finally { jj_save(9, xla); }\r
}\r
\r
- private boolean jj_3_10() {\r
- if (jj_3R_47()) return true;\r
- Token xsp;\r
- xsp = jj_scanpos;\r
- if (jj_3R_48()) jj_scanpos = xsp;\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_158() {\r
- if (jj_3R_157()) return true;\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_157() {\r
+ private boolean jj_3R_74() {\r
+ if (jj_scan_token(62)) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3_10()) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_161()) return true;\r
- }\r
+ if (jj_3R_165()) jj_scanpos = xsp;\r
+ if (jj_scan_token(63)) return true;\r
return false;\r
}\r
\r
private boolean jj_3R_85() {\r
- if (jj_3R_93()) return true;\r
+ if (jj_3R_95()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_120() {\r
+ private boolean jj_3R_124() {\r
if (jj_scan_token(75)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_125() {\r
+ private boolean jj_3R_129() {\r
if (jj_scan_token(49)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_74() {\r
- if (jj_scan_token(62)) return true;\r
+ private boolean jj_3R_152() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_158()) jj_scanpos = xsp;\r
- if (jj_scan_token(63)) return true;\r
+ if (jj_scan_token(68)) jj_scanpos = xsp;\r
+ if (jj_scan_token(IDENT)) return true;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_160()) jj_scanpos = xsp;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_161()) { jj_scanpos = xsp; break; }\r
+ }\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_103() {\r
- Token xsp;\r
- xsp = jj_scanpos;\r
- if (jj_scan_token(50)) jj_scanpos = xsp;\r
- if (jj_scan_token(44)) return true;\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_147() {\r
- Token xsp;\r
- xsp = jj_scanpos;\r
- if (jj_scan_token(68)) jj_scanpos = xsp;\r
- if (jj_scan_token(IDENT)) return true;\r
- xsp = jj_scanpos;\r
- if (jj_3R_153()) jj_scanpos = xsp;\r
- while (true) {\r
- xsp = jj_scanpos;\r
- if (jj_3R_154()) { jj_scanpos = xsp; break; }\r
- }\r
- return false;\r
- }\r
-\r
private boolean jj_3R_78() {\r
if (jj_scan_token(68)) return true;\r
if (jj_scan_token(IDENT)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_151() {\r
+ private boolean jj_3R_158() {\r
if (jj_scan_token(58)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_71() {\r
- if (jj_scan_token(21)) return true;\r
- if (jj_3R_85()) return true;\r
+ private boolean jj_3R_106() {\r
+ if (jj_scan_token(7)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_150() {\r
+ if (jj_scan_token(84)) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
+ private boolean jj_3R_71() {\r
+ if (jj_scan_token(21)) return true;\r
+ if (jj_3R_85()) return true;\r
+ return false;\r
+ }\r
+\r
private boolean jj_3R_46() {\r
if (jj_3R_60()) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_119() {\r
- if (jj_scan_token(74)) return true;\r
+ private boolean jj_3R_163() {\r
+ if (jj_scan_token(70)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3_4() {\r
- if (jj_scan_token(IDENT)) return true;\r
- if (jj_scan_token(88)) return true;\r
- if (jj_scan_token(58)) return true;\r
+ private boolean jj_3R_146() {\r
+ if (jj_3R_154()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3_3() {\r
+ private boolean jj_3R_123() {\r
+ if (jj_scan_token(74)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3_4() {\r
if (jj_scan_token(IDENT)) return true;\r
if (jj_scan_token(88)) return true;\r
if (jj_scan_token(40)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3_2() {\r
- if (jj_scan_token(IDENT)) return true;\r
- if (jj_scan_token(88)) return true;\r
+ private boolean jj_3R_145() {\r
+ if (jj_scan_token(66)) return true;\r
+ if (jj_3R_153()) return true;\r
+ if (jj_scan_token(67)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_156() {\r
- if (jj_scan_token(70)) return true;\r
+ private boolean jj_3_3() {\r
+ if (jj_scan_token(IDENT)) return true;\r
+ if (jj_scan_token(88)) return true;\r
+ if (jj_scan_token(58)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_142() {\r
- if (jj_3R_149()) return true;\r
+ private boolean jj_3R_144() {\r
+ if (jj_scan_token(62)) return true;\r
+ if (jj_3R_47()) return true;\r
+ if (jj_scan_token(63)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3_1() {\r
+ private boolean jj_3_2() {\r
if (jj_scan_token(IDENT)) return true;\r
- if (jj_3R_41()) return true;\r
- if (jj_3R_42()) return true;\r
- if (jj_scan_token(35)) return true;\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_141() {\r
- if (jj_scan_token(66)) return true;\r
- if (jj_3R_148()) return true;\r
- if (jj_scan_token(67)) return true;\r
+ if (jj_scan_token(88)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_140() {\r
- if (jj_scan_token(62)) return true;\r
- if (jj_3R_47()) return true;\r
- if (jj_scan_token(63)) return true;\r
+ private boolean jj_3R_156() {\r
+ if (jj_scan_token(87)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_138() {\r
- if (jj_3R_146()) return true;\r
+ private boolean jj_3R_142() {\r
+ if (jj_3R_151()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_104() {\r
- if (jj_scan_token(26)) return true;\r
+ private boolean jj_3R_143() {\r
+ if (jj_3R_152()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_139() {\r
- if (jj_3R_147()) return true;\r
+ private boolean jj_3_1() {\r
+ if (jj_scan_token(IDENT)) return true;\r
+ if (jj_3R_41()) return true;\r
+ if (jj_3R_42()) return true;\r
+ if (jj_scan_token(35)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_137() {\r
+ private boolean jj_3R_141() {\r
if (jj_scan_token(33)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_133() {\r
+ private boolean jj_3R_137() {\r
if (jj_scan_token(UNSIGNED_NUMBER)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_130() {\r
+ private boolean jj_3R_134() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_133()) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_134()) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_135()) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_136()) {\r
- jj_scanpos = xsp;\r
if (jj_3R_137()) {\r
jj_scanpos = xsp;\r
if (jj_3R_138()) {\r
jj_scanpos = xsp;\r
if (jj_3R_142()) {\r
jj_scanpos = xsp;\r
+ if (jj_3R_143()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_144()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_145()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_146()) {\r
+ jj_scanpos = xsp;\r
if (jj_scan_token(35)) return true;\r
}\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_136() {\r
+ private boolean jj_3R_140() {\r
if (jj_scan_token(6)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_145() {\r
- if (jj_scan_token(83)) return true;\r
+ private boolean jj_3R_139() {\r
+ if (jj_scan_token(STRING)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_143() {\r
- if (jj_scan_token(87)) return true;\r
- if (jj_3R_130()) return true;\r
+ private boolean jj_3R_108() {\r
+ if (jj_scan_token(26)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_135() {\r
- if (jj_scan_token(STRING)) return true;\r
+ private boolean jj_3R_138() {\r
+ if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_134() {\r
- if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
+ private boolean jj_3R_149() {\r
+ if (jj_scan_token(83)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_124() {\r
+ private boolean jj_3R_128() {\r
if (jj_scan_token(42)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_131() {\r
- Token xsp;\r
- xsp = jj_scanpos;\r
- if (jj_scan_token(86)) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_143()) return true;\r
- }\r
+ private boolean jj_3R_154() {\r
+ if (jj_scan_token(64)) return true;\r
+ if (jj_3R_164()) return true;\r
+ if (jj_scan_token(65)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_149() {\r
- if (jj_scan_token(64)) return true;\r
- if (jj_3R_157()) return true;\r
- if (jj_scan_token(65)) return true;\r
+ private boolean jj_3R_135() {\r
+ if (jj_3R_147()) return true;\r
+ if (jj_3R_134()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_129() {\r
- if (jj_scan_token(79)) return true;\r
+ private boolean jj_3R_105() {\r
+ if (jj_scan_token(34)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_148() {\r
- if (jj_3R_155()) return true;\r
+ private boolean jj_3R_153() {\r
+ if (jj_3R_162()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_156()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_163()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_150() {\r
+ private boolean jj_3R_157() {\r
if (jj_3R_60()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_118() {\r
+ private boolean jj_3R_133() {\r
+ if (jj_scan_token(79)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_151() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_157()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_158()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_159()) return true;\r
+ }\r
+ }\r
+ if (jj_3R_74()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_122() {\r
if (jj_scan_token(73)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_99() {\r
+ private boolean jj_3R_101() {\r
Token xsp;\r
xsp = jj_scanpos;\r
if (jj_scan_token(30)) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
if (jj_scan_token(47)) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_scan_token(34)) {\r
+ if (jj_3R_105()) {\r
jj_scanpos = xsp;\r
- if (jj_scan_token(7)) {\r
+ if (jj_3R_106()) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(61)) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(24)) {\r
jj_scanpos = xsp;\r
- if (jj_3R_103()) {\r
+ if (jj_3R_107()) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(38)) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(37)) {\r
jj_scanpos = xsp;\r
- if (jj_3R_104()) {\r
+ if (jj_3R_108()) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(17)) {\r
jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_115() {\r
- if (jj_3R_130()) return true;\r
- Token xsp;\r
- xsp = jj_scanpos;\r
- if (jj_3R_131()) jj_scanpos = xsp;\r
+ private boolean jj_3R_155() {\r
+ if (jj_scan_token(86)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_146() {\r
+ private boolean jj_3R_147() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_150()) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_151()) {\r
+ if (jj_3R_155()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_152()) return true;\r
+ if (jj_3R_156()) return true;\r
}\r
- }\r
- if (jj_3R_74()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_116() {\r
- if (jj_3R_132()) return true;\r
- if (jj_3R_115()) return true;\r
+ private boolean jj_3R_119() {\r
+ if (jj_3R_134()) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_135()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_109() {\r
- if (jj_3R_114()) return true;\r
- if (jj_3R_108()) return true;\r
+ private boolean jj_3R_120() {\r
+ if (jj_3R_136()) return true;\r
+ if (jj_3R_119()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_102() {\r
- if (jj_3R_110()) return true;\r
- if (jj_3R_101()) return true;\r
+ private boolean jj_3R_113() {\r
+ if (jj_3R_118()) return true;\r
+ if (jj_3R_112()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_144() {\r
+ private boolean jj_3R_104() {\r
+ if (jj_3R_114()) return true;\r
+ if (jj_3R_103()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_148() {\r
if (jj_scan_token(82)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_132() {\r
+ private boolean jj_3R_136() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_144()) {\r
+ if (jj_3R_148()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_145()) {\r
+ if (jj_3R_149()) {\r
jj_scanpos = xsp;\r
- if (jj_scan_token(84)) {\r
+ if (jj_3R_150()) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(85)) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_106() {\r
+ private boolean jj_3R_110() {\r
if (jj_3R_60()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_108() {\r
- if (jj_3R_115()) return true;\r
+ private boolean jj_3R_112() {\r
+ if (jj_3R_119()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_116()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_120()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_128() {\r
+ private boolean jj_3R_132() {\r
if (jj_scan_token(78)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_127() {\r
+ private boolean jj_3R_131() {\r
if (jj_scan_token(56)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_114() {\r
+ private boolean jj_3R_118() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_128()) {\r
+ if (jj_3R_132()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_129()) {\r
+ if (jj_3R_133()) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(80)) {\r
jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_95() {\r
+ private boolean jj_3R_97() {\r
if (jj_scan_token(9)) return true;\r
- if (jj_3R_94()) return true;\r
+ if (jj_3R_96()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_107() {\r
- if (jj_3R_114()) return true;\r
+ private boolean jj_3R_111() {\r
+ if (jj_3R_118()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_126() {\r
+ private boolean jj_3R_130() {\r
if (jj_scan_token(32)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_113() {\r
+ private boolean jj_3R_117() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_126()) {\r
+ if (jj_3R_130()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_127()) return true;\r
+ if (jj_3R_131()) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_101() {\r
+ private boolean jj_3R_103() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_107()) jj_scanpos = xsp;\r
- if (jj_3R_108()) return true;\r
+ if (jj_3R_111()) jj_scanpos = xsp;\r
+ if (jj_3R_112()) return true;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_109()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_113()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_123() {\r
+ private boolean jj_3R_127() {\r
if (jj_scan_token(5)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_117() {\r
+ private boolean jj_3R_121() {\r
if (jj_scan_token(72)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_112() {\r
+ private boolean jj_3R_116() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_123()) {\r
+ if (jj_3R_127()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_124()) {\r
+ if (jj_3R_128()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_125()) return true;\r
+ if (jj_3R_129()) return true;\r
}\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_110() {\r
+ private boolean jj_3R_114() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_117()) {\r
+ if (jj_3R_121()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_118()) {\r
+ if (jj_3R_122()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_119()) {\r
+ if (jj_3R_123()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_120()) {\r
+ if (jj_3R_124()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_121()) {\r
+ if (jj_3R_125()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_122()) return true;\r
+ if (jj_3R_126()) return true;\r
}\r
}\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_111() {\r
+ private boolean jj_3R_115() {\r
Token xsp;\r
xsp = jj_scanpos;\r
if (jj_scan_token(16)) {\r
return false;\r
}\r
\r
- private boolean jj_3R_105() {\r
+ private boolean jj_3R_109() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_111()) jj_scanpos = xsp;\r
+ if (jj_3R_115()) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_112()) jj_scanpos = xsp;\r
+ if (jj_3R_116()) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_113()) jj_scanpos = xsp;\r
+ if (jj_3R_117()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_98() {\r
- if (jj_3R_101()) return true;\r
+ private boolean jj_3R_100() {\r
+ if (jj_3R_103()) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_102()) jj_scanpos = xsp;\r
+ if (jj_3R_104()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_94() {\r
+ private boolean jj_3R_96() {\r
Token xsp;\r
xsp = jj_scanpos;\r
if (jj_scan_token(12)) jj_scanpos = xsp;\r
- if (jj_3R_98()) return true;\r
+ if (jj_3R_100()) return true;\r
return false;\r
}\r
\r
}\r
\r
private boolean jj_3R_86() {\r
- if (jj_3R_94()) return true;\r
+ if (jj_3R_96()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_95()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_97()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
return false;\r
}\r
\r
+ private boolean jj_3R_92() {\r
+ if (jj_scan_token(27)) return true;\r
+ return false;\r
+ }\r
+\r
private boolean jj_3_8() {\r
if (jj_3R_45()) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_66() {\r
- if (jj_3R_80()) return true;\r
+ private boolean jj_3R_172() {\r
+ if (jj_3R_47()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_100() {\r
- if (jj_3R_105()) return true;\r
- if (jj_3R_106()) return true;\r
+ private boolean jj_3R_102() {\r
+ if (jj_3R_109()) return true;\r
+ if (jj_3R_110()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_66() {\r
+ if (jj_3R_80()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_165() {\r
- if (jj_3R_47()) return true;\r
+ private boolean jj_3R_68() {\r
+ if (jj_scan_token(14)) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_68() {\r
- if (jj_scan_token(14)) return true;\r
+ private boolean jj_3R_161() {\r
+ if (jj_scan_token(68)) return true;\r
+ if (jj_scan_token(IDENT)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_97() {\r
- if (jj_3R_100()) return true;\r
+ private boolean jj_3R_99() {\r
+ if (jj_3R_102()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_154() {\r
- if (jj_scan_token(68)) return true;\r
- if (jj_scan_token(IDENT)) return true;\r
+ private boolean jj_3R_64() {\r
+ if (jj_scan_token(21)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3_6() {\r
- if (jj_scan_token(IDENT)) return true;\r
- if (jj_scan_token(88)) return true;\r
+ private boolean jj_3R_49() {\r
+ if (jj_scan_token(STRING)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_64() {\r
- if (jj_scan_token(21)) return true;\r
+ private boolean jj_3_6() {\r
+ if (jj_scan_token(IDENT)) return true;\r
+ if (jj_scan_token(88)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_49() {\r
- if (jj_scan_token(STRING)) return true;\r
+ private boolean jj_3R_41() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_49()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_122() {\r
+ private boolean jj_3R_126() {\r
if (jj_scan_token(77)) return true;\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_41() {\r
- Token xsp;\r
- xsp = jj_scanpos;\r
- if (jj_3R_49()) jj_scanpos = xsp;\r
- return false;\r
- }\r
-\r
private boolean jj_3R_88() {\r
if (jj_scan_token(46)) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_92() {\r
+ private boolean jj_3R_94() {\r
if (jj_scan_token(13)) return true;\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_96() {\r
+ private boolean jj_3R_98() {\r
+ if (jj_3R_101()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_171() {\r
+ if (jj_scan_token(69)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_93() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_98()) {\r
+ jj_scanpos = xsp;\r
if (jj_3R_99()) return true;\r
+ }\r
return false;\r
}\r
\r
- private boolean jj_3R_91() {\r
+ private boolean jj_3R_169() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_96()) {\r
+ if (jj_3R_171()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_97()) return true;\r
+ if (jj_3R_172()) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_164() {\r
- if (jj_scan_token(69)) return true;\r
+ private boolean jj_3R_167() {\r
+ if (jj_scan_token(71)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_107() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(50)) jj_scanpos = xsp;\r
+ if (jj_scan_token(44)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_91() {\r
+ if (jj_scan_token(51)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_160() {\r
+ if (jj_3R_166()) return true;\r
return false;\r
}\r
\r
xsp = jj_scanpos;\r
if (jj_scan_token(11)) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_scan_token(51)) jj_scanpos = xsp;\r
- xsp = jj_scanpos;\r
- if (jj_scan_token(27)) jj_scanpos = xsp;\r
+ if (jj_3R_91()) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_91()) {\r
- jj_scanpos = xsp;\r
- if (jj_3R_92()) return true;\r
- }\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_162() {\r
- Token xsp;\r
+ if (jj_3R_92()) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_164()) {\r
+ if (jj_3R_93()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_165()) return true;\r
+ if (jj_3R_94()) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_160() {\r
- if (jj_scan_token(71)) return true;\r
- return false;\r
- }\r
-\r
private boolean jj_3R_83() {\r
if (jj_3R_90()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_153() {\r
- if (jj_3R_159()) return true;\r
+ private boolean jj_3R_166() {\r
+ if (jj_scan_token(66)) return true;\r
+ if (jj_3R_169()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_159() {\r
- if (jj_scan_token(66)) return true;\r
- if (jj_3R_162()) return true;\r
- return false;\r
- }\r
-\r
private boolean jj_3R_63() {\r
if (jj_scan_token(71)) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_121() {\r
+ private boolean jj_3R_162() {\r
+ if (jj_3R_47()) return true;\r
+ Token xsp;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_167()) { jj_scanpos = xsp; break; }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_125() {\r
if (jj_scan_token(76)) return true;\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_155() {\r
- if (jj_3R_47()) return true;\r
- Token xsp;\r
- while (true) {\r
- xsp = jj_scanpos;\r
- if (jj_3R_160()) { jj_scanpos = xsp; break; }\r
- }\r
- return false;\r
- }\r
-\r
private boolean jj_3R_73() {\r
if (jj_scan_token(43)) return true;\r
if (jj_3R_47()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_166() {\r
+ private boolean jj_3R_173() {\r
if (jj_scan_token(IDENT)) return true;\r
if (jj_scan_token(88)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_152() {\r
+ private boolean jj_3R_159() {\r
if (jj_scan_token(46)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_163() {\r
- if (jj_3R_166()) return true;\r
+ private boolean jj_3R_170() {\r
+ if (jj_3R_173()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_168() {\r
+ if (jj_3R_170()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3_10() {\r
+ if (jj_3R_47()) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_48()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_51() {\r
- if (jj_scan_token(59)) return true;\r
+ private boolean jj_3R_165() {\r
+ if (jj_3R_164()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_161() {\r
- if (jj_3R_163()) return true;\r
+ private boolean jj_3R_164() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3_10()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_168()) return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_51() {\r
+ if (jj_scan_token(59)) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_93() {\r
+ private boolean jj_3R_95() {\r
if (jj_scan_token(IDENT)) return true;\r
return false;\r
}\r
private Token jj_scanpos, jj_lastpos;\r
private int jj_la;\r
private int jj_gen;\r
- final private int[] jj_la1 = new int[134];\r
+ final private int[] jj_la1 = new int[132];\r
static private int[] jj_la1_0;\r
static private int[] jj_la1_1;\r
static private int[] jj_la1_2;\r
jj_la1_init_2();\r
}\r
private static void jj_la1_init_0() {\r
- jj_la1_0 = new int[] {0x0,0x0,0x45020880,0x800,0x40000000,0x0,0x0,0x5020080,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x0,0x0,0x4000,0x0,0x4000,0x0,0x80001040,0x4d8329a0,0x100,0x800,0x0,0x8000000,0x458300a0,0x458300a0,0x0,0x458320a0,0x4d8329a0,0x0,0x0,0x0,0x4000,0x0,0x0,0x810000,0x810000,0x20,0x20,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x2d00,0x0,0x2d00,0x400,0x800,0x2000,0x0,0x400,0x800,0x458300a0,0x458320a0,0x458300a0,0x0,0x0,0x0,0xa0240000,0x80200000,0x0,0xa0240000,0x80201040,0x100000,0x80201040,0x80201040,0x8000,0xa0240000,0x100000,0xa0240000,0xa0240000,0x8000,0x80201040,0xa0240000,0x0,0x0,0xa0240000,0x80201040,0x2000000,0x80201040,0xa0240000,0x2000000,0xa0240000,0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80001040,0x200000,0x200000,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x80001040,0x4000,0x0,0x0,};\r
+ jj_la1_0 = new int[] {0x0,0x0,0x45020880,0x800,0x40000000,0x0,0x0,0x5020080,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x0,0x0,0x4000,0x0,0x4000,0x0,0x80001040,0x4d8329a0,0x100,0x800,0x0,0x8000000,0x458300a0,0x458300a0,0x0,0x458320a0,0x4d8329a0,0x0,0x0,0x0,0x4000,0x0,0x0,0x810000,0x810000,0x20,0x20,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x2d00,0x0,0x2d00,0x400,0x800,0x2000,0x0,0x400,0x800,0x458300a0,0x458320a0,0x458300a0,0x0,0x0,0x0,0xa0240000,0x80200000,0x0,0xa0240000,0x80201040,0x100000,0x80201040,0x80201040,0x8000,0xa0240000,0x100000,0xa0240000,0xa0240000,0x8000,0x80201040,0xa0240000,0x0,0x0,0xa0240000,0x80201040,0x2000000,0x80201040,0xa0240000,0x2000000,0xa0240000,0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80001040,0x200000,0x200000,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x80001040,0x4000,0x0,0x0,};\r
}\r
private static void jj_la1_init_1() {\r
- jj_la1_1 = new int[] {0x0,0x200000,0x20049064,0x0,0x0,0x8000,0x40000,0x20041064,0x0,0x40000000,0x0,0x0,0x40000000,0x800000,0x0,0x2106000,0x106000,0x0,0x0,0x0,0x8000000,0x0,0x0,0x4400400a,0x218e9475,0x0,0x0,0x80000,0x0,0x21069465,0x21069465,0x400000,0x21069465,0x218e9475,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x20400,0x20400,0x1000001,0x1000001,0x0,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,0x0,0x21069465,0x21069465,0x21069465,0x400000,0x4000,0x4000,0x40010800,0x880,0x40000000,0x40010800,0x4400488a,0x0,0x4400488a,0x4400488a,0x0,0x40010800,0x0,0x40010800,0x40010800,0x0,0x4400488a,0x40010800,0x0,0x200,0x40010800,0x4400488a,0x0,0x4400488a,0x40010800,0x0,0x40010800,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4004000,0x0,0x2,0x40000008,0x0,0x0,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x4400400a,0x0,0x0,0x0,};\r
+ jj_la1_1 = new int[] {0x0,0x200000,0x20049064,0x0,0x0,0x8000,0x40000,0x20041064,0x0,0x40000000,0x0,0x0,0x0,0x2106000,0x106000,0x0,0x0,0x0,0x8000000,0x0,0x0,0x4400400a,0x218e9475,0x0,0x0,0x80000,0x0,0x21069465,0x21069465,0x400000,0x21069465,0x218e9475,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x20400,0x20400,0x1000001,0x1000001,0x0,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,0x0,0x21069465,0x21069465,0x21069465,0x400000,0x4000,0x4000,0x40010800,0x880,0x40000000,0x40010800,0x4400488a,0x0,0x4400488a,0x4400488a,0x0,0x40010800,0x0,0x40010800,0x40010800,0x0,0x4400488a,0x40010800,0x0,0x200,0x40010800,0x4400488a,0x0,0x4400488a,0x40010800,0x0,0x40010800,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4004000,0x0,0x2,0x40000008,0x0,0x0,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x4400400a,0x0,0x0,0x0,};\r
}\r
private static void jj_la1_init_2() {\r
- jj_la1_2 = new int[] {0x4000010,0x0,0xc0000000,0x0,0x0,0x0,0x0,0xc0000000,0x4,0x0,0x4000000,0x80,0x0,0x0,0x80,0x0,0x0,0x8000000,0x4000010,0x0,0x0,0x0,0x4000010,0x3c03c015,0xc4000010,0x0,0x0,0x0,0x0,0xc4000010,0xc4000010,0x0,0xc4000010,0xc4000010,0x10,0x4000010,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x4,0x3000000,0x1000000,0x3000000,0x4000010,0x80,0x4000010,0x0,0x0,0x4000010,0x3000000,0x0,0x0,0xc4000010,0xc4000010,0xc4000010,0x0,0x0,0x0,0x4000010,0x4000000,0x2000000,0x4000010,0x3c03c015,0x0,0x3c03c015,0x3c03c015,0x0,0x4000010,0x0,0x4000010,0x4000010,0x0,0x3c03c015,0x4000010,0x80,0x0,0x4000010,0x3c03c015,0x0,0x3c03c015,0x4000010,0x0,0x4000010,0x0,0x3c03c015,0x0,0x3c03c015,0x20,0x20,0x0,0x0,0x0,0x3f00,0x3f00,0x3c000,0x3c000,0x3c000,0x3c0000,0x3c0000,0xc00000,0xc00000,0x4000010,0x40,0x38000000,0x4000015,0x10,0x10,0x10,0x4,0x10,0x4,0x3c03c015,0x80,0x80,0x4000000,0x80,0x3c03c015,0x80,0x3c03c015,0x80,0x80,0x3c03c035,0x0,0x4000,0x8000000,};\r
+ jj_la1_2 = new int[] {0x4000010,0x0,0xc0000000,0x0,0x0,0x0,0x0,0xc0000000,0x4,0x0,0x80,0x4000000,0x80,0x0,0x0,0x8000000,0x4000010,0x0,0x0,0x0,0x4000010,0x3c03c015,0xc4000010,0x0,0x0,0x0,0x0,0xc4000010,0xc4000010,0x0,0xc4000010,0xc4000010,0x10,0x4000010,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x4,0x3000000,0x1000000,0x3000000,0x4000010,0x80,0x4000010,0x0,0x0,0x4000010,0x3000000,0x0,0x0,0xc4000010,0xc4000010,0xc4000010,0x0,0x0,0x0,0x4000010,0x4000000,0x2000000,0x4000010,0x3c03c015,0x0,0x3c03c015,0x3c03c015,0x0,0x4000010,0x0,0x4000010,0x4000010,0x0,0x3c03c015,0x4000010,0x80,0x0,0x4000010,0x3c03c015,0x0,0x3c03c015,0x4000010,0x0,0x4000010,0x0,0x3c03c015,0x0,0x3c03c015,0x20,0x20,0x0,0x0,0x0,0x3f00,0x3f00,0x3c000,0x3c000,0x3c000,0x3c0000,0x3c0000,0xc00000,0xc00000,0x4000010,0x40,0x38000000,0x4000015,0x10,0x10,0x10,0x4,0x10,0x4,0x3c03c015,0x80,0x80,0x4000000,0x80,0x3c03c015,0x80,0x3c03c015,0x80,0x80,0x3c03c035,0x0,0x4000,0x8000000,};\r
}\r
final private JJCalls[] jj_2_rtns = new JJCalls[10];\r
private boolean jj_rescan = false;\r
token = new Token();\r
jj_ntk = -1;\r
jj_gen = 0;\r
- for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
}\r
\r
jj_ntk = -1;\r
jjtree.reset();\r
jj_gen = 0;\r
- for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
}\r
\r
token = new Token();\r
jj_ntk = -1;\r
jj_gen = 0;\r
- for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
}\r
\r
jj_ntk = -1;\r
jjtree.reset();\r
jj_gen = 0;\r
- for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
}\r
\r
token = new Token();\r
jj_ntk = -1;\r
jj_gen = 0;\r
- for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
}\r
\r
jj_ntk = -1;\r
jjtree.reset();\r
jj_gen = 0;\r
- for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
}\r
\r
la1tokens[jj_kind] = true;\r
jj_kind = -1;\r
}\r
- for (int i = 0; i < 134; i++) {\r
+ for (int i = 0; i < 132; i++) {\r
if (jj_la1[i] == jj_gen) {\r
for (int j = 0; j < 32; j++) {\r
if ((jj_la1_0[i] & (1<<j)) != 0) {\r
switch (pos)
{\r
case 0:\r
- if ((active1 & 0x80000L) != 0L)\r
- return 15;\r
- if ((active1 & 0x8000L) != 0L)\r
- return 37;\r
- if ((active1 & 0xb30010L) != 0L)\r
- return 9;\r
if ((active0 & 0x3ffffffffffffff0L) != 0L || (active1 & 0xc0000000L) != 0L)\r
{\r
jjmatchedKind = 90;\r
return 2;\r
}\r
+ if ((active1 & 0x80000L) != 0L)\r
+ return 13;\r
+ if ((active1 & 0xb30010L) != 0L)\r
+ return 9;\r
return -1;\r
case 1:\r
- if ((active1 & 0x20000L) != 0L)\r
- return 10;\r
if ((active0 & 0x108420080400000L) != 0L)\r
return 2;\r
if ((active0 & 0x3ef7bdff7fbffff0L) != 0L || (active1 & 0xc0000000L) != 0L)\r
case 44:\r
return jjStopAtPos(0, 71);\r
case 45:\r
- return jjStartNfaWithStates_0(0, 79, 37);\r
+ return jjStopAtPos(0, 79);\r
case 46:\r
jjmatchedKind = 68;\r
return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L);\r
case 47:\r
- return jjStartNfaWithStates_0(0, 83, 15);\r
+ return jjStartNfaWithStates_0(0, 83, 13);\r
case 58:\r
jjmatchedKind = 69;\r
return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);\r
break;\r
case 45:\r
if ((active1 & 0x20000L) != 0L)\r
- return jjStartNfaWithStates_0(1, 81, 10);\r
+ return jjStopAtPos(1, 81);\r
break;\r
case 47:\r
if ((active1 & 0x200000L) != 0L)\r
private int jjMoveNfa_0(int startState, int curPos)\r
{\r
int startsAt = 0;\r
- jjnewStateCnt = 37;\r
+ jjnewStateCnt = 31;\r
int i = 1;\r
jjstateSet[0] = startState;\r
int kind = 0x7fffffff;\r
{\r
switch(jjstateSet[--i])\r
{\r
- case 9:\r
- if ((0x3ff000000000000L & l) != 0L)\r
- {\r
- if (kind > 93)\r
- kind = 93;\r
- jjCheckNAddTwoStates(10, 11);\r
- }\r
- else if (curChar == 45)\r
- jjCheckNAdd(10);\r
- break;\r
- case 37:\r
- if ((0x3ff000000000000L & l) != 0L)\r
- jjCheckNAddTwoStates(32, 33);\r
- if ((0x3ff000000000000L & l) != 0L)\r
- jjCheckNAddTwoStates(25, 26);\r
- if ((0x3ff000000000000L & l) != 0L)\r
+ case 13:\r
+ if (curChar == 47)\r
{\r
- if (kind > 92)\r
- kind = 92;\r
- jjCheckNAdd(24);\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
}\r
+ else if (curChar == 42)\r
+ jjCheckNAddStates(0, 2);\r
break;\r
case 0:\r
if ((0x3ff000000000000L & l) != 0L)\r
{\r
if (kind > 92)\r
kind = 92;\r
- jjCheckNAddStates(0, 4);\r
+ jjCheckNAddStates(3, 7);\r
}\r
else if ((0x100002600L & l) != 0L)\r
{\r
if (kind > 1)\r
kind = 1;\r
}\r
- else if (curChar == 45)\r
- jjCheckNAddStates(5, 7);\r
else if (curChar == 47)\r
jjAddStates(8, 9);\r
else if (curChar == 46)\r
- jjCheckNAddTwoStates(9, 10);\r
+ jjCheckNAdd(9);\r
else if (curChar == 34)\r
jjCheckNAddStates(10, 12);\r
break;\r
- case 15:\r
- if (curChar == 47)\r
- {\r
- if (kind > 3)\r
- kind = 3;\r
- jjCheckNAdd(22);\r
- }\r
- else if (curChar == 42)\r
- jjCheckNAddStates(13, 15);\r
- break;\r
case 2:\r
if ((0x3ff400000000000L & l) == 0L)\r
break;\r
break;\r
case 8:\r
if (curChar == 46)\r
- jjCheckNAddTwoStates(9, 10);\r
+ jjCheckNAdd(9);\r
break;\r
- case 10:\r
+ case 9:\r
if ((0x3ff000000000000L & l) == 0L)\r
break;\r
if (kind > 93)\r
kind = 93;\r
- jjCheckNAddTwoStates(10, 11);\r
- break;\r
- case 12:\r
- if (curChar == 45)\r
- jjCheckNAdd(13);\r
+ jjCheckNAddTwoStates(9, 10);\r
break;\r
- case 13:\r
+ case 11:\r
if ((0x3ff000000000000L & l) == 0L)\r
break;\r
if (kind > 93)\r
kind = 93;\r
- jjCheckNAdd(13);\r
+ jjstateSet[jjnewStateCnt++] = 11;\r
break;\r
- case 14:\r
+ case 12:\r
if (curChar == 47)\r
jjAddStates(8, 9);\r
break;\r
- case 16:\r
+ case 14:\r
if ((0xfffffbffffffffffL & l) != 0L)\r
- jjCheckNAddStates(13, 15);\r
+ jjCheckNAddStates(0, 2);\r
break;\r
- case 17:\r
+ case 15:\r
if (curChar == 42)\r
- jjstateSet[jjnewStateCnt++] = 18;\r
+ jjstateSet[jjnewStateCnt++] = 16;\r
break;\r
- case 18:\r
+ case 16:\r
if ((0xffff7fffffffffffL & l) != 0L)\r
- jjCheckNAddStates(13, 15);\r
+ jjCheckNAddStates(0, 2);\r
break;\r
- case 19:\r
+ case 17:\r
if (curChar == 47 && kind > 2)\r
kind = 2;\r
break;\r
- case 20:\r
+ case 18:\r
if (curChar == 42)\r
- jjstateSet[jjnewStateCnt++] = 19;\r
+ jjstateSet[jjnewStateCnt++] = 17;\r
break;\r
- case 21:\r
+ case 19:\r
if (curChar != 47)\r
break;\r
if (kind > 3)\r
kind = 3;\r
- jjCheckNAdd(22);\r
+ jjCheckNAdd(20);\r
break;\r
- case 22:\r
+ case 20:\r
if ((0xfffffffffffffbffL & l) == 0L)\r
break;\r
if (kind > 3)\r
kind = 3;\r
- jjCheckNAdd(22);\r
+ jjCheckNAdd(20);\r
break;\r
- case 23:\r
- if (curChar == 45)\r
- jjCheckNAddStates(5, 7);\r
+ case 21:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAddStates(3, 7);\r
break;\r
- case 24:\r
+ case 22:\r
if ((0x3ff000000000000L & l) == 0L)\r
break;\r
if (kind > 92)\r
kind = 92;\r
- jjCheckNAdd(24);\r
+ jjCheckNAdd(22);\r
break;\r
- case 25:\r
+ case 23:\r
if ((0x3ff000000000000L & l) != 0L)\r
- jjCheckNAddTwoStates(25, 26);\r
+ jjCheckNAddTwoStates(23, 24);\r
break;\r
- case 26:\r
+ case 24:\r
if (curChar != 46)\r
break;\r
if (kind > 93)\r
kind = 93;\r
- jjCheckNAddStates(16, 18);\r
- break;\r
- case 27:\r
- if (curChar == 45)\r
- jjCheckNAdd(28);\r
+ jjCheckNAddTwoStates(25, 26);\r
break;\r
- case 28:\r
+ case 25:\r
if ((0x3ff000000000000L & l) == 0L)\r
break;\r
if (kind > 93)\r
kind = 93;\r
- jjCheckNAddTwoStates(28, 29);\r
+ jjCheckNAddTwoStates(25, 26);\r
break;\r
- case 30:\r
- if (curChar == 45)\r
- jjCheckNAdd(31);\r
- break;\r
- case 31:\r
+ case 27:\r
if ((0x3ff000000000000L & l) == 0L)\r
break;\r
if (kind > 93)\r
kind = 93;\r
- jjCheckNAdd(31);\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
break;\r
- case 32:\r
+ case 28:\r
if ((0x3ff000000000000L & l) != 0L)\r
- jjCheckNAddTwoStates(32, 33);\r
+ jjCheckNAddTwoStates(28, 29);\r
break;\r
- case 34:\r
- if (curChar == 45)\r
- jjCheckNAdd(35);\r
- break;\r
- case 35:\r
+ case 30:\r
if ((0x3ff000000000000L & l) == 0L)\r
break;\r
if (kind > 93)\r
kind = 93;\r
- jjCheckNAdd(35);\r
- break;\r
- case 36:\r
- if ((0x3ff000000000000L & l) == 0L)\r
- break;\r
- if (kind > 92)\r
- kind = 92;\r
- jjCheckNAddStates(0, 4);\r
+ jjstateSet[jjnewStateCnt++] = 30;\r
break;\r
default : break;\r
}\r
case 6:\r
jjCheckNAddStates(10, 12);\r
break;\r
- case 11:\r
+ case 10:\r
if ((0x2000000020L & l) != 0L)\r
- jjAddStates(19, 20);\r
+ jjstateSet[jjnewStateCnt++] = 11;\r
break;\r
+ case 14:\r
case 16:\r
- case 18:\r
- jjCheckNAddStates(13, 15);\r
+ jjCheckNAddStates(0, 2);\r
break;\r
- case 22:\r
+ case 20:\r
if (kind > 3)\r
kind = 3;\r
- jjstateSet[jjnewStateCnt++] = 22;\r
+ jjstateSet[jjnewStateCnt++] = 20;\r
break;\r
- case 29:\r
+ case 26:\r
if ((0x2000000020L & l) != 0L)\r
- jjAddStates(21, 22);\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
break;\r
- case 33:\r
+ case 29:\r
if ((0x2000000020L & l) != 0L)\r
- jjAddStates(23, 24);\r
+ jjstateSet[jjnewStateCnt++] = 30;\r
break;\r
default : break;\r
}\r
if ((jjbitVec0[i2] & l2) != 0L)\r
jjCheckNAddStates(10, 12);\r
break;\r
+ case 14:\r
case 16:\r
- case 18:\r
if ((jjbitVec0[i2] & l2) != 0L)\r
- jjCheckNAddStates(13, 15);\r
+ jjCheckNAddStates(0, 2);\r
break;\r
- case 22:\r
+ case 20:\r
if ((jjbitVec0[i2] & l2) == 0L)\r
break;\r
if (kind > 3)\r
kind = 3;\r
- jjstateSet[jjnewStateCnt++] = 22;\r
+ jjstateSet[jjnewStateCnt++] = 20;\r
break;\r
default : break;\r
}\r
kind = 0x7fffffff;\r
}\r
++curPos;\r
- if ((i = jjnewStateCnt) == (startsAt = 37 - (jjnewStateCnt = startsAt)))\r
+ if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt)))\r
return curPos;\r
try { curChar = input_stream.readChar(); }\r
catch(java.io.IOException e) { return curPos; }\r
}\r
}\r
static final int[] jjnextStates = {
- 24, 25, 26, 32, 33, 24, 25, 32, 15, 21, 4, 5, 7, 16, 17, 20,
- 27, 28, 29, 12, 13, 30, 31, 34, 35,
+ 14, 15, 18, 22, 23, 24, 28, 29, 13, 19, 4, 5, 7,
};\r
\r
/** Token literal values. */\r
0xeL, 0x0L,
};\r
protected SimpleCharStream input_stream;\r
-private final int[] jjrounds = new int[37];\r
-private final int[] jjstateSet = new int[74];\r
+private final int[] jjrounds = new int[31];\r
+private final int[] jjstateSet = new int[62];\r
private final StringBuilder jjimage = new StringBuilder();\r
private StringBuilder image = jjimage;\r
private int jjimageLen;\r
{\r
int i;\r
jjround = 0x80000001;\r
- for (i = 37; i-- > 0;)\r
+ for (i = 31; i-- > 0;)\r
jjrounds[i] = 0x80000000;\r
}\r
\r
public int JJTTERM = 62;\r
public int JJTMUL_OP = 63;\r
public int JJTFACTOR = 64;\r
- public int JJTDER_INITIAL = 65;\r
- public int JJTSUBSCRIPT_2 = 66;\r
- public int JJTARRAY = 67;\r
- public int JJTPRIMARY = 68;\r
- public int JJTNAME = 69;\r
- public int JJTCOMPONENT_REFERENCE = 70;\r
- public int JJTFUNCTION_CALL_ARGS = 71;\r
- public int JJTFUNCTION_ARGUMENTS = 72;\r
- public int JJTNAMED_ARGUMENTS = 73;\r
- public int JJTNAMED_ARGUMENT = 74;\r
- public int JJTOUTPUT_EXPRESSION_LIST = 75;\r
- public int JJTEXPRESSION_LIST = 76;\r
- public int JJTARRAY_SUBSCRIPTS = 77;\r
- public int JJTSUBSCRIPT = 78;\r
- public int JJTVOID = 79;\r
- public int JJTANNOTATION = 80;\r
+ public int JJTFACTOR_OP = 65;\r
+ public int JJTDER_INITIAL = 66;\r
+ public int JJTSUBSCRIPT_2 = 67;\r
+ public int JJTARRAY = 68;\r
+ public int JJTPRIMARY = 69;\r
+ public int JJTNAME = 70;\r
+ public int JJTCOMPONENT_REFERENCE = 71;\r
+ public int JJTFUNCTION_CALL_ARGS = 72;\r
+ public int JJTFUNCTION_ARGUMENTS = 73;\r
+ public int JJTNAMED_ARGUMENTS = 74;\r
+ public int JJTNAMED_ARGUMENT = 75;\r
+ public int JJTOUTPUT_EXPRESSION_LIST = 76;\r
+ public int JJTEXPRESSION_LIST = 77;\r
+ public int JJTARRAY_SUBSCRIPTS = 78;\r
+ public int JJTSUBSCRIPT = 79;\r
+ public int JJTVOID = 80;\r
+ public int JJTANNOTATION = 81;\r
\r
\r
public String[] jjtNodeName = {\r
"term",\r
"mul_op",\r
"factor",\r
+ "factor_op",\r
"der_initial",\r
"subscript_2",\r
"array",\r
"annotation",\r
};\r
}\r
-/* JavaCC - OriginalChecksum=2406c3a5da0aa9cd9047b868bc6069b1 (do not edit this line) */\r
+/* JavaCC - OriginalChecksum=c86e9178ecd31c01eb2447d79ce33b0f (do not edit this line) */\r
| "*" | "/" | ".*" | "./"\r
| "^" | ".^"\r
| "=" | ":=" \r
-| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".","0"-"9"])* >\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".", "0"-"9"])* >\r
| <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
{ matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
-| <UNSIGNED_INTEGER: (["-"])? (["0"-"9"])+ >\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
| <UNSIGNED_NUMBER: \r
( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
| "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
// class_specifier\r
( "encapsulated" )?\r
( "partial" )?\r
- ( "class" | "model" | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
+ ( "class" { jjtn000.op = "class"; } | "model" { jjtn000.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
"package" | "function" { jjtn000.op = "function"; } | "operator" | "operator function" | "operator record" )\r
class_specifier()/*@bgen(jjtree)*/\r
} catch (Throwable jjte000) {\r
// end IDENT \r
LOOKAHEAD(2) t=<IDENT> { jjtn000.op = t.image; } string_comment() composition() "end" <IDENT>\r
| LOOKAHEAD(2) <IDENT> "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment()\r
- | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()\r
- |LOOKAHEAD(3) <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
- | "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT>/*@bgen(jjtree)*/\r
+ | LOOKAHEAD(3) <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
+ | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()/*@bgen(jjtree)*/\r
} catch (Throwable jjte000) {\r
if (jjtc000) {\r
jjtree.clearNodeScope(jjtn000);\r
jjtree.closeNodeScope(jjtn000, true);\r
}\r
}\r
-/*@egen*/ \r
+/*@egen*/\r
+ //| "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT> \r
}\r
\r
void base_prefix() : {/*@bgen(jjtree) base_prefix */\r
// ( ( class_definition | component_clause) |\r
// replaceable ( class_definition | component_clause)\r
// [constraining_clause comment])\r
- import_clause() |\r
- extends_clause() |\r
+ import_clause()/*@bgen(jjtree)*/\r
+ {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ }\r
+/*@egen*/ { return jjtn000; } |\r
+ extends_clause()/*@bgen(jjtree)*/\r
+ {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ }\r
+/*@egen*/ { return jjtn000; } |\r
( "redeclare" )?\r
( "final" )?\r
- ( "inner" )? ( "outer" )?\r
+ ( "inner" { jjtn000.op = "inner"; } )? ( "outer" { jjtn000.op = "outer"; } )?\r
( (class_definition() | component_clause()) |\r
"replaceable" (class_definition() | component_clause())\r
(constraining_clause() comment())?)/*@bgen(jjtree)*/\r
jjtree.closeNodeScope(jjtn000, true);\r
jjtc000 = false;\r
}\r
-/*@egen*/ { jjtn000.op = "/";} | ".*" | "./"/*@bgen(jjtree)*/\r
+/*@egen*/ { jjtn000.op = "/";} | ".*"/*@bgen(jjtree)*/\r
+ {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ }\r
+/*@egen*/ { jjtn000.op = ".*";} | "./"/*@bgen(jjtree)*/\r
} finally {\r
if (jjtc000) {\r
jjtree.closeNodeScope(jjtn000, true);\r
} {/*@bgen(jjtree) factor */\r
try {\r
/*@egen*/\r
- primary() ( "^" | ".^" primary() )?/*@bgen(jjtree)*/\r
+ primary() ( factor_op() primary() )?/*@bgen(jjtree)*/\r
} catch (Throwable jjte000) {\r
if (jjtc000) {\r
jjtree.clearNodeScope(jjtn000);\r
/*@egen*/\r
}\r
\r
+void factor_op() : {/*@bgen(jjtree) factor_op */\r
+ SimpleNode jjtn000 = new SimpleNode(JJTFACTOR_OP);\r
+ boolean jjtc000 = true;\r
+ jjtree.openNodeScope(jjtn000);\r
+/*@egen*/\r
+} {/*@bgen(jjtree) factor_op */\r
+ try {\r
+/*@egen*/\r
+ "^"/*@bgen(jjtree)*/\r
+ {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ }\r
+/*@egen*/ { jjtn000.op = "^";} | ".^"/*@bgen(jjtree)*/\r
+ {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ jjtc000 = false;\r
+ }\r
+/*@egen*/ { jjtn000.op = ".^";}/*@bgen(jjtree)*/\r
+ } finally {\r
+ if (jjtc000) {\r
+ jjtree.closeNodeScope(jjtn000, true);\r
+ }\r
+ }\r
+/*@egen*/\r
+}\r
+\r
void der_initial() : {/*@bgen(jjtree) der_initial */\r
SimpleNode jjtn000 = new SimpleNode(JJTDER_INITIAL);\r
boolean jjtc000 = true;\r
/*@egen*/\r
//expression [ "," function_arguments | for for_indices ]\r
//| named_arguments\r
- LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() )?\r
+ LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() { jjtn000.op = "for"; } )?\r
| named_arguments()/*@bgen(jjtree)*/\r
} catch (Throwable jjte000) {\r
if (jjtc000) {\r
| "*" | "/" | ".*" | "./"\r
| "^" | ".^"\r
| "=" | ":=" \r
-| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".","0"-"9"])* >\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".", "0"-"9"])* >\r
| <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
{ matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
-| <UNSIGNED_INTEGER: (["-"])? (["0"-"9"])+ >\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
| <UNSIGNED_NUMBER: \r
( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
| "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
// class_specifier\r
( "encapsulated" )?\r
( "partial" )?\r
- ( "class" | "model" | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
+ ( "class" { jjtThis.op = "class"; } | "model" { jjtThis.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
"package" | "function" { jjtThis.op = "function"; } | "operator" | "operator function" | "operator record" )\r
class_specifier()\r
}\r
// end IDENT \r
LOOKAHEAD(2) t=<IDENT> { jjtThis.op = t.image; } string_comment() composition() "end" <IDENT>\r
| LOOKAHEAD(2) <IDENT> "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment()\r
+ | LOOKAHEAD(3) <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
| LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()\r
- |LOOKAHEAD(3) <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
- | "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT> \r
+ //| "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT> \r
}\r
\r
void base_prefix() : {\r
// ( ( class_definition | component_clause) |\r
// replaceable ( class_definition | component_clause)\r
// [constraining_clause comment])\r
- import_clause() |\r
- extends_clause() |\r
+ import_clause() { return jjtThis; } |\r
+ extends_clause() { return jjtThis; } |\r
( "redeclare" )?\r
( "final" )?\r
- ( "inner" )? ( "outer" )?\r
+ ( "inner" { jjtThis.op = "inner"; } )? ( "outer" { jjtThis.op = "outer"; } )?\r
( (class_definition() | component_clause()) |\r
"replaceable" (class_definition() | component_clause())\r
(constraining_clause() comment())?)\r
\r
void mul_op() : {\r
} {\r
- "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} | ".*" | "./"\r
+ "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} | ".*" { jjtThis.op = ".*";} | "./"\r
}\r
\r
void factor() : {\r
} {\r
- primary() ( "^" | ".^" primary() )?\r
+ primary() ( factor_op() primary() )?\r
+}\r
+\r
+void factor_op() : {\r
+} {\r
+ "^" { jjtThis.op = "^";} | ".^" { jjtThis.op = ".^";}\r
}\r
\r
void der_initial() : { \r
} {\r
//expression [ "," function_arguments | for for_indices ]\r
//| named_arguments\r
- LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() )?\r
+ LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() { jjtThis.op = "for"; } )?\r
| named_arguments()\r
}\r
\r
* \r
* @return Open Modelica home directory\r
*/\r
- private static File getOMHome() {\r
+ public static File getOMHome() {\r
Preferences node = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);\r
String omHomePath = node.get(OpenModelicaPreferences.OM_HOME, null);\r
if (omHomePath != null) {\r
thread.run();\r
}\r
\r
- public static SimulationLocation createSimulationLocation(File modelDir, String modelName, String modelContent) { \r
+ public static SimulationLocation createSimulationLocation(File modelDir, String modelName, String modelContent, File omHome, boolean isOldOMVersion) { \r
if (!modelDir.isDirectory()) {\r
return null;\r
}\r
}\r
\r
// full model files are (apparently) only needed for old parameter comparison routines\r
- if (isOldOMVersion()) {\r
+ if (isOldOMVersion) {\r
location.fullModelDir = new File(location.getModelDir(), "fullModel");\r
if (!location.fullModelDir.isDirectory()) {\r
location.fullModelDir.mkdir();\r
location.fullModelScriptFile = new File(location.fullModelDir, location.getModelName() + "_full.mos");\r
}\r
\r
- location.omHome = getOMHome();\r
+ location.omHome = omHome;\r
\r
return location;\r
}\r
*/\r
public DataSet getDataSet(String name) {\r
for(DataSet set : variables)\r
- if(set.name.equalsIgnoreCase(name))\r
+ if(set.name.equals(name)) // Why on earth had these been changed to equalsIgnoreCase???\r
return set;\r
for(DataSet set : initials)\r
- if(set.name.equalsIgnoreCase(name))\r
+ if(set.name.equals(name)) // Why on earth had these been changed to equalsIgnoreCase???\r
return set;\r
return null;\r
}\r
SYSDYN.DefaultRealization <T L0X.Realization
SYSDYN.ModulesSearchFunction : L0.Function
+ L0.HasLabel "Sysdyn Search" : L0.String
SYSDYN.SearchContribution : WORKBENCH.SearchContribution
WORKBENCH.hasSearchFunction SYSDYN.ModulesSearchFunction
>-- SYSDYN.DelayExpression.order --> L0.Integer <R SYSDYN.Expression.equation : L0.FunctionalRelation
>-- SYSDYN.DelayExpression.delayTime --> L0.String <R SYSDYN.Expression.equation : L0.FunctionalRelation
>-- SYSDYN.DelayExpression.initialValue --> L0.String <R SYSDYN.HasEquationOrEmpty : L0.FunctionalRelation
+ >-- SYSDYN.DelayExpression.isInformationDelay --> SYSDYN.DelayExpression <R L0.IsRelatedTo : L0.Tag
+ @L0.symmetric
SYSDYN.StockExpression <T SYSDYN.Expression
>-- SYSDYN.StockExpression.useCustomIntegral --> SYSDYN.StockExpression <R L0.IsRelatedTo : L0.Tag
>-- SYSDYN.DependencyConnection.strokeWidth --> L0.Float <R L0.HasProperty : L0.FunctionalRelation
@L0.assert SYSDYN.DependencyConnection.strokeWidth
0.3 : L0.Float
- @L0.assert SYSDYN.Dependency.angle 0.1
+ @L0.assert SYSDYN.Dependency.angle 0.3
MOD.DiagramConnectionTypeToConnectionType
SYSDYN.Dependency
@L0.assert G2D.HasFont SYSDYN.DefaultFont
else\r
y := y1 + (y2 - y1)*(u - u1)/(u2 - u1);\r
end if;\r
- end if;"""
\ No newline at end of file
+ end if;"""\r
+ \r
+ \r
+ \r
+FL.unitCast : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """unitCast(u)\r
+\r
+Casts the expression to ANY unit."""\r
+ SYSDYN.SysdynModelicaFunction.inputs _ : L0.List\r
+ @L0.list\r
+ FL.unitCast.u : SYSDYN.SysdynModelicaFunction.Input\r
+ SYSDYN.Variable.type "Real"\r
+ SYSDYN.SysdynModelicaFunction.optional false\r
+ SYSDYN.SysdynModelicaFunction.unit "ANY"\r
+ SYSDYN.SysdynModelicaFunction.definition "the expression to be casted"\r
+ SYSDYN.SysdynModelicaFunction.outputs _ : L0.List\r
+ @L0.list\r
+ FL.unitCast.y : SYSDYN.SysdynModelicaFunction.Output\r
+ SYSDYN.Variable.type "Real"\r
+ SYSDYN.SysdynModelicaFunction.unit "ANY"\r
+ SYSDYN.SysdynModelicaFunction.modelicaFunctionCode """ input Real u "the expression to be casted";\r
+ output Real y "the expression with unit ANY";\r
+algorithm\r
+ y := u;"""\r
output Real z;\r
algorithm\r
z := log(x);""" \r
-
\ No newline at end of file
+ \r
+ \r
+ \r
+VF.GAME : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """GAME(x)\r
+\r
+Returns x during normal simulation with x being any expression.\r
+\r
+In Vensim, this function allows modifying the variable in game mode. However, this behavior is not implemented yet."""\r
+ SYSDYN.SysdynModelicaFunction.inputs _ : L0.List\r
+ @L0.list\r
+ VF.GAME.x : SYSDYN.SysdynModelicaFunction.Input\r
+ SYSDYN.Variable.type "Real"\r
+ SYSDYN.SysdynModelicaFunction.optional false\r
+ SYSDYN.SysdynModelicaFunction.unit "'p"\r
+ SYSDYN.SysdynModelicaFunction.outputs _ : L0.List\r
+ @L0.list\r
+ VF.GAME.z : SYSDYN.SysdynModelicaFunction.Output\r
+ SYSDYN.Variable.type "Real"\r
+ SYSDYN.SysdynModelicaFunction.unit "'p"\r
+ SYSDYN.SysdynModelicaFunction.modelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := x;"""
\ No newline at end of file
public final Resource Built$in_Functions_Vensim_Functions_EXP;\r
public final Resource Built$in_Functions_Vensim_Functions_EXP_x;\r
public final Resource Built$in_Functions_Vensim_Functions_EXP_z;\r
+ public final Resource Built$in_Functions_Vensim_Functions_GAME;\r
+ public final Resource Built$in_Functions_Vensim_Functions_GAME_x;\r
+ public final Resource Built$in_Functions_Vensim_Functions_GAME_z;\r
public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE;\r
public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE_cond;\r
public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse;\r
public final Resource Built$in_Functions_minmax_maximum;\r
public final Resource Built$in_Functions_minmax_minimum;\r
public final Resource Built$in_Functions_minmax_result;\r
+ public final Resource Built$in_Functions_unitCast;\r
+ public final Resource Built$in_Functions_unitCast_u;\r
+ public final Resource Built$in_Functions_unitCast_y;\r
public final Resource Built$in_Functions_xidz;\r
public final Resource Built$in_Functions_xidz_divident;\r
public final Resource Built$in_Functions_xidz_divisor;\r
public final Resource DelayExpression_expression_Inverse;\r
public final Resource DelayExpression_initialValue;\r
public final Resource DelayExpression_initialValue_Inverse;\r
+ public final Resource DelayExpression_isInformationDelay;\r
public final Resource DelayExpression_order;\r
public final Resource DelayExpression_order_Inverse;\r
public final Resource Dependency;\r
public static final String Built$in_Functions_Vensim_Functions_EXP = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/EXP";\r
public static final String Built$in_Functions_Vensim_Functions_EXP_x = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/EXP/x";\r
public static final String Built$in_Functions_Vensim_Functions_EXP_z = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/EXP/z";\r
+ public static final String Built$in_Functions_Vensim_Functions_GAME = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/GAME";\r
+ public static final String Built$in_Functions_Vensim_Functions_GAME_x = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/GAME/x";\r
+ public static final String Built$in_Functions_Vensim_Functions_GAME_z = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/GAME/z";\r
public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/IFTHENELSE";\r
public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE_cond = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/IFTHENELSE/cond";\r
public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/IFTHENELSE/onfalse";\r
public static final String Built$in_Functions_minmax_maximum = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax/maximum";\r
public static final String Built$in_Functions_minmax_minimum = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax/minimum";\r
public static final String Built$in_Functions_minmax_result = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax/result";\r
+ public static final String Built$in_Functions_unitCast = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/unitCast";\r
+ public static final String Built$in_Functions_unitCast_u = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/unitCast/u";\r
+ public static final String Built$in_Functions_unitCast_y = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/unitCast/y";\r
public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz";\r
public static final String Built$in_Functions_xidz_divident = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz/divident";\r
public static final String Built$in_Functions_xidz_divisor = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz/divisor";\r
public static final String DelayExpression_expression_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/expression/Inverse";\r
public static final String DelayExpression_initialValue = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/initialValue";\r
public static final String DelayExpression_initialValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/initialValue/Inverse";\r
+ public static final String DelayExpression_isInformationDelay = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/isInformationDelay";\r
public static final String DelayExpression_order = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/order";\r
public static final String DelayExpression_order_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/order/Inverse";\r
public static final String Dependency = "http://www.simantics.org/Sysdyn-1.1/Dependency";\r
Built$in_Functions_Vensim_Functions_EXP = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP);\r
Built$in_Functions_Vensim_Functions_EXP_x = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP_x);\r
Built$in_Functions_Vensim_Functions_EXP_z = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP_z);\r
+ Built$in_Functions_Vensim_Functions_GAME = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_GAME);\r
+ Built$in_Functions_Vensim_Functions_GAME_x = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_GAME_x);\r
+ Built$in_Functions_Vensim_Functions_GAME_z = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_GAME_z);\r
Built$in_Functions_Vensim_Functions_IFTHENELSE = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE);\r
Built$in_Functions_Vensim_Functions_IFTHENELSE_cond = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE_cond);\r
Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse);\r
Built$in_Functions_minmax_maximum = getResourceOrNull(graph, URIs.Built$in_Functions_minmax_maximum);\r
Built$in_Functions_minmax_minimum = getResourceOrNull(graph, URIs.Built$in_Functions_minmax_minimum);\r
Built$in_Functions_minmax_result = getResourceOrNull(graph, URIs.Built$in_Functions_minmax_result);\r
+ Built$in_Functions_unitCast = getResourceOrNull(graph, URIs.Built$in_Functions_unitCast);\r
+ Built$in_Functions_unitCast_u = getResourceOrNull(graph, URIs.Built$in_Functions_unitCast_u);\r
+ Built$in_Functions_unitCast_y = getResourceOrNull(graph, URIs.Built$in_Functions_unitCast_y);\r
Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz);\r
Built$in_Functions_xidz_divident = getResourceOrNull(graph, URIs.Built$in_Functions_xidz_divident);\r
Built$in_Functions_xidz_divisor = getResourceOrNull(graph, URIs.Built$in_Functions_xidz_divisor);\r
DelayExpression_expression_Inverse = getResourceOrNull(graph, URIs.DelayExpression_expression_Inverse);\r
DelayExpression_initialValue = getResourceOrNull(graph, URIs.DelayExpression_initialValue);\r
DelayExpression_initialValue_Inverse = getResourceOrNull(graph, URIs.DelayExpression_initialValue_Inverse);\r
+ DelayExpression_isInformationDelay = getResourceOrNull(graph, URIs.DelayExpression_isInformationDelay);\r
DelayExpression_order = getResourceOrNull(graph, URIs.DelayExpression_order);\r
DelayExpression_order_Inverse = getResourceOrNull(graph, URIs.DelayExpression_order_Inverse);\r
Dependency = getResourceOrNull(graph, URIs.Dependency);\r
about.text = Simantics System Dynamics\n\\r
\n\\r
-Version 1.7.0\n\\r
+Version 1.8.0\n\\r
\n\\r
-Copyright (c) 2013 Association for Decentralized Information Management in Industry THTH ry.\n\\r
+Copyright (c) 2014 Association for Decentralized Information Management in Industry THTH ry.\n\\r
\n\\r
Contributors:\n\\r
VTT Technical Research Centre of Finland\n\\r
targetID="org.simantics.sysdyn.ui.perspective">\r
<view\r
id="org.simantics.browsing.ui.graph.propertyView"\r
- ratio="0.6f"\r
+ ratio="0.65f"\r
relationship="bottom"\r
relative="org.eclipse.ui.editorss">\r
</view>\r
id="org.simantics.workbench.search.browser"\r
minimized="false"\r
relationship="stack"\r
- relative="org.simantics.browsing.ui.graph.propertyView">\r
+ relative="org.simantics.sysdyn.ui.browser">\r
</view>\r
<!--\r
<view\r
id="org.simantics.workbench.search.browser"\r
minimized="false"\r
relationship="stack"\r
- relative="org.simantics.browsing.ui.graph.propertyView">\r
+ relative="org.simantics.sysdyn.ui.browser">\r
</view>\r
</perspectiveExtension>\r
<perspectiveExtension\r
id="org.simantics.workbench.search.browser"\r
minimized="false"\r
relationship="stack"\r
- relative="org.simantics.browsing.ui.graph.propertyView">\r
+ relative="org.simantics.sysdyn.ui.browser">\r
</view>\r
</perspectiveExtension>\r
</extension>\r
</with>\r
</visibleWhen>\r
</command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.synthesisSimulation"\r
+ hoverIcon="icons/equalizer.png"\r
+ icon="icons/equalizer.png"\r
+ label="Sliders and Trends"\r
+ style="toggle"\r
+ tooltip="Sliders and Trends">\r
+ <visibleWhen>\r
+ <with\r
+ variable="activeContexts">\r
+ <iterate\r
+ ifEmpty="false"\r
+ operator="or">\r
+ <equals\r
+ value="org.simantics.sysdyn.ui.basicExperiment">\r
+ </equals>\r
+ </iterate>\r
+ <and>\r
+ <not>\r
+ <count\r
+ value="0">\r
+ </count>\r
+ </not>\r
+ </and>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
</toolbar>\r
<toolbar\r
id="org.simantics.sysdyn.ui.playbackControlToolbar">\r
</with>\r
</visibleWhen>\r
</command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newModel"\r
+ icon="platform:/plugin/com.famfamfam.silk/icons/chart_organisation.png"\r
+ id="org.simantics.sysdyn.ui.browser.newModel"\r
+ label="Model"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
<!--\r
<command\r
commandId="org.simantics.documentation.workbench.newDocumentation"\r
label="Find"\r
style="push">\r
</command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.activateExperiment"\r
+ icon="platform:/plugin/com.famfamfam.silk/icons/control_play_blue.png"\r
+ id="org.simantics.sysdyn.ui.browser.activateExperiment"\r
+ label="Activate Experiment"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
</menuContribution>\r
<menuContribution\r
locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
id="org.simantics.sysdyn.ui.toggleSimulation.state">\r
</state>\r
</command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.SynthesisSimulation"\r
+ id="org.simantics.sysdyn.ui.synthesisSimulation"\r
+ name="Slider and Trends">\r
+ <state\r
+ class="org.eclipse.jface.commands.ToggleState"\r
+ id="org.simantics.sysdyn.ui.synthesisSimulation.state">\r
+ </state>\r
+ </command>\r
<command\r
defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewModuleNodeHandler"\r
id="org.simantics.sysdyn.ui.newModuleNode"\r
class="org.simantics.sysdyn.ui.handlers.DiagramToolHandler"\r
commandId="org.simantics.sysdyn.ui.diagramTool">\r
</handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator"\r
+ commandId="org.simantics.sysdyn.ui.activateExperiment">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
</extension>\r
<extension\r
point="org.eclipse.ui.importWizards">\r
createArrowShape(shapes,\r
begin.parentObstacle,\r
end.parentObstacle,\r
- 0.1,\r
+ 0.3,\r
null);\r
\r
Path2D path = new Path2D.Double();\r
/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
\r
import java.awt.Color;\r
import java.awt.Font;\r
+import java.io.StringReader;\r
import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Set;\r
import java.util.concurrent.ConcurrentSkipListMap;\r
import java.util.concurrent.atomic.AtomicInteger;\r
\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.Statement;\r
+import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.procedure.AsyncMultiProcedure;\r
import org.simantics.db.procedure.AsyncProcedure;\r
import org.simantics.g2d.element.IElement;\r
import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
import org.simantics.sysdyn.ui.preferences.SysdynDiagramPreferences;\r
import org.simantics.sysdyn.ui.preferences.SysdynDiagramPropertyExternalRead;\r
* consists of connection edge segments and branch points as its children.\r
* \r
* @author Tuukka Lehtonen\r
+ * @author Tuomas Miettinen\r
*/\r
public class DependencyConnectionFactory extends ElementFactoryAdapter {\r
\r
if(result != null && !result.isAsserted(elementResource)) {\r
element.setHint(ElementHints.KEY_TEXT_COLOR, G2DUtils.getColor(graph, result.getObject()));\r
} else {\r
- String color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_COLOR)));\r
- if(color != null) {\r
+ String color;\r
+ if (isForStockInitialOnly(graph, elementResource)) {\r
+ color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_STOCK_INITIAL_COLOR)));\r
+ } else {\r
+ color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_COLOR)));\r
+ }\r
+ if(color != null) {\r
RGB rgb = StringConverter.asRGB(color, null);\r
if(rgb != null) {\r
Color c = new Color(rgb.red, rgb.green, rgb.blue);\r
\r
}\r
\r
+ protected static boolean isForStockInitialOnly(ReadGraph graph,\r
+ Resource elementResource) throws DatabaseException {\r
+ SysdynResource SR = SysdynResource.getInstance(graph);\r
+ ModelingResources MO = ModelingResources.getInstance(graph);\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Resource connection = graph.getPossibleObject(elementResource, MO.DiagramConnectionToConnection);\r
+ Resource tail = graph.getPossibleObject(connection, SR.Variable_HasTail);\r
+ if (tail == null)\r
+ return false;\r
+ \r
+ if (graph.isInstanceOf(tail, SR.Shadow))\r
+ tail = graph.getPossibleObject(tail, SR.Shadow_original);\r
+ \r
+ Resource head = graph.getPossibleObject(connection, SR.Variable_HasHead);\r
+ if (head == null || !graph.isInstanceOf(head, SR.Stock) || tail == null)\r
+ return false;\r
+ \r
+ Resource expressionListResource = graph.getPossibleObject(head, SR.Variable_expressionList);\r
+ List<Resource> expressionList = ListUtils.toPossibleList(graph, expressionListResource);\r
+ \r
+ // Keep track on whether at least one initial equation contains the variable\r
+ boolean initialContainsVariable = false;\r
+ // Go through all expressions\r
+ for (Resource expression : expressionList) {\r
+ if (!graph.isInstanceOf(expression, SR.StockExpression))\r
+ return false;\r
+ \r
+ String tailStr = graph.getPossibleRelatedValue(tail, L0.HasName, Bindings.STRING);\r
+ String integral = graph.getPossibleRelatedValue(expression, SR.StockExpression_integralEquation, Bindings.STRING);\r
+ if (equationContainsVariable(graph, integral, tailStr))\r
+ // At least one integral equation contains the variable\r
+ return false;\r
+ String initial = graph.getPossibleRelatedValue(expression, SR.StockExpression_initialEquation, Bindings.STRING);\r
+ if (!initialContainsVariable && equationContainsVariable(graph, initial, tailStr))\r
+ // At least one initial equation contains the variable\r
+ initialContainsVariable = true;\r
+ }\r
+ \r
+ // No integral equation contains the variable.\r
+ return initialContainsVariable;\r
+ }\r
+\r
+ private static boolean equationContainsVariable(ReadGraph graph,\r
+ String equation, String variable) {\r
+ ExpressionParser parser = new ExpressionParser(new StringReader(equation));\r
+ try {\r
+ parser.expr();\r
+ } catch (Throwable t) {\r
+ return false;\r
+ }\r
+ \r
+ // Collect references\r
+ Set<String> references = parser.getReferences().keySet();\r
+ \r
+ // See if the equation contains variable\r
+ return references.contains(variable);\r
+ }\r
+\r
}\r
private Stroke stroke;\r
private Shape beginBounds;\r
private Shape endBounds;\r
- private double angle = 0.1;\r
+ private double angle = 0.3;\r
private String side;\r
private boolean delayMark = false;\r
private boolean arrowHead = true;\r
@Override\r
public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {\r
try {\r
- // Check whether only currently open diagram is searched\r
- String filteredQuery = query.getQuery("Name","Types");\r
- Collection<Map<String, Object>> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model, filteredQuery, MAX_RESULTS);\r
+ String origQuery = query.getOriginalQuery();\r
+ SearchQuery wildcardedQuery;\r
+ if (!origQuery.isEmpty()) // Add asterisks for performSearch \r
+ wildcardedQuery = query.withOriginalQuery("*" + origQuery + "*");\r
+ else\r
+ wildcardedQuery = query.withOriginalQuery("*");\r
+ \r
+ String filteredQuery = wildcardedQuery.escaped(false).getQuery("Name","Types");\r
+ Collection<Map<String, Object>> results = Searching.performSearch(graph, \r
+ Layer0X.getInstance(graph).Dependencies, \r
+ model, \r
+ filteredQuery, \r
+ MAX_RESULTS);\r
\r
+ // Check whether only currently open diagram is searched\r
if (!query.getSearchParams().contains(FindSearchTrim.CURRENT_DIAGRAM_OPTION))\r
return generateSearchResults(graph, results, Scope.ALL_MODELS);\r
else\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2014 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.Command;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
+import org.eclipse.ui.commands.IElementUpdater;\r
+import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * @author Tuomas Miettinen\r
+ */\r
+public class SynthesisSimulation extends AbstractHandler implements IElementUpdater {\r
+\r
+ public static final String COMMAND = "org.simantics.sysdyn.ui.synthesisSimulation";\r
+ public static final String STATE = "org.simantics.sysdyn.ui.synthesisSimulation.state";\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = service.getCommand(COMMAND);\r
+ State state = command.getState(STATE);\r
+ Boolean value = (Boolean) state.getValue();\r
+ value = !value;\r
+ state.setValue(value);\r
+ service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+ \r
+ Command toggleCommand = service.getCommand(ToggleSimulation.COMMAND);\r
+ State toggleState = toggleCommand.getState(ToggleSimulation.STATE);\r
+ toggleState.setValue(value);\r
+ service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+ \r
+ IExperimentManager manager = \r
+ SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if(experiment instanceof SysdynExperiment) {\r
+ if(getState()) {\r
+ ((SysdynExperiment)experiment).toggleSimulation(true);\r
+ } else {\r
+ ((SysdynExperiment)experiment).toggleSimulation(false);\r
+ }\r
+ }\r
+ \r
+ HandlerUtils.saveBeforeExperimentRun(event);\r
+\r
+ return null;\r
+ }\r
+\r
+ public static Boolean getState() {\r
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = service.getCommand(COMMAND);\r
+ State state = command.getState(STATE);\r
+ return (Boolean)state.getValue();\r
+ }\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public void updateElement(UIElement element, Map parameters) {\r
+ ICommandService commandService =\r
+ (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = commandService.getCommand(COMMAND);\r
+ boolean checked = (Boolean) command.getState(STATE).getValue();\r
+ element.setChecked(checked);\r
+ }\r
+}\r
\r
import java.util.concurrent.Semaphore;\r
\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.core.runtime.IStatus;\r
import org.eclipse.core.runtime.Status;\r
import org.eclipse.core.runtime.SubMonitor;\r
import org.eclipse.core.runtime.jobs.Job;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.RequestProcessor;\r
import org.simantics.db.Resource;\r
import org.simantics.simulation.project.IExperimentActivationListener;\r
import org.simantics.simulation.project.IExperimentManager;\r
import org.simantics.sysdyn.ui.listeners.SysdynExperimentManagerListener;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.DataContainer;\r
import org.simantics.utils.ui.ErrorLogger;\r
import org.simantics.utils.ui.ExceptionUtils;\r
import org.simantics.utils.ui.dialogs.ShowMessage;\r
\r
-public class SysdynExperimentActivator {\r
+public class SysdynExperimentActivator extends AbstractHandler {\r
/**\r
* @param project\r
* @param experimentManager\r
}\r
}\r
\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ISelection selection = HandlerUtil.getCurrentSelection(event);\r
+ final Resource experiment = ResourceAdaptionUtils.toSingleResource(selection);\r
+ if (experiment == null)\r
+ return null;\r
+\r
+ final IProject project = SimanticsUI.getProject();\r
+ if (project == null)\r
+ return null;\r
+ \r
+ final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if (experimentManager == null) {\r
+ ErrorLogger.defaultLogWarning("Experiment manager not available.", new Exception());\r
+ return null;\r
+ }\r
+ \r
+ SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, experiment);\r
+ return null;\r
+ }\r
+\r
}\r
/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
state.setValue(value);\r
service.refreshElements(RunBasicExperiment.COMMAND, null);\r
\r
+ Command synthesisCommand = service.getCommand(SynthesisSimulation.COMMAND);\r
+ State synthesisState = synthesisCommand.getState(SynthesisSimulation.STATE);\r
+ synthesisState.setValue(false);\r
+ service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+ \r
IExperimentManager manager = \r
SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
IExperiment experiment = manager.getActiveExperiment();\r
// Use import default path.\r
path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
}\r
+ if (saveAs == false && !(new File(path).exists())) {\r
+ // Save == Save as... when the path doesn't exist. \r
+ return getAbsolutePath(model, event, true);\r
+ }\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
\r
/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
import org.simantics.simulation.experiment.ExperimentState;\r
import org.simantics.simulation.experiment.IExperimentListener;\r
import org.simantics.sysdyn.ui.handlers.RunBasicExperiment;\r
+import org.simantics.sysdyn.ui.handlers.SynthesisSimulation;\r
import org.simantics.sysdyn.ui.handlers.ToggleSimulation;\r
import org.simantics.sysdyn.ui.handlers.game.ReloadGameExperimentHandler;\r
import org.simantics.sysdyn.ui.handlers.game.StepHandler;\r
public void run() {\r
ICommandService commandService =\r
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
- Command command = commandService.getCommand(ToggleSimulation.COMMAND);\r
- State buttonState = command.getState(ToggleSimulation.STATE);\r
+ Command toggleCommand = commandService.getCommand(ToggleSimulation.COMMAND);\r
+ State toggleButtonState = toggleCommand.getState(ToggleSimulation.STATE);\r
+ Command synhesisCommand = commandService.getCommand(SynthesisSimulation.COMMAND);\r
+ State synthesisButtonState = synhesisCommand.getState(SynthesisSimulation.STATE);\r
\r
switch(state) {\r
case DISPOSED:\r
- buttonState.setValue(false); \r
+ toggleButtonState.setValue(false); \r
+ synthesisButtonState.setValue(false); \r
break;\r
+ default:\r
+ break;\r
}\r
- commandService.refreshElements(command.getId(), null); \r
+ commandService.refreshElements(toggleCommand.getId(), null); \r
+ commandService.refreshElements(synhesisCommand.getId(), null); \r
commandService.refreshElements(RunBasicExperiment.COMMAND, null);\r
commandService.refreshElements(PlaybackExperimentHandler.COMMAND, null);\r
commandService.refreshElements(PlaybackResetHandler.COMMAND, null);\r
/*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2013, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
*\r
* Contributors:\r
* Semantum Oy\r
+ * VTT Technical Research Centre of Finland\r
*******************************************************************************/\r
\r
package org.simantics.sysdyn.ui.preferences;\r
/**\r
* \r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
public class SysdynDiagramPreferencePage extends FieldEditorPreferencePage implements\r
GridDataFactory.fillDefaults().applyTo(label);\r
\r
addColorFieldEditor(SysdynDiagramPreferences.ARROW_COLOR, "&Dependency", SysdynDiagramPreferences.ARROW_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.ARROW_STOCK_INITIAL_COLOR, "&Dependency to Stock Initial", SysdynDiagramPreferences.ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR);\r
addColorFieldEditor(SysdynDiagramPreferences.FLOW_COLOR, "&Flow", SysdynDiagramPreferences.FLOW_USE_DEFAULT_COLOR);\r
addColorFieldEditor(SysdynDiagramPreferences.AUXILIARY_COLOR, "&Auxiliary", SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_COLOR);\r
addColorFieldEditor(SysdynDiagramPreferences.STOCK_COLOR, "&Stock", SysdynDiagramPreferences.STOCK_USE_DEFAULT_COLOR);\r
/*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2013, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
*\r
* Contributors:\r
* Semantum Oy\r
+ * VTT Technical Research Centre of Finland\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.preferences;\r
\r
/**\r
* \r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
public class SysdynDiagramPreferences {\r
public static String DEFAULT_FONT = "Default font";\r
\r
public static String ARROW_COLOR = "Arrow color";\r
+ public static String ARROW_STOCK_INITIAL_COLOR = "Arrow stock initial color";\r
public static String FLOW_COLOR = "Flow color";\r
public static String AUXILIARY_COLOR = "Auxiliary color";\r
public static String CLOUD_COLOR = "Cloud color";\r
static {\r
colorPreferenceNames = new HashMap<String, String>();\r
colorPreferenceNames.put(SysdynResource.URIs.DependencyConnection, ARROW_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.DependencyConnection + "_stockInitial", ARROW_STOCK_INITIAL_COLOR);\r
colorPreferenceNames.put(SysdynResource.URIs.FlowConnection, FLOW_COLOR);\r
colorPreferenceNames.put(SysdynResource.URIs.AuxiliarySymbol, AUXILIARY_COLOR);\r
colorPreferenceNames.put(SysdynResource.URIs.CloudSymbol, CLOUD_COLOR);\r
}\r
\r
public static String ARROW_USE_DEFAULT_COLOR = "Arrow use default color";\r
+ public static String ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR = "Arrow stock initial use default color";\r
public static String FLOW_USE_DEFAULT_COLOR = "Flow use default color";\r
public static String AUXILIARY_USE_DEFAULT_COLOR = "Auxiliary use default color";\r
public static String CLOUD_USE_DEFAULT_COLOR = "Cloud use default color";\r
static {\r
colorDefaults = new HashMap<String, String>();\r
colorDefaults.put(ARROW_COLOR, ARROW_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(ARROW_STOCK_INITIAL_COLOR, ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR);\r
colorDefaults.put(FLOW_COLOR, FLOW_USE_DEFAULT_COLOR);\r
colorDefaults.put(AUXILIARY_COLOR, AUXILIARY_USE_DEFAULT_COLOR);\r
colorDefaults.put(CLOUD_COLOR, CLOUD_USE_DEFAULT_COLOR);\r
/*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2013, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
*\r
* Contributors:\r
* Semantum Oy\r
+ * VTT Technical Research Centre of Finland\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.preferences;\r
\r
/**\r
* \r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
public class SysdynDiagramPreferencesInitializer extends AbstractPreferenceInitializer { \r
public void initializeDefaultPreferences() {\r
RGB black = new RGB(0, 0, 0);\r
RGB arrow = new RGB(0,128,192);\r
+ RGB arrowToStockInitial = new RGB(128,128,128);\r
\r
IPreferenceStore store = Activator.getDefault().getPreferenceStore();\r
\r
PreferenceConverter.setDefault(store, SysdynDiagramPreferences.DEFAULT_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.ARROW_STOCK_INITIAL_COLOR, arrowToStockInitial);\r
PreferenceConverter.setDefault(store, SysdynDiagramPreferences.ARROW_COLOR, arrow);\r
PreferenceConverter.setDefault(store, SysdynDiagramPreferences.FLOW_COLOR, black);\r
PreferenceConverter.setDefault(store, SysdynDiagramPreferences.AUXILIARY_COLOR, black);\r
\r
\r
store.setDefault(SysdynDiagramPreferences.ARROW_USE_DEFAULT_COLOR, false);\r
+ store.setDefault(SysdynDiagramPreferences.ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR, false);\r
store.setDefault(SysdynDiagramPreferences.FLOW_USE_DEFAULT_COLOR, true);\r
store.setDefault(SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_COLOR, true);\r
store.setDefault(SysdynDiagramPreferences.STOCK_USE_DEFAULT_COLOR, true);\r
import org.simantics.sysdyn.ui.editor.SysdynEditorNamingService;\r
import org.simantics.ui.workbench.IEditorNamingService;\r
import org.simantics.utils.FileUtils;\r
+import org.simantics.utils.ui.BundleUtils;\r
\r
public class SysdynProject extends AbstractProjectFeature {\r
private static final String DEFAULT_PERSPECTIVE = "org.simantics.sysdyn.ui.perspective";\r
final IProject project = getProject();\r
final Session session = getSession();\r
\r
+ try {\r
+ File base = BundleUtils.findFile("org.simantics.sysdyn.ui", "");\r
+ File f = new File(base, "../org.simantics.sysdyn.tests/src/org/simantics/sysdyn/tests/scripts");\r
+ if(f.exists()) {\r
+ System.setProperty("scl.test.path", f.getAbsolutePath());\r
+ }\r
+ } catch (Exception e) {\r
+ \r
+ }\r
+ \r
+\r
getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
\r
// Multi for simupedia use\r
Map<String, Object> map = new HashMap<String, Object>();\r
map.put("year", "year");\r
map.put("month", "month");\r
+ map.put("week", "week");\r
map.put("day", "day");\r
map.put("hour", "hour");\r
map.put("min", "min");\r
import org.eclipse.swt.events.FocusEvent;\r
import org.eclipse.swt.events.FocusListener;\r
import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyEvent;\r
import org.eclipse.swt.events.ModifyListener;\r
import org.eclipse.swt.events.SelectionAdapter;\r
import org.eclipse.swt.events.SelectionEvent;\r
import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Combo;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Label;\r
import org.eclipse.swt.widgets.Spinner;\r
private Spinner order;\r
private final ExpressionWidgetInput input;\r
private Resource expression;\r
+ private Combo delayTypeCombo;\r
\r
/**\r
* Creates a new DelayExpression\r
@Override\r
public void createExpressionFields(Composite parent, final Map<String, Object> data, Table allowedVariables) {\r
// Get possible existing data\r
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent);\r
+ GridLayoutFactory.fillDefaults().numColumns(5).applyTo(parent);\r
String eq = data.get("equation") != null ? (String)data.get("equation") : "";\r
String dt = data.get("delayTime") != null ? (String)data.get("delayTime") : "";\r
String iv = data.get("initialValue") != null ? (String)data.get("initialValue") : "";\r
int o = data.get("order") != null ? (Integer)data.get("order") : 3;\r
\r
Label l = new Label(parent, SWT.NONE);\r
- l.setText("expression");\r
+ l.setText("Expression");\r
\r
// Equation that is delayed\r
equation = new ExpressionField(parent, SWT.BORDER, allowedVariables, true, input);\r
equation.setExpression(eq);\r
- GridDataFactory.fillDefaults().grab(true, true).applyTo(equation);\r
+ GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(equation);\r
equation.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
\r
@Override\r
});\r
\r
l = new Label(parent, SWT.NONE);\r
- l.setText("delay time");\r
+ l.setText("Delay time");\r
\r
// How much the equation is delayed\r
delayTime = new ExpressionField(parent, SWT.BORDER, allowedVariables, true, input);\r
delayTime.setExpression(dt);\r
- GridDataFactory.fillDefaults().grab(true, true).applyTo(delayTime);\r
+ GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(delayTime);\r
\r
delayTime.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
\r
});\r
\r
l = new Label(parent, SWT.NONE);\r
- l.setText("initial value");\r
+ l.setText("Initial value");\r
\r
// What is the initial value of the delay (empty == same as equation)\r
initialValue = new ExpressionField(parent, SWT.BORDER, allowedVariables, true, input);\r
initialValue.setExpression(iv);\r
- GridDataFactory.fillDefaults().grab(true, true).applyTo(initialValue);\r
+ GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(initialValue);\r
\r
initialValue.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
\r
\r
\r
l = new Label(parent, SWT.NONE);\r
- l.setText("order");\r
+ l.setText("Order");\r
\r
// The order of the delay (default == 3)\r
order = new Spinner(parent, SWT.BORDER);\r
save(expression, data);\r
}\r
});\r
- GridDataFactory.fillDefaults().applyTo(order);\r
+ GridDataFactory.fillDefaults().grab(false, false).applyTo(order);\r
+ \r
+ l = new Label(parent, SWT.NONE);\r
+ l.setText("Delay type");\r
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(l);\r
+ \r
+ // The type of the delay (material / information delay)\r
+ delayTypeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);\r
+ delayTypeCombo.add("Material");\r
+ delayTypeCombo.add("Information");\r
+ GridDataFactory.fillDefaults().applyTo(delayTypeCombo);\r
+ \r
+ // Initial selection to the combo\r
+ try {\r
+ boolean isInformationDelay = SimanticsUI.getSession().syncRequest(new Read<Boolean>(){\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ return graph.hasStatement(expression, sr.DelayExpression_isInformationDelay, expression);\r
+ }\r
+ });\r
+ delayTypeCombo.select(isInformationDelay ? 1 : 0);\r
+ } catch (DatabaseException e1) {\r
+ delayTypeCombo.select(0);\r
+ e1.printStackTrace();\r
+ }\r
+ \r
+ // Modify listener for selecting the delay type\r
+ delayTypeCombo.addModifyListener(new ModifyListener() {\r
+\r
+ @Override\r
+ public void modifyText(ModifyEvent e) {\r
+ save(expression, data);\r
+ }\r
+ });\r
\r
lastSelectedText = equation;\r
}\r
class Auxiliary {\r
String equation, delayTime, initialValue;\r
Integer order;\r
+ Boolean isInformationDelay;\r
}\r
\r
Auxiliary results = null;\r
results.delayTime = graph.getPossibleRelatedValue(expression, sr.DelayExpression_delayTime);\r
results.initialValue = graph.getPossibleRelatedValue(expression, sr.DelayExpression_initialValue);\r
results.order = graph.getPossibleRelatedValue(expression, sr.DelayExpression_order);\r
+ results.isInformationDelay = graph.hasStatement(expression, sr.DelayExpression_isInformationDelay, expression);\r
} else {\r
results.equation = "";\r
results.delayTime = "";\r
results.order = 1;\r
+ results.isInformationDelay = false;\r
}\r
return results;\r
}\r
data.put("initialValue", results.initialValue);\r
if(results.order != null)\r
data.put("order", results.order);\r
+ if(results.isInformationDelay != null)\r
+ data.put("isInformationDelay", results.isInformationDelay);\r
}\r
\r
@Override\r
final String currentDelayTime = this.delayTime.getExpression();\r
final String currentInitialValue = this.initialValue.getExpression();\r
final Integer currentOrder = this.order.getSelection();\r
+ final Boolean currentIsInformationDelay = (this.delayTypeCombo.getSelectionIndex() == 1);\r
\r
String oldEquation = (String)data.get("equation");\r
String oldDelayTime = (String)data.get("delayTime");\r
String oldInitialValue = (String)data.get("initialValue");\r
Integer oldOrder = (Integer)data.get("order");\r
+ Boolean oldIsInformationDelay = (Boolean)data.get("isInformationDelay");\r
\r
- if((oldEquation == null || oldDelayTime == null || oldOrder == null || oldInitialValue == null) ||\r
- !oldEquation.equals(currentEquation) || !oldDelayTime.equals(currentDelayTime) ||\r
- !oldOrder.equals(currentOrder) || !oldInitialValue.equals(currentInitialValue)) {\r
+ if(oldEquation == null || oldDelayTime == null || oldOrder == null \r
+ || oldInitialValue == null || oldIsInformationDelay == null \r
+ || !oldEquation.equals(currentEquation) || !oldDelayTime.equals(currentDelayTime) \r
+ || !oldOrder.equals(currentOrder) || !oldInitialValue.equals(currentInitialValue)\r
+ || !oldIsInformationDelay.equals(currentIsInformationDelay)) {\r
// old value was null or value has changed -> Do save\r
\r
data.putAll(data);\r
data.put("delayTime", currentDelayTime);\r
data.put("initialValue", currentInitialValue);\r
data.put("order", currentOrder);\r
+ data.put("isInformationDelay", currentIsInformationDelay);\r
\r
SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
@Override\r
graph.deny(variable, sr.IndependentVariable_activeExpression);\r
graph.claim(variable, sr.IndependentVariable_activeExpression, newExpression);\r
}\r
- }\r
- );\r
+ });\r
expression = newExpression;\r
}\r
\r
g.claimLiteral(expression, sr.DelayExpression_delayTime, currentDelayTime);\r
g.claimLiteral(expression, sr.DelayExpression_initialValue, currentInitialValue);\r
g.claimLiteral(expression, sr.DelayExpression_order, currentOrder);\r
+ if (currentIsInformationDelay)\r
+ g.claim(expression, sr.DelayExpression_isInformationDelay, expression);\r
+ else\r
+ g.deny(expression, sr.DelayExpression_isInformationDelay, expression);\r
}\r
});\r
}\r
data.put("initialValue", this.initialValue.getExpression()); \r
if(this.order != null)\r
data.put("order", this.order.getSelection()); \r
+ if(this.delayTypeCombo != null)\r
+ data.put("isInformationDelay", (this.delayTypeCombo.getSelectionIndex() == 1));\r
}\r
\r
@Override\r
}\r
frame.repaint();\r
frame.validate();\r
- panel.requestFocus();\r
+ panel.requestFocusInWindow();\r
+ //panel.requestFocus();\r
}\r
\r
});\r
+include "UI/Progress"\r
include "Simantics/DB"\r
include "Simantics/Variables"\r
\r
formatDate :: Long -> <ReadGraph> String \r
\r
@JavaName importModel\r
- importModel :: String -> <Proc> ()\r
+ importModel :: String -> <Proc> Resource\r
\r
@JavaName isParameter\r
isParameter :: Variable -> <ReadGraph> Boolean\r
+\r
+ lastValue :: Resource -> String -> String -> Double\r
+\r
+importJava "org.simantics.sysdyn.manager.SysdynExperiments" where\r
+ \r
+ activateExperiment :: Resource -> String\r
+ run :: String -> ()\r
\ No newline at end of file
super(graph, parent, indexes);\r
}\r
\r
+ public static double[] UNRESOLVED = new double[0];\r
+ \r
@Override\r
public double[] getValue() {\r
if(experiment == null)\r
- return new double[0];\r
+ return UNRESOLVED;\r
\r
Collection<SysdynResult> results = experiment.getActiveResults();\r
ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
if(ds != null && ds.values != null && ds.values.length > 0) {\r
result[i] = ds.values[ds.values.length-1];\r
} else {\r
- result[i] = 0;\r
+ return UNRESOLVED;\r
}\r
}\r
}\r
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
case 84:\r
jj_consume_token(84);\r
- primary();\r
break;\r
case 85:\r
jj_consume_token(85);\r
- primary();\r
break;\r
default:\r
jj_la1[15] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
+ primary();\r
break;\r
default:\r
jj_la1[16] = jj_gen;\r
return false;\r
}\r
\r
- private boolean jj_3R_74() {\r
+ private boolean jj_3R_72() {\r
if (jj_scan_token(67)) return true;\r
- if (jj_3R_73()) return true;\r
+ if (jj_3R_71()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_79() {\r
+ private boolean jj_3R_77() {\r
if (jj_scan_token(41)) return true;\r
if (jj_3R_16()) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_76() {\r
+ private boolean jj_3R_74() {\r
if (jj_scan_token(69)) return true;\r
- if (jj_3R_75()) return true;\r
+ if (jj_3R_73()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_67() {\r
+ private boolean jj_3R_65() {\r
if (jj_scan_token(69)) return true;\r
- if (jj_3R_55()) return true;\r
+ if (jj_3R_53()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_64() {\r
+ private boolean jj_3R_62() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_67()) {\r
+ if (jj_3R_65()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_68()) return true;\r
+ if (jj_3R_66()) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_58() {\r
+ private boolean jj_3R_56() {\r
if (jj_scan_token(66)) return true;\r
- if (jj_3R_52()) return true;\r
+ if (jj_3R_50()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_78() {\r
+ private boolean jj_3R_76() {\r
if (jj_3R_14()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_75() {\r
+ private boolean jj_3R_73() {\r
if (jj_3R_14()) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_79()) jj_scanpos = xsp;\r
+ if (jj_3R_77()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_77() {\r
+ private boolean jj_3R_75() {\r
if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_73() {\r
+ private boolean jj_3R_71() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_77()) {\r
+ if (jj_3R_75()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_78()) return true;\r
+ if (jj_3R_76()) return true;\r
}\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_72() {\r
- if (jj_3R_75()) return true;\r
+ private boolean jj_3R_70() {\r
+ if (jj_3R_73()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_76()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_74()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_54() {\r
+ private boolean jj_3R_52() {\r
if (jj_scan_token(68)) return true;\r
- if (jj_3R_53()) return true;\r
+ if (jj_3R_51()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_61() {\r
+ private boolean jj_3R_59() {\r
if (jj_3R_16()) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_64()) jj_scanpos = xsp;\r
+ if (jj_3R_62()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_66() {\r
+ private boolean jj_3R_64() {\r
if (jj_scan_token(69)) return true;\r
- if (jj_3R_65()) return true;\r
+ if (jj_3R_63()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_71() {\r
- if (jj_3R_73()) return true;\r
+ private boolean jj_3R_69() {\r
+ if (jj_3R_71()) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_74()) jj_scanpos = xsp;\r
+ if (jj_3R_72()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_60() {\r
+ private boolean jj_3R_58() {\r
if (jj_3R_13()) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_63()) jj_scanpos = xsp;\r
+ if (jj_3R_61()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
- private boolean jj_3R_55() {\r
+ private boolean jj_3R_53() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_60()) {\r
+ if (jj_3R_58()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_61()) return true;\r
+ if (jj_3R_59()) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_56() {\r
- if (jj_3R_55()) return true;\r
+ private boolean jj_3R_54() {\r
+ if (jj_3R_53()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_70() {\r
+ private boolean jj_3R_68() {\r
if (jj_3R_12()) return true;\r
- if (jj_3R_51()) return true;\r
+ if (jj_3R_49()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_51() {\r
+ private boolean jj_3R_49() {\r
if (jj_scan_token(60)) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_56()) jj_scanpos = xsp;\r
+ if (jj_3R_54()) jj_scanpos = xsp;\r
if (jj_scan_token(61)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_50() {\r
- if (jj_scan_token(85)) return true;\r
- if (jj_3R_41()) return true;\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_57() {\r
- if (jj_3R_62()) return true;\r
+ private boolean jj_3R_55() {\r
+ if (jj_3R_60()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_69() {\r
+ private boolean jj_3R_67() {\r
if (jj_scan_token(67)) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_65() {\r
+ private boolean jj_3R_63() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_69()) {\r
+ if (jj_3R_67()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_70()) {\r
+ if (jj_3R_68()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_71()) return true;\r
+ if (jj_3R_69()) return true;\r
}\r
}\r
return false;\r
\r
private boolean jj_3R_48() {\r
if (jj_scan_token(62)) return true;\r
- if (jj_3R_55()) return true;\r
+ if (jj_3R_53()) return true;\r
if (jj_scan_token(63)) return true;\r
return false;\r
}\r
\r
private boolean jj_3R_47() {\r
if (jj_scan_token(64)) return true;\r
- if (jj_3R_53()) return true;\r
+ if (jj_3R_51()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_54()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_52()) { jj_scanpos = xsp; break; }\r
}\r
if (jj_scan_token(65)) return true;\r
return false;\r
}\r
\r
private boolean jj_3R_45() {\r
- if (jj_3R_52()) return true;\r
+ if (jj_3R_50()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_59() {\r
+ private boolean jj_3R_57() {\r
if (jj_scan_token(69)) return true;\r
if (jj_3R_16()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_62() {\r
+ private boolean jj_3R_60() {\r
if (jj_scan_token(64)) return true;\r
- if (jj_3R_65()) return true;\r
+ if (jj_3R_63()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_66()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_64()) { jj_scanpos = xsp; break; }\r
}\r
if (jj_scan_token(65)) return true;\r
return false;\r
\r
private boolean jj_3R_44() {\r
if (jj_3R_12()) return true;\r
- if (jj_3R_51()) return true;\r
- return false;\r
- }\r
-\r
- private boolean jj_3R_49() {\r
- if (jj_scan_token(84)) return true;\r
- if (jj_3R_41()) return true;\r
+ if (jj_3R_49()) return true;\r
return false;\r
}\r
\r
private boolean jj_3R_42() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_49()) {\r
+ if (jj_scan_token(84)) {\r
jj_scanpos = xsp;\r
- if (jj_3R_50()) return true;\r
+ if (jj_scan_token(85)) return true;\r
}\r
+ if (jj_3R_41()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_53() {\r
+ private boolean jj_3R_51() {\r
if (jj_3R_16()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_59()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_57()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_63() {\r
+ private boolean jj_3R_61() {\r
if (jj_scan_token(69)) return true;\r
- if (jj_3R_55()) return true;\r
+ if (jj_3R_53()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_68() {\r
+ private boolean jj_3R_66() {\r
if (jj_scan_token(21)) return true;\r
- if (jj_3R_72()) return true;\r
+ if (jj_3R_70()) return true;\r
return false;\r
}\r
\r
return false;\r
}\r
\r
- private boolean jj_3R_52() {\r
+ private boolean jj_3R_50() {\r
if (jj_3R_14()) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_57()) jj_scanpos = xsp;\r
+ if (jj_3R_55()) jj_scanpos = xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_58()) jj_scanpos = xsp;\r
+ if (jj_3R_56()) jj_scanpos = xsp;\r
return false;\r
}\r
\r
\r
void factor() : {\r
} {\r
- primary() ( "^" primary() | ".^" primary() )?\r
+ primary() ( ( "^" | ".^" ) primary() )?\r
}\r
\r
void mul_op() : {\r
FunctionUtils.updateFunctionFilesForExperiment(this);\r
\r
\r
- SimulationLocation location = ModelicaManager.createSimulationLocation(simulationDir, sysdynModel.getConfiguration().getLabel(), modelText);\r
+ SimulationLocation location = ModelicaManager.createSimulationLocation(simulationDir, sysdynModel.getConfiguration().getLabel(), modelText, ModelicaManager.getOMHome(), ModelicaManager.isOldOMVersion());\r
if (fmu) {\r
ModelicaManager.createFMUSimulationScripts(location, inits, additionalScript);\r
}\r
--- /dev/null
+package org.simantics.sysdyn.manager;\r
+\r
+import java.util.concurrent.Semaphore;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.NullProgressMonitor;\r
+import org.eclipse.core.runtime.SubMonitor;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.model.ExperimentLoadingFailed;\r
+import org.simantics.simulation.project.IExperimentActivationListener;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class SysdynExperiments {\r
+\r
+ public static String activateExperiment(IProgressMonitor monitor, final IProject project, final IExperimentManager manager, final Resource experimentResource) {\r
+ \r
+ if(monitor == null) monitor = new NullProgressMonitor();\r
+ \r
+ final SubMonitor mon = SubMonitor.convert(monitor, "Activating experiment", 100000);\r
+\r
+// SysdynExperimentManagerListener.listenManager(manager);\r
+ IExperiment[] experiments = manager.getExperiments();\r
+ SubMonitor shutdownMon = mon.newChild(10000);\r
+ int workPerExperiment;\r
+ if (experiments.length > 0)\r
+ workPerExperiment = 10000 / experiments.length;\r
+ else\r
+ workPerExperiment = 10000;\r
+ for(IExperiment e : experiments)\r
+ if(e.getState() != ExperimentState.DISPOSED)\r
+ e.shutdown(shutdownMon.newChild(workPerExperiment));\r
+ mon.setWorkRemaining(90000);\r
+\r
+ final Semaphore activated = new Semaphore(0);\r
+ final DataContainer<Throwable> problem = new DataContainer<Throwable>();\r
+ final DataContainer<IExperiment> run = new DataContainer<IExperiment>();\r
+ manager.startExperiment(experimentResource, new IExperimentActivationListener() {\r
+\r
+ @Override\r
+ public void onExperimentActivated(final IExperiment experiment) {\r
+// MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null));\r
+ activated.release();\r
+ run.set(experiment);\r
+ }\r
+ @Override\r
+ public void onFailure(Throwable e) {\r
+ problem.set(e);\r
+ activated.release();\r
+ }\r
+ @Override\r
+ public void onMessage(IStatus message) {\r
+// MessageService.getDefault().log(message);\r
+ }\r
+ @Override\r
+ public IProgressMonitor getProgressMonitor() {\r
+ return mon;\r
+ }\r
+ }, true);\r
+ try {\r
+ activated.acquire();\r
+ Throwable t = problem.get();\r
+ if (t != null) {\r
+ if (t instanceof ExperimentLoadingFailed) {\r
+// ErrorLogger.defaultLogError(t);\r
+// ShowMessage.showError("Experiment Activation Failed", t.getMessage());\r
+ } else {\r
+// ExceptionUtils.logAndShowError(t);\r
+ }\r
+ }\r
+\r
+ return run.get().getIdentifier();\r
+ //return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Experiment activation failed, see exception for details.", problem.get());\r
+ } catch (InterruptedException e) {\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ \r
+ public static String activateExperiment(Resource experiment) throws DatabaseException {\r
+\r
+// Resource experiment = Layer0Utils.getPossibleChild(graph, model, name);\r
+// if( experiment == null) return false;\r
+\r
+// SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+// if (!graph.isInstanceOf(experiment, SIMU.Experiment)) return false;\r
+ \r
+ final IProject project = Simantics.getProject();\r
+ if (project == null) return null;\r
+ \r
+ final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if(experimentManager == null) return null;\r
+ \r
+ return SysdynExperiments.activateExperiment(null, project, experimentManager, experiment);\r
+ \r
+ }\r
+ \r
+ public static void run(String experimentId) throws DatabaseException {\r
+\r
+ final IProject project = Simantics.getProject();\r
+ if (project == null) return;\r
+ \r
+ final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if(experimentManager == null) return;\r
+ \r
+ IExperiment experiment = experimentManager.getExperiment(experimentId);\r
+ if(experiment instanceof IDynamicExperiment)\r
+ ((IDynamicExperiment)experiment).simulate(true);\r
+ \r
+ }\r
+ \r
+\r
+ \r
+ \r
+}\r
break;\r
case 87:\r
jj_consume_token(87);\r
- primary();\r
break;\r
default:\r
jj_la1[108] = jj_gen;\r
jj_consume_token(-1);\r
throw new ParseException();\r
}\r
+ primary();\r
break;\r
default:\r
jj_la1[109] = jj_gen;\r
return false;\r
}\r
\r
- private boolean jj_3R_138() {\r
+ private boolean jj_3R_137() {\r
if (jj_3R_46()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_136() {\r
+ private boolean jj_3R_135() {\r
Token xsp;\r
xsp = jj_scanpos;\r
if (jj_scan_token(69)) {\r
jj_scanpos = xsp;\r
- if (jj_3R_138()) return true;\r
+ if (jj_3R_137()) return true;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_132() {\r
+ private boolean jj_3R_131() {\r
if (jj_scan_token(71)) return true;\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_134() {\r
+ private boolean jj_3R_133() {\r
if (jj_scan_token(66)) return true;\r
- if (jj_3R_136()) return true;\r
+ if (jj_3R_135()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_131() {\r
+ private boolean jj_3R_130() {\r
if (jj_scan_token(68)) return true;\r
if (jj_scan_token(IDENT)) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_126() {\r
+ private boolean jj_3R_125() {\r
if (jj_3R_46()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_132()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_131()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_137() {\r
+ private boolean jj_3R_136() {\r
if (jj_scan_token(IDENT)) return true;\r
if (jj_scan_token(88)) return true;\r
return false;\r
return false;\r
}\r
\r
- private boolean jj_3R_135() {\r
- if (jj_3R_137()) return true;\r
+ private boolean jj_3R_134() {\r
+ if (jj_3R_136()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_130() {\r
- if (jj_3R_134()) return true;\r
+ private boolean jj_3R_129() {\r
+ if (jj_3R_133()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_133() {\r
- if (jj_3R_135()) return true;\r
+ private boolean jj_3R_132() {\r
+ if (jj_3R_134()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_124() {\r
+ private boolean jj_3R_123() {\r
if (jj_3R_63()) return true;\r
return false;\r
}\r
\r
- private boolean jj_3R_128() {\r
+ private boolean jj_3R_127() {\r
Token xsp;\r
xsp = jj_scanpos;\r
if (jj_3_10()) {\r
jj_scanpos = xsp;\r
- if (jj_3R_133()) return true;\r
+ if (jj_3R_132()) return true;\r
}\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_129() {\r
- if (jj_3R_128()) return true;\r
+ private boolean jj_3R_128() {\r
+ if (jj_3R_127()) return true;\r
return false;\r
}\r
\r
if (jj_scan_token(62)) return true;\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_129()) jj_scanpos = xsp;\r
+ if (jj_3R_128()) jj_scanpos = xsp;\r
if (jj_scan_token(63)) return true;\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_125() {\r
+ private boolean jj_3R_124() {\r
Token xsp;\r
xsp = jj_scanpos;\r
if (jj_scan_token(68)) jj_scanpos = xsp;\r
if (jj_scan_token(IDENT)) return true;\r
xsp = jj_scanpos;\r
- if (jj_3R_130()) jj_scanpos = xsp;\r
+ if (jj_3R_129()) jj_scanpos = xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_131()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_130()) { jj_scanpos = xsp; break; }\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_127() {\r
+ private boolean jj_3R_126() {\r
if (jj_scan_token(70)) return true;\r
return false;\r
}\r
return false;\r
}\r
\r
- private boolean jj_3R_123() {\r
- if (jj_scan_token(87)) return true;\r
- if (jj_3R_113()) return true;\r
- return false;\r
- }\r
-\r
private boolean jj_3R_106() {\r
if (jj_3R_63()) return true;\r
return false;\r
xsp = jj_scanpos;\r
if (jj_scan_token(86)) {\r
jj_scanpos = xsp;\r
- if (jj_3R_123()) return true;\r
+ if (jj_scan_token(87)) return true;\r
}\r
+ if (jj_3R_113()) return true;\r
return false;\r
}\r
\r
\r
private boolean jj_3R_122() {\r
if (jj_scan_token(64)) return true;\r
- if (jj_3R_128()) return true;\r
+ if (jj_3R_127()) return true;\r
if (jj_scan_token(65)) return true;\r
return false;\r
}\r
\r
private boolean jj_3R_121() {\r
if (jj_scan_token(66)) return true;\r
- if (jj_3R_126()) return true;\r
+ if (jj_3R_125()) return true;\r
Token xsp;\r
while (true) {\r
xsp = jj_scanpos;\r
- if (jj_3R_127()) { jj_scanpos = xsp; break; }\r
+ if (jj_3R_126()) { jj_scanpos = xsp; break; }\r
}\r
if (jj_scan_token(67)) return true;\r
return false;\r
private boolean jj_3R_118() {\r
Token xsp;\r
xsp = jj_scanpos;\r
- if (jj_3R_124()) {\r
+ if (jj_3R_123()) {\r
jj_scanpos = xsp;\r
if (jj_scan_token(58)) {\r
jj_scanpos = xsp;\r
}\r
\r
private boolean jj_3R_119() {\r
- if (jj_3R_125()) return true;\r
+ if (jj_3R_124()) return true;\r
return false;\r
}\r
\r
\r
void factor() : {\r
} {\r
- primary() ( "^" | ".^" primary() )?\r
+ primary() ( ( "^" | ".^" ) primary() )?\r
}\r
\r
void primary() : {\r
import java.util.ArrayList;\r
import java.util.Collection;\r
import java.util.Collections;\r
+import java.util.Comparator;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
import java.util.List;\r
* @param Configurations Configurations, one main configuration and possible modules\r
* @return Complete Modelica code of a model\r
*/\r
- public static String write(Collection<Configuration> configurations, boolean isGame, String omVersion) {\r
+ public static String write(Collection<Configuration> _configurations, boolean isGame, String omVersion) {\r
+ \r
+ ArrayList<Configuration> configurations = new ArrayList<Configuration>(_configurations);\r
+ Collections.sort(configurations, new Comparator<Configuration>() {\r
+\r
+ boolean uses(Configuration o1, Configuration o2) {\r
+ ModuleType type = o2.getModuleType();\r
+ if(type == null) return false;\r
+ for(IElement e : o1.getElements()) {\r
+ if(e instanceof Module) {\r
+ Module m = (Module)e;\r
+ if(m.getType().equals(type)) {\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ @Override\r
+ public int compare(Configuration o1, Configuration o2) {\r
+ if(uses(o1, o2)) return 1;\r
+ else if(uses(o2, o1)) return -1;\r
+ else return 0;\r
+ }\r
+ \r
+ });\r
+ \r
Configuration modelConf = null;\r
for(Configuration conf : configurations) {\r
if(conf.getModel() != null) {\r
\r
b.append("\n");\r
\r
+\r
+ if(!enumerations.isEmpty()) {\r
+ b.append("// Enumeration definitions\n");\r
+ for(Enumeration e : enumerations) {\r
+ b.append(e.getDeclaration());\r
+ }\r
+ }\r
+\r
b.append("// Variable definitions\n");\r
for(IndependentVariable variable : variables) {\r
app = variable.getDeclaration();\r
// Input definitions\r
inputDefinitions(b, configuration, inputs, inputReferences);\r
\r
- if(!enumerations.isEmpty()) {\r
- b.append("// Enumeration definitions\n");\r
- for(Enumeration e : enumerations) {\r
- b.append(e.getDeclaration());\r
- }\r
- }\r
-\r
boolean initialEquations = false;\r
for(Stock stock : stocks) {\r
app = stock.getInitialEquation();\r
public String getDocumentationDefinition(ReadGraph graph) throws DatabaseException {\r
return null;\r
}\r
+ \r
+ @Override\r
+ public String getModelicaName() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getModelicaName();\r
+ else\r
+ return super.getModelicaName();\r
+ }\r
+ \r
}\r
\r
package org.simantics.sysdyn.solver;\r
\r
+import java.io.File;\r
import java.util.HashMap;\r
\r
import org.simantics.modelica.ModelicaManager;\r
import org.simantics.sysdyn.modelica.ModelicaWriter;\r
import org.simantics.sysdyn.representation.Model;\r
import org.simantics.sysdyn.solver.SolverSettings.SolverType;\r
+import org.simantics.utils.FileUtils;\r
\r
import fi.semantum.sysdyn.solver.Solver;\r
\r
public class InternalSolver implements ISolver {\r
\r
+ public static final boolean PRINT_CODE = false;\r
+ \r
private SysdynExperiment experiment;\r
private SysdynModel model;\r
private ISolverMonitor monitor;\r
\r
@Override\r
public void initialize() throws Exception {\r
- String omVersion = ModelicaManager.getDefaultOMVersion();\r
- String modelContent = ModelicaWriter.write(model.getModules(), false, omVersion);\r
+// String omVersion = ModelicaManager.getDefaultOMVersion();\r
+ String modelContent = ModelicaWriter.write(model.getModules(), false, "1.9");\r
\r
// update some stuff\r
FunctionUtils.updateFunctionFilesForExperiment(experiment);\r
\r
location = ModelicaManager.createSimulationLocation(experiment.getExperimentDir(), \r
- model.getConfiguration().getLabel(), modelContent);\r
+ model.getConfiguration().getLabel(), modelContent, null, false);\r
\r
// set solver parameters\r
Model representation = model.getConfiguration().getModel();\r
\r
@Override\r
public void buildModel() throws Exception {\r
- String flat = ModelicaManager.getFlatModelText(location, monitor, FunctionUtils.getLibraryPathsForModelica(experiment));\r
- solver.prepare(flat);\r
+ \r
+// String flat = ModelicaManager.getFlatModelText(location, monitor, FunctionUtils.getLibraryPathsForModelica(experiment));\r
+// System.err.println("=== FLAT ===");\r
+// System.err.println(flat);\r
+// System.err.println("=== FLAT ENDS ===");\r
+ \r
+ StringBuilder code = new StringBuilder();\r
+ for(String path : FunctionUtils.getLibraryPathsForModelica(experiment)) {\r
+ File f = new File(location.modelFile.getParentFile(), path);\r
+ code.append(FileUtils.getContents(f));\r
+ }\r
+ code.append(FileUtils.getContents(location.modelFile));\r
+ \r
+ if(PRINT_CODE) {\r
+ System.err.println("=== CODE === ");\r
+ System.err.println(code.toString());\r
+ System.err.println("=== CODE ENDS ===");\r
+ }\r
+\r
+ solver.prepare(code.toString());\r
+ \r
}\r
\r
@Override\r
public void runSolver() throws Exception {\r
+ \r
+ long startTime = System.nanoTime();\r
+ \r
// the number of result intervals in the simulation (account for initial values)\r
int count = (int)((stop - start) / interval) + 1;\r
// the number of steps in one result interval\r
// an array containing an accurate time stamp for each interval\r
double[] times = new double[count];\r
// a map containing values of all variables for each interval\r
- HashMap<String, double[]> values = new HashMap<String, double[]>();\r
+\r
+ String[] keys = solver.keys();\r
+\r
+ double[][] values = new double[keys.length][];\r
+ \r
+// HashMap<String, double[]> values = new HashMap<String, double[]>();\r
// initialize the temporary data structures\r
times[0] = start;\r
- HashMap<String, Double> tmp = solver.values();\r
- for (String key : tmp.keySet()) {\r
- values.put(key, new double[count]);\r
- values.get(key)[0] = tmp.get(key);\r
+ \r
+ double[] valueArray = solver.values();\r
+// HashMap<String, Double> tmp = solver.values();\r
+// String[] keys = new ArrayList<String>(tmp.keySet()).toArray(new String[tmp.size()]);\r
+\r
+ for(int i=0;i<keys.length;i++) {\r
+ values[i] = new double[count];\r
+ values[i][0] = valueArray[i];\r
}\r
\r
// run the simulation\r
solver.step();\r
}\r
times[interval] = times[interval-1] + steps * step;\r
- tmp = solver.values();\r
- for (String key : tmp.keySet()) {\r
- values.get(key)[interval] = tmp.get(key);\r
+\r
+ valueArray = solver.values();\r
+ for(int i=0;i<keys.length;i++) {\r
+ values[i][interval] = valueArray[i];\r
}\r
+ \r
}\r
\r
results = new HashMap<String, SysdynDataSet>();\r
- for (String name : values.keySet()) {\r
- results.put(name, new SysdynDataSet(name, null, times, values.get(name)));\r
+ for(int i=0;i<keys.length;i++) {\r
+ String name = keys[i];\r
+ double[] arr = values[i];\r
+ results.put(name, new SysdynDataSet(name, null, times, arr));\r
}\r
+\r
+// for (String name : values.keySet()) {\r
+// results.put(name, new SysdynDataSet(name, null, times, values.get(name)));\r
+// }\r
+ \r
+ long endTime = System.nanoTime();\r
+ \r
+ System.err.println("ran simulation in " + 1e-6*(endTime-startTime) + "ms.");\r
+ \r
}\r
\r
@Override\r
protected String name;\r
protected SysdynExperiment experiment;\r
protected ISolver solver;\r
+ protected ISolverMonitor solverMonitor;\r
\r
public SysdynSimulationJob(String name, SysdynExperiment experiment) {\r
super(name);\r
this.name = name;\r
this.experiment = experiment;\r
this.solver = null;\r
+ this.solverMonitor = SysdynConsole.INSTANCE;\r
}\r
\r
@Override\r
// has changed, a new solver must be created\r
if (solver == null || !solver.getType().equals(type)) {\r
if (SolverType.INTERNAL.equals(type)) {\r
- solver = new InternalSolver(experiment, experiment.sysdynModel, SysdynConsole.INSTANCE);\r
+ solver = new InternalSolver(experiment, experiment.sysdynModel, solverMonitor);\r
}\r
else if (SolverType.OPENMODELICA.equals(type)) {\r
return new Status(Status.ERROR, pluginId, "The experiment should be reloaded");\r
import java.util.Comparator;\r
import java.util.Date;\r
import java.util.List;\r
+import java.util.concurrent.TimeUnit;\r
\r
import org.eclipse.core.runtime.NullProgressMonitor;\r
+import org.simantics.Simantics;\r
import org.simantics.databoard.Bindings;\r
import org.simantics.databoard.util.Base64;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.common.request.ObjectsWithSupertype;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.EvaluatingListener;\r
+import org.simantics.db.layer0.util.EvaluatingListener.Criterion;\r
+import org.simantics.db.layer0.util.EvaluatingListener.Evaluation;\r
import org.simantics.db.layer0.variable.Variables;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.modeling.ModelingResources;\r
+import org.simantics.scl.runtime.function.FunctionImpl1;\r
import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.adapter.ValueIndexVariable;\r
import org.simantics.sysdyn.manager.SysdynModel;\r
import org.simantics.sysdyn.manager.SysdynModelManager;\r
import org.simantics.sysdyn.representation.Book;\r
import org.simantics.sysdyn.representation.Variability;\r
import org.simantics.sysdyn.representation.Variable;\r
import org.simantics.sysdyn.utils.imports.ImportUtils;\r
+import org.simantics.utils.DataContainer;\r
\r
public class DocumentationUtils {\r
\r
* \r
* @param path\r
*/\r
- public static void importModel(String path) {\r
- ImportUtils.importModelFile(path, new NullProgressMonitor());\r
+ public static Resource importModel(String path) {\r
+ final DataContainer<Resource> m = new DataContainer<Resource>();\r
+ ImportUtils.importModelFile(path, new NullProgressMonitor(), new FunctionImpl1<Resource,WriteRequest>() {\r
+\r
+ @Override\r
+ public WriteRequest apply(Resource model) {\r
+ m.set(model);\r
+ return null;\r
+ }\r
+ \r
+ });\r
+ return m.get();\r
}\r
\r
public static boolean isParameter(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable) throws DatabaseException {\r
Resource expression = expressions.get(0);\r
return graph.isInstanceOf(expression, SR.ParameterExpression);\r
}\r
+ \r
+ public static double lastValue(final Resource experiment, final String runId, final String path) throws DatabaseException {\r
+ \r
+ try {\r
+ double[] values = EvaluatingListener.<double[]>trySyncRequest(Simantics.getSession(),\r
+ \r
+ new UniqueRead<double[]>(){\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public double[] perform(ReadGraph graph) throws DatabaseException{\r
+ \r
+ org.simantics.db.layer0.variable.Variable var = Variables.getVariable(graph, experiment);\r
+ if(var == null) return null;\r
+ org.simantics.db.layer0.variable.Variable run = var.getPossibleChild(graph, runId);\r
+ if(run == null) return null;\r
+ org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, path + "#value#");\r
+ if(v == null) return null;\r
+ return v.getPossibleValue(graph);\r
+ \r
+ } \r
+ }, \r
+ new Criterion<double[]>() {\r
+\r
+ @Override\r
+ public Evaluation evaluate(double[] result) {\r
+ if(result == null) return Evaluation.DISCARD;\r
+ return (result != ValueIndexVariable.UNRESOLVED) ? Evaluation.ACCEPT : Evaluation.IGNORE;\r
+ }\r
+ \r
+ },\r
+ 15, TimeUnit.SECONDS);\r
+ return values[0];\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ return Double.NaN;\r
+ }\r
+ \r
+ }\r
+ \r
}\r
output = (UnitCheckingNode) outputParser.expr();\r
outputReader.close();\r
result.appendResult(output.getUnits(null, functions, allowEquivalents));\r
- result.setUnitType(UnitType.NORMAL);\r
} catch (UnitCheckingException e) {\r
e.printStackTrace();\r
} catch (ParseException e) {\r
while ((index = ret.indexOf('\'')) >= 0) {\r
String replaced = ret.substring(index, index + 2); // The replaced units are always of length 2.\r
try {\r
- ret = ret.replace(replaced, correspondences.get(replaced));\r
+ ret = ret.replace(replaced, "(" + correspondences.get(replaced) + ")");\r
} catch (NullPointerException npe) {\r
throw new UnitCheckingException("Function " + f.getName() + " output unit could not be determined. Replacement unit " \r
+ replaced + " not found in input unit definitions.");\r
--- /dev/null
+The models in this folder are made by Sampsa Ruutu (openprod_demo), \r
+Tero Jokinen (MaintenanceModel, WorkModel), and Ossi Koivula \r
+(HealthModel). Health model and openprod_demo seem to be broken in \r
+newer versions of the tool. The models are not distributed with the \r
+installer, even though they're probably public.
\ No newline at end of file