X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEBlock.java;h=c911474eba8b39c41004b10cff3d7b824b73a8a4;hp=2c70bd90742ef6562d8c9f141bd705838264dc82;hb=e12e3ad357853a07b24923b341c4732962a94623;hpb=862c09c9608329f326404342d12da61792eece2c diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java index 2c70bd907..c911474eb 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java @@ -3,9 +3,12 @@ package org.simantics.scl.compiler.elaboration.expressions; import java.util.ArrayList; import java.util.List; +import org.simantics.scl.compiler.elaboration.chr.CHRRule; import org.simantics.scl.compiler.elaboration.chr.CHRRuleset; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRQueryTranslationMode; import org.simantics.scl.compiler.elaboration.chr.translation.CHRTranslation; import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.elaboration.expressions.block.BlockType; import org.simantics.scl.compiler.elaboration.expressions.block.CHRStatement; import org.simantics.scl.compiler.elaboration.expressions.block.ConstraintStatement; import org.simantics.scl.compiler.elaboration.expressions.block.GuardStatement; @@ -18,20 +21,21 @@ import org.simantics.scl.compiler.errors.Locations; public class EBlock extends ASTExpression { - ArrayList statements = new ArrayList(); - boolean monadic; + public ArrayList statements = new ArrayList(); + BlockType blockType = BlockType.Normal; public EBlock() { + this.blockType = blockType; + } + + public void setBlockType(BlockType blockType) { + this.blockType = blockType; } public void addStatement(Statement statement) { statements.add(statement); } - public void setMonadic(boolean monadic) { - this.monadic = monadic; - } - public ArrayList getStatements() { return statements; } @@ -62,7 +66,7 @@ public class EBlock extends ASTExpression { Statement cur = statements.get(i); StatementGroup group = cur.getStatementGroup(); if(group == null) - in = cur.toExpression(context, monadic, in); + in = cur.toExpression(context, blockType, in); else { int endId = i+1; while(i>0 && statements.get(i-1).getStatementGroup() == group) @@ -74,10 +78,14 @@ public class EBlock extends ASTExpression { case Rule: in = extractRules(i, endId, in); break; - case CHR: - in = new ECHRRuleset(extractCHRRules(context, i, endId), in); + case CHR: { + CHRRuleset ruleset = extractCHRRules(context, i, endId); + long location = Locations.combine(ruleset.location, in.location); + in = new ECHRRuleset(ruleset, in); + in.location = location; break; } + } } } return in.resolve(context); @@ -92,10 +100,14 @@ public class EBlock extends ASTExpression { ruleset.location = Locations.combine(statements.get(begin).location, statements.get(end-1).location); for(int i=begin;i