]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSASimplificationContext.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / utils / SSASimplificationContext.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSASimplificationContext.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSASimplificationContext.java
new file mode 100644 (file)
index 0000000..2740a78
--- /dev/null
@@ -0,0 +1,61 @@
+package org.simantics.scl.compiler.internal.codegen.utils;
+
+import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.constants.SCLConstant;
+import org.simantics.scl.compiler.environment.Environment;
+import org.simantics.scl.compiler.internal.codegen.ssa.SSAModule;
+import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
+
+public class SSASimplificationContext {
+    SSAModule module;
+    Environment environment;
+    boolean modified = false;
+    public static int modiId = 0;
+    int phase;
+    
+    public SSASimplificationContext(SSAModule module, Environment environment, int phase) {
+        this.module = module;
+        this.environment = environment;
+        this.phase = phase;
+    }
+
+    public void markModified(String description) {
+        if(SCLCompilerConfiguration.PRINT_OPTIMIZATION_TRANSFORMATIONS)
+            System.out.println("(" + modiId + ") DID " + description);
+        modified = true;
+        if(SCLCompilerConfiguration.VALIDATE_AFTER_OPTIMIZATIONS)
+            module.validate();
+        ++ modiId;
+    }
+
+    public boolean didModify() {
+        return modified;
+    }
+    
+    public Environment getEnvironment() {
+        return environment;
+    }
+    
+    public int getPhase() {
+        return phase;
+    }
+
+    static int tempNameCount = 0;
+    
+    public void addConstant(SCLConstant constant) {
+        module.put(constant.getName(), constant);        
+    }
+    
+    public SCLConstant removeConstant(Name name) {
+        return module.remove(name);
+    }
+    
+    public void printConstant(Name name) {
+        System.out.println("--- " + name + " ---------------------------");
+        System.out.println(module.get(name));
+    }
+
+    public void validate() {
+        module.validate();
+    }
+}