rev 696 - in trunk: pr/pretest pr/test src

SVN User <[email protected]> Sat, 03 Jul 2004 02:29:10 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-07-03 02:29:07 -0400 (Sat, 03 Jul 2004)
New Revision: 696

Modified:
   trunk/pr/pretest/imp.pr
   trunk/pr/pretest/prop.pr
   trunk/pr/pretest/prosist.pr
   trunk/pr/test/init.pr
   trunk/pr/test/new.pr
   trunk/pr/test/threads.pr
   trunk/src/builtins-dict.c
   trunk/src/builtins-list.c
   trunk/src/interp.c
   trunk/src/main.c
   trunk/src/memory_mgr.c
   trunk/src/parser_routines.c
Log:
working on prosist bug

Modified: trunk/pr/pretest/imp.pr
===================================================================
--- trunk/pr/pretest/imp.pr	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/pr/pretest/imp.pr	2004-07-03 06:29:07 UTC (rev 696)
@@ -2,8 +2,8 @@
 
 #  imp.pr
 
-sys.path.append!('../../pr/test')
-sys.path.append!('../pr/test')
+sys.path.append!('../../pr/pretest')
+sys.path.append!('../pr/pretest')
 print sys.path
 
 import imp2

Modified: trunk/pr/pretest/prop.pr
===================================================================
--- trunk/pr/pretest/prop.pr	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/pr/pretest/prop.pr	2004-07-03 06:29:07 UTC (rev 696)
@@ -9,7 +9,7 @@
 			self.x_ = v
 			return v
 		def del_():
-			print "illegal delete operation"
+			print "attempt to delete (correct response)"
 
 p = Proto1()
 p.x = 3

Modified: trunk/pr/pretest/prosist.pr
===================================================================
--- trunk/pr/pretest/prosist.pr	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/pr/pretest/prosist.pr	2004-07-03 06:29:07 UTC (rev 696)
@@ -70,6 +70,6 @@
 a = 1
 
 print
-print x,
+print x,eol=' '
 y = x[6]
 print y.a, y.b, y.c

Modified: trunk/pr/test/init.pr
===================================================================
--- trunk/pr/test/init.pr	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/pr/test/init.pr	2004-07-03 06:29:07 UTC (rev 696)
@@ -3,13 +3,14 @@
 # init.pr
 
 print
-print """This should print: 
+print """
+This should print: 
 0 1234 0 -1
 0 12.34 .333333
  abc 123
 () (1, 2, 3) (4, 5, 6)
 [] [1, 2, 3] [4, 5, 6]
-{1:2, 3:4} {a:1, b:2, c:3}
+{1:2, 3:4} {$a:1, $b:2, $c:3}
 
 """
 

Modified: trunk/pr/test/new.pr
===================================================================
--- trunk/pr/test/new.pr	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/pr/test/new.pr	2004-07-03 06:29:07 UTC (rev 696)
@@ -13,12 +13,14 @@
     def str_():
         return '*'+self.x+'*'
 
-print
-print 'Should print ...'
-print '*1*'
-print '*a*'
-print
+print """
 
