public String paramsAsJava() { String s = ""; for (Iterator itr = this.parameters.iterator(); itr.hasNext(); ) { Object o = itr.next(); if (o instanceof DNVariable) { DNVariable var = (DNVariable) o; s = s + var.getName(); } else if (o instanceof Expression) { s = s + ((Expression) o).asJava(); } else { throw new RuntimeException("Something funny in the params " + parameters); } if (itr.hasNext()) { s = s + ", "; } } return s; }
public static boolean matchesBinaryOperatorExpression( OperatorStatement os, BinaryOperatorExpression boe, InterpretationContext context) { if (os.getName().equals(boe.getOperator()) && os.isBinary()) { // types now have to match DNVariable leftArg = (DNVariable) os.getArgs().get(0); DNVariable rightArg = (DNVariable) os.getArgs().get(1); DNType leftArgT = context.getLibrary().getProgramDefinedOrLibraryDNTypeFor(leftArg.getType()); DNType rightArgT = context.getLibrary().getProgramDefinedOrLibraryDNTypeFor(rightArg.getType()); if (leftArgT.isEqualOrIsSuperType(boe.getLeftExpression().getDNType()) && rightArgT.isEqualOrIsSuperType(boe.getRightExpression().getDNType())) { return true; } } return false; }
private static List createVBArrayCreationDeclatationsAndSubstituteParams( List oldParameters, List newParameters, InterpretationContext context) { List arrayCreationDeclarations = new ArrayList(); String s = ACE_VARIABLE_NAME; for (Iterator itr = oldParameters.iterator(); itr.hasNext(); ) { Object o = itr.next(); if (o instanceof ArrayCreationExpression) { ArrayCreationExpression ace = (ArrayCreationExpression) o; LocalVariableDeclaration ds = LocalVariableDeclaration.createVBLocalVariableDeclaration(context, ace, s + aceCounter); arrayCreationDeclarations.add(ds); newParameters.add(DNVariable.createVBVariable(s + aceCounter, ace.getName() + "()")); aceCounter++; } else { newParameters.add(o); } } return arrayCreationDeclarations; }