public LHS toLHS( CallStack callstack, Interpreter interpreter) throws EvalError { try { return getName( callstack.top() ).toLHS( callstack, interpreter ); } catch ( UtilEvalError e ) { throw e.toEvalError( this, callstack ); } }
public LHS ambiguousNameToLHS( BSHAmbiguousName node ) throws EvalError { try { return node.getName( callstack.top() ).toLHS( this ); } catch ( UtilEvalError e ) { throw e.toEvalError( node, callstack ); } }
/** Assign the value to the name. name may evaluate to anything assignable. e.g. a variable or field. */ public void set( String name, Object value ) throws EvalError { // map null to Primtive.NULL coming in... if ( value == null ) value = Primitive.NULL; CallStack callstack = new CallStack(); try { if ( Name.isCompound( name ) ) { LHS lhs = globalNameSpace.getNameResolver( name ).toLHS( callstack, this ); lhs.assign( value, false ); } else // optimization for common case globalNameSpace.setVariable( name, value, false ); } catch ( UtilEvalError e ) { throw e.toEvalError( SimpleNode.JAVACODE, callstack ); } }
/** Assign the value to the name. name may evaluate to anything assignable. e.g. a variable or field. */ public void set( String name, Object value ) throws EvalError { // map null to Primtive.NULL coming in... if ( value == null ) value = Primitive.NULL; CallStack callstack = new CallStack(); try { if ( Name.isCompound( name ) ) { LHS lhs = globalNameSpace.getNameResolver( name ).toLHS( new BshEvaluatingVisitor(callstack, this) ); lhs.assign( value, false ); } else // optimization for common case globalNameSpace.setVariable( name, value, false ); } catch ( UtilEvalError e ) { throw e.toEvalError( SimpleNode.JAVACODE, callstack ); } }
/** Unassign the variable name. Name should evaluate to a variable. */ public void unset( String name ) throws EvalError { /* We jump through some hoops here to handle arbitrary cases like unset("bsh.foo"); */ CallStack callstack = new CallStack(); try { LHS lhs = globalNameSpace.getNameResolver( name ).toLHS( callstack, this ); if ( lhs.type != LHS.VARIABLE ) throw new EvalError("Can't unset, not a variable: "+name, SimpleNode.JAVACODE, new CallStack()); lhs.nameSpace.unsetVariable( name ); } catch ( UtilEvalError e ) { throw new EvalError( e.getMessage(), SimpleNode.JAVACODE, new CallStack(), e); } }
/** Unassign the variable name. Name should evaluate to a variable. */ public void unset( String name ) throws EvalError { /* We jump through some hoops here to handle arbitrary cases like unset("bsh.foo"); */ CallStack callstack = new CallStack(); try { LHS lhs = globalNameSpace.getNameResolver( name ).toLHS( new BshEvaluatingVisitor(callstack, this) ); if ( lhs.type != LHS.VARIABLE ) throw new EvalError("Can't unset, not a variable: "+name, SimpleNode.JAVACODE, new CallStack() ); //lhs.assign( null, false ); lhs.nameSpace.unsetVariable( name ); } catch ( UtilEvalError e ) { throw new EvalError( e.getMessage(), SimpleNode.JAVACODE, new CallStack() ); } }