logo       

rev 468 - in trunk: pr src: msg#00035

Subject: rev 468 - in trunk: pr src
Author: mark
Date: 2004-05-12 15:42:34 -0400 (Wed, 12 May 2004)
New Revision: 468

Modified:
   trunk/pr/test.pr
   trunk/src/interp.c
Log:
added proper exception when local var lookup fails

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr    2004-05-12 19:18:37 UTC (rev 467)
+++ trunk/pr/test.pr    2004-05-12 19:42:34 UTC (rev 468)
@@ -1,13 +1,31 @@
-object proto1:
-    def init_():
-        print 1
+#!/usr/bin/env prothon
 
-object proto2(proto1):
-    def init_():  
-        proto1.init_()
+# bin.pr
 
-object proto3(proto2):  
-               pass
+x = Exception
 
-print 'xx'
-proto3()
+object obj(String, Int):
+        Int.init_{obj}(99)      # inits using second proto
+        print Int.str_{obj}()   # prints 99
+        
+try:
+    with obj: Int.init_{obj}(99)   # init Int a second time
+except x,e: print e    # throws "object has binary data, expected none"
+
+try:
+    obj.init_('abc') # init as String
+except x,e: print e     # throws "object has binary data, expected none"
+
+L = Proto(List) # L is uninitialized list
+
+L.init_(1,2,3)
+print L             # prints [1, 2, 3] 
+
+L.init_(4,5,6)
+print L             # prints [4, 5, 6] 
+
+d = {1:2, 'a':'b'}
+print d             # prints {1:2, 'a':'b'}
+
+d.init_(c = 'd', f = 'g')
+print d             # prints {f:'g', c:'d'} 
\ No newline at end of file

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c  2004-05-12 19:18:37 UTC (rev 467)
+++ trunk/src/interp.c  2004-05-12 19:42:34 UTC (rev 468)
@@ -831,6 +831,12 @@
                                obj_p att;                      
                                fr_sp -= 2;
                                att = get_item(ist, fr_stack[fr_sp], 
fr_stack[fr_sp+1]);
+                               if (!att) {
+                                       raise_exception( ist, 
OBJ(INTERPRETER_EXC), 
+                                                                               
  "attribute %s not found", 
+                                                                             
as_str(ist, fr_stack[fr_sp+1]) );
+                                       break;
+                               }
                                fr_push(att);
                        }   break;
                        case OP_ASSIGN: {




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe