]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java
Merge "Ensure GetElementClassRequest is not constructed without elementFactory"
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / commands / CommandSession.java
index 8ad47b0a093d9b6ebeecc121e603cf4e0ffaa6f7..82d615ca89f476e248615ffb158075d5b7fa5826 100644 (file)
@@ -1,9 +1,5 @@
 package org.simantics.scl.compiler.commands;
 
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.procedure.TObjectProcedure;
-import gnu.trove.set.hash.THashSet;
-
 import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -20,7 +16,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.common.names.Names;
 import org.simantics.scl.compiler.constants.StringConstant;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EBlock;
@@ -51,7 +47,6 @@ import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
 import org.simantics.scl.compiler.top.ExpressionEvaluator;
 import org.simantics.scl.compiler.top.LocalStorage;
 import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
-import org.simantics.scl.compiler.types.TCon;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.runtime.SCLContext;
@@ -62,6 +57,10 @@ import org.simantics.scl.runtime.reporting.SCLReporting;
 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
 import org.simantics.scl.runtime.tuple.Tuple0;
 
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.procedure.TObjectProcedure;
+import gnu.trove.set.hash.THashSet;
+
 
 public class CommandSession {
 
@@ -78,10 +77,6 @@ public class CommandSession {
     
     PrintStream fileOutput;
 
-    private static final String CONTEXT_MODULE = "Expressions/Context";
-    private static final TCon CONTEXT_TYPE = Types.con(CONTEXT_MODULE, "Context");
-    private static final Name CONTEXT_GET = Name.create(CONTEXT_MODULE, "contextGet");
-
     public CommandSession(ModuleRepository moduleRepository, SCLReportingHandler handler) {
         this.moduleRepository = moduleRepository;
         this.defaultHandler = new PrintDecorator(
@@ -202,7 +197,7 @@ public class CommandSession {
         }, Types.functionE(Types.STRING, Types.PROC, Types.UNIT)));
         LOCAL_FUNCTIONS.put("reset", new LocalFunction(new FunctionImpl2<CommandSession, Tuple0, Tuple0>() {
             @Override
-            public Tuple0 apply(CommandSession commandSession, Tuple0 _) {
+            public Tuple0 apply(CommandSession commandSession, Tuple0 dummy) {
                 commandSession.removeTransientImports();
                 commandSession.removeVariables();
                 commandSession.moduleRepository.getSourceRepository().checkUpdates();
@@ -212,7 +207,7 @@ public class CommandSession {
         }, Types.functionE(Types.UNIT, Types.PROC, Types.UNIT)));
         LOCAL_FUNCTIONS.put("variables", new LocalFunction(new FunctionImpl2<CommandSession, Tuple0, List<String>>() {
             @Override
-            public List<String> apply(CommandSession commandSession, Tuple0 _) {
+            public List<String> apply(CommandSession commandSession, Tuple0 dummy) {
                 ArrayList<String> result = new ArrayList<String>(commandSession.variableTypes.keySet());
                 Collections.sort(result);
                 return result;
@@ -255,7 +250,7 @@ public class CommandSession {
         }, Types.functionE(Types.STRING, Types.PROC, Types.UNIT)));
         LOCAL_FUNCTIONS.put("stopPrintingToFile", new LocalFunction(new FunctionImpl2<CommandSession, Tuple0, Tuple0>() {
             @Override
-            public Tuple0 apply(final CommandSession commandSession, Tuple0 _) {
+            public Tuple0 apply(final CommandSession commandSession, Tuple0 dummy) {
                 if(commandSession.fileOutput != null) {
                     commandSession.fileOutput.close();
                     commandSession.fileOutput = null;
@@ -267,13 +262,13 @@ public class CommandSession {
 
     private LocalEnvironment createLocalEnvironment() {
         return new AbstractLocalEnvironment() {
-            Variable contextVariable = new Variable("context", CONTEXT_TYPE);
+            Variable contextVariable = new Variable("context", Names.Expressions_Context_Context);
             @Override
             public Expression resolve(Environment environment, String localName) {
                 Type type = variableTypes.get(localName);
                 if(type != null)
                     return new EApply(
-                            new EConstant(environment.getValue(CONTEXT_GET), type),
+                            new EConstant(environment.getValue(Names.Expressions_Context_contextGet), type),
                             new EVariable(contextVariable),
                             new ELiteral(new StringConstant(localName))
                             );