📄 minusexpr.java
字号:
package AST;
import java.util.HashSet;import java.util.LinkedHashSet;import java.io.FileNotFoundException;import java.io.File;import java.util.*;import beaver.*;import java.util.ArrayList;import java.util.zip.*;import java.io.*;public class MinusExpr extends Unary implements Cloneable {
public void flushCache() { super.flushCache(); constant_visited = -1; isConstant_visited = -1; printPreOp_visited = -1; type_visited = -1; type_computed = false; type_value = null; } @SuppressWarnings({"unchecked", "cast"}) public MinusExpr clone() throws CloneNotSupportedException { MinusExpr node = (MinusExpr)super.clone(); node.constant_visited = -1; node.isConstant_visited = -1; node.printPreOp_visited = -1; node.type_visited = -1; node.type_computed = false; node.type_value = null; node.in$Circle(false); node.is$Final(false); return node; } @SuppressWarnings({"unchecked", "cast"}) public MinusExpr copy() { try { MinusExpr node = (MinusExpr)clone(); if(children != null) node.children = (ASTNode[])children.clone(); return node; } catch (CloneNotSupportedException e) { } System.err.println("Error: Could not clone node of type " + getClass().getName() + "!"); return null; } @SuppressWarnings({"unchecked", "cast"}) public MinusExpr fullCopy() { MinusExpr res = (MinusExpr)copy(); for(int i = 0; i < getNumChildNoTransform(); i++) { ASTNode node = getChildNoTransform(i); if(node != null) node = node.fullCopy(); res.setChild(node, i); } return res; } // Declared in TypeCheck.jrag at line 275 // 15.15.4 public void typeCheck() { if(!getOperand().type().isNumericType()) error("unary minus only operates on numeric types"); } // Declared in java.ast at line 3 // Declared in java.ast line 142
public MinusExpr() { super();
} // Declared in java.ast at line 10
// Declared in java.ast line 142 public MinusExpr(Expr p0) { setChild(p0, 0); } // Declared in java.ast at line 14 protected int numChildren() {
return 1;
} // Declared in java.ast at line 17
public boolean mayHaveRewrite() { return true; } // Declared in java.ast at line 2 // Declared in java.ast line 139 public void setOperand(Expr node) { setChild(node, 0); } // Declared in java.ast at line 5 public Expr getOperand() { return (Expr)getChild(0); } // Declared in java.ast at line 9 public Expr getOperandNoTransform() { return (Expr)getChildNoTransform(0); } protected int constant_visited = -1; // Declared in ConstantExpression.jrag at line 114 @SuppressWarnings({"unchecked", "cast"}) public Constant constant() { if(constant_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: constant in class: "); constant_visited = boundariesCrossed; Constant constant_value = constant_compute(); constant_visited = -1; return constant_value; } private Constant constant_compute() { return type().minus(getOperand().constant()); } protected int isConstant_visited = -1; // Declared in ConstantExpression.jrag at line 472 @SuppressWarnings({"unchecked", "cast"}) public boolean isConstant() { if(isConstant_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: isConstant in class: "); isConstant_visited = boundariesCrossed; boolean isConstant_value = isConstant_compute(); isConstant_visited = -1; return isConstant_value; } private boolean isConstant_compute() { return getOperand().isConstant(); } protected int printPreOp_visited = -1; // Declared in PrettyPrint.jadd at line 395 @SuppressWarnings({"unchecked", "cast"}) public String printPreOp() { if(printPreOp_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: printPreOp in class: "); printPreOp_visited = boundariesCrossed; String printPreOp_value = printPreOp_compute(); printPreOp_visited = -1; return printPreOp_value; } private String printPreOp_compute() { return "-"; } protected int type_visited = -1; // Declared in TypeAnalysis.jrag at line 317 @SuppressWarnings({"unchecked", "cast"}) public TypeDecl type() { if(type_computed) return type_value; if(type_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: type in class: "); type_visited = boundariesCrossed; int num = boundariesCrossed; boolean isFinal = this.is$Final(); type_value = type_compute(); if(isFinal && num == boundariesCrossed) type_computed = true; type_visited = -1; return type_value; } private TypeDecl type_compute() { return getOperand().type().unaryNumericPromotion(); }public ASTNode rewriteTo() { // Declared in ConstantExpression.jrag at line 233 if(getOperand() instanceof IntegerLiteral && ((IntegerLiteral)getOperand()).isDecimal() && getOperand().isPositive()) { duringConstantExpression++; ASTNode result = rewriteRule0(); duringConstantExpression--; return result; } // Declared in ConstantExpression.jrag at line 238 if(getOperand() instanceof LongLiteral && ((LongLiteral)getOperand()).isDecimal() && getOperand().isPositive()) { duringConstantExpression++; ASTNode result = rewriteRule1(); duringConstantExpression--; return result; } return super.rewriteTo();} // Declared in ConstantExpression.jrag at line 233 private IntegerLiteral rewriteRule0() { debugRewrite("Rewriting " + getClass().getName() + " using rule in ConstantExpression.jrag at line 233"); return new IntegerLiteral("-" + ((IntegerLiteral)getOperand()).getLITERAL()); } // Declared in ConstantExpression.jrag at line 238 private LongLiteral rewriteRule1() { debugRewrite("Rewriting " + getClass().getName() + " using rule in ConstantExpression.jrag at line 238"); return new LongLiteral("-" + ((LongLiteral)getOperand()).getLITERAL()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -