Changeset 3944 for to-imperative


Ignore:
Timestamp:
Sep 18, 2008, 8:34:13 PM (12 years ago)
Author:
orlov
Message:
 
Location:
to-imperative/trunk/opents/samples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/opents/samples/access.hh

    r3942 r3944  
    1313  TExpr e;
    1414  ((Expr&)e).init(1);
    15   ((Expr&)e)[0].init(((Expr&)_exp).get_len());
     15  ((Expr&)e)[0].init_int(((Expr&)_exp).get_len());
    1616  _res = e;
    1717  return 0;
     
    2020int Left (TExpr& _left, TExpr& _len, TExpr& _exp, TExpr& _res) {
    2121  Term t = ((Expr&)_left)[0];
    22   if (t.type != INT) throw "Invalid argument";
     22  if (t.type != Term::INT) throw "Invalid argument";
    2323  intptr_t left = t.data;
    2424  if (left < 0) throw "Invalid argument";
    2525
    2626  t = ((Expr&)_len)[0];
    27   if (t.type != INT) throw "Invalid argument";
     27  if (t.type != Term::INT) throw "Invalid argument";
    2828  intptr_t len = t.data;
    2929  if (len < 0) throw "Invalid argument";
    3030
    31   Expr exp = (Expr&)_exp;
    32   if (len > exp.get_len())
     31  Expr& exp = (Expr&)_exp;
     32  if ((uintptr_t)len > exp.get_len())
    3333    return 1;
    34   if (left > exp.get_len() - len)
     34  if ((uintptr_t)left > exp.get_len() - len)
    3535    return 1;
    3636
     
    4343int Right (TExpr& _right, TExpr& _len, TExpr& _exp, TExpr& _res) {
    4444  Term t = ((Expr&)_right)[0];
    45   if (t.type != INT) throw "Invalid argument";
     45  if (t.type != Term::INT) throw "Invalid argument";
    4646  intptr_t right = t.data;
    4747  if (right < 0) throw "Invalid argument";
    4848
    4949  t = ((Expr&)_len)[0];
    50   if (t.type != INT) throw "Invalid argument";
     50  if (t.type != Term::INT) throw "Invalid argument";
    5151  intptr_t len = t.data;
    5252  if (len < 0) throw "Invalid argument";
    5353
    54   Expr exp = (Expr&)_exp;
    55   if (len > exp.get_len())
     54  Expr& exp = (Expr&)_exp;
     55  if ((uintptr_t)len > exp.get_len())
    5656    return 1;
    57   if (right > exp.get_len() - len)
     57  if ((uintptr_t)right > exp.get_len() - len)
    5858    return 1;
    5959
     
    6666int Middle (TExpr& _left, TExpr& _right, TExpr& _exp, TExpr& _res) {
    6767  Term t = ((Expr&)_left)[0];
    68   if (t.type != INT) throw "Invalid argument";
     68  if (t.type != Term::INT) throw "Invalid argument";
    6969  intptr_t left = t.data;
    7070  if (left < 0) throw "Invalid argument";
    7171
    7272  t = ((Expr&)_right)[0];
    73   if (t.type != INT) throw "Invalid argument";
     73  if (t.type != Term::INT) throw "Invalid argument";
    7474  intptr_t right = t.data;
    7575  if (right < 0) throw "Invalid argument";
    7676
    77   Expr exp = (Expr&)_exp;
    78   if (left > exp.get_len())
     77  Expr& exp = (Expr&)_exp;
     78  if ((uintptr_t)left > exp.get_len())
    7979    return 1;
    80   if (right > exp.get_len() - left)
     80  if ((uintptr_t)right > exp.get_len() - left)
    8181    return 1;
    8282
  • to-imperative/trunk/opents/samples/stdio.hh

    r3927 r3944  
    1515}
    1616
     17int WriteLn (TExpr& _e) {
     18  std::cout << _e << std::endl;
     19  return 0;
     20}
     21
    1722}
    1823
Note: See TracChangeset for help on using the changeset viewer.