if (firstAssignment.getLeftValue() == null || secondAssignment.getRightValue() == null) { return null; if (firstAssignment.isAsync() || secondAssignment.isAsync()) { return null; if (!(firstAssignment.getLeftValue() instanceof VariableExpr) || !(secondAssignment.getLeftValue() instanceof VariableExpr)) { return null; VariableExpr firstLhs = (VariableExpr) firstAssignment.getLeftValue(); VariableExpr secondLhs = (VariableExpr) secondAssignment.getLeftValue(); if (firstLhs.getIndex() == secondLhs.getIndex()) { ConditionalExpr conditionalExpr = new ConditionalExpr(); conditionalExpr.setCondition(statement.getCondition()); conditionalExpr.setConsequent(firstAssignment.getRightValue()); conditionalExpr.setAlternative(secondAssignment.getRightValue()); conditionalExpr.setLocation(statement.getCondition().getLocation()); AssignmentStatement assignment = new AssignmentStatement(); assignment.setLocation(conditionalExpr.getLocation()); VariableExpr lhs = new VariableExpr(); lhs.setIndex(firstLhs.getIndex()); assignment.setLeftValue(lhs); assignment.setRightValue(conditionalExpr); writeFrequencies[lhs.getIndex()]--; return assignment;
@Override public void visit(AssignmentStatement statement) { try { output.writeByte(statement.getLeftValue() != null ? 0 : 1); writeLocation(statement.getLocation()); if (statement.getLeftValue() != null) { writeExpr(statement.getLeftValue()); } writeExpr(statement.getRightValue()); output.writeBoolean(statement.isAsync()); } catch (IOException e) { throw new IOExceptionWrapper(e); } }
public static AssignmentStatement assign(Expr left, Expr right) { AssignmentStatement stmt = new AssignmentStatement(); stmt.setLeftValue(left); stmt.setRightValue(right); return stmt; }
@Override public void visit(AssignmentStatement statement) { if (statement.getLeftValue() != null) { statement.getLeftValue().acceptVisitor(this); } statement.getRightValue().acceptVisitor(this); }
@Override public void visit(AssignmentStatement statement) { pushLocation(statement.getLocation()); try { if (statement.getLeftValue() == null) { statement.getRightValue().acceptVisitor(this); if (resultExpr instanceof InvocationExpr && tryApplyConstructor((InvocationExpr) resultExpr)) { resultStmt = new SequentialStatement(); } else { statement.setRightValue(resultExpr); resultStmt = statement; statement.getRightValue().acceptVisitor(this); Expr right = resultExpr; Expr left = statement.getLeftValue(); if (!(statement.getLeftValue() instanceof VariableExpr)) { statement.getLeftValue().acceptVisitor(this); left = resultExpr; } else { int varIndex = ((VariableExpr) statement.getLeftValue()).getIndex(); if (!preservedVars[varIndex] && initialWriteFrequences[varIndex] == 1 && constants[varIndex] != null) { statement.setLeftValue(left); statement.setRightValue(right); resultStmt = statement;
switch (type) { case 0: { AssignmentStatement stmt = new AssignmentStatement(); stmt.setLocation(readLocation(input)); stmt.setLeftValue(readExpr(input)); stmt.setRightValue(readExpr(input)); stmt.setAsync(input.readBoolean()); return stmt; AssignmentStatement stmt = new AssignmentStatement(); stmt.setLocation(readLocation(input)); stmt.setRightValue(readExpr(input)); stmt.setAsync(input.readBoolean()); return stmt;
@Override public void visit(AssignmentStatement statement) { Expr left = statement.getLeftValue(); if (left == null) { accept(statement.getRightValue()); result.acceptVisitor(typeInference); if (typeInference.getResult() != null) { result = new WasmDrop(result); result.setLocation(statement.getLocation()); } } else if (left instanceof VariableExpr) { VariableExpr varExpr = (VariableExpr) left; WasmLocal local = function.getLocalVariables().get(varExpr.getIndex() - firstVariable); accept(statement.getRightValue()); result = new WasmSetLocal(local, result); result.setLocation(statement.getLocation()); } else if (left instanceof QualificationExpr) { QualificationExpr lhs = (QualificationExpr) left; storeField(lhs.getQualified(), lhs.getField(), statement.getRightValue(), statement.getLocation()); } else if (left instanceof SubscriptExpr) { SubscriptExpr lhs = (SubscriptExpr) left; storeArrayItem(lhs, statement.getRightValue()); } else { throw new UnsupportedOperationException("This expression is not supported yet"); } }
if (!(assignment.getLeftValue() instanceof VariableExpr)) { return false; VariableExpr var = (VariableExpr) assignment.getLeftValue(); if (!(expr.getArguments().get(0) instanceof VariableExpr)) { return false; return false; if (!(assignment.getRightValue() instanceof NewExpr)) { return false; NewExpr constructed = (NewExpr) assignment.getRightValue(); if (!constructed.getConstructedClass().equals(expr.getMethod().getClassName())) { return false; InvocationExpr constructrExpr = Expr.constructObject(expr.getMethod(), args); constructrExpr.setLocation(expr.getLocation()); assignment.setRightValue(constructrExpr); readFrequencies[var.getIndex()]--; return true;
private void assign(Expr source, Variable target) { AssignmentStatement stmt = Statement.assign(Expr.var(target.getIndex()), source); stmt.setLocation(currentLocation); statements.add(stmt); }
@Override public void visit(InvokeInstruction insn) { Expr[] exprArgs = new Expr[insn.getMethod().getParameterTypes().length]; for (int i = 0; i < insn.getArguments().size(); ++i) { exprArgs[i] = Expr.var(insn.getArguments().get(i).getIndex()); } InvocationExpr invocationExpr; if (insn.getInstance() != null) { if (insn.getType() == InvocationType.VIRTUAL) { invocationExpr = Expr.invoke(insn.getMethod(), Expr.var(insn.getInstance().getIndex()), exprArgs); } else { invocationExpr = Expr.invokeSpecial(insn.getMethod(), Expr.var(insn.getInstance().getIndex()), exprArgs); } } else { invocationExpr = Expr.invokeStatic(insn.getMethod(), exprArgs); } AssignmentStatement stmt; if (insn.getReceiver() != null) { stmt = Statement.assign(Expr.var(insn.getReceiver().getIndex()), invocationExpr); } else { stmt = Statement.assign(null, invocationExpr); } stmt.setLocation(currentLocation); stmt.setAsync(async); async = false; statements.add(stmt); }
@Override public void visit(AssignmentStatement statement) { super.visit(statement); if (statement.isAsync()) { consumer.consumeFunction("$rt_suspending"); } }
@Override public void visit(AssignmentStatement statement) { InvocationExpr invocation = (InvocationExpr) statement.getRightValue(); asyncCalls.add(invocation.getMethod()); }
@Override public void visit(AssignmentStatement statement) { pushLocation(statement.getLocation()); try { if (statement.getLeftValue() == null) { statement.getRightValue().acceptVisitor(this); if (resultExpr instanceof InvocationExpr && tryApplyConstructor((InvocationExpr) resultExpr)) { resultStmt = new SequentialStatement(); } else { statement.setRightValue(resultExpr); resultStmt = statement; } } else { statement.getRightValue().acceptVisitor(this); Expr right = resultExpr; Expr left = statement.getLeftValue(); if (!(statement.getLeftValue() instanceof VariableExpr)) { statement.getLeftValue().acceptVisitor(this); left = resultExpr; } statement.setLeftValue(left); statement.setRightValue(right); resultStmt = statement; } } finally { popLocation(); } }
switch (type) { case 0: { AssignmentStatement stmt = new AssignmentStatement(); stmt.setLocation(readLocation(input)); stmt.setLeftValue(readExpr(input)); stmt.setRightValue(readExpr(input)); stmt.setAsync(input.readBoolean()); return stmt; AssignmentStatement stmt = new AssignmentStatement(); stmt.setLocation(readLocation(input)); stmt.setRightValue(readExpr(input)); stmt.setAsync(input.readBoolean()); return stmt;
public static AssignmentStatement assign(Expr left, Expr right) { AssignmentStatement stmt = new AssignmentStatement(); stmt.setLeftValue(left); stmt.setRightValue(right); return stmt; }
@Override public void visit(AssignmentStatement statement) { Expr left = statement.getLeftValue(); if (left == null) { accept(statement.getRightValue()); result.acceptVisitor(typeInference); if (typeInference.getResult() != null) { result = new WasmDrop(result); result.setLocation(statement.getLocation()); } } else if (left instanceof VariableExpr) { VariableExpr varExpr = (VariableExpr) left; WasmLocal local = function.getLocalVariables().get(varExpr.getIndex() - firstVariable); accept(statement.getRightValue()); result = new WasmSetLocal(local, result); result.setLocation(statement.getLocation()); } else if (left instanceof QualificationExpr) { QualificationExpr lhs = (QualificationExpr) left; storeField(lhs.getQualified(), lhs.getField(), statement.getRightValue(), statement.getLocation()); } else if (left instanceof SubscriptExpr) { SubscriptExpr lhs = (SubscriptExpr) left; storeArrayItem(lhs, statement.getRightValue()); } else { throw new UnsupportedOperationException("This expression is not supported yet"); } }
if (!(assignment.getLeftValue() instanceof VariableExpr)) { return false; VariableExpr var = (VariableExpr) assignment.getLeftValue(); if (!(expr.getArguments().get(0) instanceof VariableExpr)) { return false; return false; if (!(assignment.getRightValue() instanceof NewExpr)) { return false; NewExpr constructed = (NewExpr) assignment.getRightValue(); if (!constructed.getConstructedClass().equals(expr.getMethod().getClassName())) { return false; InvocationExpr constructrExpr = Expr.constructObject(expr.getMethod(), args); constructrExpr.setLocation(expr.getLocation()); assignment.setRightValue(constructrExpr); readFrequencies[var.getIndex()]--; return true;
@Override public void visit(AssignmentStatement statement) { if (statement.getLeftValue() != null) { statement.getLeftValue().acceptVisitor(this); writer.print(" = "); } statement.getRightValue().acceptVisitor(this); writer.println(";"); }
@Override public void visit(AssignInstruction insn) { AssignmentStatement stmt = Statement.assign(Expr.var(insn.getReceiver().getIndex()), Expr.var(insn.getAssignee().getIndex())); stmt.setLocation(currentLocation); statements.add(stmt); }
@Override public void visit(InvokeInstruction insn) { Expr[] exprArgs = new Expr[insn.getMethod().getParameterTypes().length]; for (int i = 0; i < insn.getArguments().size(); ++i) { exprArgs[i] = Expr.var(insn.getArguments().get(i).getIndex()); } InvocationExpr invocationExpr; if (insn.getInstance() != null) { if (insn.getType() == InvocationType.VIRTUAL) { invocationExpr = Expr.invoke(insn.getMethod(), Expr.var(insn.getInstance().getIndex()), exprArgs); } else { invocationExpr = Expr.invokeSpecial(insn.getMethod(), Expr.var(insn.getInstance().getIndex()), exprArgs); } } else { invocationExpr = Expr.invokeStatic(insn.getMethod(), exprArgs); } AssignmentStatement stmt; if (insn.getReceiver() != null) { stmt = Statement.assign(Expr.var(insn.getReceiver().getIndex()), invocationExpr); } else { stmt = Statement.assign(null, invocationExpr); } stmt.setLocation(currentLocation); stmt.setAsync(async); async = false; statements.add(stmt); }