]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/declarations/DDerivingInstanceAst.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / parsing / declarations / DDerivingInstanceAst.java
1 package org.simantics.scl.compiler.internal.parsing.declarations;
2
3 import java.util.ArrayList;
4
5 import org.simantics.scl.compiler.elaboration.expressions.EVar;
6 import org.simantics.scl.compiler.internal.parsing.types.TypeAst;
7
8 public class DDerivingInstanceAst extends DeclarationAst {
9     public final TypeAst[] context;
10     public final EVar name;
11     public final TypeAst[] types;
12     
13     public DDerivingInstanceAst(ArrayList<TypeAst> context, EVar name, 
14             TypeAst[] types) {
15         this.context = context.toArray(new TypeAst[context.size()]);
16         this.name = name;
17         this.types = types;
18     }
19     
20     @Override
21     public void toString(int indentation, StringBuilder b) {
22         for(int i=0;i<indentation;++i) b.append("    ");
23         b.append("deriving instance ");
24         if(context.length > 0) {
25             b.append("(");
26             for(int i=0;i<context.length;++i) {
27                 if(i>0)
28                     b.append(", ");
29                 context[i].toString(b);
30             }
31             b.append(") => ");
32             
33         }
34         b.append(name);
35         for(TypeAst type : types) {
36             b.append(' ');
37             type.toString(b, 1);
38         }
39     }
40 }