Add concat()

This commit is contained in:
kevinresol
2016-08-21 15:02:42 +08:00
parent 92f60cbe4f
commit 241919549c

View File

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