type.java

来自「23种设计模式JAVA实现,很好很有用的东西.」· Java 代码 · 共 27 行

JAVA
27
字号
package symbols;import lexer.*;public class Type extends Word {   public int width = 0;          // width is used for storage allocation   public Type(String s, int tag, int w) { super(s, tag); width = w; }   public static final Type      Int   = new Type( "int",   Tag.BASIC, 4 ),      Float = new Type( "float", Tag.BASIC, 8 ),      Char  = new Type( "char",  Tag.BASIC, 1 ),      Bool  = new Type( "bool",  Tag.BASIC, 1 );   public static boolean numeric(Type p) {      if (p == Type.Char || p == Type.Int || p == Type.Float) return true;      else return false;   }   public static Type max(Type p1, Type p2 ) {      if ( ! numeric(p1) || ! numeric(p2) ) return null;      else if ( p1 == Type.Float || p2 == Type.Float ) return Type.Float;      else if ( p1 == Type.Int   || p2 == Type.Int   ) return Type.Int;      else return Type.Char;   }}

⌨️ 快捷键说明

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