예제 #1
0
 // Assign ---
 // Exp lhs, rhs;
 public IrStmt visit(AstAssign n)
 {
     IrExp lhs = n.lhs.accept(this);
     IrExp rhs = n.rhs.accept(this);
     return new IrMove(lhs, rhs);
 }
예제 #2
0
 public void visit(AstAssign n)
 {
 }
예제 #3
0
 /* throws ParseException */
 /* final */
 public static AstStmt astStmt()
 {
     AstExp e1, e2; AstStmt s, s1, s2; AstExpList el; AstStmtList sl;
     jj_consume_token(AstRegExpId.kw56);
     switch ((jj_ntk == AstRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk) {
     case AstRegExpId.kwBlock:
       jj_consume_token(AstRegExpId.kwBlock);
       sl = astStmtList();
                                s = new AstBlock(sl);
       break;
     case AstRegExpId.kwAssign:
       jj_consume_token(AstRegExpId.kwAssign);
       e1 = astExp();
       e2 = astExp();
                                s = new AstAssign(e1,e2);
       break;
     case AstRegExpId.kwCallStmt:
       jj_consume_token(AstRegExpId.kwCallStmt);
       e1 = astExp();
       e2 = astExp();
       el = astExpList();
                                s = new AstCallStmt(e1,(AstId)e2,el);
       break;
     case AstRegExpId.kwIf:
       jj_consume_token(AstRegExpId.kwIf);
       e1 = astExp();
       s1 = astStmt();
       s2 = astStmt();
                                s = new AstIf(e1,s1,s2);
       break;
     case AstRegExpId.kwWhile:
       jj_consume_token(AstRegExpId.kwWhile);
       e1 = astExp();
       s1 = astStmt();
                                s = new AstWhile(e1,s1);
       break;
     case AstRegExpId.kwPrint:
       jj_consume_token(AstRegExpId.kwPrint);
       e1 = astExp();
                                s = new AstPrint(e1);
       break;
     case AstRegExpId.kwReturn:
       jj_consume_token(AstRegExpId.kwReturn);
       e1 = astExp();
                                s = new AstReturn(e1);
       break;
     case AstRegExpId.kwNullStmt:
       jj_consume_token(AstRegExpId.kwNullStmt);
                                s = null;
       break;
     default:
       jj_la1[8] = jj_gen;
       jj_consume_token(AstRegExpId.UNDEFINED);
       throw new AstParseException();
     }
     jj_consume_token(AstRegExpId.kw57);
     {if (true) return s;}
     throw new Error("Missing return statement in function");
 }
예제 #4
0
        /* throws Exception */
        // Assign ---
        // Exp lhs, rhs;
        public void visit(AstAssign n)
        {
            AstType t1 = n.lhs.accept(this);
            AstType t2 = n.rhs.accept(this);

            if (! ((null != (n.lhs as AstId) )
                || (null != (n.lhs as AstField) )
                || (null != (n.lhs as AstArrayElm))))
                throw new TypeException("Invalid LHS in Assign: " + n.lhs);

            if (!compatible(t1,t2))
                throw new TypeException("Incompatible types in Assign: " + t1 + " <- " + t2);
        }