CPD Results

The following document contains the results of PMD's CPD[1] 7.17.0.

Duplications

File Line
io/jawk/jrt/HashAssocArray.java 48[2]
io/jawk/jrt/SortedAssocArray.java 71[3]
@Override
	public Object get(Object key) {
		key = AssocArray.normalizeKey(key);
		Object result = super.get(key);
		if (result != null) {
			return result;
		}
		Long lKey = AssocArray.toLongKey(key);
		if (lKey != null) {
			result = super.get(lKey);
			if (result != null) {
				return result;
			}
			key = lKey;
		}
		result = UNTYPED;
		super.put(key, result);
		return result;
	}

	/**
	 * Associates the specified value with the specified key, normalizing the key
	 * to a {@code Long} when the key is a valid integer string.
	 *
	 * @param key the key
	 * @param value the value
	 * @return the previous value associated with the key, or {@code null}
	 */
	@Override
	public Object put(Object key, Object value) {
		key = AssocArray.normalizeKey(key);
		Long lKey = AssocArray.toLongKey(key);
		// null has no meaning in an AWK array: store the untyped marker so
		// callers never have to special-case it
		return super.put(lKey != null ? lKey : key, value == null ? UNTYPED : value);
	}

	/**
	 * Removes the mapping for the specified key, trying both the original and its
	 * {@code Long} equivalent.
	 *
	 * @param key the key whose mapping is to be removed
	 * @return the previous value associated with the key, or {@code null}
	 */
	@Override
	public Object remove(Object key) {
		key = AssocArray.normalizeKey(key);
		Object result = super.remove(key);
		if (result != null) {
			return result;
		}
		Long lKey = AssocArray.toLongKey(key);
		return lKey != null ? super.remove(lKey) : null;
	}

	/**
	 * Returns the specification version of the underlying {@link HashMap} class.
	 *
	 * @return the specification version string, or {@code null} if unavailable
	 */
	@Override
	public String getMapVersion() {
		return HashMap.class.getPackage().getSpecificationVersion();
File Line
io/jawk/SandboxedAwk.java 120[4]
io/jawk/SandboxedAwk.java 180[5]
final class SandboxedCompiledAwkProgram extends AwkProgram {
	private static final long serialVersionUID = 1L;

	@Override
	public void printToFile(int numExprs, boolean append) {
		deny("Output redirection is disabled in sandbox mode");
	}

	@Override
	public void printToPipe(int numExprs) {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void printfToFile(int numExprs, boolean append) {
		deny("Output redirection is disabled in sandbox mode");
	}

	@Override
	public void printfToPipe(int numExprs) {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void system() {
		deny("system() is disabled in sandbox mode");
	}

	@Override
	public void useAsCommandInput() {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void useAsFileInput() {
		deny("Input redirection is disabled in sandbox mode");
	}

	@Override
	public void assignARGC() {
		deny("Assigning to ARGC is disabled in sandbox mode");
	}

	@Override
	public void argcOffset(int offset) {
		// no-op: keep argcOffset at NULL_OFFSET; AVM.getARGC() returns the
		// command-line argument count when ARGC is not materialized.
	}

	@Override
	public void argvOffset(int offset) {
		// no-op: keep argvOffset at NULL_OFFSET; AVM.getARGV() returns a
		// synthetic AssocArray when ARGV is not materialized.
	}

	private static void deny(String message) {
		throw new AwkSandboxException(message);
	}
}
File Line
io/jawk/intermediate/AwkTuples.java 2773[6]
io/jawk/intermediate/AwkTuples.java 2808[7]
while (!worklist.isEmpty()) {
			int index = worklist.removeFirst();
			Tuple tuple = queue.get(index);

			if (fallsThrough(tuple.getOpcode())) {
				Tuple nextTuple = tuple.getNext();
				if (nextTuple != null) {
					int nextIndex = index + 1;
					if (!reachable[nextIndex]) {
						reachable[nextIndex] = true;
						worklist.addLast(nextIndex);
					}
				}
			}

			for (Address address : tuple.getAddresses()) {
				int targetIndex = address.index();
				if (targetIndex < 0 || targetIndex >= size) {
					throw new Error("address " + address + " doesn't resolve to an actual list element");
				}
				referencesFromReachable[targetIndex]++;
				if (!reachable[targetIndex]) {
					reachable[targetIndex] = true;
					worklist.addLast(targetIndex);
				}
			}
		}
File Line
io/jawk/SandboxedAwk.java 123[8]
io/jawk/intermediate/SandboxedAwkTuples.java 39[9]
@Override
	public void printToFile(int numExprs, boolean append) {
		deny("Output redirection is disabled in sandbox mode");
	}

	@Override
	public void printToPipe(int numExprs) {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void printfToFile(int numExprs, boolean append) {
		deny("Output redirection is disabled in sandbox mode");
	}

	@Override
	public void printfToPipe(int numExprs) {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void system() {
		deny("system() is disabled in sandbox mode");
	}

	@Override
	public void useAsCommandInput() {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void useAsFileInput() {
		deny("Input redirection is disabled in sandbox mode");
	}

	@Override
	public void assignARGC() {
		deny("Assigning to ARGC is disabled in sandbox mode");
	}

	@Override
	public void argcOffset(int offset) {
		// no-op: keep argcOffset at NULL_OFFSET; AVM.getARGC() returns the
		// command-line argument count when ARGC is not materialized.
	}

	@Override
	public void argvOffset(int offset) {
		// no-op: keep argvOffset at NULL_OFFSET; AVM.getARGV() returns a
		// synthetic AssocArray when ARGV is not materialized.
	}
File Line
io/jawk/SandboxedAwk.java 183[10]
io/jawk/intermediate/SandboxedAwkTuples.java 39[9]
@Override
	public void printToFile(int numExprs, boolean append) {
		deny("Output redirection is disabled in sandbox mode");
	}

	@Override
	public void printToPipe(int numExprs) {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void printfToFile(int numExprs, boolean append) {
		deny("Output redirection is disabled in sandbox mode");
	}

	@Override
	public void printfToPipe(int numExprs) {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void system() {
		deny("system() is disabled in sandbox mode");
	}

	@Override
	public void useAsCommandInput() {
		deny("Command execution through pipelines is disabled in sandbox mode");
	}

	@Override
	public void useAsFileInput() {
		deny("Input redirection is disabled in sandbox mode");
	}

	@Override
	public void assignARGC() {
		deny("Assigning to ARGC is disabled in sandbox mode");
	}

	@Override
	public void argcOffset(int offset) {
		// no-op: keep argcOffset at NULL_OFFSET; AVM.getARGC() returns the
		// command-line argument count when ARGC is not materialized.
	}

	@Override
	public void argvOffset(int offset) {
		// no-op: keep argvOffset at NULL_OFFSET; AVM.getARGV() returns a
		// synthetic AssocArray when ARGV is not materialized.
	}
File Line
io/jawk/frontend/AwkParser.java 2408[11]
io/jawk/frontend/AwkParser.java 2434[12]
expectKeyword("print");
		ParsedPrintStatement parsedPrintStatement = parsePrintStatement();

		AST params = parsedPrintStatement.getFuncParams();
		if (parsedPrintStatement.isParenthesized()
				&& token == Token.QUESTION_MARK
				&& params instanceof FunctionCallParamListAst
				&& ((FunctionCallParamListAst) params).getAst2() == null) {
			AST condExpr = ((FunctionCallParamListAst) params).getAst1();
			lexer();
			AST trueBlock = TERNARY_EXPRESSION(null, true, true, true);
			lexer(Token.COLON);
			AST falseBlock = TERNARY_EXPRESSION(null, true, true, true);
			params = new FunctionCallParamListAst(
					new TernaryExpressionAst(condExpr, trueBlock, falseBlock),
					null);
		}

		return new PrintAst(
File Line
io/jawk/Awk.java 1060[13]
io/jawk/backend/AVM.java 4566[14]
private static final class SingleRecordInputSource implements InputSource {

		private final String record;

		private boolean consumed;

		private SingleRecordInputSource(String record) {
			this.record = record;
		}

		@Override
		public boolean nextRecord() {
			if (consumed || record == null) {
				return false;
			}
			consumed = true;
			return true;
		}

		@Override
		public String getRecordText() {
			return consumed ? record : null;
		}

		@Override
		public List<String> getFields() {
			return null;
		}

		@Override
		public boolean isFromFilenameList() {
			return false;
		}
	}
File Line
io/jawk/frontend/AwkParser.java 5441[15]
io/jawk/frontend/AwkParser.java 5553[16]
tuples.inc(idAst.offset, idAst.isGlobal);
			} else if (getAst1() instanceof ArrayReferenceAst) {
				ArrayReferenceAst arrAst = (ArrayReferenceAst) getAst1();
				if (arrAst.getAst1() instanceof IDAst) {
					IDAst idAst = (IDAst) arrAst.getAst1();
					if (idAst.isScalar()) {
						throw new SemanticException("Cannot use " + idAst + " as an array.");
					}
					idAst.setArray(true);
				}
				arrAst.populateTargetReferenceTuples(tuples);
				tuples.incMapRef();
			} else if (getAst1() instanceof DollarExpressionAst) {
File Line
io/jawk/frontend/AwkParser.java 5441[15]
io/jawk/frontend/AwkParser.java 5494[17]
io/jawk/frontend/AwkParser.java 5553[16]
io/jawk/frontend/AwkParser.java 5596[18]
tuples.inc(idAst.offset, idAst.isGlobal);
			} else if (getAst1() instanceof ArrayReferenceAst) {
				ArrayReferenceAst arrAst = (ArrayReferenceAst) getAst1();
				if (arrAst.getAst1() instanceof IDAst) {
					IDAst idAst = (IDAst) arrAst.getAst1();
					if (idAst.isScalar()) {
						throw new SemanticException("Cannot use " + idAst + " as an array.");
					}
					idAst.setArray(true);
				}
				arrAst.populateTargetReferenceTuples(tuples);
				tuples.incMapRef();
File Line
io/jawk/frontend/AwkParser.java 2654[19]
io/jawk/frontend/AwkParser.java 2712[20]
return 0;
		}
		AST argument = params.getAst1();
		if (argument instanceof IDAst
				&& !isJrtManagedSpecialName(((IDAst) argument).id)) {
			IDAst idAst = (IDAst) argument;
			tuples.pushIndirectArgument(idAst.offset, idAst.isGlobal);
		} else if (argument instanceof ArrayReferenceAst) {
			((ArrayReferenceAst) argument).populateTargetReferenceTuples(tuples);
			tuples.pushIndirectArrayArgument();
		} else {
			argument.populateTuples(tuples);
		}
File Line
io/jawk/frontend/AwkParser.java 4013[21]
io/jawk/frontend/AwkParser.java 4190[22]
io/jawk/frontend/AwkParser.java 4250[23]
io/jawk/frontend/AwkParser.java 4293[24]
private AssignmentExpressionAst(AST lhs, Token op, String text, AST rhs) {
			super(lhs, rhs);
			this.op = op;
			this.text = text;
		}

		@Override
		public String toString() {
			return super.toString() + " (" + op + "/" + text + ")";
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);
File Line
io/jawk/frontend/AwkParser.java 3783[25]
io/jawk/frontend/AwkParser.java 3835[26]
super(block, expr);
			addFlag(AstFlag.BREAKABLE);
			addFlag(AstFlag.CONTINUEABLE);
		}

		@Override
		public Address breakAddress() {
			return breakAddress;
		}

		@Override
		public Address continueAddress() {
			return continueAddress;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			breakAddress = tuples.createAddress("breakAddress");
			continueAddress = tuples.createAddress("continueAddress");
File Line
io/jawk/backend/AVM.java 1594[27]
io/jawk/backend/AVM.java 1609[28]
case INC_ARRAY_REF: {
					// arg[0] = offset
					// arg[1] = isGlobal
					// stack[0] = array index
					VariableTuple variableTuple = (VariableTuple) tuple;
					boolean isGlobal = variableTuple.isGlobal();
					Map<Object, Object> aa = ensureMapVariable(variableTuple.getVariableOffset(), isGlobal);
					Object key = pop();
					checkScalar(key);
					Object o = aa.get(key);
					double ans = JRT.toDouble(o) + 1;
File Line
io/jawk/frontend/AwkParser.java 5427[29]
io/jawk/frontend/AwkParser.java 5480[30]
io/jawk/frontend/AwkParser.java 5576[31]
private PreIncAst(AST symbolAst) {
			super(symbolAst);
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);
			if (getAst1() instanceof IDAst && isJrtManagedSpecialName(((IDAst) getAst1()).id)) {
				// the sequence already leaves the new value on the stack
				populateSpecialIncDec(tuples, ((IDAst) getAst1()).id, true, false);
File Line
io/jawk/frontend/AwkParser.java 3732[32]
io/jawk/frontend/AwkParser.java 3835[26]
io/jawk/frontend/AwkParser.java 3906[33]
super(expr, block);
			addFlag(AstFlag.BREAKABLE);
			addFlag(AstFlag.CONTINUEABLE);
		}

		@Override
		public Address breakAddress() {
			return breakAddress;
		}

		@Override
		public Address continueAddress() {
			return continueAddress;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			breakAddress = tuples.createAddress("breakAddress");
File Line
io/jawk/backend/AVM.java 3149[34]
io/jawk/backend/AVM.java 3808[35]
String orig = jrt.toAwkString(pop());
		String repl = jrt.toAwkString(pop());
		String ere = jrt.toAwkString(pop());
		push(isGsub ? jrt.replaceAll(orig, repl, ere) : jrt.replaceFirst(orig, repl, ere));
File Line
io/jawk/frontend/AwkParser.java 5205[36]
io/jawk/frontend/AwkParser.java 5237[37]
io/jawk/frontend/AwkParser.java 5264[38]
addFlag(AstFlag.NON_STATEMENT);
		}

		@Override
		public String toString() {
			return super.toString() + " (" + value + ")";
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);
			tuples.push(value);
			popSourceLineNumber(tuples);
			return 1;
		}
	}

	/**
	 * Can either assume the role of a double or an integer
	 * by aggressively normalizing the value to an int if possible.
	 */
	private final class DoubleAst extends ScalarExpressionAst {
File Line
io/jawk/frontend/AwkParser.java 5545[39]
io/jawk/frontend/AwkParser.java 5588[40]
if (getAst1() instanceof ArrayReferenceAst) {
					((ArrayReferenceAst) getAst1()).populateTargetValueTuples(tuples);
					tuples.unaryPlus();
				} else {
					getAst1().populateTuples(tuples);
				}
				if (getAst1() instanceof IDAst) {
					IDAst idAst = (IDAst) getAst1();
					tuples.postInc(idAst.offset, idAst.isGlobal);
File Line
io/jawk/jrt/StreamInputSource.java 336[41]
io/jawk/jrt/StreamInputSource.java 355[42]
hasFilenames = detectFilenames();
				if (partitioningReader == null && !hasFilenames) {
					partitioningReader = new PartitioningReader(
							new InputStreamReader(defaultInput, StandardCharsets.UTF_8),
							jrt.getRSString());
					currentReaderIsDefaultInput = true;
					jrt.setFILENAMEViaJrt(jrt.toInputScalar(""));
					// gawk clears ERRNO whenever the main input advances
					// successfully
					jrt.setERRNO("");
					return true;
				}
File Line
io/jawk/backend/AVM.java 2041[43]
io/jawk/backend/AVM.java 2058[44]
case IS_EMPTY_KEYLIST: {
					// arg[0] = address
					// stack[0] = Deque
					Object o = pop();
					if (o == null || !(o instanceof Deque)) {
						throw new AwkRuntimeException(
								position.lineNumber(),
								"Cannot get a key list (via 'in') of a non associative array. arg = " + o.getClass() + ", " + o);
					}
					Deque<?> keylist = (Deque<?>) o;
File Line
io/jawk/frontend/AwkParser.java 3732[32]
io/jawk/frontend/AwkParser.java 3783[25]
io/jawk/frontend/AwkParser.java 3906[33]
super(expr, block);
			addFlag(AstFlag.BREAKABLE);
			addFlag(AstFlag.CONTINUEABLE);
		}

		@Override
		public Address breakAddress() {
			return breakAddress;
		}

		@Override
		public Address continueAddress() {
			return continueAddress;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			breakAddress = tuples.createAddress("breakAddress");
File Line
io/jawk/backend/AVM.java 436[45]
io/jawk/backend/AVM.java 513[46]
installProgramMetadata(compiledProgram);

		jrt.prepareForExecution(settings.getFieldSeparator(), settings.getDefaultRS());
		if (!executionSpecialVariables.isEmpty()) {
			jrt.applySpecialVariables(executionSpecialVariables);
		}
		rebindResolvedInputSource(resolvedSource);
		executeTuples(compiledProgram.top());
	}

	/**
	 * Executes a compiled AWK program while persisting user-defined global
	 * variables across repeated executions on this AVM instance.
	 * <p>
	 * Before the new program starts, this method imports any user-defined
	 * globals currently materialized in the AVM and remaps them onto the
	 * incoming program's compiled global slots.
	 *
	 * @param program compiled program to execute
	 * @param inputSource input source providing records
	 * @throws ExitException when the program terminates via {@code exit}
	 * @throws IOException if execution fails
	 */
	public void executePersistingGlobals(AwkProgram program, InputSource inputSource)
awk
Links:
  • [1] https://pmd.github.io/latest/pmd_userdocs_cpd.html
  • [2] ./xref/io/jawk/jrt/HashAssocArray.html#L48
  • [3] ./xref/io/jawk/jrt/SortedAssocArray.html#L71
  • [4] ./xref/io/jawk/SandboxedAwk.html#L120
  • [5] ./xref/io/jawk/SandboxedAwk.html#L180
  • [6] ./xref/io/jawk/intermediate/AwkTuples.html#L2773
  • [7] ./xref/io/jawk/intermediate/AwkTuples.html#L2808
  • [8] ./xref/io/jawk/SandboxedAwk.html#L123
  • [9] ./xref/io/jawk/intermediate/SandboxedAwkTuples.html#L39
  • [10] ./xref/io/jawk/SandboxedAwk.html#L183
  • [11] ./xref/io/jawk/frontend/AwkParser.html#L2408
  • [12] ./xref/io/jawk/frontend/AwkParser.html#L2434
  • [13] ./xref/io/jawk/Awk.html#L1060
  • [14] ./xref/io/jawk/backend/AVM.html#L4566
  • [15] ./xref/io/jawk/frontend/AwkParser.html#L5441
  • [16] ./xref/io/jawk/frontend/AwkParser.html#L5553
  • [17] ./xref/io/jawk/frontend/AwkParser.html#L5494
  • [18] ./xref/io/jawk/frontend/AwkParser.html#L5596
  • [19] ./xref/io/jawk/frontend/AwkParser.html#L2654
  • [20] ./xref/io/jawk/frontend/AwkParser.html#L2712
  • [21] ./xref/io/jawk/frontend/AwkParser.html#L4013
  • [22] ./xref/io/jawk/frontend/AwkParser.html#L4190
  • [23] ./xref/io/jawk/frontend/AwkParser.html#L4250
  • [24] ./xref/io/jawk/frontend/AwkParser.html#L4293
  • [25] ./xref/io/jawk/frontend/AwkParser.html#L3783
  • [26] ./xref/io/jawk/frontend/AwkParser.html#L3835
  • [27] ./xref/io/jawk/backend/AVM.html#L1594
  • [28] ./xref/io/jawk/backend/AVM.html#L1609
  • [29] ./xref/io/jawk/frontend/AwkParser.html#L5427
  • [30] ./xref/io/jawk/frontend/AwkParser.html#L5480
  • [31] ./xref/io/jawk/frontend/AwkParser.html#L5576
  • [32] ./xref/io/jawk/frontend/AwkParser.html#L3732
  • [33] ./xref/io/jawk/frontend/AwkParser.html#L3906
  • [34] ./xref/io/jawk/backend/AVM.html#L3149
  • [35] ./xref/io/jawk/backend/AVM.html#L3808
  • [36] ./xref/io/jawk/frontend/AwkParser.html#L5205
  • [37] ./xref/io/jawk/frontend/AwkParser.html#L5237
  • [38] ./xref/io/jawk/frontend/AwkParser.html#L5264
  • [39] ./xref/io/jawk/frontend/AwkParser.html#L5545
  • [40] ./xref/io/jawk/frontend/AwkParser.html#L5588
  • [41] ./xref/io/jawk/jrt/StreamInputSource.html#L336
  • [42] ./xref/io/jawk/jrt/StreamInputSource.html#L355
  • [43] ./xref/io/jawk/backend/AVM.html#L2041
  • [44] ./xref/io/jawk/backend/AVM.html#L2058
  • [45] ./xref/io/jawk/backend/AVM.html#L436
  • [46] ./xref/io/jawk/backend/AVM.html#L513
Searching...
No results.