1 package org.simantics.scl.compiler.internal.parsing.declarations;
3 import java.util.ArrayList;
5 import org.simantics.scl.compiler.elaboration.expressions.EVar;
6 import org.simantics.scl.compiler.internal.parsing.types.TypeAst;
8 public class DInstanceAst extends DeclarationAst {
9 public final TypeAst[] context;
10 public final EVar name;
11 public final TypeAst[] types;
12 public final DeclarationAst[] declarations;
14 public DInstanceAst(long loc, TypeAst[] context, EVar name, TypeAst[] types) {
16 this.context = context;
19 this.declarations = DeclarationAst.EMPTY_ARRAY;
22 public DInstanceAst(ArrayList<TypeAst> context, EVar name,
23 TypeAst[] types, ArrayList<DeclarationAst> declarations) {
24 this.context = context.toArray(new TypeAst[context.size()]);
27 this.declarations = declarations == null ? EMPTY_ARRAY : declarations.toArray(new DeclarationAst[declarations.size()]);
31 public void toString(int indentation, StringBuilder b) {
32 for(int i=0;i<indentation;++i) b.append(" ");
33 b.append("instance ");
34 if(context.length > 0) {
36 for(int i=0;i<context.length;++i) {
39 context[i].toString(b);
45 for(TypeAst type : types) {
49 if(declarations.length > 0) {
51 for(DeclarationAst declaration : declarations) {
53 declaration.toString(indentation+1, b);