rev 667 - in trunk: . include/prothon modules/Re src
SVN User <[email protected]> Sun, 27 Jun 2004 03:50:41 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-06-27 03:50:38 -0400 (Sun, 27 Jun 2004)
New Revision: 667
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/modules/Re/Re.c
trunk/src/builtins-core.c
trunk/src/interp.c
trunk/src/parser_routines.c
trunk/src/symbol.c
Log:
made symbol objects immutable, formal params now have Star_ and StarStar_ objects in default value position
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/STATUS.txt 2004-06-27 07:50:38 UTC (rev 667)
@@ -100,8 +100,6 @@
--- Does simple 1+2 expr evaluation create objects? If so, need shortcuts to speed it up
---- move OBJ(PARAM_STAR) and OBJ(PARAM_STAR_STAR) to right side of pair
-
--- clean up prt_code_line mess with some cleaner coding technique
--- reduce array of act params passed to function to only odd entries
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/include/prothon/prothon.h 2004-06-27 07:50:38 UTC (rev 667)
@@ -1091,10 +1091,10 @@
// FORM_STARn_PARAM: convenience macros for variable number of formal right parameters
// equivalent to func(*args), func(**kwargs), and func(*args, **kwargs)
-#define FORM_STAR_PARAM (list2(ist, OBJ(PARAM_STAR), SYM(ARGS)))
-#define FORM_STAR2_PARAM (list2(ist, OBJ(PARAM_STAR_STAR), SYM(KWARGS)))
-#define FORM_STAR3_PARAM (list4(ist, OBJ(PARAM_STAR), SYM(ARGS), \
- OBJ(PARAM_STAR_STAR), SYM(KWARGS) ))
+#define FORM_STAR_PARAM (list2(ist, SYM(ARGS), OBJ(PARAM_STAR) ))
+#define FORM_STAR2_PARAM (list2(ist, SYM(KWARGS), OBJ(PARAM_STAR_STAR) ))
+#define FORM_STAR3_PARAM (list4(ist, SYM(ARGS), OBJ(PARAM_STAR), \
+ SYM(KWARGS), OBJ(PARAM_STAR_STAR) ))
// CALL_FUNC: Call a function, either Prothon or C based
// This C function provides a way to call any Prothon or C function from C.
Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/modules/Re/Re.c 2004-06-27 07:50:38 UTC (rev 667)
@@ -576,8 +576,8 @@
return res;
}
-DEF( reMatch, group, list4(ist, sym(ist, "groupid"), OBJ(ZERO_INT),
- OBJ(PARAM_STAR), sym(ist, "groupids") ) ) {
+DEF( reMatch, group, list4( ist, sym(ist, "groupid"), OBJ(ZERO_INT),
+ sym(ist, "groupids"), OBJ(PARAM_STAR) ) ) {
int i, j, llen, ngrps = ((int)list_len(ist, self))/2, sp, ep;
char* orig_s;
obj_p orig_s_obj, res;
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/src/builtins-core.c 2004-06-27 07:50:38 UTC (rev 667)
@@ -387,10 +387,19 @@
obj_p arg_dict = parms[3];
int i, llen = (int) list_len(ist, arg_list);
char *sep, *eol, *str;
- obj_p sep_obj = dict_item(ist, arg_dict, sym(ist, "sep"));
- obj_p eol_obj = dict_item(ist, arg_dict, sym(ist, "eol"));
- if (sep_obj) sep = pr2c_strptr(ist, sep_obj); else sep = " ";
- if (eol_obj) eol = pr2c_strptr(ist, eol_obj); else eol = "\n";
+ obj_p sep_obj, eol_obj;
+ sep_obj = dict_item(ist, arg_dict, sym(ist, "sep")); if_exc_return NULL;
+ if (sep_obj) {
+ CHECK_TYPE_EXC(sep_obj, OBJ(STRING_PROTO), String);
+ sep = pr2c_strptr(ist, sep_obj);
+ } else
+ sep = " ";
+ eol_obj = dict_item(ist, arg_dict, sym(ist, "eol")); if_exc_return NULL;
+ if (eol_obj) {
+ CHECK_TYPE_EXC(eol_obj, OBJ(STRING_PROTO), String);
+ eol = pr2c_strptr(ist, eol_obj);
+ } else
+ eol = "\n";
str = pr_malloc(strlen(eol)+1);
str[0] = 0;
for (i=0; i < llen; i++) {
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/src/interp.c 2004-06-27 07:50:38 UTC (rev 667)
@@ -380,14 +380,14 @@
value = list_item(ist, form_params, i+1);
if (pstate == 3) goto fparmerr;
if (pstate && value == OBJ(NODEF)) goto fparmerr;
- if (label == OBJ(PARAM_STAR)) {
+ if (value == OBJ(PARAM_STAR)) {
if (pstate == 2) goto fparmerr;
pstate = 2;
- fparam_proc_state->free_pos_list_key = value;
+ fparam_proc_state->free_pos_list_key = label;
fparam_proc_state->free_pos_list_obj = NEW_LIST(10);
- } else if (label == OBJ(PARAM_STAR_STAR)) {
+ } else if (value == OBJ(PARAM_STAR_STAR)) {
pstate = 3;
- fparam_proc_state->free_label_list_key = value;
+ fparam_proc_state->free_label_list_key = label;
fparam_proc_state->free_label_list_obj = NEW_DICT(10);
} else {
if (value != OBJ(NODEF)) pstate = 1;
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/src/parser_routines.c 2004-06-27 07:50:38 UTC (rev 667)
@@ -642,15 +642,15 @@
code_p star_ref_to_formparm(void* param, obj_p label){
code_p res = new_code(param, 3, 2, 2, OP_PUSH);
res->code_data[0].bytecode.param = 3;
- res->code_data[1].data = OBJ(PARAM_STAR);
- res->code_data[2].data = sym(IST, pr2c_strptr(IST, label));
+ res->code_data[1].data = sym(IST, pr2c_strptr(IST, label));
+ res->code_data[2].data = OBJ(PARAM_STAR);
return debug_retrn(__LINE__, res);
}
code_p star_star_ref_to_formparm(void* param, obj_p label){
code_p res = new_code(param, 3, 2, 2, OP_PUSH);
res->code_data[0].bytecode.param = 3;
- res->code_data[1].data = OBJ(PARAM_STAR_STAR);
- res->code_data[2].data = sym(IST, pr2c_strptr(IST, label));
+ res->code_data[1].data = sym(IST, pr2c_strptr(IST, label));
+ res->code_data[2].data = OBJ(PARAM_STAR_STAR);
return debug_retrn(__LINE__, res);
}
code_p expr_to_sparm(void* param, code_p p1){
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c 2004-06-27 06:59:47 UTC (rev 666)
+++ trunk/src/symbol.c 2004-06-27 07:50:38 UTC (rev 667)
@@ -272,6 +272,7 @@
dict_add(ist, OBJ(SYMBOLS), NEW_INT(sym->data.key), sym);
un_su(i);
pr_free(s);
+ set_immutable(sym);
return sym;
}