]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/JustConstant.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / singletons / JustConstant.java
index 4de7fda198a4658022bfa58e9b0659f02ac9e5af..1ec01dd2484838a05bf28041d6f8949175b1d99d 100644 (file)
@@ -1,90 +1,90 @@
-package org.simantics.scl.compiler.constants.singletons;\r
-\r
-import org.cojen.classfile.TypeDesc;\r
-import org.objectweb.asm.Label;\r
-import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;\r
-import org.simantics.scl.compiler.constants.FunctionValue;\r
-import org.simantics.scl.compiler.constants.GetPrimitiveConstant;\r
-import org.simantics.scl.compiler.constants.LocalVariableConstant;\r
-import org.simantics.scl.compiler.constants.NoRepConstant;\r
-import org.simantics.scl.compiler.internal.codegen.continuations.Cont;\r
-import org.simantics.scl.compiler.internal.codegen.references.IVal;\r
-import org.simantics.scl.compiler.internal.codegen.references.Val;\r
-import org.simantics.scl.compiler.internal.codegen.types.JavaTypeTranslator;\r
-import org.simantics.scl.compiler.internal.codegen.utils.LocalVariable;\r
-import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;\r
-import org.simantics.scl.compiler.types.TVar;\r
-import org.simantics.scl.compiler.types.Type;\r
-import org.simantics.scl.compiler.types.Types;\r
-import org.simantics.scl.compiler.types.exceptions.MatchException;\r
-import org.simantics.scl.compiler.types.kinds.Kinds;\r
-\r
-public class JustConstant extends FunctionValue {\r
-    \r
-    private static final TVar A = Types.var(Kinds.STAR);\r
-    public static final JustConstant INSTANCE = new JustConstant();\r
-    \r
-    private JustConstant() {\r
-        super(new TVar[] {A}, Types.NO_EFFECTS, Types.apply(Types.MAYBE, A), A);\r
-    }\r
-    \r
-    @Override\r
-    public Type applyExact(MethodBuilder mb, Val[] parameters) {                \r
-        parameters[0].push(mb);\r
-        mb.box(parameters[0].getType());\r
-        return getReturnType();\r
-    }\r
-    \r
-    @Override\r
-    public void deconstruct(MethodBuilder mb, IVal parameter,\r
-            Cont success, Label failure) {\r
-        Type componentType;\r
-        try {\r
-            componentType = Types.matchApply(Types.MAYBE, parameter.getType());\r
-        } catch (MatchException e) {\r
-            throw new InternalCompilerError();\r
-        }\r
-        TypeDesc componentTypeDesc =\r
-                mb.getJavaTypeTranslator().toTypeDesc(componentType);\r
-        \r
-        if(failure == null) {\r
-            IVal val = componentTypeDesc.isPrimitive() \r
-                    ? new GetPrimitiveConstant(componentType, parameter, componentTypeDesc)\r
-                    : parameter;\r
-            mb.jump(success, val);\r
-        }\r
-        else {\r
-            Label failureLabel = mb.createLabel();\r
-            \r
-            parameter.push(mb);\r
-            mb.dup();\r
-            mb.ifNullBranch(failureLabel, true);\r
-            \r
-            if(componentTypeDesc.equals(TypeDesc.VOID)) {\r
-                mb.pop();\r
-                mb.jump(success, new NoRepConstant(componentType));\r
-            }\r
-            else {\r
-                if(componentTypeDesc.isPrimitive())\r
-                    mb.convert(JavaTypeTranslator.toObjectType(componentTypeDesc), componentTypeDesc);\r
-                \r
-                LocalVariable lv = mb.createLocalVariable("temp", componentTypeDesc);\r
-                mb.storeLocal(lv);\r
-                \r
-                mb.jump(success, new LocalVariableConstant(componentType, lv));\r
-            }\r
-            \r
-            //\r
-            mb.setLocation(failureLabel);\r
-            mb.pop();\r
-            mb.branch(failure);\r
-        }\r
-    }\r
-    public int constructorTag() {\r
-        return 1;\r
-    }\r
-    @Override\r
-    public String toString() {\r
-        return "Just";\r
-    }\r
+package org.simantics.scl.compiler.constants.singletons;
+
+import org.cojen.classfile.TypeDesc;
+import org.objectweb.asm.Label;
+import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.constants.FunctionValue;
+import org.simantics.scl.compiler.constants.GetPrimitiveConstant;
+import org.simantics.scl.compiler.constants.LocalVariableConstant;
+import org.simantics.scl.compiler.constants.NoRepConstant;
+import org.simantics.scl.compiler.internal.codegen.continuations.Cont;
+import org.simantics.scl.compiler.internal.codegen.references.IVal;
+import org.simantics.scl.compiler.internal.codegen.references.Val;
+import org.simantics.scl.compiler.internal.codegen.types.JavaTypeTranslator;
+import org.simantics.scl.compiler.internal.codegen.utils.LocalVariable;
+import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
+import org.simantics.scl.compiler.types.TVar;
+import org.simantics.scl.compiler.types.Type;
+import org.simantics.scl.compiler.types.Types;
+import org.simantics.scl.compiler.types.exceptions.MatchException;
+import org.simantics.scl.compiler.types.kinds.Kinds;
+
+public class JustConstant extends FunctionValue {
+    
+    private static final TVar A = Types.var(Kinds.STAR);
+    public static final JustConstant INSTANCE = new JustConstant();
+    
+    private JustConstant() {
+        super(new TVar[] {A}, Types.NO_EFFECTS, Types.apply(Types.MAYBE, A), A);
+    }
+    
+    @Override
+    public Type applyExact(MethodBuilder mb, Val[] parameters) {                
+        parameters[0].push(mb);
+        mb.box(parameters[0].getType());
+        return getReturnType();
+    }
+    
+    @Override
+    public void deconstruct(MethodBuilder mb, IVal parameter,
+            Cont success, Label failure) {
+        Type componentType;
+        try {
+            componentType = Types.matchApply(Types.MAYBE, parameter.getType());
+        } catch (MatchException e) {
+            throw new InternalCompilerError();
+        }
+        TypeDesc componentTypeDesc =
+                mb.getJavaTypeTranslator().toTypeDesc(componentType);
+        
+        if(failure == null) {
+            IVal val = componentTypeDesc.isPrimitive() 
+                    ? new GetPrimitiveConstant(componentType, parameter, componentTypeDesc)
+                    : parameter;
+            mb.jump(success, val);
+        }
+        else {
+            Label failureLabel = mb.createLabel();
+            
+            parameter.push(mb);
+            mb.dup();
+            mb.ifNullBranch(failureLabel, true);
+            
+            if(componentTypeDesc.equals(TypeDesc.VOID)) {
+                mb.pop();
+                mb.jump(success, new NoRepConstant(componentType));
+            }
+            else {
+                if(componentTypeDesc.isPrimitive())
+                    mb.convert(JavaTypeTranslator.toObjectType(componentTypeDesc), componentTypeDesc);
+                
+                LocalVariable lv = mb.createLocalVariable("temp", componentTypeDesc);
+                mb.storeLocal(lv);
+                
+                mb.jump(success, new LocalVariableConstant(componentType, lv));
+            }
+            
+            //
+            mb.setLocation(failureLabel);
+            mb.pop();
+            mb.branch(failure);
+        }
+    }
+    public int constructorTag() {
+        return 1;
+    }
+    @Override
+    public String toString() {
+        return "Just";
+    }
 }
\ No newline at end of file