]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/StandardTypeConstructor.java
Added info on backup location to documentation backup.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / types / StandardTypeConstructor.java
1 package org.simantics.scl.compiler.internal.codegen.types;
2
3 import org.cojen.classfile.TypeDesc;
4 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
5 import org.simantics.scl.compiler.types.TCon;
6 import org.simantics.scl.compiler.types.Type;
7 import org.simantics.scl.compiler.types.kinds.Kind;
8
9 public class StandardTypeConstructor extends TypeConstructor {
10     private TypeDesc typeDesc; // null, if trivial data type (one constructor with one parameter)
11     public boolean external;
12     
13     public StandardTypeConstructor(TCon con, Kind kind) {
14         super(con, kind);
15     }
16     
17     public StandardTypeConstructor(TCon con, Kind kind, TypeDesc typeDesc) {
18         this(con, kind);
19         this.typeDesc = typeDesc;
20     }
21     
22     public StandardTypeConstructor(TCon con, Kind kind, TypeDesc typeDesc, String documentation) {
23         this(con, kind);
24         this.typeDesc = typeDesc;
25         this.documentation = documentation;
26     }
27
28     public void setTypeDesc(TypeDesc typeDesc) {
29         this.typeDesc = typeDesc;
30     }
31     
32     public TypeDesc getTypeDesc() {
33         return typeDesc;
34     }
35
36     @Override
37     public TypeDesc construct(JavaTypeTranslator translator, Type[] parameters) {
38         if(typeDesc == null)
39             typeDesc = translator.toTypeDesc(constructors[0].parameterTypes[0]);
40         return typeDesc;
41     }
42 }