protected List<ST> rot_map_iterator(ST self, Iterator attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator iter = (Iterator)attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(self, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
void storeArgs(ST self, int nargs, ST st) { int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, self, current_ip, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
protected List<ST> rot_map_iterator(InstanceScope scope, Iterator<?> attr, List<ST> prototypes) { List<ST> mapped = new ArrayList<ST>(); Iterator<?> iter = attr; int i0 = 0; int i = 1; int ti = 0; while ( iter.hasNext() ) { Object iterValue = iter.next(); if ( iterValue == null ) { mapped.add(null); continue; } int templateIndex = ti % prototypes.size(); // rotate through ti++; ST proto = prototypes.get(templateIndex); ST st = group.createStringTemplateInternally(proto); setFirstArgument(scope, st, iterValue); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", i0); st.rawSetAttribute("i", i); } mapped.add(st); i0++; i++; } return mapped; }
void storeArgs(InstanceScope scope, int nargs, ST st) { if ( nargs>0 && !st.impl.hasFormalArgs && st.impl.formalArguments==null ) { st.add(ST.IMPLICIT_ARG_NAME, null); // pretend we have "it" arg } int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, scope, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
void storeArgs(InstanceScope scope, int nargs, ST st) { if ( nargs>0 && !st.impl.hasFormalArgs && st.impl.formalArguments==null ) { st.add(ST.IMPLICIT_ARG_NAME, null); // pretend we have "it" arg } int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, scope, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
void storeArgs(InstanceScope scope, int nargs, ST st) { if ( nargs>0 && !st.impl.hasFormalArgs && st.impl.formalArguments==null ) { st.add(ST.IMPLICIT_ARG_NAME, null); // pretend we have "it" arg } int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, scope, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
void storeArgs(InstanceScope scope, int nargs, ST st) { if ( nargs>0 && !st.impl.hasFormalArgs && st.impl.formalArguments==null ) { st.add(ST.IMPLICIT_ARG_NAME, null); // pretend we have "it" arg } int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, scope, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
void storeArgs(InstanceScope scope, int nargs, ST st) { if ( nargs>0 && !st.impl.hasFormalArgs && st.impl.formalArguments==null ) { st.add(ST.IMPLICIT_ARG_NAME, null); // pretend we have "it" arg } int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, scope, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
void storeArgs(InstanceScope scope, int nargs, ST st) { if ( nargs>0 && !st.impl.hasFormalArgs && st.impl.formalArguments==null ) { st.add(ST.IMPLICIT_ARG_NAME, null); // pretend we have "it" arg } int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int firstArg = sp-(nargs-1); int numToStore = Math.min(nargs, nformalArgs); if ( st.impl.isAnonSubtemplate ) nformalArgs -= predefinedAnonSubtemplateAttributes.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, scope, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } if ( st.impl.formalArguments==null ) return; Iterator<String> argNames = st.impl.formalArguments.keySet().iterator(); for (int i=0; i<numToStore; i++) { Object o = operands[firstArg+i]; // value to store String argName = argNames.next(); st.rawSetAttribute(argName, o); } }
void storeArgs(ST self, Map<String,Object> attrs, ST st) { int nformalArgs = 0; if ( st.impl.formalArguments!=null ) nformalArgs = st.impl.formalArguments.size(); int nargs = 0; if ( attrs!=null ) nargs = attrs.size(); if ( nargs < (nformalArgs-st.impl.numberOfArgsWithDefaultValues) || nargs > nformalArgs ) { errMgr.runTimeError(this, self, current_ip, ErrorType.ARGUMENT_COUNT_MISMATCH, nargs, st.impl.name, nformalArgs); } for (String argName : attrs.keySet()) { // don't let it throw an exception in rawSetAttribute if ( st.impl.formalArguments==null || !st.impl.formalArguments.containsKey(argName) ) { errMgr.runTimeError(this, self, current_ip, ErrorType.NO_SUCH_ATTRIBUTE, argName); continue; } Object o = attrs.get(argName); st.rawSetAttribute(argName, o); } }
protected void rot_map(ST self, Object attr, List<ST> prototypes) { if ( attr==null ) { operands[++sp] = null; return; } attr = convertAnythingIteratableToIterator(attr); if ( attr instanceof Iterator ) { List<ST> mapped = rot_map_iterator(self, (Iterator) attr, prototypes); operands[++sp] = mapped; } else { // if only single value, just apply first template to sole value ST proto = prototypes.get(0); ST st = group.createStringTemplateInternally(proto); if ( st!=null ) { setFirstArgument(self, st, attr); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", 0); st.rawSetAttribute("i", 1); } operands[++sp] = st; } else { operands[++sp] = null; } } }
/** * Renders expressions of the form {@code <names:a()>} or * {@code <names:a(),b()>}. */ protected void rot_map(InstanceScope scope, Object attr, List<ST> prototypes) { if ( attr==null ) { operands[++sp] = null; return; } attr = convertAnythingIteratableToIterator(scope, attr); if ( attr instanceof Iterator ) { List<ST> mapped = rot_map_iterator(scope, (Iterator) attr, prototypes); operands[++sp] = mapped; } else { // if only single value, just apply first template to sole value ST proto = prototypes.get(0); ST st = group.createStringTemplateInternally(proto); if ( st!=null ) { setFirstArgument(scope, st, attr); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", 0); st.rawSetAttribute("i", 1); } operands[++sp] = st; } else { operands[++sp] = null; } } }
/** * Renders expressions of the form {@code <names:a()>} or * {@code <names:a(),b()>}. */ protected void rot_map(InstanceScope scope, Object attr, List<ST> prototypes) { if ( attr==null ) { operands[++sp] = null; return; } attr = convertAnythingIteratableToIterator(scope, attr); if ( attr instanceof Iterator ) { List<ST> mapped = rot_map_iterator(scope, (Iterator) attr, prototypes); operands[++sp] = mapped; } else { // if only single value, just apply first template to sole value ST proto = prototypes.get(0); ST st = group.createStringTemplateInternally(proto); if ( st!=null ) { setFirstArgument(scope, st, attr); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", 0); st.rawSetAttribute("i", 1); } operands[++sp] = st; } else { operands[++sp] = null; } } }
/** * Renders expressions of the form {@code <names:a()>} or * {@code <names:a(),b()>}. */ protected void rot_map(InstanceScope scope, Object attr, List<ST> prototypes) { if ( attr==null ) { operands[++sp] = null; return; } attr = convertAnythingIteratableToIterator(scope, attr); if ( attr instanceof Iterator ) { List<ST> mapped = rot_map_iterator(scope, (Iterator) attr, prototypes); operands[++sp] = mapped; } else { // if only single value, just apply first template to sole value ST proto = prototypes.get(0); ST st = group.createStringTemplateInternally(proto); if ( st!=null ) { setFirstArgument(scope, st, attr); if ( st.impl.isAnonSubtemplate ) { st.rawSetAttribute("i0", 0); st.rawSetAttribute("i", 1); } operands[++sp] = st; } else { operands[++sp] = null; } } }