+Should print ...
+*1*
+*a*
+
+"""
+
 x = New(p, 1)
 print x
 

Modified: trunk/pr/test/threads.pr
===================================================================
--- trunk/pr/test/threads.pr	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/pr/test/threads.pr	2004-07-03 06:29:07 UTC (rev 696)
@@ -5,7 +5,7 @@
 Finished_thread_count = 0
 
 def func(n, d):
-	my_thread = CurrentThread()
+	my_thread = currentThread()
 	print my_thread, "started"
 	for i in n:
 		Sleep(d)

Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/src/builtins-dict.c	2004-07-03 06:29:07 UTC (rev 696)
@@ -247,6 +247,7 @@
 		default: llen = len;     break;
 	}
 	list_obj = NEW_LIST((int)llen);
+	if_exc_return NULL;
 	for(i=0; i < size; i++) {
 		if ((dp=dictptr(dict,i))->entry.hash > 0) {
 			assert (cnt++ < len);

Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/src/builtins-list.c	2004-07-03 06:29:07 UTC (rev 696)
@@ -87,7 +87,7 @@
 	obj_p list_obj = NEW_OBJ(OBJ(LIST_PROTO));
 	list_p lstp = list_obj->data.ptr = 
 		      pr_malloc(list_sizeof(max(initial_size,2)));
-	SET_TYPE_IF_EXC(List_OBJ, list_obj, DATA_TYPE_DATAPTR) return NULL;
+	SET_TYPE_IF_EXC(OBJ(TUPLE_PROTO), list_obj, DATA_TYPE_DATAPTR) return NULL;
 	lstpsetsize(lstp, max(initial_size,2));
 	lstplen(lstp)  = 0;
 	return list_obj;

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/src/interp.c	2004-07-03 06:29:07 UTC (rev 696)
@@ -653,7 +653,7 @@
 				     int store_local, obj_p alias, int return_mod ){
 	int i, llen, pkg_depth = 1;
 	obj_p dest_module, module_symbol, dmod;
-	char ch, full_path[APR_PATH_MAX], pkg_path[APR_PATH_MAX];
+	char full_path[APR_PATH_MAX], pkg_path[APR_PATH_MAX];
 	char *module_name = NULL;
 	obj_p path_list = get_sys_path_list();
 	apr_finfo_t finfo;
@@ -661,11 +661,6 @@
 	module_symbol = fr_data(param - 1);
 	module_name = symch(ist, module_symbol);
 
-	if (alias)
-		ch = *symch(ist, alias);
-	else
-		ch = *module_name;
-
 	if (store_local)
 		dest_module = frame->locals;
 	else
@@ -1070,7 +1065,11 @@
 			case OP_SEQ_ASSIGN: {
 				obj_p list;
 				fr_sp -= param+1;
-				if (has_proto(ist, list=fr_stack[fr_sp], OBJ(TUPLE_PROTO))){
+				if (has_proto(ist, list=fr_stack[fr_sp], OBJ(TUPLE_PROTO))) {
+					if (list_len(ist, list) > 1 && param == 1) {
+						set_attr(ist, frame->locals, fr_stack[fr_sp+1], list);
+						break;
+					}
 					if (list_len(ist, list) != param){
 						raise_exception(ist, OBJ(INTERPRETER_EXC), "For param list length doesn't match sequence length");
 						break;
@@ -1092,6 +1091,7 @@
 				for (i=0; i < param; i++)
 					listitem(tuple_obj, i) = fr_stack[fr_sp+i];
 				fr_push(tuple_obj);
+				set_immutable(tuple_obj);
 			}	break;
 			case OP_NEWLIST: {
 				obj_p list_obj = NEW_LIST(param);
@@ -2181,7 +2181,7 @@
 		return NULL;
 	}
 	for (i=0; i < parm_cnt; i += 2) {
-		lbl_val_arr[i]   = NULL;
+		lbl_val_arr[i]   = OBJ(NOKEY);
 		lbl_val_arr[i+1] = list_item(ist, uthread->params, i/2);
 	}
 	thread_module = NEW_OBJ(NULL);

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/src/main.c	2004-07-03 06:29:07 UTC (rev 696)
@@ -94,6 +94,21 @@
 	}
 }
 
+//********************************* finalize_all ******************************
+void finalize_all(void) {
+	isp ist = new_ist(ACC_SYSTEM);
+	obj_p obj;
+	pr_lock(&object_list_lock); 
+	obj = obj_list_root;
+	pr_unlock(&object_list_lock); 
+	while(obj) {
+		call_func(ist, obj, SYM(FINAL_), NULL, 0, NULL, NULL);
+		check_exceptions(ist);
+		pr_lock(&object_list_lock); 
+		obj = obj->next_obj;
+		pr_unlock(&object_list_lock); 
+	}
+}
 //********************************* main **************************************
 int main(int argc, char *argv[]) {
 	obj_p sys_argv_obj, main_argv_obj, threads, code_str_obj, main1_thread_obj;
@@ -108,7 +123,10 @@
 		printf("APR init error: %s\n", apr_strerror(aprerr, buf, 1024));
 		pr_exit(1);
 	}
+
 	atexit(&apr_terminate);
+	atexit(finalize_all);
+
 	if ((aprerr = apr_pool_create(&apr_root_pool, NULL)))  {
 		printf("Main error: apr_pool_create: %s\n",
 		       apr_strerror(aprerr, buf, sizeof(buf)));

Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/src/memory_mgr.c	2004-07-03 06:29:07 UTC (rev 696)
@@ -337,28 +337,6 @@
 		last_obj_count     = obj_count;
 	}
 	if (mem_mgr_req_termination) {
-		obj_p obj;
-		int obj_count = 0;
-#ifdef DEBUG_MEM_MGR
-		time = clock();
-		printf("Memory manager phase: Calling final_ on all remaining objects\n");
-#endif
-		mem_mgr_phase = MM_PHASE_DELETING;
-		pr_lock(&object_list_lock); 
-		obj=obj_list_root;
-		pr_unlock(&object_list_lock); 
-		while(obj) {
-			obj_count++;
-			call_func(ist, obj, SYM(FINAL_), NULL, 0, NULL, NULL);
-			check_exceptions(ist);
-			pr_lock(&object_list_lock); 
-			obj = obj->next_obj;
-			pr_unlock(&object_list_lock); 
-		}
-#ifdef DEBUG_MEM_MGR
-		printf("Memory manager: Called final_ on %d objects, elapsed time(secs): %g\n", 
-			    obj_count, ((clock()-time)*1.0)/CLOCKS_PER_SEC );
-#endif
 #ifdef DEBUG_THREADS
 		if (debug_threads) printf("Memory manager thread terminating\n");
 #endif

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-07-02 23:09:00 UTC (rev 695)
+++ trunk/src/parser_routines.c	2004-07-03 06:29:07 UTC (rev 696)
@@ -1207,11 +1207,11 @@
 	code *res;
 	int k=0, len=0, stack_depth=0, max_stack_depth = 0;
 	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
-	len += 5;
+	len += 5; stack_depth += 3;  max_stack_depth += 3;  
 	calc_code(rparm, &len, &stack_depth, &max_stack_depth); 
-	len++;
+	len++; stack_depth -= 3; 
 	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
-	len += 2;
+	len += 2; stack_depth -= 3; 
 	res = new_code(param, len, stack_depth, max_stack_depth, 0);
 	add_code_no_free(ref, res, &k);
 	res->code_data[k++].bytecode.opcode = OP_DEREF;