public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { //noinspection unchecked return widen ? typeCheck(statement.getValue(ctx, thisValue, factory), egressType) : convert(statement.getValue(ctx, thisValue, factory), egressType); }
private boolean canCast(Class from, Class to) { return isAssignableFrom(from, to) || (from.isInterface() && interfaceAssignable(from, to)); }
return lastNode = new TypeCast(expr, st, cursor - st, cls, fields, pCtx);
public TypeCast(char[] expr, int start, int offset, Class cast, int fields, ParserContext pCtx) { super(pCtx); this.egressType = cast; this.expr = expr; this.start = start; this.offset = offset; if ((fields & COMPILE_IMMEDIATE) != 0) { if ((statement = (ExecutableStatement) subCompileExpression(expr, start, offset, pCtx)) .getKnownEgressType() != Object.class && !canConvert(cast, statement.getKnownEgressType())) { if (canCast(statement.getKnownEgressType(), cast)) { widen = true; } else { throw new CompileException("unable to cast type: " + statement.getKnownEgressType() + "; to: " + cast, expr, start); } } } }
ExecutableStatement statement = ((TypeCast)node).getStatement(); if (statement instanceof ExecutableAccessor) { ExecutableAccessor accessor = (ExecutableAccessor) statement;
return lastNode = new TypeCast(expr, st, cursor - st, cls, fields, pCtx);
public TypeCast(char[] expr, int start, int offset, Class cast, int fields, ParserContext pCtx) { super(pCtx); this.egressType = cast; this.expr = expr; this.start = start; this.offset = offset; if ((fields & COMPILE_IMMEDIATE) != 0) { if ((statement = (ExecutableStatement) subCompileExpression(expr, start, offset, pCtx)) .getKnownEgressType() != Object.class && !canConvert(cast, statement.getKnownEgressType())) { if (canCast(statement.getKnownEgressType(), cast)) { widen = true; } else { throw new CompileException("unable to cast type: " + statement.getKnownEgressType() + "; to: " + cast, expr, start); } } } }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { //noinspection unchecked return widen ? typeCheck(eval(expr, start, offset, ctx, factory), egressType) : convert(eval(expr, start, offset, ctx, factory), egressType); }
captureToEOS(); return lastNode = new TypeCast(subset(expr, start, cursor - start), cls, fields, pCtx);
private boolean canCast(Class from, Class to) { return isAssignableFrom(from, to) || (from.isInterface() && interfaceAssignable(from, to)); }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { //noinspection unchecked return widen ? typeCheck(eval(name, ctx, factory), egressType) : convert(eval(name, ctx, factory), egressType); }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { //noinspection unchecked return widen ? typeCheck(statement.getValue(ctx, thisValue, factory), egressType) : convert(statement.getValue(ctx, thisValue, factory), egressType); }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { //noinspection unchecked return widen ? typeCheck(eval(expr, start, offset, ctx, factory), egressType) : convert(eval(expr, start, offset, ctx, factory), egressType); }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { //noinspection unchecked return widen ? typeCheck(statement.getValue(ctx, thisValue, factory), egressType) : convert(statement.getValue(ctx, thisValue, factory), egressType); }