rev 244 - trunk/src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-03-31 20:44:43 -0500 (Wed, 31 Mar 2004)
New Revision: 244

Modified:
   trunk/src/interp.c
   trunk/src/object.c
   trunk/src/src.vcproj
Log:
fixed super (^)

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-04-01 01:00:43 UTC (rev 243)
+++ trunk/src/interp.c	2004-04-01 01:44:43 UTC (rev 244)
@@ -894,7 +894,7 @@
 					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__);
-					goto call_get_func;
+					goto get_func;
 				}
 			}	break;
 			case OP_WITH:
@@ -907,9 +907,8 @@
 			case OP_CALL: {
 				fr_sp -= 2+(2*param);
 				if (has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SUPER_PROTO))) {
-					obj_p proto_list_obj = proto_list(ist, fr_stack[fr_sp]); if (intrp_exobj) break;
-					fr_stack[fr_sp]   = list_item(ist, proto_list_obj,1);  del_unlock(proto_list_obj);
-					fr_stack[fr_sp+1] = fr_stack[fr_sp+1]->data.ptr;
+					func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]->data.ptr, NULL, TRUE);
+					goto got_func;
 				}
 				if (!has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SYMBOL_PROTO))) {
 					raise_exception(ist, OBJ(INTERNAL_EXC), "Indexed function call not supported yet");
@@ -927,8 +926,9 @@
 					break;
 				}
 				if_exc_return NULL;
-call_get_func:
-				func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL);  if_exc_return NULL;
+get_func:
+				func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL, FALSE);  if_exc_return NULL;
+got_func:
 				if (intrp_exobj) break;
 				if (!func_obj) {
 					raise_exception(ist, OBJ(FUNCNOTFOUND_EXC),
@@ -979,13 +979,13 @@
 
 					if (fr_stack[fr_sp+1] != SYM(__INIT__)) {
 						value = get_proto_attr(ist, fr_stack[fr_sp],
-								fr_stack[fr_sp+1], NULL);
+								fr_stack[fr_sp+1], NULL, FALSE);
 						if_exc_return NULL;
 
 						if (value) {
 							fr_stack[fr_sp]   = new_object(value);
 							fr_stack[fr_sp+1] = SYM(__INIT__);
-							goto call_get_func;
+							goto get_func;
 						}
 					}
 					raise_exception(ist, OBJ(FUNCNOTFOUND_EXC),
@@ -1168,7 +1168,7 @@
 				 int parm_cnt, obj_p* lbl_val_arr, obj_p dyn_locals ) {
     obj_p func_obj;
 	if (func_sym) {
-		func_obj = get_proto_attr(ist, self, func_sym, NULL); if_exc_return NULL;
+		func_obj = get_proto_attr(ist, self, func_sym, NULL, FALSE); if_exc_return NULL;
 		if (!func_obj) {
 			if (!ist) {
 				printf("Internal error with exceptions disabled: Function not found: \"%s\"", as_str(ist, func_sym));

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-04-01 01:00:43 UTC (rev 243)
+++ trunk/src/object.c	2004-04-01 01:44:43 UTC (rev 244)
@@ -560,7 +560,7 @@
 //********************************* get_proto_attr *****************************
 // same as get_attr but will look in all protos for key as well
 // if proto_pp not null, then will return proto obj that attr was found in
-obj_p get_proto_attr(isp ist, obj_p objid, obj_p key, obj_p *proto_pp) {
+obj_p get_proto_attr(isp ist, obj_p objid, obj_p key, obj_p *proto_pp, int second) {
 	obj_p  obj=objid, proto, res;
 	int i, j, len;
 	clist_t *pao_list;
@@ -568,8 +568,10 @@
 	while (TRUE){
 		read_lock(ist, obj);
 		if( (res = get_attr(ist, obj, key)) || obj == OBJ(OBJECT) ) {
-			read_unlock(ist, obj);
-			break;
+			if (!second) {
+				read_unlock(ist, obj);
+				break;
+			} else second = FALSE;
 		}
 		if ((len = proto_len(ist, obj)) == 1) {
 			proto = proto_item(ist, obj, 0);
@@ -616,10 +618,14 @@
 		for (i=0; i < clist_len(pao_list); i++)
 			if ( (obj = clist_item(pao_list,i)) && 
 					(res = get_attr(ist, obj, key)) ) {
-				if (proto_pp) *proto_pp = obj;
-				clist_read_unlock(ist, pao_list);
-				free_clist(pao_list);
-				return res;
+				if (proto_pp) {
+					if (!second) {
+						*proto_pp = obj;
+						clist_read_unlock(ist, pao_list);
+						free_clist(pao_list);
+						return res;
+					} else second = FALSE;
+				}
 			}
 		clist_read_unlock(ist, pao_list);
 		free_clist(pao_list);
@@ -779,7 +785,7 @@
 	if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
 		obj_p res;
 		if_exc_return NULL;
-		res = get_proto_attr(ist, ref_self, ref_key, NULL);
+		res = get_proto_attr(ist, ref_self, ref_key, NULL, FALSE);
 		if (!res) {
 			raise_exception(ist, OBJ(NAME_EXC), "Attribute %s not found",
 					symch(ist, ref_key));
@@ -791,9 +797,8 @@
 		param[0]=0; param[1]=ref_key;
         return call_func(ist, ref_self, SYM(__GETITEM__), 2, param, 0);
 	} else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
-		obj_p proto_list_obj; if_exc_return NULL;
-		proto_list_obj = proto_list(ist, ref_self); if_exc_return NULL;
-        return get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, NULL);
+		if_exc_return NULL;
+        return get_proto_attr(ist, ref_self, ref_key->data.ptr, NULL, TRUE);
 	} else {
 		raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference type");
 		return NULL;
@@ -813,7 +818,7 @@
 	} else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
 		obj_p proto_list_obj, proto_obj; if_exc_return;
 		proto_list_obj = proto_list(ist, ref_self); if_exc_return;
-        get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, &proto_obj);
+        get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, &proto_obj, FALSE);
 		if_exc_return;
 		if (!proto_obj) proto_obj = list_item(ist, proto_list_obj,1);
 		set_attr(ist, proto_obj, ref_key->data.ptr, value);
@@ -835,7 +840,7 @@
 	} else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
 		obj_p proto_list_obj, proto_obj; if_exc_return;
 		proto_list_obj = proto_list(ist, ref_self); if_exc_return;
-        get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, &proto_obj);
+        get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, &proto_obj, FALSE);
 		if_exc_return;
 		if (proto_obj) del_attr(ist, proto_obj, ref_key->data.ptr);
 	} else {

Modified: trunk/src/src.vcproj
===================================================================
--- trunk/src/src.vcproj	2004-04-01 01:00:43 UTC (rev 243)
+++ trunk/src/src.vcproj	2004-04-01 01:44:43 UTC (rev 244)
@@ -218,6 +218,9 @@
 				RelativePath="init.pth">
 			</File>
 			<File
+				RelativePath="..\pr\meow.pr">
+			</File>
+			<File
 				RelativePath="..\pr\oops.pr">
 			</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.