Esempio n. 1
0
        // Print ---
        // Exp e;
        public IrStmt visit(AstPrint n)
        {
            IrName func = new IrName("print");

            IrExpList args = new IrExpList();

            if (n.e != null)
                args.add(n.e.accept(this));

            return new IrCallst(func, args);
        }
Esempio n. 2
0
 public void visit(AstPrint n)
 {
 }
Esempio 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");
 }
Esempio n. 4
0
 /* throws Exception */
 // Print ---
 // Exp e;
 public void visit(AstPrint n)
 {
     if (n.e != null)
     {
         AstType t = n.e.accept(this);
         if ((null == (t as AstBasicType)))
             throw new TypeException("Argument to Print must be of a basic type" + " or a string literal: " + t);
     }
 }