|
|
Choosing A Webhost: |
rev 225 - in trunk: . modules/Tuple src: msg#00093lang.prothon.cvs
Author: mark Date: 2004-03-31 02:44:50 -0500 (Wed, 31 Mar 2004) New Revision: 225 Modified: trunk/STATUS.txt trunk/modules/Tuple/Tuple.c trunk/src/builtins.c trunk/src/parser_routines.c Log: added cmp of lists and tuples Modified: trunk/STATUS.txt =================================================================== --- trunk/STATUS.txt 2004-03-31 06:14:45 UTC (rev 224) +++ trunk/STATUS.txt 2004-03-31 07:44:50 UTC (rev 225) @@ -31,14 +31,18 @@ add/replace int and float single decimal type with bounded precision and floating point. http://www.python.org/peps/pep-0327.html -Full unicode support like Java +Full unicode support like Java -- store compressed ucs4 ? Syntax extension modifier -- language spec? make := work like = but usable as an expr +sets and other zephyr email items -- use <> ? + ----------------------- TO-DO (highest priority first) ------------------------ +--- smarter continuation - remove \ + --- make print a function --- write and publish prothon directives @@ -50,7 +54,7 @@ --- memory bounds -> mem-mgr priorities --- -i interactive console needs globals and locals from main1 module ---- flesh out dlls, list.sort!(), dict stuff, string %, built-in funcs +--- flesh out dlls, list.sort!(), dict stuff, string % --- higher level pseudo classes, bases, meta-class replacements etc. (oops.pr) @@ -76,7 +80,6 @@ --- thread monitor function ---- convert all to apr_snprintf() ------------------------------ bugs ------------------------------------------- parser Modified: trunk/modules/Tuple/Tuple.c =================================================================== --- trunk/modules/Tuple/Tuple.c 2004-03-31 06:14:45 UTC (rev 224) +++ trunk/modules/Tuple/Tuple.c 2004-03-31 07:44:50 UTC (rev 225) @@ -61,11 +61,54 @@ MODULE_DECLARE(Tgen); MODULE_DECLARE(Tuple); +//******************************** TUPLE OBJECT ******************************* MODULE_START(Tuple) { Tuple_OBJ = OBJ(TUPLE_PROTO); } +DEF(Tuple, cmp, FORM_RPARAM) { + int i, llen, tlen, mlen; + obj_p res; + obj_p self_item, tgt_item, tgt_list; + if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO))) { + raise_exception(ist, OBJ(TYPE_EXC), "sequence can only be compared to a sequence"); + return NULL; + } + llen = list_len(ist, self); + tgt_list = parms[1]; + tlen = list_len(ist, tgt_list); + mlen = min(llen, tlen); + for(i=0; i < mlen; i++) { + self_item = list_item(ist, self, i); + tgt_item = list_item(ist, tgt_list, i); + res = call_func1(ist, self_item, SYM(CMP), tgt_item); if_exc_return NULL; + if (res->data.i64) + return new_int_obj(res->data.i64); + } + if (llen < tlen) return new_int_obj(-1); + if (llen > tlen) return new_int_obj(+1); + return OBJ(ZERO_INT); +} + +DEF(Tuple, __eq__QUES, FORM_RPARAM) { + int i, llen, tlen; + obj_p self_item, tgt_item, tgt_list, false_obj = OBJ(PR_FALSE); + if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO))) return false_obj; + llen = list_len(ist, self); + tgt_list = parms[1]; + tlen = list_len(ist, tgt_list); + if (llen != tlen) return false_obj; + for(i=0; i < llen; i++) { + self_item = list_item(ist, self, i); + tgt_item = list_item(ist, tgt_list, i); + if (call_func1(ist, self_item, SYM(__EQ__QUES), tgt_item) == false_obj) + return false_obj; + else if_exc_return NULL; + } + return OBJ(PR_TRUE); +} + DEF(Tuple, __rin__QUES, FORM_RPARAM) { int i, llen = list_len(ist, self); obj_p item, tgt = parms[1]; @@ -197,6 +240,7 @@ MODULE_END(Tuple); +//*************************** TUPLE GENERATOR OBJECT ************************** MODULE_START(Tgen) { Tgen_OBJ = new_object(NULL); @@ -217,6 +261,7 @@ MODULE_END(Tgen); +//********************************* INITIALIZATION **************************** MAIN_MODULE_INIT(Tuple) { MODULE_SUB_INIT(Tuple); Modified: trunk/src/builtins.c =================================================================== --- trunk/src/builtins.c 2004-03-31 06:14:45 UTC (rev 224) +++ trunk/src/builtins.c 2004-03-31 07:44:50 UTC (rev 225) @@ -1290,7 +1290,7 @@ OBJ(MODULES) = new_object(NULL); OBJ(PR_FALSE) = new_object(NULL); OBJ(PR_TRUE) = new_object(NULL); - OBJ(NONE) = new_object(NULL); + OBJ(NONE) = new_object(NULL); OBJ(EXCEPTION) = new_object(NULL); OBJ(GEN_PROTO) = new_object(NULL); OBJ(INT_PROTO) = new_object(NULL); Modified: trunk/src/parser_routines.c =================================================================== --- trunk/src/parser_routines.c 2004-03-31 06:14:45 UTC (rev 224) +++ trunk/src/parser_routines.c 2004-03-31 07:44:50 UTC (rev 225) @@ -974,7 +974,7 @@ return debug_retrn(__LINE__, res); } code* new_tuple_list(void* param, clist_p lst, int tuple_flag){ - int i, k=0, len=1, stack_depth=1, max_stack_depth=0; + int i, k=0, len=1, stack_depth=1, max_stack_depth=1; code* res; for(i=0; i < clist_len(lst); i++) calc_code((code*)clist_item(lst,i), &len, &stack_depth, &max_stack_depth);
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | rev 224 - in trunk: . bison include/prothon modules/File modules/Float modules/List modules/Re modules/String modules/Tuple pr src, SVN User |
|---|---|
| Next by Date: | rev 226 - trunk/src, SVN User |
| Previous by Thread: | rev 224 - in trunk: . bison include/prothon modules/File modules/Float modules/List modules/Re modules/String modules/Tuple pr src, SVN User |
| Next by Thread: | rev 226 - trunk/src, SVN User |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |