Author: pmichaud
Date: Mon Jan  8 19:21:32 2007
New Revision: 16511

Modified:
   trunk/compilers/pge/PGE/Match.pir

Log:
[PGE]:
* Update 'new' and 'newfrom' methods in Match to report a useful
  'Class "<grammar>" not found' instead of 'Illegal PMC enum(0) in new'
* Courtesy Klass-Jan Stol <[EMAIL PROTECTED]>, with modifications



Modified: trunk/compilers/pge/PGE/Match.pir
==============================================================================
--- trunk/compilers/pge/PGE/Match.pir   (original)
+++ trunk/compilers/pge/PGE/Match.pir   Mon Jan  8 19:21:32 2007
@@ -66,6 +66,7 @@
     from = clone from
   new_me:
     $I0 = find_type grammar
+    if $I0 == 0 goto err_grammar
     me = new $I0
     setattribute me, '$.target', target
     setattribute me, '$.from', from
@@ -77,6 +78,15 @@
     from = fromd
   end:
     .return (me, target, from, pos)
+  err_grammar:
+    .local pmc ex
+    .local string message
+    ex = new .Exception
+    message = "Class '"
+    message .= grammar
+    message .= "' not found"
+    ex['_message'] = message
+    throw ex
 .end
 
 =back
@@ -175,6 +185,7 @@
     ##   create the new match object
     .local pmc mob, mfrom, mpos
     $I0 = find_type grammar
+    if $I0 == 0 goto err_grammar
     mob = new $I0
     setattribute mob, '$.target', target
     mfrom = new .Integer
@@ -185,6 +196,16 @@
     setattribute mob, '$.pos', mpos
 
     .return (mob, pos, target, mfrom, mpos, iscont)
+
+  err_grammar:
+    .local pmc ex
+    .local string message
+    ex = new .Exception
+    message = "Class '"
+    message .= grammar
+    message .= "' not found"
+    ex['_message'] = message
+    throw ex
 .end
 
     

Reply via email to