示例#1
0
文件: Ast.cs 项目: robin5/DemiTasse
 public static void Append(AstType t)
 {
     if (t == null)
         _astData.Append("(NullType) ");
     else
         t.GenerateAstData();
 }
示例#2
0
 public MethodRec(AstId id, AstType type)
 {
     _id = id;
     _rtype = type;
     _params = new List<VarRec>();
     _locals = new List<VarRec>();
 }
示例#3
0
 public VarRec(AstId id, AstType type, int kind, int idx, AstExp e)
 {
     _id = id;
     _type = type;
     _kind = kind;
     _idx = idx;
     _init = e;
 }
示例#4
0
 public VarRec(AstId id, AstType type, int kind, int idx)
 {
     _id = id;
     _type = type;
     _kind = kind;
     _idx = idx;
     _init = null;
 }
示例#5
0
 public AstMethodDecl(AstType at, AstId i, AstFormalList afl, 
 AstVarDeclList avl, AstStmtList asl)
 {
     t=at; mid=i; fl=afl; vl=avl; sl=asl;
 }
示例#6
0
 public AstVarDecl(AstType at, AstId i, AstExp ae)
 {
     t = at;
     var = i;
     e = ae;
 }
示例#7
0
 public AstNewArray(AstType t, int i)
 {
     et = t; size = i;
 }
示例#8
0
 private bool isIntType(AstType t)
 {
     return (null != (t as AstBasicType)) && (((AstBasicType)t).typ == AstBasicType.Int);
 }
示例#9
0
 /* throws Exception */
 private bool compatible(AstType t1, AstType t2)
 {
     if (t1 == t2)
         return true;
     else if ((null != (t1 as AstBasicType)) && (null != (t2 as AstBasicType)))
     {
         int bt1 = ((AstBasicType)t1).typ;
         int bt2 = ((AstBasicType)t2).typ;
         if (bt1 == bt2)
         return true;
     }
     else if ((null != (t1 as AstObjType)) && (null != (t2 as AstObjType)))
     {
         AstId cid1 = ((AstObjType) t1).cid;
         AstId cid2 = ((AstObjType) t2).cid;
         if (cid1.s.Equals(cid2.s))
         {
             return true;
         }
         else
         {
             ClassRec c = symTable.GetClass(cid2);
             while ((c = c.Parent()) != null)
             {
                 if (cid1.s.Equals(c.Id().s))
                 return true;
             }
         }
     }
     else if ((null != (t1 as AstArrayType)) && (null != (t2 as AstArrayType)))
     {
         return compatible(((AstArrayType) t1).et, ((AstArrayType) t2).et);
     }
     return false;
 }
示例#10
0
 public AstArrayType(AstType t)
 {
     et = t;
 }