]> gerrit.simantics Code Review - simantics/platform.git/blob
25d14e2d289496a88ec4e40c23783cd29130edd8
[simantics/platform.git] /
1 package org.simantics.scl.compiler.internal.parsing.declarations;
2
3 import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
4 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
5
6
7
8 public class DModuleHeader extends DeclarationAst {
9     public final FieldAssignment[] fields;
10     
11     public DModuleHeader(FieldAssignment[] fields) {
12         this.fields = fields;
13     }
14
15     @Override
16     public void toString(int indentation, StringBuilder b) {
17         for(int i=0;i<indentation;++i) b.append("    ");
18         b.append("module {");
19         ExpressionToStringVisitor visitor = new ExpressionToStringVisitor(b);
20         boolean first = true;
21         for(FieldAssignment field : fields) {
22             if(first)
23                 first = false;
24             else
25                 b.append(',');
26             b.append('\n');
27             for(int i=0;i<=indentation;++i) b.append("    ");
28             b.append(field.name);
29             b.append(" = ");
30             field.value.accept(visitor);
31         }
32         b.append('\n');
33         for(int i=0;i<indentation;++i) b.append("    ");
34         b.append('}');
35     }
36 }