]> gerrit.simantics Code Review - simantics/platform.git/blob
c9bfa6fdefe6be4a41237baf28b580ae47a2413d
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.modules;\r
2 \r
3 import gnu.trove.map.hash.THashMap;\r
4 \r
5 import org.simantics.scl.compiler.constants.Constant;\r
6 import org.simantics.scl.compiler.elaboration.errors.ElabNode;\r
7 import org.simantics.scl.compiler.types.TPred;\r
8 import org.simantics.scl.compiler.types.TVar;\r
9 \r
10 public class TypeClassInstance extends ElabNode {\r
11     public final TypeClass typeClass;\r
12     public final TPred[] context;    \r
13     public final TPred instance;  \r
14     public final THashMap<String, MethodImplementation> methodImplementations;\r
15     public final Constant generator;\r
16     public final TVar[] generatorParameters;\r
17     public final String javaName;\r
18     public SCLValue[] superExpressions;\r
19         \r
20     public TypeClassInstance(long loc, TypeClass typeClass,\r
21             Constant generator, \r
22             TVar[] generatorParameters, TPred[] context, TPred instance,\r
23             THashMap<String, MethodImplementation> methodImplementations,\r
24             String javaName) {\r
25         this.location = loc;\r
26         this.typeClass = typeClass;\r
27         this.generator = generator;\r
28         this.generatorParameters = generatorParameters;                \r
29         this.context = context;\r
30         this.instance = instance;        \r
31         this.methodImplementations = methodImplementations;\r
32         this.javaName = javaName;\r
33     }\r
34     \r
35     /*\r
36     public void toString(final StringBuilder b) {\r
37         final TypeUnparsingContext tuc = new TypeUnparsingContext();\r
38         b.append("instance (");\r
39         for(int i=0;i<context.length;++i) {\r
40             if(i>0)\r
41                 b.append(", ");\r
42             context[i].toString(tuc);\r
43             b.append(context[i]);\r
44         }\r
45         b.append(") => ");\r
46         b.append(instance.toString(tuc));\r
47         b.append(" where\n");\r
48         methodImplementations.forEachEntry(new TObjectObjectProcedure<String, Name>() {            \r
49             @Override\r
50             public boolean execute(String name, Name functionName) {\r
51                 b.append("    ");\r
52                 b.append(name);\r
53                 b.append(" = ");\r
54                 b.append(functionName);\r
55                 b.append('\n');\r
56                 return true;\r
57             }\r
58         });\r
59     }\r
60     */\r
61 }\r