return scopeCode.createLineCode(source);
}
@Override
public Code visitInclude_directive(Include_directiveContext ctx) {
Expression_listContext expression_list = ctx.expression_list();
SegmentListCode childrenCode = (SegmentListCode) expression_list.accept(this);
if (childrenCode.size() > 2) {
throw reportError("Arguments mismatch for #include directive.", ctx);
}
// argument 1: file
SegmentCode fileCode = childrenCode.getChild(0);
ExpressionContext fileExpression = expression_list.expression(0);
if (!String.class.equals(fileCode.getKlass())) {
throw reportError("Type mismatch: the first argument cannot convert from " + fileCode.getKlassName() + " to String", fileExpression);
}
// argument 2: parameters
SegmentCode parametersCode = null;
if (childrenCode.size() > 1) {
parametersCode = childrenCode.getChild(1);
if (!(Map.class.equals(parametersCode.getKlass()))) {
throw reportError("Type mismatch: the second argument cannot convert from " + parametersCode.getKlassName() + " to Map", expression_list.expression(1));
}
}
// 如果 file 是常量,那么进行 file.exists() 校验
if (fileExpression instanceof Expr_constantContext) {