Get the next object by consuming one or more components of evalName. Often this consumes just one component, but if the name is a classname it will consume all of the components necessary to make the class identifier.
( CallStack callstack, Interpreter interpreter, boolean forceClass, boolean autoAllocateThis )
| 218 | identifier. |
| 219 | */ |
| 220 | private Object consumeNextObjectField( |
| 221 | CallStack callstack, Interpreter interpreter, |
| 222 | boolean forceClass, boolean autoAllocateThis ) |
| 223 | throws UtilEvalError |
| 224 | { |
| 225 | /* |
| 226 | Is it a simple variable name? |
| 227 | Doing this first gives the correct Java precedence for vars |
| 228 | vs. imported class names (at least in the simple case - see |
| 229 | tests/precedence1.bsh). It should also speed things up a bit. |
| 230 | */ |
| 231 | if ( (evalBaseObject == null && !isCompound(evalName) ) |
| 232 | && !forceClass ) |
| 233 | { |
| 234 | Object obj = resolveThisFieldReference( |
| 235 | callstack, namespace, interpreter, evalName, false ); |
| 236 | |
| 237 | if ( obj != Primitive.VOID ) |
| 238 | return completeRound( evalName, FINISHED, obj ); |
| 239 | } |
| 240 | |
| 241 | /* |
| 242 | Is it a bsh script variable reference? |
| 243 | If we're just starting the eval of name (no base object) |
| 244 | or we're evaluating relative to a This type reference check. |
| 245 | */ |
| 246 | String varName = prefix(evalName, 1); |
| 247 | if ( ( evalBaseObject == null || evalBaseObject instanceof This ) |
| 248 | && !forceClass ) |
| 249 | { |
| 250 | if ( Interpreter.DEBUG ) |
| 251 | Interpreter.debug("trying to resolve variable: " + varName); |
| 252 | |
| 253 | Object obj; |
| 254 | // switch namespace and special var visibility |
| 255 | if ( evalBaseObject == null ) { |
| 256 | obj = resolveThisFieldReference( |
| 257 | callstack, namespace, interpreter, varName, false ); |
| 258 | } else { |
| 259 | obj = resolveThisFieldReference( |
| 260 | callstack, ((This)evalBaseObject).namespace, |
| 261 | interpreter, varName, true ); |
| 262 | } |
| 263 | |
| 264 | if ( obj != Primitive.VOID ) |
| 265 | { |
| 266 | // Resolved the variable |
| 267 | if ( Interpreter.DEBUG ) |
| 268 | Interpreter.debug( "resolved variable: " + varName + |
| 269 | " in namespace: "+namespace); |
| 270 | |
| 271 | return completeRound( varName, suffix(evalName), obj ); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /* |
| 276 | Is it a class name? |
| 277 | If we're just starting eval of name try to make it, else fail. |
no test coverage detected