constant.java

来自「A compiler for a subset of the Java lang」· Java 代码 · 共 35 行

JAVA
35
字号
package inter;import lexer.*; import symbols.*;public class Constant extends Expr {   public Constant(Token tok, Type p) { super(tok, p); }   public Constant(int i) { super(new Num(i), Type.Int); }   public static final Constant      True  = new Constant(Word.True,  Type.Bool),      False = new Constant(Word.False, Type.Bool);   public void jumping(int t, int f) {      if ( this == True && t != 0 ) emit("goto L" + t);      else if ( this == False && f != 0) emit("goto L" + f);   }      public String toString()   {	   if(type == Type.Int)	   {		   return "ldc " + ((Num)op).value + "\n";	   }	   else if(type == Type.Float)	   {		   return "ldc " + ((Real) op).value + "\n";   	   }	   else if(type == Type.Complex)	   {		   return "ldc 0.0\nldc " + ((Complex) op).iValue + "\n";	   }	   return "nop\n";   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?