@Override public void visit(Symbol name) { if (!unique || !set.contains(name)) { if (maxNames == -1 || names.length() < maxNames) { names.add(StringArrayVector.valueOf(name.getPrintName())); set.add(name); } } }
@Override public SEXP getVariable(Symbol name) { int index = list.getIndexByName(name.getPrintName()); if (index == -1) { return Symbol.UNBOUND_VALUE; } else { return list.getElementAsSEXP(index); } }
private Function evaluateFunction(SEXP functionExp, Environment rho) { if (functionExp instanceof Symbol) { Symbol symbol = (Symbol) functionExp; Function fn = rho.findFunction(this, symbol); if (fn == null) { throw new EvalException("could not find function '%s'", symbol.getPrintName()); } return fn; } else { SEXP evaluated = evaluate(functionExp, rho).force(this); if (!(evaluated instanceof Function)) { throw new EvalException( "'function' of lang expression is of unsupported type '%s'", evaluated.getTypeName()); } return (Function) evaluated; } }
private SEXP evaluateSymbol(Symbol symbol, Environment rho) { clearInvisibleFlag(); if (symbol == Symbol.MISSING_ARG) { return symbol; } SEXP value = rho.findVariable(symbol); if (value == Symbol.UNBOUND_VALUE) { throw new EvalException(String.format("object '%s' not found", symbol.getPrintName())); } if (value instanceof Promise) { return evaluate(value, rho); } else { return value; } }
@Override public boolean hasVariable(Symbol name) { return list.getIndexByName(name.getPrintName()) != -1; }