use of kalang.ast.UnknownFieldExpr in project kalang by kasonyang.
the class AstBuilder method getObjectFieldLikeExpr.
protected ExprNode getObjectFieldLikeExpr(ExprNode expr, String fieldName, @Nullable ParserRuleContext rule) {
ExprNode ret;
Type type = expr.getType();
if (!(type instanceof ObjectType)) {
AstBuilder.this.handleSyntaxError("unsupported type", rule == null ? ParserRuleContext.EMPTY : rule);
return null;
}
ObjectType exprType = (ObjectType) type;
if ((exprType instanceof ArrayType) && fieldName.equals("length")) {
ret = new ArrayLengthExpr(expr);
} else {
try {
ret = ObjectFieldExpr.create(expr, fieldName, thisClazz);
} catch (FieldNotFoundException ex) {
this.diagnosisReporter.report(Diagnosis.Kind.ERROR, "field not found:" + fieldName, rule);
ret = new UnknownFieldExpr(expr, exprType.getClassNode(), fieldName);
}
}
if (rule != null)
mapAst(ret, rule);
return ret;
}
Aggregations