private List<Integer> allocateNamedLocals(RegexpNode regexpNode) { RubyRegexp pattern = RubyRegexp.newRegexp(configuration.getRuntime(), regexpNode.getValue(), regexpNode.getOptions()); pattern.setLiteral(); String[] names = pattern.getNames(); int length = names.length; List<Integer> locals = new ArrayList<Integer>(); StaticScope scope = getCurrentScope(); for (int i = 0; i < length; i++) { if (RubyLexer.getKeyword(names[i]) == null && !Character.isUpperCase(names[i].charAt(0))) { String id = names[i]; int slot = scope.isDefined(id); if (slot >= 0) { // If verbose and the variable is not just another named capture, warn if (warnings.isVerbose() && !scope.isNamedCapture(slot)) { Ruby runtime = getConfiguration().getRuntime(); warn(ID.AMBIGUOUS_ARGUMENT, getPosition(regexpNode), str(runtime, "named capture conflicts a local variable - " , ids(runtime, names[i]))); } locals.add(slot); } else { locals.add(getCurrentScope().addNamedCaptureVariable(id)); } } } return locals; }
private List<Integer> allocateNamedLocals(RegexpNode regexpNode) { RubyRegexp pattern = RubyRegexp.newRegexp(configuration.getRuntime(), regexpNode.getValue(), regexpNode.getOptions()); pattern.setLiteral(); String[] names = pattern.getNames(); int length = names.length; List<Integer> locals = new ArrayList<Integer>(); StaticScope scope = getCurrentScope(); for (int i = 0; i < length; i++) { if (RubyLexer.getKeyword(names[i]) == null && !Character.isUpperCase(names[i].charAt(0))) { String id = names[i]; int slot = scope.isDefined(id); if (slot >= 0) { // If verbose and the variable is not just another named capture, warn if (warnings.isVerbose() && !scope.isNamedCapture(slot)) { Ruby runtime = getConfiguration().getRuntime(); warn(ID.AMBIGUOUS_ARGUMENT, getPosition(regexpNode), str(runtime, "named capture conflicts a local variable - " , ids(runtime, names[i]))); } locals.add(slot); } else { locals.add(getCurrentScope().addNamedCaptureVariable(id)); } } } return locals; }