rev 254 - in trunk: . src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-01 20:44:19 -0500 (Thu, 01 Apr 2004)
New Revision: 254

Modified:
   trunk/STATUS.txt
   trunk/src/interp.c
   trunk/src/interp.h
   trunk/src/src.vcproj
Log:
__init__ uses originally created object, not returned object

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-04-02 00:27:07 UTC (rev 253)
+++ trunk/STATUS.txt	2004-04-02 01:44:19 UTC (rev 254)
@@ -36,7 +36,11 @@
 Syntax extension modifier -- language spec?
 
 make := work like = but usable as an expr
+   looks like a no-go
 
+Point = proto(base1, base2): function?
+func  = def(arg1, arg2):     function?
+
 sets and other zephyr email items -- use <> ?
 
 Allow obj^attr ?

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-04-02 00:27:07 UTC (rev 253)
+++ trunk/src/interp.c	2004-04-02 01:44:19 UTC (rev 254)
@@ -98,23 +98,18 @@
 							           obj_p func_obj, code* code_in ) {
 	exec_frame_t* frame;
 	code* code;
+	size_t flen;
 	if (func_obj) code = obj_data_p(func_obj);
 	else		  code = code_in;
-	frame = pr_malloc(sizeof(exec_frame_t) + (code->max_stack_depth+STACK_PADDING) * sizeof(obj_p));
-	frame->next_frame		= NULL;
-	frame->prev_frame		= NULL;
-	frame->called_from_c	= FALSE;
-	frame->do_not_free		= FALSE;
-	frame->gen_marker		= FALSE;
+	flen = sizeof(exec_frame_t) + (code->max_stack_depth+STACK_PADDING) * sizeof(obj_p);
+	frame = pr_malloc(flen);
+	memset(frame, 0, flen);
 	frame->self				= self;
 	frame->globals			= (func_obj ? get_attr(ist, func_obj, SYM(__GLOBALS__))    : globals);
 	frame->syn_locals		= (func_obj ? get_attr(ist, func_obj, SYM(__SYN_LOCALS__)) : syn_locals);
 	frame->dyn_locals		= dyn_locals;
 	frame->locals			= locals;
-	frame->pc				= 0;
 	frame->code				= code;
-	frame->exc_stack		= NULL;
-	frame->stack_ptr		= 0;
 	if(!frame->globals)       frame->globals = globals;
 	if(!frame->syn_locals) frame->syn_locals = syn_locals;
 	if(!frame->syn_locals) frame->syn_locals = locals;
@@ -893,7 +888,10 @@
 				} else {
 					memmove(fr_stack+fr_sp+2, fr_stack+fr_sp+1, (param*2) * sizeof(obj_p));
 					fr_stack[fr_sp]   = new_object(fr_stack[fr_sp]);
-					fr_stack[fr_sp+1] = SYM(__INIT__);
+					fr_stack[fr_sp+1] = fr_stack[fr_sp];
+					fr_stack[fr_sp+2] = SYM(__INIT__);
+					fr_sp++;
+					frame->calling_init = TRUE;
 					goto get_func;
 				}
 			}	break;
@@ -925,9 +923,9 @@
 					switch_frame = new_frame;
 					break;
 				}
-				if_exc_return NULL;
+				if (intrp_exobj) break;
 get_func:
-				func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL, FALSE);  if_exc_return NULL;
+				func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL, FALSE);
 got_func:
 				if (intrp_exobj) break;
 				if (!func_obj) {
@@ -949,7 +947,10 @@
 					post_call_unlock(slf, plist);
 					free_clist(plist);
 					if (intrp_exobj) break;
-					fr_push(res);
+					if (frame->calling_init)
+						frame->calling_init = FALSE;
+					else
+						fr_push(res);
 				} else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
 					obj_p new_locals;
 					exec_frame_t* new_frame;
@@ -976,15 +977,16 @@
 					fr_push(func_obj);
 				} else {
 					obj_p value;
-
 					if (fr_stack[fr_sp+1] != SYM(__INIT__)) {
 						value = get_proto_attr(ist, fr_stack[fr_sp],
 								fr_stack[fr_sp+1], NULL, FALSE);
-						if_exc_return NULL;
-
+						if (intrp_exobj) break;
 						if (value) {
 							fr_stack[fr_sp]   = new_object(value);
-							fr_stack[fr_sp+1] = SYM(__INIT__);
+							fr_stack[fr_sp+1] = fr_stack[fr_sp];
+							fr_stack[fr_sp+2] = SYM(__INIT__);
+							fr_sp++;
+							frame->calling_init = TRUE;
 							goto get_func;
 						}
 					}
@@ -1150,6 +1152,10 @@
 				exc_try_loc	= p->try_loc;
 				exc_exc_loc	= p->exc_loc;
 			}
+			if (frame != DONE_FRAME_FLAG && frame->calling_init) {
+				frame->calling_init = FALSE;
+				fr_sp--;
+			}
 		}
 		if (return_flag || frame == DONE_FRAME_FLAG) {
 #ifdef TRACE_INTERPRETER

Modified: trunk/src/interp.h
===================================================================
--- trunk/src/interp.h	2004-04-02 00:27:07 UTC (rev 253)
+++ trunk/src/interp.h	2004-04-02 01:44:19 UTC (rev 254)
@@ -75,6 +75,7 @@
 	struct exec_frame_t*  next_frame;
 	struct exec_frame_t*  prev_frame;
 	int			called_from_c;
+	int			calling_init;
 	int			do_not_free;
 	int			gen_marker;
 	obj_p		self;

Modified: trunk/src/src.vcproj
===================================================================
--- trunk/src/src.vcproj	2004-04-02 00:27:07 UTC (rev 253)
+++ trunk/src/src.vcproj	2004-04-02 01:44:19 UTC (rev 254)
@@ -131,9 +131,6 @@
 			Name="Source Files"
 			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
 			<File
-				RelativePath="amain.c">
-			</File>
-			<File
 				RelativePath="argproc.c">
 			</File>
 			<File
@@ -155,6 +152,9 @@
 				RelativePath="lock.c">
 			</File>
 			<File
+				RelativePath=".\main.c">
+			</File>
+			<File
 				RelativePath="memory_mgr.c">
 			</File>
 			<File
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.