rev 520 - in trunk: include/prothon pr/test src

SVN User <[email protected]> Thu, 20 May 2004 19:17:41 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-05-20 19:17:39 -0400 (Thu, 20 May 2004)
New Revision: 520

Modified:
   trunk/include/prothon/prothon.h
   trunk/pr/test/test.pr
   trunk/src/builtins-core.c
   trunk/src/interp.c
   trunk/src/memory_mgr.c
   trunk/src/object.c
   trunk/src/object.h
Log:
fixed object statement problem with garbage collector

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/include/prothon/prothon.h	2004-05-20 23:17:39 UTC (rev 520)
@@ -17,7 +17,7 @@
  * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
  * Applications; All Rights Reserved" are retained in Prothon alone or
  * in any derivative version prepared by Licensee.
- *  
+ *   
  * 3. In the event Licensee prepares a derivative work that is based on or
  * incorporates Prothon or any part thereof, and wants to make the
  * derivative work available to others as provided herein, then Licensee

Modified: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/pr/test/test.pr	2004-05-20 23:17:39 UTC (rev 520)
@@ -27,72 +27,24 @@
 object ModInt(Int):
     modulo = 10
     def call_(i=0):
-
-        if nextProto is not None:
-            proto2 = self.protoList()[1]
-            if proto2 is not nextProto:
-                print "err before"
-                raise xxx
-
         call = refer(ModInt, 'call_')
-        
-        if nextProto is not None:
-            proto2 = self.protoList()[1]
-            if proto2 is not nextProto:
-                print "err after"
-                raise xxx
-
         return call{self}(i % self.modulo)
 
     def add_(other):
         if self.modulo != other.modulo:
             raise TypeError
         proto = self.protoList()[1]
-        
-        if proto is not lastProto:
-                print "err 1"
-                raise xxx
-        proto2 = proto.protoList()[1]
-        if proto2 is not nextProto:
-                print "err 2"
-                raise xxx
-        
         add = refer(ModInt, 'add_')
-        
-        if proto is not lastProto:
-                print "err 3"
-                raise xxx
-        proto2 = proto.protoList()[1]
-        if proto2 is not nextProto:
-                print "err 4"
-                raise xxx
-        
         x =  proto(add{self}(other))
-        
-        proto = x.protoList()[1]
-        if proto is not lastProto:
-                print "err 5"
-                raise xxx
-        proto2 = proto.protoList()[1]
-        if proto2 is not nextProto:
-                print "err 6"
-                raise xxx
-        
         print "new", x
         return x
 
 object Mod8Int(ModInt):
     modulo = 8
 
-nextProto = None
 m = Mod8Int(1)
-lastProto = m.protoList()[1]
-nextProto = lastProto.protoList()[1]
-print "lastProto: %x" % lastProto.objId_()
-print "nextProto: %x" % nextProto.objId_()
-
 n = Mod8Int(1)
 print "%i, %s" % (m, m.protoList().str_())
-for i in 100:
+for i in 1000:
     m = m + n
     print "%i, %s" % (m, m.protoList().str_())

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/src/builtins-core.c	2004-05-20 23:17:39 UTC (rev 520)
@@ -114,6 +114,10 @@
 	return NEW_INT((intptr_t) self);
 }
 
+DEF(Object, debug_, NULL) {
+	return debug_object(self);
+}
+
 DEF(Object, Proto, FORM_STAR_PARAM) {
 	int i, llen = (int) list_len(ist, parms[1]);
 	obj_p new_obj;
@@ -768,6 +772,7 @@
 	MODULE_ADD_SYM(Object, call_);
 	MODULE_ADD_SYM(Object, init_);
 	MODULE_ADD_SYM(Object, objId_);
+	MODULE_ADD_SYM(Object, debug_);
 	MODULE_ADD_SYM(Object, Proto);
 	MODULE_ADD_SYM(Object, copy);
 	MODULE_ADD_SYM(Object, setReadAccess);

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/src/interp.c	2004-05-20 23:17:39 UTC (rev 520)
@@ -739,6 +739,10 @@
 		exc_exc_loc	= p->exc_loc;
 	}
 	while(TRUE){
+		if (debug_obj) {
+			if (debug_obj->attr_proto.proto != debug_obj_proto)
+				debug_obj_proto = debug_obj->attr_proto.proto;
+		}
 		while (have_exstk && (fr_pc <= exc_try_loc || fr_pc >= exc_exc_loc)) {
 			if (exc_final && fr_pc != exc_exc_loc) {
 				exc_final_return = fr_pc;
@@ -1145,10 +1149,10 @@
 				key = fr_stack[fr_sp+1];
 				if (has_proto_QUES(ist, key, OBJ(LOCAL_PROTO))) {
 					key = key->data.ptr;
-					del_unlock(fr_stack[fr_sp+1]);
+					//del_unlock(fr_stack[fr_sp+1]);
 				}
 				set_attr(ist, fr_stack[fr_sp], key, new_obj); IF_EXC_BREAK;
-				del_unlock(new_obj);
+				//del_unlock(new_obj);
 				fr_push(new_obj);
 				goto op_with;
 			}

Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/src/memory_mgr.c	2004-05-20 23:17:39 UTC (rev 520)
@@ -268,6 +268,8 @@
 		while(obj) {
 			obj_count++;
 			if (obj->state != OBJ_STATE_NEW_OR_MARKED && !obj->del_locked) {
+				if (obj == debug_obj)
+					obj = debug_obj;
 				call_func(ist, obj, SYM(DEL_), 0, NULL, NULL);
 				ist->exception_obj = 0;
 				mm_write_lock(ist, obj);

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/src/object.c	2004-05-20 23:17:39 UTC (rev 520)
@@ -246,6 +246,16 @@
 	BUILTIN_LOAD(Tuple);
 }
 
+//********************************* debug_object ******************************
+obj_p debug_obj       = NULL;
+obj_p debug_obj_proto = NULL;
+
+obj_p debug_object(obj_p obj) {
+	debug_obj = obj;
+	debug_obj_proto = obj->attr_proto.proto;
+	return obj;
+}
+
 //********************************* new_object ********************************
 obj_p new_object(isp ist, obj_p proto){
 	obj_p obj = pr_malloc(sizeof(obj_t));

Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h	2004-05-20 19:39:22 UTC (rev 519)
+++ trunk/src/object.h	2004-05-20 23:17:39 UTC (rev 520)
@@ -131,6 +131,10 @@
 obj_p copy_object(isp ist, obj_p obj);
 void free_object(obj_p obj);
 
+obj_p debug_object(obj_p obj);
+extern obj_p debug_obj;
+extern obj_p debug_obj_proto;
+
 void set_item(isp ist, obj_p ref_self, obj_p ref_key, obj_p value);
 void del_item(isp ist, obj_p ref_self, obj_p ref_key);