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

SVN User <[email protected]> Sun, 23 May 2004 18:36:10 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-05-23 18:36:07 -0400 (Sun, 23 May 2004)
New Revision: 538

Modified:
   trunk/include/prothon/prothon.h
   trunk/pr/test/test.pr
   trunk/src/interp.c
Log:
fixed ante keyword

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-05-23 19:45:09 UTC (rev 537)
+++ trunk/include/prothon/prothon.h	2004-05-23 22:36:07 UTC (rev 538)
@@ -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-23 19:45:09 UTC (rev 537)
+++ trunk/pr/test/test.pr	2004-05-23 22:36:07 UTC (rev 538)
@@ -1,24 +1,31 @@
 #!/usr/bin/env prothon
 
-d={}
-max = 50
+Animal = Object()
+with Animal:
+   def describe():
+       print "I am an animal."
+       self.make_noise()
+   def make_noise():
+     print "I make animal noise."
+   
+Mammal = Animal()
+with Mammal:
+   def describe():
+          print "I am a mammal."
+          ante.describe()
+          self.make_noise()
+   def make_noise():
+     print "I make mammal noise."
+   
+Cat = Mammal()
+with Cat:
+     def describe():
+          print "I am a cat."
+          Mammal.describe{self}()
+          self.make_noise()
+     def make_noise():
+       print "meow"
 
-def Key(n):
-    return "B%02i" % n
+c = Cat()
+c.describe()
 
-print "Loading dictionary ..."
-
-for n in max:
-    d[Key(n)] = True
-
-print "\nChecking dictionary ..."
-lost = False
-for n in max:
-    if Key(n) not in d:
-        lost = True
-        print "Key %s not found" % Key(n)
-
-if lost:
-    print d.keys().sort!()
-else:
-	print "\ntest passed"

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-05-23 19:45:09 UTC (rev 537)
+++ trunk/src/interp.c	2004-05-23 22:36:07 UTC (rev 538)
@@ -143,10 +143,13 @@
 
 //********************************* new_ante_obj *****************************
 obj_p new_ante_obj(isp ist, obj_p container, obj_p symbol) {
+	int i;
 	obj_p ante_obj = NEW_OBJ(OBJ(ANTE_PROTO));
 	ante_obj->data_type = DATA_TYPE_DATAPTR;
 	ante_obj->data.ptr = symbol;
+	su(i);
 	set_attr(ist, ante_obj, SYM(CONT_), container);
+	un_su(i);
 	ante_obj->immutable = TRUE;
 	return ante_obj;
 }
@@ -932,15 +935,10 @@
 				fr_sp -= 2;
 				att = get_item(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]); IF_EXC_BREAK;
 				if (!att) {
-					raise_exception( ist, OBJ(INTERPRETER_EXC), 
-										  "attribute %s not found", 
+					raise_exception( ist, OBJ(INTERPRETER_EXC), "attribute %s not found", 
 									      as_str(ist, fr_stack[fr_sp+1]) );
 					break;
 				}
-				if (has_proto_QUES(ist, att, OBJ(FUNC_PROTO))) {
-					set_attr(ist, att, SYM(CONT_), fr_stack[fr_sp]);
-					set_attr(ist, att, SYM(NAME_), fr_stack[fr_sp+1]);
-				}
 				fr_push(att);
 			}   break;
 			case OP_ASSIGN: {
@@ -1017,6 +1015,8 @@
 					set_attr(ist, func,    SYM(FPARAMS_),  fparams_obj);
 				}
 				set_attr(ist, func, SYM(PREVSCOPE_),  frame->locals);
+				set_attr(ist, func, SYM(CONT_),       fr_stack[fr_sp]);
+				set_attr(ist, func, SYM(NAME_),       fr_stack[fr_sp+1]);
 #ifdef DUMP_MODULE_CODE
 				if (dump_module_code) {
 					char dump_name[256];
@@ -1349,11 +1349,6 @@
 					frame_p new_frame;
 					IF_EXC_BREAK;
 					if (!func_obj->data.ptr) goto no_func_ptr2;
-					if (name_obj) {
-						set_attr(ist, func_obj, SYM(CONT_), fr_stack[fr_sp]);
-						set_attr(ist, func_obj, SYM(NAME_), name_obj);
-						name_obj = NULL;
-					}
 					new_locals = NEW_OBJ(NULL);
 					if ( !(self = fr_stack[fr_sp+2]) &&
 						 !(self = get_attr(ist, func_obj, SYM(BINDOBJ_))) &&