rev 462 - in trunk: . include/prothon pr src
SVN User <[email protected]> Thu, 06 May 2004 03:09:42 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-05-06 03:09:39 -0400 (Thu, 06 May 2004)
New Revision: 462
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/pr/test.pr
trunk/src/interp.c
Log:
throw exception when calling uninitialized function
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-05-06 06:54:28 UTC (rev 461)
+++ trunk/STATUS.txt 2004-05-06 07:09:39 UTC (rev 462)
@@ -3,8 +3,6 @@
--- change obj$func() to obj.func$()
---- Fix function extension bug.
-
--- Add properties methods support (__get__, __set__, __delete__) rename protoList
--- Add Globals built-in attribute (actually a synonym for current Main module which can be named Main1, Main2, ...)
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-05-06 06:54:28 UTC (rev 461)
+++ trunk/include/prothon/prothon.h 2004-05-06 07:09:39 UTC (rev 462)
@@ -851,7 +851,7 @@
// The function must always return an object-id (OBJ(NONE) if nothing else).
typedef obj_p (pr_func)( isp ist, obj_p self,
int parm_cnt, obj_p* lbl_parm_arr, obj_p dyn_locals );
-
+
#define PARAM_NORMAL ((obj_p)0)
#define PARAM_STAR ((obj_p)1)
#define PARAM_STAR_STAR ((obj_p)2)
Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr 2004-05-06 06:54:28 UTC (rev 461)
+++ trunk/pr/test.pr 2004-05-06 07:09:39 UTC (rev 462)
@@ -1,15 +1,21 @@
-def f1():
- print 'f1'
-def f2():
- print 'f2'
-print f1
-print f2
+def f1(x=''):
+ print 'f1'+x
+
+def f2(y=''):
+ print 'f2'+y
+
f = Proto(f1)
-print f
+
+f()
+
f.__init__(f2)
-print f
+
f1()
f2()
-x = ^
-f()
\ No newline at end of file
+f()
+
+g = Func(f1)
+h = Func(f2)
+g(' g')
+h(' h')
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-05-06 06:54:28 UTC (rev 461)
+++ trunk/src/interp.c 2004-05-06 07:09:39 UTC (rev 462)
@@ -997,9 +997,12 @@
} break;
case OP_OBJCALL: {
fr_sp -= 1+2*param;
- if ((func_obj = fr_stack[fr_sp])->data_type == DATA_TYPE_FUNCPTR){
+ func_obj = fr_stack[fr_sp];
+ if (func_obj->data_type == DATA_TYPE_FUNCPTR) {
obj_p res, self;
- clist_p plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+1);
+ clist_p plist;
+ if (!func_obj->data.ptr) goto no_func_ptr;
+ plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+1);
if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
self = frame->self; IF_EXC_BREAK;
pre_call_lock(ist, self, plist); IF_EXC_BREAK;
@@ -1016,6 +1019,7 @@
obj_p new_locals, syn_self, self;
frame_p new_frame;
IF_EXC_BREAK;
+ if (!func_obj->data.ptr) goto no_func_ptr;
new_locals = NEW_OBJ(NULL);
syn_self = get_attr(ist, func_obj, SYM(__SYN_SELF__)); IF_EXC_BREAK;
if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
@@ -1042,6 +1046,8 @@
goto get_func;
}
} break;
+no_func_ptr: raise_exception(ist, OBJ(INTERNAL_EXC), "attempt to call an uninitialized function");
+ break;
case OP_OBJ: {
int i, num_protos = (int)(intptr_t) fr_data(2);
obj_p new_obj;
@@ -1120,8 +1126,10 @@
break;
}
if (func_obj->data_type == DATA_TYPE_FUNCPTR){
+ clist_p plist;
obj_p res, self, slf = super_flag? frame->self : fr_stack[fr_sp];
- clist_p plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+2);
+ if (!func_obj->data.ptr) goto no_func_ptr2;
+ plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+2);
IF_EXC_BREAK;
if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
self = slf; IF_EXC_BREAK;
@@ -1140,6 +1148,7 @@
obj_p new_locals, syn_self, self;
frame_p new_frame;
IF_EXC_BREAK;
+ if (!func_obj->data.ptr) goto no_func_ptr2;
new_locals = NEW_OBJ(NULL);
syn_self = get_attr(ist, func_obj, SYM(__SYN_SELF__)); IF_EXC_BREAK;
if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
@@ -1176,6 +1185,8 @@
as_str(ist, fr_stack[fr_sp+1]));
}
} break;
+no_func_ptr2: raise_exception(ist, OBJ(INTERNAL_EXC), "attempt to call an uninitialized function");
+ break;
case OP_RAISE:
ist->exception_obj = fr_pop;
break;