rev 269 - in trunk: pr src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-03 20:37:11 -0500 (Sat, 03 Apr 2004)
New Revision: 269
Modified:
trunk/pr/test.pr
trunk/src/interp.c
trunk/src/interp.h
Log:
fixed bug in calling __init__ with params
Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr 2004-04-04 00:14:48 UTC (rev 268)
+++ trunk/pr/test.pr 2004-04-04 01:37:11 UTC (rev 269)
@@ -1,15 +1,9 @@
#!/usr/local/bin/prothon
-def outer():
- print 'outer',
- 'outer2'
- def x():
- print 2, (5+
-12)
- return x
-
-def block2():
- print 'block2'
-
-outer()()
-block2()
+p = Object()
+with p:
+ def .__init__(x=1):
+ print x
+
+y=p()
+y=p(2)
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-04-04 00:14:48 UTC (rev 268)
+++ trunk/src/interp.c 2004-04-04 01:37:11 UTC (rev 269)
@@ -62,6 +62,7 @@
#include <apr_thread_proc.h>
#include <apr_strings.h>
#include <apr_dso.h>
+#include <string.h>
#define STACK_PADDING 4
@@ -738,7 +739,7 @@
apr_snprintf(dump_name, sizeof(dump_name),
"%s_def_dump.txt",
symch(ist, fr_stack[fr_sp+1]));
- dump_code(func->data.ptr, dump_name);
+ dump_code(ist, func, func->data.ptr, dump_name);
}
#endif
if (op == OP_GEN) {
@@ -982,6 +983,7 @@
fr_stack[fr_sp+1], NULL, FALSE);
if (intrp_exobj) break;
if (value) {
+ memmove(&fr_stack[fr_sp+3], &fr_stack[fr_sp+2], param*2*sizeof(obj_p));
fr_stack[fr_sp] = new_object(value);
fr_stack[fr_sp+1] = fr_stack[fr_sp];
fr_stack[fr_sp+2] = SYM(__INIT__);
@@ -1296,7 +1298,7 @@
}
*d = 0;
strcat(name, "_execstr_code.txt");
- dump_code(code, name);
+ dump_code(ist, NULL, code, name);
}
#endif
if (frame_p && *frame_p) {
@@ -1357,7 +1359,7 @@
{
char dump_name[256];
apr_snprintf(dump_name, sizeof(dump_name), "%s_module_dump.txt", name);
- dump_code(code, dump_name);
+ dump_code(ist, NULL, code, dump_name);
}
#endif
apr_snprintf(full_doc, sizeof(full_doc), "%s%s", name, comment);
@@ -1579,8 +1581,9 @@
return pc + 1;
}
//******************************** dump_code **********************************
-void dump_code(code* code, char* filename){
+void dump_code(isp ist, obj_p func, code* code, char* filename){
int i, pc=0;
+ obj_p lbl_value_list;
FILE* fout;
fout = fopen(filename, "w");
@@ -1592,6 +1595,19 @@
fprintf(fout,"misc_param: %4d\n", code->misc_param);
if (code->file_path)
fprintf(fout,"file_path: %s\n\n", code->file_path);
+ if (func && (lbl_value_list = get_attr(ist, func, SYM(__FPARAMS__)))) {
+ int llen = list_len(ist, lbl_value_list);
+ if (llen) fprintf(fout,"\nFormal Params:\n");
+ for (i=0; i < llen; i += 2) {
+ char *lbl_str = NULL, *val_str = NULL;
+ obj_p lbl = list_item(ist, lbl_value_list, i);
+ obj_p val = list_item(ist, lbl_value_list, i+1);
+ if (lbl) lbl_str = as_str(ist, lbl);
+ if (val) val_str = as_str(ist, val);
+ fprintf(fout," %s = %s\n", lbl_str, val_str);
+ }
+ if (llen) fprintf(fout,"\n");
+ }
if (code->srcmap && code->srcmap->items)
for (i=0; i < clist_len(code->srcmap); i+=3){
fprintf(fout, " srcmap pc:%3d, lin:%3d, col:%3d\n",
Modified: trunk/src/interp.h
===================================================================
--- trunk/src/interp.h 2004-04-04 00:14:48 UTC (rev 268)
+++ trunk/src/interp.h 2004-04-04 01:37:11 UTC (rev 269)
@@ -134,6 +134,6 @@
#define fr_push(w) frame->stack[frame->stack_ptr++] = w
#define fr_pop (frame->stack[--frame->stack_ptr])
-void dump_code(code* code, char* filename);
+void dump_code(isp ist, obj_p func, code* code, char* filename);
#endif // #define INTERP_H