This commit is contained in:
Juraj Kirchheim
2017-02-18 18:40:57 +01:00
3 changed files with 48 additions and 28 deletions

View File

@@ -388,6 +388,17 @@ class Exprs {
case EFunction(_, f): Success(f);
default: e.pos.makeFailure(NOT_A_FUNCTION);
}
static public function concat(e:Expr, with:Expr, ?pos) {
if(pos == null) pos = e.pos;
return
switch [e.expr, with.expr] {
case [EBlock(e1), EBlock(e2)]: EBlock(e1.concat(e2)).at(pos);
case [EBlock(e1), e2]: EBlock(e1.concat([with])).at(pos);
case [e1, EBlock(e2)]: EBlock([e].concat(e2)).at(pos);
default: EBlock([e, with]).at(pos);
}
}
static inline var NOT_AN_INT = "integer constant expected";
static inline var NOT_AN_IDENT = "identifier expected";