]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/VectorType.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / types / VectorType.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/VectorType.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/VectorType.java
new file mode 100644 (file)
index 0000000..04df8c4
--- /dev/null
@@ -0,0 +1,28 @@
+package org.simantics.scl.compiler.internal.codegen.types;\r
+\r
+\r
+import org.cojen.classfile.TypeDesc;\r
+import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;\r
+import org.simantics.scl.compiler.types.TCon;\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.kinds.Kinds;\r
+\r
+public class VectorType extends TypeConstructor {\r
+    private static final TVar ELEMENT_TYPE = Types.var(Kinds.STAR);\r
+    \r
+    public VectorType(TCon constructor) {\r
+        super(constructor, ELEMENT_TYPE);\r
+    }\r
+    \r
+    @Override\r
+    public TypeDesc construct(JavaTypeTranslator translator, Type[] parameters) {\r
+        Type parameter = Types.canonical(parameters[0]);\r
+        if(parameter instanceof TVar)\r
+            return TypeDesc.OBJECT;\r
+        else\r
+            return translator.toTypeDesc(parameter).toArrayType();\r
+    }\r
+\r
+}\r