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