]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/StandardTypeConstructor.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / types / StandardTypeConstructor.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/StandardTypeConstructor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/StandardTypeConstructor.java
new file mode 100644 (file)
index 0000000..09923c3
--- /dev/null
@@ -0,0 +1,42 @@
+package org.simantics.scl.compiler.internal.codegen.types;
+
+import org.cojen.classfile.TypeDesc;
+import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
+import org.simantics.scl.compiler.types.TCon;
+import org.simantics.scl.compiler.types.Type;
+import org.simantics.scl.compiler.types.kinds.Kind;
+
+public class StandardTypeConstructor extends TypeConstructor {
+    private TypeDesc typeDesc; // null, if trivial data type (one constructor with one parameter)
+    public boolean external;
+    
+    public StandardTypeConstructor(TCon con, Kind kind) {
+        super(con, kind);
+    }
+    
+    public StandardTypeConstructor(TCon con, Kind kind, TypeDesc typeDesc) {
+        this(con, kind);
+        this.typeDesc = typeDesc;
+    }
+    
+    public StandardTypeConstructor(TCon con, Kind kind, TypeDesc typeDesc, String documentation) {
+        this(con, kind);
+        this.typeDesc = typeDesc;
+        this.documentation = documentation;
+    }
+
+    public void setTypeDesc(TypeDesc typeDesc) {
+        this.typeDesc = typeDesc;
+    }
+    
+    public TypeDesc getTypeDesc() {
+        return typeDesc;
+    }
+
+    @Override
+    public TypeDesc construct(JavaTypeTranslator translator, Type[] parameters) {
+        if(typeDesc == null)
+            typeDesc = translator.toTypeDesc(constructors[0].parameterTypes[0]);
+        return typeDesc;
+    }
+}