- @Override
- public IVal toVal(Environment env, CodeWriter w) {
- ArrayList<Row> rows = new ArrayList<Row>(cases.length);
- for(Case case_ : cases)
- rows.add(new Row(case_.patterns, case_.value));
-
- IVal[] scrutineeVals = new IVal[scrutinee.length];
- for(int i=0;i<scrutinee.length;++i)
- scrutineeVals[i] = scrutinee[i].toVal(env, w);
-
- CodeWriter joinPoint = w.createBlock(getType());
- CodeWriter failurePoint = w.createBlock(); // TODO generate only one failurePoint per function
- PatternMatchingCompiler.split(w, env, scrutineeVals, joinPoint.getContinuation(), failurePoint.getContinuation(), rows);
- failurePoint.throw_(location, Throw.MatchingException, "Matching failure at: " + toString());
- w.continueAs(joinPoint);
- return w.getParameters()[0];