@Override public void visitVariableIdentifierExpr( VariableIdentifierExpr variableIdentifierExpr) { names.add(variableIdentifierExpr.getName()); } }.getIteratorVariableNames(forStmt)
@Override public void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr) { super.visitVariableIdentifierExpr(variableIdentifierExpr); if (isCurrentComponentVariable(variableIdentifierExpr.getName()) && !inDeclarationOfTargetVariable) { parentMap.getParent(variableIdentifierExpr).replaceChild( variableIdentifierExpr, new MemberLookupExpr(new VariableIdentifierExpr(mergeSet.getMergedName()), getSwizzle(variableIdentifierExpr.getName()))); } }
@Override public VariableIdentifierExpr clone() { return new VariableIdentifierExpr(name); }
private static void replaceLoopCounterInIncrement(Expr increment, String newLoopCounter) { ((VariableIdentifierExpr) ((UnaryExpr) increment).getExpr()).setName(newLoopCounter); }
@Override public Expr generateExpr(IRandom generator, Expr... args) { assert args.length == getNumArguments(); return new VariableIdentifierExpr(name); }
private static void replaceLoopCounterInCondition(Expr condition, String newLoopCounter) { BinaryExpr binaryExpr = (BinaryExpr) condition; VariableIdentifierExpr toReplace; if (binaryExpr.getLhs() instanceof VariableIdentifierExpr) { toReplace = (VariableIdentifierExpr) binaryExpr.getLhs(); } else { toReplace = (VariableIdentifierExpr) binaryExpr.getRhs(); } toReplace.setName(newLoopCounter); }
private boolean isSameVarIdentifier(Expr expr, String loopCounterName) { return expr instanceof VariableIdentifierExpr && ((VariableIdentifierExpr)expr).getName().equals(loopCounterName); }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); for (int i = 0; i < functionCallExpr.getNumArgs(); i++) { Expr arg = functionCallExpr.getArg(i); if (arg instanceof VariableIdentifierExpr && ((VariableIdentifierExpr) arg) .getName().equals(declaration.getVariablesDeclaration().getDeclInfo(0).getName())) { functionCallExpr.setArg(i, new VariableIdentifierExpr(originalVariableInfo.getName())); } } }
private Expr injectionSwitch(String dimension) { assert generationParams.getInjectionSwitchIsAvailable(); return new MemberLookupExpr(new VariableIdentifierExpr(Constants.INJECTION_SWITCH), dimension); }
private boolean isVariable(Expr expr, String name) { return expr instanceof VariableIdentifierExpr && ((VariableIdentifierExpr) expr).getName().equals(name); }
referencedVariables.stream().map(item -> new VariableIdentifierExpr(item)) .collect(Collectors.toList())), BinOp.ASSIGN)); ((VariableIdentifierExpr) be.getLhs()).getName()); if (returnType == null) { switch (((VariableIdentifierExpr) be.getLhs()).getName()) { case OpenGlConstants.GL_FRAG_COLOR: case OpenGlConstants.GL_FRAG_COORD: default: assert returnType != null : "No type for " + ((VariableIdentifierExpr) be.getLhs()).getName();
private Expr makeHasReturned() { return new VariableIdentifierExpr( makeHasReturnedName()); }
@Override public void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr) { out.append(variableIdentifierExpr.getName()); }
@Override public void visitMemberLookupExpr(MemberLookupExpr memberLookupExpr) { super.visitMemberLookupExpr(memberLookupExpr); if (!(memberLookupExpr.getStructure() instanceof VariableIdentifierExpr)) { return; } VariableIdentifierExpr structVariable = ((VariableIdentifierExpr) memberLookupExpr .getStructure()); ScopeEntry se = currentScope.lookupScopeEntry(structVariable.getName()); if (se == null) { return; } if (se.getType().getWithoutQualifiers().equals(declaration.getVariablesDeclaration() .getBaseType().getWithoutQualifiers())) { // We've found the variable reference, but now we might have a chain, like: // s._f0._f2._f1._f0.v // We need to find the member expression that has .v and replace that with v MemberLookupExpr current = memberLookupExpr; while (current.getMember().startsWith(Constants.STRUCTIFICATION_FIELD_PREFIX)) { current = (MemberLookupExpr) parentMap.getParent(current); } parentMap.getParent(current).replaceChild( current, new VariableIdentifierExpr(originalVariableInfo.getName())); } } }.visit(tu);
private Expr makeReturnValue() { return new VariableIdentifierExpr( makeReturnValueName()); }
private static Optional<String> maybeGetName(Expr expr) { if (!(expr instanceof VariableIdentifierExpr)) { return Optional.empty(); } return Optional.of(((VariableIdentifierExpr) expr).getName()); }