]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 package org.simantics.scl.compiler.internal.codegen.types;\r
2 \r
3 \r
4 import org.cojen.classfile.TypeDesc;\r
5 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;\r
6 import org.simantics.scl.compiler.types.TCon;\r
7 import org.simantics.scl.compiler.types.TVar;\r
8 import org.simantics.scl.compiler.types.Type;\r
9 import org.simantics.scl.compiler.types.Types;\r
10 import org.simantics.scl.compiler.types.kinds.Kinds;\r
11 \r
12 public class VectorType extends TypeConstructor {\r
13     private static final TVar ELEMENT_TYPE = Types.var(Kinds.STAR);\r
14     \r
15     public VectorType(TCon constructor) {\r
16         super(constructor, ELEMENT_TYPE);\r
17     }\r
18     \r
19     @Override\r
20     public TypeDesc construct(JavaTypeTranslator translator, Type[] parameters) {\r
21         Type parameter = Types.canonical(parameters[0]);\r
22         if(parameter instanceof TVar)\r
23             return TypeDesc.OBJECT;\r
24         else\r
25             return translator.toTypeDesc(parameter).toArrayType();\r
26     }\r
27 \r
28 }\r