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

Method getIndexAux

src/bsh/BSHPrimarySuffix.java:201–226  ·  view source on GitHub ↗
(
		Object obj, CallStack callstack, Interpreter interpreter, 
		SimpleNode callerInfo )

Source from the content-addressed store, hash-verified

199 /**
200 */
201 static int getIndexAux(
202 Object obj, CallStack callstack, Interpreter interpreter,
203 SimpleNode callerInfo )
204 throws EvalError
205 {
206 if ( !obj.getClass().isArray() )
207 throw new EvalError("Not an array", callerInfo, callstack );
208
209 int index;
210 try {
211 Object indexVal =
212 ((SimpleNode)callerInfo.jjtGetChild(0)).eval(
213 callstack, interpreter );
214 if ( !(indexVal instanceof Primitive) )
215 indexVal = Types.castObject(
216 indexVal, Integer.TYPE, Types.ASSIGNMENT );
217 index = ((Primitive)indexVal).intValue();
218 } catch( UtilEvalError e ) {
219 Interpreter.debug("doIndex: "+e);
220 throw e.toEvalError(
221 "Arrays may only be indexed by integer types.",
222 callerInfo, callstack );
223 }
224
225 return index;
226 }
227
228 /**
229 array index.

Callers 1

doIndexMethod · 0.95

Calls 7

castObjectMethod · 0.95
debugMethod · 0.95
getClassMethod · 0.80
intValueMethod · 0.80
evalMethod · 0.65
jjtGetChildMethod · 0.65
toEvalErrorMethod · 0.45

Tested by

no test coverage detected