Changeset 1778


Ignore:
Timestamp:
Jun 15, 2005, 11:45:12 AM (15 years ago)
Author:
orlov
Message:
  • Runtime support for closures.
Location:
to-imperative/trunk
Files:
3 added
39 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/bootstrap/compiler/rfp-filt.cc

    r1774 r1778  
    116116  _c_0 = Expr::create<Integer>("1");
    117117  _c_1 = Char::create_expr ("-r");
    118   _c_2 = Expr (To_m_Rfp);
    119   _c_3 = Expr (To_m_Cpp);
     118  _c_2 = Expr::create_sym<Func> (To_m_Rfp);
     119  _c_3 = Expr::create_sym<Func> (To_m_Cpp);
    120120}
    121121
  • to-imperative/trunk/bootstrap/compiler/rfp_as2as.cc

    r1712 r1778  
    23442344  _c_15 = Expr::create<Word>("ERROR");
    23452345  _c_16 = Expr::create<Word>("arg");
    2346   _c_18 = Expr (Old_m_Var_q_);
    2347   _c_19 = Expr (Rename);
    2348   _c_20 = Expr (Rename_m_Vars);
     2346  _c_18 = Expr::create_sym<Func> (Old_m_Var_q_);
     2347  _c_19 = Expr::create_sym<Func> (Rename);
     2348  _c_20 = Expr::create_sym<Func> (Rename_m_Vars);
    23492349  _c_21 = Expr::create<Word>("_");
    23502350  _c_23 = Expr::create<Word>("SVAR");
  • to-imperative/trunk/bootstrap/compiler/rfp_asail.cc

    r1774 r1778  
    241241static Expr _c_84;
    242242
     243static Expr _c_85;
     244
     245static Expr _c_86;
     246
     247static Expr _c_87;
     248
     249static Expr _c_88;
     250
     251static Expr _c_89;
     252
     253static Expr _c_90;
     254
     255static Expr _c_91;
     256
     257static Expr _c_92;
     258
     259static Expr _c_93;
     260
     261static Expr _c_94;
     262
     263static Expr _c_95;
     264
     265static Expr _c_96;
     266
     267static Expr _c_97;
     268
     269static Expr _c_98;
     270
     271static Expr _c_99;
     272
     273static Expr _c_100;
     274
     275static Expr _c_101;
     276
     277static Expr _c_102;
     278
     279static Expr _c_103;
     280
     281static Expr _c_104;
     282
     283static Expr _c_105;
     284
     285static Expr _c_106;
     286
     287static Expr _c_107;
     288
     289static Expr _c_108;
     290
     291static Expr _c_109;
     292
     293static Expr _c_110;
     294
     295static Expr _c_111;
     296
     297static Expr _c_112;
     298
     299static Expr _c_113;
     300
     301static Expr _c_114;
     302
     303static Expr _c_115;
     304
     305static Expr _c_116;
     306
     307static Expr _c_117;
     308
     309static Expr _c_118;
     310
     311static Expr _c_119;
     312
     313static Expr _c_120;
     314
     315static Expr _c_121;
     316
     317static Expr _c_122;
     318
     319static Expr _c_123;
     320
     321static Expr _c_124;
     322
     323static Expr _c_125;
     324
     325static Expr _c_126;
     326
     327static Expr _c_128;
     328
     329static Expr _c_127;
     330
     331static Expr _c_129;
     332
     333static Expr _c_130;
     334
    243335static Expr _c_131;
    244 
    245 static Expr _c_85;
    246 
    247 static Expr _c_86;
    248 
    249 static Expr _c_87;
    250 
    251 static Expr _c_88;
    252 
    253 static Expr _c_89;
    254 
    255 static Expr _c_90;
    256 
    257 static Expr _c_91;
    258 
    259 static Expr _c_92;
    260 
    261 static Expr _c_93;
    262 
    263 static Expr _c_94;
    264 
    265 static Expr _c_95;
    266 
    267 static Expr _c_96;
    268 
    269 static Expr _c_97;
    270 
    271 static Expr _c_98;
    272 
    273 static Expr _c_99;
    274 
    275 static Expr _c_100;
    276 
    277 static Expr _c_101;
    278 
    279 static Expr _c_102;
    280 
    281 static Expr _c_103;
    282 
    283 static Expr _c_104;
    284 
    285 static Expr _c_105;
    286 
    287 static Expr _c_106;
    288 
    289 static Expr _c_107;
    290 
    291 static Expr _c_108;
    292 
    293 static Expr _c_109;
    294 
    295 static Expr _c_110;
    296 
    297 static Expr _c_111;
    298 
    299 static Expr _c_112;
    300 
    301 static Expr _c_113;
    302 
    303 static Expr _c_114;
    304 
    305 static Expr _c_115;
    306 
    307 static Expr _c_116;
    308 
    309 static Expr _c_117;
    310 
    311 static Expr _c_118;
    312 
    313 static Expr _c_119;
    314 
    315 static Expr _c_120;
    316 
    317 static Expr _c_121;
    318 
    319 static Expr _c_122;
    320 
    321 static Expr _c_123;
    322 
    323 static Expr _c_124;
    324 
    325 static Expr _c_125;
    326 
    327 static Expr _c_126;
    328 
    329 static Expr _c_128;
    330 
    331 static Expr _c_127;
    332 
    333 static Expr _c_129;
    334 
    335 static Expr _c_130;
    336336
    337337static Expr _c_134;
     
    37943794  _c_79 = Expr::create<Word>("INFIX");
    37953795  _c_80 = Char::create_expr ("empty");
    3796   _c_81 = Expr (Term_m_Ref_m_To_m_CPP);
     3796  _c_81 = Expr::create_sym<Func> (Term_m_Ref_m_To_m_CPP);
    37973797  _c_82 = Expr::create<Word>("+");
    37983798  _c_83 = Expr (_c_48, 1, 1);
    37993799  _c_84 = Expr (_c_53, 5, 3);
    3800   _c_131 = Char::create_expr (" + Expr (");
    3801   _c_85 = Expr (_c_131, 3, 6);
     3800  _c_85 = Char::create_expr ("Expr (");
    38023801  _c_86 = Expr::create<Word>("REF");
    38033802  _c_87 = Expr::create<Word>("ERROR-EXPR");
     
    38083807  _c_92 = Char::create_expr ("pxx_max (");
    38093808  _c_93 = Char::create_expr ("pxx_min (");
    3810   _c_94 = Expr (Expr_m_Int_m_To_m_CPP);
     3809  _c_94 = Expr::create_sym<Func> (Expr_m_Int_m_To_m_CPP);
    38113810  _c_95 = Expr::create<Word>("CALL");
    38123811  _c_96 = Char::create_expr ("RF_CALL (");
     
    38233822  _c_107 = Expr::create<Word>("NOT");
    38243823  _c_108 = Char::create_expr ("!");
    3825   _c_109 = Expr (Cond_m_To_m_CPP);
     3824  _c_109 = Expr::create_sym<Func> (Cond_m_To_m_CPP);
    38263825  _c_110 = Expr::create<Word>("&&");
    38273826  _c_111 = Expr::create<Word>("||");
     
    38453844  _c_129 = Char::create_expr (") ()");
    38463845  _c_130 = Char::create_expr (" + (");
     3846  _c_131 = Char::create_expr (" + Expr::create_sym<Func> (");
    38473847  _c_134 = Char::create_expr (" + Expr::create<Word>(\"");
    38483848  _c_132 = Expr (_c_134, 20, 3);
  • to-imperative/trunk/bootstrap/compiler/rfp_clashes.cc

    r1774 r1778  
    21372137  _c_1 = Expr::create<Integer>("0");
    21382138  _c_2 = Expr::create<Integer>("-1");
    2139   _c_3 = Expr (Add_m_Clash_m_To_m_Var);
     2139  _c_3 = Expr::create_sym<Func> (Add_m_Clash_m_To_m_Var);
    21402140  _c_4 = Compute_m_Length + Unknown_m_Lengths;
    21412141  _c_5 = Expr::create<Integer>("1");
     
    21482148  _c_11 = (_c_1) () + (_c_1) ();
    21492149  _c_12 = Expr::create<Word>("LEFT");
    2150   _c_13 = Expr (rfp__helper::L_m_);
     2150  _c_13 = Expr::create_sym<Func> (rfp__helper::L_m_);
    21512151  _c_14 = Expr::create<Word>("RIGHT");
    2152   _c_15 = Expr (rfp__helper::R_m_);
     2152  _c_15 = Expr::create_sym<Func> (rfp__helper::R_m_);
    21532153  _c_16 = (empty) ();
    21542154  _c_17 = (Expr::create<Word>("VAR")) ();
     
    21602160  _c_23 = Expr::create<Word>("compose");
    21612161  _c_24 = Expr::create<Word>("EXPR");
    2162   _c_25 = Expr (Not_m_Idx);
    2163   _c_26 = Expr (Not_m_Instantiated_m_Var);
     2162  _c_25 = Expr::create_sym<Func> (Not_m_Idx);
     2163  _c_26 = Expr::create_sym<Func> (Not_m_Instantiated_m_Var);
    21642164  _c_27 = Expr::create<Word>("LSPLIT");
    21652165  _c_28 = Expr::create<Word>("lsplit_");
    21662166  _c_29 = Expr::create<Word>("RSPLIT");
    21672167  _c_30 = Expr::create<Word>("rsplit_");
    2168   _c_31 = Expr (Reclassify_m_Clash);
     2168  _c_31 = Expr::create_sym<Func> (Reclassify_m_Clash);
    21692169  _c_32 = Expr::create<Word>("FUNC");
    21702170  _c_33 = Expr::create<Word>("Length");
  • to-imperative/trunk/bootstrap/compiler/rfp_compile.cc

    r1774 r1778  
    60596059  _c_13 = Expr::create<Word>("OBJ") + Expr::create<Word>("LOCAL");
    60606060  _c_12 = Expr (_c_13, 1, 1);
    6061   _c_14 = Expr (Gener_m_Stub);
     6061  _c_14 = Expr::create_sym<Func> (Gener_m_Stub);
    60626062  _c_15 = Expr::create<Word>("stub");
    60636063  _c_16 = Expr::create<Word>("STUB");
     
    60726072  _c_21 = ((_c_139) ()) () + (_c_140) ();
    60736073  _c_22 = Expr::create<Word>("res");
    6074   _c_23 = Expr (rfp__vars::Set_m_Var_m_);
     6074  _c_23 = Expr::create_sym<Func> (rfp__vars::Set_m_Var_m_);
    60756075  _c_141 = Expr::create<Word>("Instantiated?") + Expr::create<Word>("True");
    60766076  _c_24 = (_c_141) ();
     
    61456145  _c_92 = Expr (_c_93, 0, 1);
    61466146  _c_94 = Expr::create<Word>("aux");
    6147   _c_95 = Expr (Get_m_Vars);
    6148   _c_96 = Expr (Max_m_Require);
    6149   _c_97 = Expr (Subst_m_Aux_m_Var);
    6150   _c_98 = Expr (Extract_m_Assigns);
     6147  _c_95 = Expr::create_sym<Func> (Get_m_Vars);
     6148  _c_96 = Expr::create_sym<Func> (Max_m_Require);
     6149  _c_97 = Expr::create_sym<Func> (Subst_m_Aux_m_Var);
     6150  _c_98 = Expr::create_sym<Func> (Extract_m_Assigns);
    61516151  _c_125 = Expr::create<Word>("Clashes");
    61526152  _c_99 = (_c_125) ();
     
    61766176  _c_123 = Expr::create<Word>("INFIX") + Expr::create<Word>("/");
    61776177  _c_124 = Expr::create<Word>("Length");
    6178   _c_126 = Expr (rfp__clashes::Reclassify_m_Clash);
     6178  _c_126 = Expr::create_sym<Func> (rfp__clashes::Reclassify_m_Clash);
    61796179  _c_127 = Expr::create<Word>("INFIX") + Expr::create<Word>("||");
    61806180  _c_128 = Expr::create<Word>("LENGTH");
  • to-imperative/trunk/bootstrap/compiler/rfp_const.cc

    r1774 r1778  
    10151015  _c_10 = Expr::create<Word>("SUBEXPR");
    10161016  _c_11 = Expr::create<Word>("CONSTEXPR") + Expr::create<Word>("LOCAL");
    1017   _c_12 = Expr (Bind_m_Static);
    1018   _c_13 = Expr (Static_m_To_m_Constexprs);
     1017  _c_12 = Expr::create_sym<Func> (Bind_m_Static);
     1018  _c_13 = Expr::create_sym<Func> (Static_m_To_m_Constexprs);
    10191019}
    10201020
  • to-imperative/trunk/bootstrap/compiler/rfp_format.cc

    r1774 r1778  
    27002700  _c_11 = (_c_7) ();
    27012701  _c_12 = (empty) ();
    2702   _c_13 = Expr (MSG_m_Exprs);
     2702  _c_13 = Expr::create_sym<Func> (MSG_m_Exprs);
    27032703  _c_15 = (Expr::create<Word>("TVAR")) ();
    27042704  _c_16 = Expr::create<Integer>("1");
  • to-imperative/trunk/bootstrap/compiler/rfp_src.cc

    r1712 r1778  
    355355  RFP_m_Sources = new rftype::StaticObject<rftype::Table>(L"RFP-Sources");
    356356  _c_0 = Expr::create<Word>("r");
    357   _c_1 = Expr::create<Word>("FILE") + Expr (RFP_m_Get_m_Line_m_From_m_File);
     357  _c_1 = Expr::create<Word>("FILE") + Expr::create_sym<Func> (RFP_m_Get_m_Line_m_From_m_File);
    358358  _c_2 = Expr (_c_1, 0, 1);
    359   _c_4 = Expr::create<Word>("STDIN") + Expr (RFP_m_Get_m_Line_m_From_m_File) + (Char::create_expr ("StdIN")) () + (empty) ();
     359  _c_4 = Expr::create<Word>("STDIN") + Expr::create_sym<Func> (RFP_m_Get_m_Line_m_From_m_File) + (Char::create_expr ("StdIN")) () + (empty) ();
    360360  _c_3 = Expr (_c_4, 0, 1);
    361361  _c_5 = Expr::create<Integer>("1");
  • to-imperative/trunk/bootstrap/compiler/rfp_vars.cc

    r1774 r1778  
    25312531  _c_12 = (Expr::create<Word>("Instantiated?") + Expr::create<Word>("True")) ();
    25322532  _c_13 = Expr::create<Word>("LENGTH");
    2533   _c_14 = Expr (Reset_m_Var);
     2533  _c_14 = Expr::create_sym<Func> (Reset_m_Var);
    25342534  _c_15 = Expr::create<Word>("Decl");
    2535   _c_16 = Expr (Print_m_Var);
    2536   _c_17 = Expr (Decl_m_Var);
     2535  _c_16 = Expr::create_sym<Func> (Print_m_Var);
     2536  _c_17 = Expr::create_sym<Func> (Decl_m_Var);
    25372537  _c_18 = Expr::create<Word>("DECL") + Expr::create<Word>("Expr");
    25382538  _c_19 = Expr::create<Word>("Declare");
  • to-imperative/trunk/compiler/rfp_asail.rf

    r1773 r1778  
    397397      ' + ' <Rfp2Cpp t.item>;
    398398    (FUNC t.name) =
    399       ' + Expr (' <Name-To-CPP t.name> ')';
     399      ' + Expr::create_sym<Func> (' <Name-To-CPP t.name> ')';
    400400    s.sym, {
    401401      <Int? s.sym> =
  • to-imperative/trunk/library/Apply/apply.cc

    r1679 r1778  
    1212
    1313RF_FUNC (Apply, (RF_ARG _func, _arg;;), (RF_RES _res;;))
    14   if (_func.get_len() == 1) {
    15     Term* t = _func.get_first();
    16     Func* f = t->cast_to<Func>();
    17     if (f) {
    18       RF_TAILCALL(f, _arg, _res)
    19     }
     14  assert (_func.get_len() == 1);
     15  Term* t = _func.get_first();
     16  if (t->is_instance_of<Func>())
     17  {
     18    RF_TAILCALL(t->get_obj_ptr<Func>(), _arg, _res)
     19  }
     20  if (t->is_instance_of<Closure>())
     21  {
     22    RF_TAILAPPLY(t->get_obj_ptr<Closure>(), _arg, _res)
    2023  }
    2124  RF_LIB_ERROR("Invalid argument");
  • to-imperative/trunk/library/Class/func_q.cc

    r1591 r1778  
    1717RF_FUNC (Func_q_, (RF_ARG e_Exp;;), RF_VOID)
    1818  if (e_Exp.get_len() == 1) {
    19     Term* p = e_Exp.get_first();
    20     if (p->get_type() != type_func)
     19    if (!e_Exp.get_first()->is_instance_of<Func>())
    2120      RF_RETFAIL;
    2221  }
  • to-imperative/trunk/library/CppMangle/CppMangle.cc

    r1704 r1778  
    10061006  _c_13 = Expr (_c_11, 0, 1);
    10071007  _c_14 = Expr::create<Word>("OBJ");
    1008   _c_15 = Expr (Qualifier2Cpp);
     1008  _c_15 = Expr::create_sym<Func> (Qualifier2Cpp);
    10091009  _c_16 = Char::create_expr ("_r_");
    10101010  _c_17 = Char::create_expr ("::");
    1011   _c_18 = Expr (A_m_Char2Cpp);
     1011  _c_18 = Expr::create_sym<Func> (A_m_Char2Cpp);
    10121012  _c_19 = Char::create_expr ("?!");
    10131013  _c_20 = Char::create_expr ("b");
  • to-imperative/trunk/library/Lexer/Lexer.cc

    r1773 r1778  
    18201820  _c_3 = Char::create_expr ("\t");
    18211821  _c_4 = Char::create_expr ("\n");
    1822   _c_5 = Expr::create<ObjectRef>(Blank_q___0);
     1822  _c_5 = Expr::create_sym<Func> (Blank_q___0);
    18231823  _c_6 = Char::create_expr ("*");
    18241824  _c_7 = Char::create_expr ("/");
     
    18291829  _c_12 = Word::create_expr ("Unexpected end of file");
    18301830  _c_13 = Char::create_expr ("$");
    1831   _c_14 = Expr::create<ObjectRef>(Class::Letter_q___0);
     1831  _c_14 = Expr::create_sym<Func> (Class::Letter_q___0);
    18321832  _c_15 = Char::create_expr ("box");
    18331833  _c_16 = Word::create_expr ("BOX");
     
    18681868  _c_51 = Char::create_expr ("+");
    18691869  _c_52 = Char::create_expr ("-");
    1870   _c_53 = Expr::create<ObjectRef>(Class::Digit_q___0);
     1870  _c_53 = Expr::create_sym<Func> (Class::Digit_q___0);
    18711871  _c_54 = Word::create_expr ("NUMBER");
    18721872  _c_55 = Expr (_c_45, 1, 1);
     
    18791879  _c_62 = Word::create_expr ("TVAR");
    18801880  _c_63 = Char::create_expr (".");
    1881   _c_64 = Expr::create<ObjectRef>(Var_m_Sym_q___0);
    1882   _c_65 = Expr::create<ObjectRef>(Fun_m_Sym_q___0);
     1881  _c_64 = Expr::create_sym<Func> (Var_m_Sym_q___0);
     1882  _c_65 = Expr::create_sym<Func> (Fun_m_Sym_q___0);
    18831883  _c_66 = Word::create_expr ("WORD");
    18841884  _c_67 = Char::create_expr ("\"");
  • to-imperative/trunk/library/List/List.cc

    r1703 r1778  
    707707static void init_ ()
    708708{
    709   _c_0 = Expr (Deparen_m_Term__0);
    710   _c_1 = Expr (Paren_m_Term__0);
     709  _c_0 = Expr::create_sym<Func> (Deparen_m_Term__0);
     710  _c_1 = Expr::create_sym<Func> (Paren_m_Term__0);
    711711  _c_2 = Expr::create<Integer>("0");
    712712  _c_3 = Expr::create<Integer>("1");
  • to-imperative/trunk/library/RF_Stack/RF_Stack.cc

    r1701 r1778  
    4040  }
    4141  if (depth > stack->get_depth()) RF_RETFAIL;
    42   _v_res1 = Expr::create<ObjectRef>(stack->get_func(depth));
     42  _v_res1 = Expr::create_sym<rftype::Func>(stack->get_func(depth));
    4343RF_END
    4444
  • to-imperative/trunk/library/StdIO/StdIO.cc

    r1743 r1778  
    407407  _c_1 = Word::create_expr ("Arg 1 is not a Channel");
    408408  _c_2 = Word::create_expr ("Arg 3 is not a Word");
    409   _c_3 = Expr::create<ObjectRef>(Prim_m_Read__0);
     409  _c_3 = Expr::create_sym<Func> (Prim_m_Read__0);
    410410  _c_4 = Word::create_expr ("StdIO") + Word::create_expr ("Close-Channel");
    411411  _c_5 = Word::create_expr ("StdIO") + Word::create_expr ("EOF?");
  • to-imperative/trunk/library/Stream/Stream.cc

    r1773 r1778  
    750750  _c_1 = Word::create_expr ("Arg 1 is not a Function");
    751751  _c_2 = (empty) ();
    752   _c_3 = Expr::create<ObjectRef>(Read_m_Expr__0);
     752  _c_3 = Expr::create_sym<Func> (Read_m_Expr__0);
    753753  _c_4 = Word::create_expr ("R");
    754   _c_5 = Expr::create<ObjectRef>(Prim_m_Read__0);
     754  _c_5 = Expr::create_sym<Func> (Prim_m_Read__0);
    755755  _c_6 = Word::create_expr ("Stream") + Word::create_expr ("File-Close");
    756756  _c_7 = Word::create_expr ("Arg 1 is not a Streamed File");
  • to-imperative/trunk/runtime/Makefile

    r1772 r1778  
    1616  rf_memory_chunk \
    1717  rf_types \
     18  rf_func \
    1819  rf_char \
    1920  rf_word \
    2021  rf_short_int \
    2122  rf_integer \
    22   rf_func \
    2323  rf_object \
    2424  rf_static_object \
     
    3030
    3131RFRT_SOURCES = $(RFRT_MODULES:=.cc)
    32 RFRT_HEADERS = $(RFRT_MODULES:=.hh) rf_expr_constr.hh
    33 RFRT_IHEADERS = $(RFRT_MODULES:=.ih)
     32RFRT_IHEADERS = $(RFRT_MODULES:=.ih) rf_symbol.ih rf_closure.ih
     33RFRT_HEADERS = $(RFRT_IHEADERS:.ih=.hh) rf_expr_constr.hh rf_box.hh rf_parenth.hh
    3434RFRT_OBJECTS = $(RFRT_MODULES:=.o)
    3535
  • to-imperative/trunk/runtime/rf_char.hh

    r1763 r1778  
    2929#endif
    3030
    31   static Expr create_expr (wchar_t const* _wstr, size_t _len = -1) ;
    32  
     31  static Expr create_expr (wchar_t const* _wstr, size_t _len = (size_t)-1) ;
     32
    3333  static Expr create_expr (const WString& _wstr) ;
    3434  static Expr create_expr (const wchar_t _ch) ;
  • to-imperative/trunk/runtime/rf_common.cc

    r1772 r1778  
    3333bool use_rts = true;
    3434bool trap_stack_on = false;
     35wchar_t temp_string[temp_string_len];
    3536#if DEBUG
    3637uintptr_t empty_copy = 0;
  • to-imperative/trunk/runtime/rf_common.hh

    r1772 r1778  
    99#include "pxx_heap_allocator.hh"
    1010#include "pxx_chunk_allocator.hh"
     11
     12#include "assert.h"
    1113
    1214namespace rfrt
     
    3032extern bool use_rts ;
    3133extern bool trap_stack_on ;
     34
     35static const unsigned temp_string_len = 128;
     36extern wchar_t temp_string[];
    3237
    3338#if UINTPTR_MAX == UINT32_MAX
  • to-imperative/trunk/runtime/rf_core.cc

    r1772 r1778  
    8080
    8181pxx::HeapAllocator* allocator = null ;
     82pxx::ChunkAllocator<ExprWrapper>* expr_allocator = null ;
    8283
    8384const Expr empty ;
     
    187188
    188189RF_REGISTER_SYMBOL(Expr);
    189 //TypeRegister rftype::Parenth::reg(&Parenth::funcs, type_parenth) ;
    190190TypeRegister rftype::ObjectRef::reg(&ObjectRef::funcs, type_object) ;
    191191TypeRegister rftype::Char::reg(&Char::funcs, type_char) ;
     
    202202ObjectRegister rftype::String::reg(type_string) ;
    203203ObjectRegister rftype::Table::reg(type_table) ;
    204 ObjectRegister rftype::Func::reg(type_func) ;
    205 
     204
     205RF_REGISTER_SYMBOL(Func);
     206RF_REGISTER_SYMBOL(Closure);
    206207RF_REGISTER_SYMBOL(BoxContents);
    207208RF_REGISTER_SYMBOL_VARIANT(NamedObject<BoxContents>, BoxContents);
     
    241242    new pxx::ChunkAllocator<Integer::MpzContainer>(*allocator);
    242243#endif // !defined RFRT_WITHOUT_GMP
     244  expr_allocator = new pxx::ChunkAllocator<ExprWrapper>(*allocator);
    243245  default_allocator.set(*allocator);
    244246  double start = clock ();
     
    267269        uintptr_t n = (q++)->cast_to<Integer>()->to_int();
    268270        wchar_t const* fname;
    269         (q++)->cast_to<Func>()->get_name(&fname);
     271        (q++)->get_name(&fname);
    270272        printf("#%-2u %ls\n", n, fname);
    271273//        printf(q < e.get_last() ? ":\n" : "\n");
  • to-imperative/trunk/runtime/rf_core.hh

    r1772 r1778  
    4141#include "rf_channel.ih"
    4242#include "rf_func.ih"
     43#include "rf_closure.ih"
    4344#include "rf_table.ih"
    4445#include "rf_string.ih"
  • to-imperative/trunk/runtime/rf_expr.hh

    r1772 r1778  
    341341};
    342342
     343
     344struct ExprWrapper
     345{
     346  uintptr_t ptr;
     347  Expr      expr;
     348};
     349
     350extern pxx::ChunkAllocator<ExprWrapper>* expr_allocator;
     351
    343352///
    344353/// A class representing a splitting of expression into two parts. This class
  • to-imperative/trunk/runtime/rf_func.cc

    r1678 r1778  
    1 #include "rf_func.ih"
     1#include "rf_core.hh"
     2#include <refal/CppMangle.hh>
     3
     4namespace rftype
     5{
     6
     7namespace FuncInternals
     8{
     9
     10RF_FUNC (Codes2Rfp, (RF_ARG _v_arg1;;), (RF_RES _v_res1;;))
     11#if 0
     12  RF_CALL (refal::CppMangle::Codes2Rfp, _v_arg1, _v_res1);
     13#endif
     14  static const Expr Conv_m_Table = (Char::create_expr ("!e")) () + (Char::create_expr ("?q")) () + (Char::create_expr ("_")) () + (Char::create_expr ("-m")) () + (Char::create_expr ("+p")) () + (Char::create_expr ("<lt")) () + (Char::create_expr (">gt")) () + (Char::create_expr ("=eq")) () + (Char::create_expr ("*a")) () + (Char::create_expr ("/s")) () + (Char::create_expr (" sp")) () + (Char::create_expr ("\\bs")) () + (Char::create_expr ("|bar")) () + (Char::create_expr ("~tilde")) () + (Char::create_expr ("@at")) () + (Char::create_expr ("#num")) () + (Char::create_expr ("$dollar")) () + (Char::create_expr ("%percnt")) () + (Char::create_expr ("^circ")) () + (Char::create_expr ("&amp")) () + (Char::create_expr ("(lpar")) () + (Char::create_expr (")rpar")) () + (Char::create_expr ("[lsqb")) () + (Char::create_expr ("]rsqb")) () + (Char::create_expr ("{lcub")) () + (Char::create_expr ("}rcub")) () + (Char::create_expr ("`grave")) () + (Char::create_expr ("'apos")) () + (Char::create_expr ("\"quot")) () + (Char::create_expr (",comma")) () + (Char::create_expr (".period")) () + (Char::create_expr (":colon")) () + (Char::create_expr (";semi")) ();
     15  static const Expr _c_13 = Expr::create<Char> (L'_');
     16  static const Expr _c_32 = Expr::create<Char> (L'?');
     17  {
     18    {
     19      if ((_v_arg1.get_len () < 2))
     20      {
     21        goto _block1__branch1;
     22      }
     23      if (!_c_13.term_eq (_v_arg1, 0))
     24      {
     25        goto _block1__branch1;
     26      }
     27      Expr _v_subexpr__arg1 (_v_arg1, 1, (_v_arg1.get_len () - 1));
     28      lsplit (_v_subexpr__arg1, 0, _ve_code, _v_lsplit__arg1);
     29      for ( ; ; iter(_v_subexpr__arg1)++)
     30      {
     31        {
     32          if (!iter(_v_subexpr__arg1))
     33          {
     34            goto _block1__branch1;
     35          }
     36          uintptr_t _v_len1 = _v_lsplit__arg1.get_len ();
     37          uintptr_t _v_len2 = 1;
     38          if ((_v_len1 < _v_len2))
     39          {
     40            goto _block1__branch1;
     41          }
     42          uintptr_t _v_len__rest = (_v_len1 - _v_len2);
     43          if (!_c_13.term_eq (_v_lsplit__arg1, 0))
     44          {
     45            goto _continue1;
     46          }
     47          Expr _ve_rest (_v_lsplit__arg1, 1, _v_len__rest);
     48          lsplit (Conv_m_Table, 0, _ve__e__e_tmp_m_CppManglerf_m_131_m_20, _v_lsplit__Conv_m_Table);
     49          (void)_ve__e__e_tmp_m_CppManglerf_m_131_m_20;
     50          for ( ; ; iter(Conv_m_Table)++)
     51          {
     52            {
     53              if (!iter(Conv_m_Table))
     54              {
     55                RF_RETFAIL;
     56              }
     57              uintptr_t _v_len3 = _v_lsplit__Conv_m_Table.get_len ();
     58              uintptr_t _v_len4 = 1;
     59              if ((_v_len3 < _v_len4))
     60              {
     61                RF_RETFAIL;
     62              }
     63              uintptr_t _v_len___e__e_tmp_m_CppManglerf_m_131_m_38 = (_v_len3 - _v_len4);
     64              if (_v_lsplit__Conv_m_Table.symbol_at (0))
     65              {
     66                goto _continue2;
     67              }
     68              Expr _v_deref__lsplit__Conv_m_Table (_v_lsplit__Conv_m_Table, 0);
     69              if ((_v_deref__lsplit__Conv_m_Table.get_len () != (_ve_code.get_len () + 1)))
     70              {
     71                goto _continue2;
     72              }
     73              if (!_v_deref__lsplit__Conv_m_Table.symbol_at (0))
     74              {
     75                goto _continue2;
     76              }
     77              if (!_ve_code.eq (_v_deref__lsplit__Conv_m_Table, 1))
     78              {
     79                goto _continue2;
     80              }
     81              Expr _ve__e__e_tmp_m_CppManglerf_m_131_m_38 (_v_lsplit__Conv_m_Table, 1, _v_len___e__e_tmp_m_CppManglerf_m_131_m_38);
     82              Expr _vs_char (_v_deref__lsplit__Conv_m_Table, 0, 1);
     83              Expr _v_Codes2Rfp1;
     84              if (!RF_CALL (Codes2Rfp, _ve_rest, _v_Codes2Rfp1))
     85              {
     86                RF_RETFAIL;
     87              }
     88              _v_res1 = (_vs_char + _v_Codes2Rfp1);
     89              goto _exit2;
     90            }
     91        _continue2: {}
     92          }
     93        _exit2: {}
     94          goto _exit1;
     95        }
     96    _continue1: {}
     97      }
     98    _exit1: {}
     99      goto _block1;
     100    }
     101  _block1__branch1: {}
     102    {
     103      uintptr_t _v_len5 = _v_arg1.get_len ();
     104      uintptr_t _v_len6 = 1;
     105      if ((_v_len5 < _v_len6))
     106      {
     107        goto _block1__branch2;
     108      }
     109      uintptr_t _v_len__rest2 = (_v_len5 - _v_len6);
     110      if (!_v_arg1.symbol_at (0))
     111      {
     112        goto _block1__branch2;
     113      }
     114      Expr _vs_char (_v_arg1, 0, 1);
     115      Expr _ve_rest (_v_arg1, 1, _v_len__rest2);
     116      {
     117        if (_vs_char.get_first()->cast_to<Char>()->is_digit())
     118        {
     119          goto _block2;
     120        }
     121        if (!_vs_char.get_first()->cast_to<Char>()->is_letter())
     122        {
     123          RF_RETFAIL;
     124        }
     125        {
     126          if (!_vs_char.term_eq (_c_32, 0))
     127          {
     128            goto _negation1;
     129          }
     130          RF_RETFAIL;
     131        }
     132      _negation1: {}
     133      }
     134    _block2: {}
     135      Expr _v_Codes2Rfp2;
     136      if (!RF_CALL (Codes2Rfp, _ve_rest, _v_Codes2Rfp2))
     137      {
     138        RF_RETFAIL;
     139      }
     140      _v_res1 = (_vs_char + _v_Codes2Rfp2);
     141      goto _block1;
     142    }
     143  _block1__branch2: {}
     144    if ((_v_arg1.get_len () != 0))
     145    {
     146      RF_ERROR (Expr::create<Word>("FuncInternals") + Expr::create<Word>("Codes2Rfp") + unexpected_fail);
     147    }
     148    _v_res1 = empty;
     149  }
     150_block1: {}
     151RF_END
     152
     153}
     154
     155}
     156
  • to-imperative/trunk/runtime/rf_func.hh

    r1678 r1778  
    44#define __rf_func_hh__
    55
    6 #include "rf_types.hh"
    7 #include "rf_object.hh"
    8 #include "rf_retval.hh"
     6#include "rf_symbol.hh"
     7
     8namespace rfrt
     9{
     10  class RetVal ;
     11  typedef RetVal (*rf_func_t)() ;
     12}
    913
    1014namespace rftype
    1115{
    1216
    13 using namespace rfrt ;
     17using namespace rfrt;
    1418
    15 class Func :
    16   public Object
     19class Func
    1720{
    1821
    19   typedef RetVal (*rf_func_t)() ;
     22  rf_func_t func;
    2023
    21   rf_func_t func ;
     24  wchar_t* name;
     25  size_t   length;
    2226
    23 //  NO_COPY_CTOR(Func)
    24   NO_ASSIGN(Func)
     27  inline void name_to_rfp () ;
    2528
    2629public:
    2730
    28   static ObjectRegister reg ;
    29 
    30   inline Func (rf_func_t _func) ;
    31   inline Func (Func const& _func) ;
    32 //  inline Func& Func::operator = (Func const& _func) ;
    33  
    34   inline unsigned get_type () const ;
    35 
    36   inline pxx::WString to_string () const ;
     31  inline Func (rf_func_t _func, wchar_t* _name) ;
    3732
    3833  inline RetVal operator () () const ;
     34
     35  inline size_t get_name (wchar_t const** _name) ;
     36  inline pxx::WString to_string () ;
    3937
    4038};
  • to-imperative/trunk/runtime/rf_func.ih

    r1744 r1778  
    55
    66#include "rf_func.hh"
    7 #include "rf_object.ih"
    8 #include "rf_static_object.hh"
    9 #include <refal/CppMangle.hh>
     7#include "rf_retval.ih"
     8#include "rf_symbol.ih"
     9#include "rf_char.ih"
    1010
    1111namespace rftype
     
    1414using namespace rfrt ;
    1515
    16 inline Func::Func (rf_func_t _func) :
    17   func (_func)
     16namespace FuncInternals { RF_DECL (Codes2Rfp); }
     17
     18inline Func::Func (rf_func_t _func, wchar_t* _name) :
     19  func (_func),
     20  name (_name),
     21  length (0)
    1822{}
    19 
    20 inline Func::Func (Func const& _func) :
    21   Object(),
    22   func (_func.func)
    23 {}
    24 
    25 #if 0
    26 inline Func& Func::operator = (Func const& _func)
    27 {
    28   if (this != &_func)
    29   {
    30     func = _func.func;
    31   }
    32   return self;
    33 }
    34 #endif
    35 
    36 inline unsigned Func::get_type () const
    37 {
    38   return reg.get_type();
    39 }
    40 
    41 inline pxx::WString Func::to_string () const
    42 {
    43   wchar_t buf[32];
    44   int n = swprintf(buf, sizeof(buf), L"[*%p]", func);
    45   if (n == -1) return pxx::WString(L"[<unknown func>]");
    46   return pxx::WString(buf, n);
    47 }
    4823
    4924inline RetVal Func::operator () () const
     
    5227}
    5328
    54 
    55 template <>
    56 inline StaticObject<Func>::StaticObject (
    57     Func const& _obj, wchar_t const* _name, size_t _length
    58 ) :
    59   Func   (_obj),
    60   name   (_name),
    61   length (_length)
    62 {}
    63 
    64 template <>
    65 inline StaticObject<Func>::~StaticObject ()
     29inline void Func::name_to_rfp ()
    6630{
    67 //  if (name[0]) free(const_cast<wchar_t*>(name));
    68   FATAL("Static functions are never destructed");
     31  if (length) return;
     32//  Expr e = Expr::create<Word>(name);
     33//  RF_CALL(refal::CppMangle::Cpp2Rfp, e, e);
     34  Expr e = Expr::create_seq<Char>(name, wcslen(name));
     35  RF_CALL(FuncInternals::Codes2Rfp, e, e);
     36  pxx::WString str = e;
     37  length = str.get_length() + 1;
     38  name = static_cast<wchar_t*>(malloc((length + 1) * sizeof(wchar_t)));
     39  if (!name) FATAL("Out of memory");
     40  wmemcpy(name + 1, str.get_data(), length);
     41  name[0] = L'&';
    6942}
    7043
    71 template <>
    72 inline void* StaticObject<Func>::operator new (size_t _size)
     44inline size_t Func::get_name (wchar_t const** _name)
    7345{
    74   void* p = malloc(_size);
    75   if (!p) FATAL("Out of memory");
    76   return p;
     46  name_to_rfp();
     47  *_name = name + 1;
     48  return length - 1;
    7749}
    7850
    79 //template <>
    80 //inline void StaticObject<Func>::operator delete (void*)
    81 //{
    82 //  FATAL("Static functions are never deleted");
    83 //}
    84 
    85 inline static size_t name_to_rfp (
    86     wchar_t const* _name, size_t _len, wchar_t** _dest
    87 )
     51inline pxx::WString Func::to_string ()
    8852{
    89   Expr e = Expr::create<Word>(_name, _len);
    90   RF_CALL(refal::CppMangle::Cpp2Rfp, e, e);
    91   pxx::WString pstr = e;
    92   size_t length = pstr.get_length() + 1;
    93   *_dest = static_cast<wchar_t*>(malloc((length + 1) * sizeof(wchar_t)));
    94   if (!*_dest) FATAL("Out of memory");
    95   wmemcpy((*_dest) + 1, pstr.get_data(), length);
    96   **_dest = L'&';
    97   return length;
    98 }
    99 
    100 template <>
    101 inline pxx::WString StaticObject<Func>::to_string () const
    102 {
    103   if (!name[0]) {
    104     *const_cast<size_t*>(&length) =
    105       name_to_rfp(name + 1, length - 1, const_cast<wchar_t**>(&name));
    106   }
     53  name_to_rfp();
    10754  return pxx::WString(name, length, pxx::const_data);
    10855}
    10956
    110 template <>
    111 inline size_t StaticObject<Func>::get_name (wchar_t const** _name) const
     57
     58RF_NEW_SYMBOL(Func, StaticTerm);
     59
     60inline size_t RF_SYMBOL(Func)::get_name (
     61    RF_SYMBOL(Func) const* _s, wchar_t const** _name
     62)
    11263{
    113   if (!name[0]) {
    114     *const_cast<size_t*>(&length) =
    115       name_to_rfp(name + 1, length - 1, const_cast<wchar_t**>(&name));
    116   }
    117   *_name = name + 1;
    118   return length;
     64  return _s->get_obj_ptr()->get_name(_name);
     65}
     66
     67inline pxx::WString RF_SYMBOL(Func)::to_string (RF_SYMBOL(Func) const* _s)
     68{
     69  return _s->get_obj_ptr()->to_string();
    11970}
    12071
  • to-imperative/trunk/runtime/rf_macros.cc

    r1772 r1778  
     1#include "rf_expr.ih"
    12#include "rf_macros.hh"
    23
     
    67Expr* __rf_call_saved_top;
    78
     9rftype::Closure* __rf_closure_to_call;
     10
    811}
  • to-imperative/trunk/runtime/rf_macros.hh

    r1772 r1778  
    44#define __rf_macros_hh__
    55
    6 #include "rf_func.hh"
     6#include "rf_closure.hh"
     7#include "rf_retval.hh"
    78
    89namespace rfrt
     
    1011
    1112extern Expr* __rf_call_saved_top;
     13
     14extern rftype::Closure* __rf_closure_to_call;
    1215
    1316#ifndef RFRT_STINGY_STACK
     
    154157
    155158
     159#define RF_APPLY(f,args,ress) \
     160  rfrt::__rf_closure_to_call = f; \
     161  RF_CALL(f->get_func(), args, ress);
     162
     163#define RF_TAILAPPLY(f,args,ress) \
     164  rfrt::__rf_closure_to_call = f; \
     165  RF_TAILCALL(f->get_func(), args, ress);
     166
     167
     168#define RF_FUNC(f,args,ress) \
     169  namespace rffunc { RetVal f##_func_ (void); } \
     170  rftype::Func* f = new rftype::Func(rffunc::f##_func_, WSTRPREFIX#f); \
     171  RetVal rffunc::f##_func_ (void) { \
     172    RF_start_args; \
     173    for args { \
     174      RF_start_ress; \
     175      for ress { \
     176        RF_stop_ress(f);
     177
     178#define RF_END \
     179        return true; \
     180      } \
     181    } \
     182  }
     183
     184#define RF_CLOSURE(f,params,args,ress) \
     185  RF_FUNC(f, args, ress) \
     186  for params { \
     187    rfrt::__rf_closure_to_call->pop_arg();
     188
     189#define RF_END_CLOSURE \
     190    RF_END \
     191  }
     192
     193#if 0
    156194#define RF_FUNC(f,args,ress) \
    157195  namespace rffunc { \
     
    174212    } \
    175213  }
     214#endif
    176215
    177216#if 0
     
    180219#endif
    181220#define RF_DECL(f) \
    182   extern rftype::StaticObject<rftype::Func>* f;
     221  extern rftype::Func* f;
    183222
    184223#define RF_ARG rfrt::Arg
     
    251290      wchar_t const* fname; \
    252291      size_t len = stack->get_func(stack->get_depth())->get_name(&fname); \
    253       throw Expr::create<Word>(fname, len - 1) + msg; \
     292      throw Expr::create<Word>(fname, len) + msg; \
    254293    } while (0)
    255294#else
  • to-imperative/trunk/runtime/rf_retval.hh

    r1772 r1778  
    2525
    2626#include "rf_expr.hh"
    27 
    28 namespace rftype {
    29   class Func;
    30 }
     27#include "rf_func.hh"
    3128
    3229namespace rfrt
     
    3431
    3532class RetVal ;
    36 //typedef RetVal (*rf_func_t)() ;
     33typedef RetVal (*rf_func_t)() ;
    3734
    3835class RetVal
  • to-imperative/trunk/runtime/rf_stack.hh

    r1772 r1778  
    2424
    2525#include "rf_expr.hh"
     26#include "rf_func.hh"
    2627#include "pxx_heap.ih"
    2728
     
    8990  inline void start_ress_mode () ;
    9091
    91   inline void stop_ress_mode (rftype::Object const* _f) ;
     92  inline void stop_ress_mode (rftype::Func const* _f) ;
    9293
    9394  inline void start_pop_mode () ;
     
    109110  inline size_t get_depth () const ;
    110111
    111   inline rftype::Object* get_func (size_t _depth) const ;
     112  inline rftype::Func* get_func (size_t _depth) const ;
    112113
    113114  inline int get_args (size_t _depth, Expr** _args) const ;
    114115
    115   inline static rftype::Object* getf (Expr const* _p) ;
     116  inline static rftype::Func* getf (Expr const* _p) ;
    116117
    117118  inline static int getn (Expr const* _p) ;
  • to-imperative/trunk/runtime/rf_stack.ih

    r1772 r1778  
    55#include "rf_expr.ih"
    66#include "rf_integer.ih"
     7#include "rf_func.ih"
    78
    89namespace rfrt
     
    8485}
    8586
    86 inline void Stack::stop_ress_mode (rftype::Object const* _f)
     87inline void Stack::stop_ress_mode (rftype::Func const* _f)
    8788{
    8889  if (top > last) FATAL("Stack exhausted");
     
    152153}
    153154
    154 inline rftype::Object* Stack::get_func (size_t _depth) const
     155inline rftype::Func* Stack::get_func (size_t _depth) const
    155156{
    156157  uintptr_t* p = reinterpret_cast<uintptr_t*>(get_upper(depth - _depth) - 1);
    157   return reinterpret_cast<rftype::Object*>(*(p + 2));
     158  return reinterpret_cast<rftype::Func*>(*(p + 2));
    158159}
    159160
     
    165166}
    166167
    167 inline rftype::Object* Stack::getf (Expr const* _p)
    168 {
    169   return reinterpret_cast<rftype::Object*>(
     168inline rftype::Func* Stack::getf (Expr const* _p)
     169{
     170  return reinterpret_cast<rftype::Func*>(
    170171      *(reinterpret_cast<uintptr_t const*>(_p) + 2));
    171172}
     
    195196  while (_len--)
    196197  {
    197     Expr s_f(getf(p));
    198198    int  n   = getn(p);
    199199    Expr const* ap = geta(p);
    200200    Expr e_args;
    201201    while (n--) e_args = e_args + (*ap++)();
    202     e = e + (Expr::create<Integer>(depth--) + s_f + e_args)();
     202    e = e + (Expr::create<Integer>(depth--) +
     203             Expr::create_sym<Func>(getf(p)) + e_args)();
    203204    p = getup(p);
    204205  }
  • to-imperative/trunk/runtime/rf_symbol.hh

    r1772 r1778  
    5252
    5353template<class C>
     54class Symbol<C, StaticTerm> :
     55  public Term
     56{
     57
     58  NO_COPY_CTOR(Symbol)
     59  NO_ASSIGN(Symbol)
     60
     61public:
     62
     63  inline Symbol (C* _p) ;
     64
     65  inline C* get_obj_ptr () const ;
     66
     67  static void ctor (Symbol* _to, Symbol const* _from) ;
     68  static void dtor (Symbol* _term) ;
     69  static bool eq (Symbol const* _term1, Symbol const* _term2) ;
     70  static int compare (Symbol const* _term1, Symbol const* _term2) ;
     71  static uint32_t hash (Symbol const* _term) ;
     72  static pxx::WString to_string (Symbol const* _term) ;
     73  static size_t get_name (Symbol const* _s, wchar_t const** _np) ;
     74
     75  static short_type_funcs_t funcs ;
     76
     77  static const TypeRegister reg ;
     78
     79  static inline unsigned get_type() ;
     80
     81};
     82
     83template<class C>
    5484class Symbol<C, ObjectTerm> :
    5585  public Term
     
    83113  static uint32_t hash (Symbol const* _term) ;
    84114  static pxx::WString to_string (Symbol const* _term) ;
     115  static size_t get_name (Symbol const* _s, wchar_t const** _np) ;
    85116
    86117  static short_type_funcs_t funcs ;
  • to-imperative/trunk/runtime/rf_symbol.ih

    r1772 r1778  
    2929}
    3030*/
     31
     32
     33template <class C>
     34inline Symbol<C, StaticTerm>::Symbol (C* _p) :
     35  Term (get_type(), _p)
     36{}
     37
     38template <class C>
     39inline C* Symbol<C, StaticTerm>::get_obj_ptr () const
     40{
     41  return static_cast<C*>(ptr_data2);
     42}
     43
     44template <class C>
     45void Symbol<C, StaticTerm>::ctor (
     46    Symbol<C, StaticTerm>* _to, Symbol<C, StaticTerm> const* _from
     47)
     48{
     49  _to->data1 = _from->data1;
     50  _to->ptr_data2 = _from->ptr_data2;
     51}
     52
     53template <class C>
     54void Symbol<C, StaticTerm>::dtor (Symbol<C, StaticTerm>*)
     55{}
     56
     57template <class C>
     58bool Symbol<C, StaticTerm>::eq (
     59    Symbol<C, StaticTerm> const* _s1, Symbol<C, StaticTerm> const* _s2
     60)
     61{
     62  return _s1->get_obj_ptr() == _s2->get_obj_ptr();
     63}
     64
     65template <class C>
     66int Symbol<C, StaticTerm>::compare (
     67    Symbol<C, StaticTerm> const* _s1, Symbol<C, StaticTerm> const* _s2
     68)
     69{
     70  if (_s1->get_obj_ptr() > _s2->get_obj_ptr()) return 1;
     71  if (_s1->get_obj_ptr() < _s2->get_obj_ptr()) return -1;
     72  return 0;
     73}
     74
     75template <class C>
     76pxx::WString Symbol<C, StaticTerm>::to_string (
     77    Symbol<C, StaticTerm> const* _s
     78)
     79{
     80  size_t max_len = hex_ptr_len + max_int_len + 4;
     81  wchar_t* str = static_cast<wchar_t*>(alloca(max_len * sizeof(wchar_t)));
     82  C* ptr = _s->get_obj_ptr();
     83  int len = swprintf(str, max_len, L"<%u|%p>", get_type(), ptr);
     84  if (-1 == len)
     85    FATAL("<%u|%p> is more then %u wide characters", get_type(), ptr, max_len);
     86  return pxx::WString(str, len);
     87}
     88
     89template <class C>
     90size_t Symbol<C, StaticTerm>::get_name (
     91    Symbol<C, StaticTerm> const* _s, wchar_t const** _np
     92)
     93{
     94  return (size_t)-1;
     95}
     96
     97template <class C>
     98short_type_funcs_t Symbol<C, StaticTerm>::funcs = {
     99  0,
     100  (void (*)(Term*, Term const*))   (Symbol<C, StaticTerm>::ctor),
     101  (void (*)(Term*))                (Symbol<C, StaticTerm>::dtor),
     102  (bool (*)(Term const*, Term const*))   (Symbol<C, StaticTerm>::eq),
     103  (int  (*)(Term const*, Term const*))   (Symbol<C, StaticTerm>::compare),
     104  null, // (uint32_t (*)(Term const*))            (Symbol<C, StaticTerm>::hash),
     105  (pxx::WString (*)(Term const*))  (Symbol<C, StaticTerm>::to_string),
     106  (size_t (*)(Term const*, wchar_t const**)) (Symbol<C, StaticTerm>::get_name)
     107};
     108
     109template <class C>
     110inline unsigned Symbol<C, StaticTerm>::get_type ()
     111{
     112  return reg.get_type();
     113}
    31114
    32115
  • to-imperative/trunk/runtime/rf_term.hh

    r1772 r1778  
    8888  /// Constructor for empty term with given class and type
    8989  inline Term (unsigned _type) ;
     90  ///
     91  /// Constructor for pointer term of given type (to use for static terms)
     92  inline Term (unsigned _type, void* _ptr) ;
    9093  ///
    9194  /// Create expression with specified length
  • to-imperative/trunk/runtime/rf_term.ih

    r1772 r1778  
    2424using namespace rftype ;
    2525
    26 inline Term::Term (unsigned _type)
    27 {
    28   set_type(_type);
    29 }
    30 
    31 #if 0
    32 inline Term::Term (uint16_t _c) :
    33   uint_data2 (_c)
    34 {
    35   set_type(type_char);
    36 }
    37 #endif
     26inline Term::Term (unsigned _type) :
     27  data1 (_type)
     28{
     29//  set_type(_type);
     30}
     31
     32inline Term::Term (unsigned _type, void* _ptr) :
     33  data1 (_type),
     34  ptr_data2 (_ptr)
     35{}
    3836
    3937inline Term::~Term ()
  • to-imperative/trunk/runtime/rf_types.hh

    r1772 r1778  
    9090} term_class_t ;
    9191
     92struct StaticTerm ;
    9293struct FlatTerm ;
    9394struct ShortTerm ;
  • to-imperative/trunk/samples/Apply/Makefile

    r1602 r1778  
    66  apply \
    77  apply2 \
    8   apply3
     8  apply3 \
     9  apply_inv1
    910
    1011include $(TOPDIR)/samples/samples.mk
Note: See TracChangeset for help on using the changeset viewer.