| 144 | } |
| 145 | |
| 146 | public Object getValue() throws UtilEvalError |
| 147 | { |
| 148 | if ( type == VARIABLE ) |
| 149 | return nameSpace.getVariable( varName ); |
| 150 | |
| 151 | if (type == FIELD) |
| 152 | try { |
| 153 | Object o = field.get( object ); |
| 154 | return Primitive.wrap( o, field.getType() ); |
| 155 | } catch(IllegalAccessException e2) { |
| 156 | throw new UtilEvalError("Can't read field: " + field); |
| 157 | } |
| 158 | |
| 159 | if ( type == PROPERTY ) |
| 160 | { |
| 161 | // return the raw type here... we don't know what it's supposed |
| 162 | // to be... |
| 163 | CollectionManager cm = CollectionManager.getCollectionManager(); |
| 164 | if ( cm.isMap( object ) ) |
| 165 | return cm.getFromMap( object/*map*/, propName ); |
| 166 | else |
| 167 | try { |
| 168 | return Reflect.getObjectProperty(object, propName); |
| 169 | } catch(ReflectError e) { |
| 170 | Interpreter.debug(e.getMessage()); |
| 171 | throw new UtilEvalError("No such property: " + propName); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if ( type == INDEX ) |
| 176 | try { |
| 177 | return Reflect.getIndex(object, index); |
| 178 | } |
| 179 | catch(Exception e) { |
| 180 | throw new UtilEvalError("Array access: " + e); |
| 181 | } |
| 182 | |
| 183 | throw new InterpreterError("LHS type"); |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | Assign a value to the LHS. |