1 package org.simantics.scl.compiler.elaboration.fundeps;
3 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
4 import org.simantics.scl.compiler.internal.parsing.declarations.FundepAst;
8 public static final Fundep[] EMPTY_ARRAY = new Fundep[0];
9 public final int[] from;
10 public final int[] to;
12 public Fundep(int[] from, int[] to) {
17 public Fundep(int[] from, int to) {
18 this(from, new int[] {to});
21 private static int mapParameterName(String[] parameterNames, String name) {
22 for(int i=0;i<parameterNames.length;++i)
23 if(parameterNames[i].equals(name))
25 throw new InternalCompilerError("Fundep.mapParameterName error handling missing.");
28 private static int[] mapParameterNames(String[] parameterNames, String[] names) {
29 int[] result = new int[names.length];
30 for(int i=0;i<names.length;++i)
31 result[i] = mapParameterName(parameterNames, names[i]);
35 public static Fundep[] mapFundeps(String[] parameterNames, FundepAst[] fundeps) {
36 Fundep[] result = new Fundep[fundeps.length];
37 for(int i=0;i<fundeps.length;++i)
38 result[i] = new Fundep(
39 mapParameterNames(parameterNames, fundeps[i].from),
40 mapParameterName(parameterNames, fundeps[i].to));