MCPcopy Index your code
hub / github.com/antlr/codebuff / storeArgs

Method storeArgs

output/java8/1.4.15/Interpreter.java:531–597  ·  view source on GitHub ↗
(InstanceScope scope, Map<String, Object> attrs, ST st)

Source from the content-addressed store, hash-verified

529 }
530
531 void storeArgs(InstanceScope scope, Map<String, Object> attrs, ST st) {
532 boolean noSuchAttributeReported = false;
533 if ( attrs!=null ) {
534 for (Map.Entry<String, Object> argument : attrs.entrySet()) {
535 if ( !st.impl.hasFormalArgs ) {
536 if ( st.impl.formalArguments==null || !st.impl.formalArguments.containsKey(argument.getKey()) ) {
537 try {
538 // we clone the CompiledST to prevent modifying the original
539 // formalArguments map during interpretation.
540 st.impl = st.impl.clone();
541 st.add(argument.getKey(), argument.getValue());
542 }
543 catch (CloneNotSupportedException ex) {
544 noSuchAttributeReported = true;
545 errMgr.runTimeError(this, scope, ErrorType.NO_SUCH_ATTRIBUTE, argument.getKey());
546 }
547 }
548 else {
549 st.rawSetAttribute(argument.getKey(), argument.getValue());
550 }
551 }
552 else {
553 // don't let it throw an exception in rawSetAttribute
554 if ( st.impl.formalArguments==null || !st.impl.formalArguments.containsKey(argument.getKey()) ) {
555 noSuchAttributeReported = true;
556 errMgr.runTimeError(this, scope, ErrorType.NO_SUCH_ATTRIBUTE, argument.getKey());
557 continue;
558 }
559 st.rawSetAttribute(argument.getKey(), argument.getValue());
560 }
561 }
562 }
563 if ( st.impl.hasFormalArgs ) {
564 boolean argumentCountMismatch = false;
565 Map<String, FormalArgument> formalArguments = st.impl.formalArguments;
566 if ( formalArguments==null ) {
567 formalArguments = Collections.emptyMap();
568 }
569
570 // first make sure that all non-default arguments are specified
571 // ignore this check if a NO_SUCH_ATTRIBUTE error already occurred
572 if ( !noSuchAttributeReported ) {
573 for (Map.Entry<String, FormalArgument> formalArgument : formalArguments.entrySet()) {
574 if ( formalArgument.getValue().defaultValueToken!=null || formalArgument.getValue().defaultValue!=null ) {
575 // this argument has a default value, so it doesn't need to appear in attrs
576 continue;
577 }
578 if ( attrs==null || !attrs.containsKey(formalArgument.getKey()) ) {
579 argumentCountMismatch = true;
580 break;
581 }
582 }
583 }
584
585 // next make sure there aren't too many arguments. note that the names
586 // of arguments are checked below as they are applied to the template
587 // instance, so there's no need to do that here.
588 if ( attrs!=null && attrs.size()> formalArguments.size() ) {

Callers 2

_execMethod · 0.95
super_newMethod · 0.95

Calls 14

entrySetMethod · 0.65
containsKeyMethod · 0.65
getKeyMethod · 0.65
addMethod · 0.65
getValueMethod · 0.65
runTimeErrorMethod · 0.65
sizeMethod · 0.65
iteratorMethod · 0.65
keySetMethod · 0.65
nextMethod · 0.65
cloneMethod · 0.45
rawSetAttributeMethod · 0.45

Tested by

no test coverage detected