MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / pushArgs

Method pushArgs

ij/src/main/java/ij/macro/Interpreter.java:427–515  ·  view source on GitHub ↗

Push function arguments onto the stack.

()

Source from the content-addressed store, hash-verified

425
426 /** Push function arguments onto the stack. */
427 int pushArgs() {
428 getLeftParen();
429 int count = 0;
430 Variable[] args = new Variable[MAX_ARGS];
431 double value;
432 if (nextToken()!=')') {
433 do {
434 if (count==MAX_ARGS)
435 error("Too many arguments");
436 int next = nextToken();
437 int nextPlus = pgm.code[pc+2]&0xff;
438 if (next==STRING_CONSTANT || next==STRING_FUNCTION)
439 args[count] = new Variable(0, 0.0, getString());
440 else if (next==USER_FUNCTION) {
441 int savePC = pc;
442 getToken(); // the function
443 boolean simpleFunctionCall = isSimpleFunctionCall(false);
444 pc = savePC;
445 if (simpleFunctionCall) {
446 getToken(); // the function
447 Variable v2 = runUserFunction();
448 if (v2==null)
449 error("No return value");
450 args[count] = v2;
451 } else
452 args[count] = new Variable(0, getExpression(), null);
453 } else if (next==WORD && (nextPlus==','||nextPlus==')')) {
454 value = 0.0;
455 Variable[] array = null;
456 int arraySize = 0;
457 String str = null;
458 getToken();
459 Variable v = lookupVariable();
460 if (v!=null) {
461 int type = v.getType();
462 if (type==Variable.VALUE)
463 value = v.getValue();
464 else if (type==Variable.ARRAY) {
465 array = v.getArray();
466 arraySize = v.getArraySize();
467 } else
468 str = v.getString();
469 }
470 args[count] = new Variable(0, value, str, array);
471 if (array!=null) args[count].setArraySize(arraySize);
472 } else if (next==WORD && nextPlus=='[' ) {
473 int savePC = pc;
474 getToken();
475 Variable v = lookupVariable();
476 v = getArrayElement(v);
477 if (v.getString()!=null)
478 args[count] = new Variable(0, 0.0, v.getString(), null);
479 else {
480 pc = savePC;
481 args[count] = new Variable(0, getExpression(), null);
482 }
483 } else if (next==WORD && nextPlus=='.' ) { // s.length, s.substring(), etc.
484 boolean stringFunction = (pgm.code[pc+3]&0xff)==136;

Callers 1

runUserFunctionMethod · 0.95

Calls 15

getLeftParenMethod · 0.95
nextTokenMethod · 0.95
errorMethod · 0.95
getStringMethod · 0.95
getTokenMethod · 0.95
isSimpleFunctionCallMethod · 0.95
runUserFunctionMethod · 0.95
getExpressionMethod · 0.95
lookupVariableMethod · 0.95
getTypeMethod · 0.95
getValueMethod · 0.95
getArrayMethod · 0.95

Tested by

no test coverage detected