public int compare(Object o1, Object o2){ Object o = invoke(o1, o2); if(o instanceof Number) { Number n = (Number) o; return n.intValue(); } if(RT.booleanCast(o)) return -1; return RT.booleanCast(invoke(o2,o1))? 1 : 0; } }
@Override public boolean checkInstance(Object o) { return RT.booleanCast(pred.invoke(o)); }
static public boolean suppressRead(){ return booleanCast(SUPPRESS_READ.deref()); }
void validate(IFn vf, Object val){ try { if(vf != null && !RT.booleanCast(vf.invoke(val))) throw new IllegalStateException("Invalid reference state"); } catch(RuntimeException re) { throw re; } catch(Exception e) { throw new IllegalStateException("Invalid reference state", e); } }
void validate(IFn vf, Object val){ try { if(vf != null && !RT.booleanCast(vf.invoke(val))) throw new IllegalStateException("Invalid reference state"); } catch(RuntimeException re) { throw re; } catch(Exception e) { throw new IllegalStateException("Invalid reference state", e); } }
public int compare(Object o1, Object o2){ try { Object o = invoke(o1, o2); if(o instanceof Boolean) { if(RT.booleanCast(o)) return -1; return RT.booleanCast(invoke(o2,o1))? 1 : 0; } Number n = (Number) o; return n.intValue(); } catch(Exception e) { throw Util.sneakyThrow(e); } } }
static boolean isPreserveReadCond(Object opts) { if(RT.booleanCast(READ_COND_ENV.deref()) && opts instanceof IPersistentMap) { Object readCond = ((IPersistentMap) opts).valAt(OPT_READ_COND); return COND_PRESERVE.equals(readCond); } else return false; }
static public ClassLoader baseLoader(){ if(Compiler.LOADER.isBound()) return (ClassLoader) Compiler.LOADER.deref(); else if(booleanCast(USE_CONTEXT_CLASSLOADER.deref())) return Thread.currentThread().getContextClassLoader(); return Compiler.class.getClassLoader(); }
boolean isVolatile(LocalBinding lb){ return RT.booleanCast(RT.contains(fields, lb.sym)) && RT.booleanCast(RT.get(lb.sym.meta(), Keyword.intern("volatile-mutable"))); }
public boolean isMacro(){ return RT.booleanCast(meta().valAt(macroKey)); }
public boolean isPublic(){ return !RT.booleanCast(meta().valAt(privateKey)); }
private boolean isA(Object x, Object y) { return RT.booleanCast(isa.invoke(hierarchy.deref(), x, y)); }
private boolean isA(Object x, Object y) { return RT.booleanCast(isa.invoke(hierarchy.deref(), x, y)); }
public boolean isMacro(){ return RT.booleanCast(meta().valAt(macroKey)); }
public InstanceFieldExpr(int line, int column, Expr target, String fieldName, Symbol tag) { this.target = target; this.targetClass = target.hasJavaClass() ? target.getJavaClass() : null; this.field = targetClass != null ? Reflector.getField(targetClass, fieldName, false) : null; this.fieldName = fieldName; this.line = line; this.column = column; this.tag = tag; if(field == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { RT.errPrintWriter() .format("Reflection warning, %s:%d:%d - reference to field %s can't be resolved.\n", SOURCE_PATH.deref(), line, column, fieldName); } }
boolean isMutable(LocalBinding lb){ return isVolatile(lb) || RT.booleanCast(RT.contains(fields, lb.sym)) && RT.booleanCast(RT.get(lb.sym.meta(), Keyword.intern("unsynchronized-mutable"))); }
public static boolean isQualifiedSpecials(){ Namespace n = currentNS(); IPersistentMap mm = n.meta(); return RT.booleanCast(RT.get(mm,qualifiedSpecialsKey)); }
public static boolean satisfies(Var proto, Object o) { boolean ret = (SAT != null) && (proto.get() != null) && (RT.booleanCast(SAT.invoke(proto.get(), o))); return ret; }
public InstanceFieldExpr(int line, int column, Expr target, String fieldName, Symbol tag, boolean requireField) { this.target = target; this.targetClass = target.hasJavaClass() ? target.getJavaClass() : null; this.field = targetClass != null ? Reflector.getField(targetClass, fieldName, false) : null; this.fieldName = fieldName; this.line = line; this.column = column; this.tag = tag; this.requireField = requireField; if(field == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { if(targetClass == null) { RT.errPrintWriter() .format("Reflection warning, %s:%d:%d - reference to field %s can't be resolved.\n", SOURCE_PATH.deref(), line, column, fieldName); } else { RT.errPrintWriter() .format("Reflection warning, %s:%d:%d - reference to field %s on %s can't be resolved.\n", SOURCE_PATH.deref(), line, column, fieldName, targetClass.getName()); } } }
static public IFn isInline(Object op, int arity) { //no local inlines for now if(op instanceof Symbol && referenceLocal((Symbol) op) != null) return null; if(op instanceof Symbol || op instanceof Var) { Var v = (op instanceof Var) ? (Var) op : lookupVar((Symbol) op, false); if(v != null) { if(v.ns != currentNS() && !v.isPublic()) throw new IllegalStateException("var: " + v + " is not public"); IFn ret = (IFn) RT.get(v.meta(), inlineKey); if(ret != null) { IFn arityPred = (IFn) RT.get(v.meta(), inlineAritiesKey); if(arityPred == null || RT.booleanCast(arityPred.invoke(arity))) return ret; } } } return null; }