use of kalang.ast.ExprNode in project kalang by kasonyang.
the class AstBuilder method visitExprStat.
@Override
public AstNode visitExprStat(ExprStatContext ctx) {
ExprNode expr = visitExpression(ctx.expression());
ExprStmt es = new ExprStmt(expr);
mapAst(es, ctx);
return es;
}
use of kalang.ast.ExprNode in project kalang by kasonyang.
the class AstUtil method matchTypes.
/**
* @param args
* @param from
* @param target
* @return array when matched,null when not
*/
@Nullable
public static ExprNode[] matchTypes(ExprNode[] args, Type[] from, Type[] target) {
if (args == null)
return null;
if (from == null || from.length == 0) {
if (target == null || target.length == 0) {
return args;
} else {
return null;
}
}
if (from.length != target.length || from.length != args.length) {
return null;
}
if (from.length == 0)
return new ExprNode[0];
ExprNode[] newParams = new ExprNode[from.length];
for (int i = 0; i < from.length; i++) {
Type f = from[i];
Type t = target[i];
newParams[i] = matchType(f, t, args[i]);
if (newParams[i] == null)
return null;
}
return newParams;
}
Aggregations