MCPcopy Create free account
hub / github.com/beanshell/beanshell / consumeNextObjectField

Method consumeNextObjectField

src/bsh/Name.java:220–450  ·  view source on GitHub ↗

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 )

Source from the content-addressed store, hash-verified

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.

Callers 2

toObjectMethod · 0.95
toLHSMethod · 0.95

Calls 15

isCompoundMethod · 0.95
completeRoundMethod · 0.95
prefixMethod · 0.95
debugMethod · 0.95
suffixMethod · 0.95
countPartsMethod · 0.95
setVariableMethod · 0.95
getParentMethod · 0.95
getStaticFieldValueMethod · 0.95
getObjectFieldValueMethod · 0.95
getClassMethod · 0.80

Tested by

no test coverage detected