1 package org.simantics.scl.compiler.elaboration.modules;
\r
3 import gnu.trove.map.hash.THashMap;
\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
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
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
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
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
42 context[i].toString(tuc);
\r
43 b.append(context[i]);
\r
46 b.append(instance.toString(tuc));
\r
47 b.append(" where\n");
\r
48 methodImplementations.forEachEntry(new TObjectObjectProcedure<String, Name>() {
\r
50 public boolean execute(String name, Name functionName) {
\r
54 b.append(functionName);
\r