Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles parrot's exceptions in Str.substr. #142

Closed
p6rt opened this issue Jun 22, 2008 · 8 comments
Closed

Handles parrot's exceptions in Str.substr. #142

p6rt opened this issue Jun 22, 2008 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 22, 2008

Migrated from rt.perl.org#56216 (status was 'resolved')

Searchable as RT56216$

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @bacek

Hello.

Attached patch handles parrot's exception on substr invocations and
returns Failure instead.

--
Bacek

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @bacek

substr.diff
diff --git a/languages/perl6/src/classes/Str.pir b/languages/perl6/src/classes/Str.pir
index 6195989..eb454cb 100644
--- a/languages/perl6/src/classes/Str.pir
+++ b/languages/perl6/src/classes/Str.pir
@@ -258,10 +284,17 @@ Returns a Perl representation of the Str.
     len = len - start
 
   end:
+    push_eh cant_substr
     $S0 = substr self, start, len
+    pop_eh
     s = new 'Str'
     s = $S0
     .return (s)
+  cant_substr:
+    .get_results ($P0, $S0)
+    s = new 'Failure'
+    .return (s)
+    
 .end
 
 =back

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @pmichaud

Patch postponed for now -- instead of creating Failure objects directly
we'll have some sort of 'fail' function for PIR to use to catch and
return the exception (and that can honor 'use fatal').

Pm

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 14, 2008

From @bacek

On Sat Jun 21 21​:46​:33 2008, pmichaud wrote​:

Patch postponed for now -- instead of creating Failure objects directly
we'll have some sort of 'fail' function for PIR to use to catch and
return the exception (and that can honor 'use fatal').

Here it is.

--
Bacek

@p6rt
Copy link
Author

p6rt commented Nov 14, 2008

From @bacek

substr2.patch
diff --git a/languages/perl6/src/builtins/any-str.pir b/languages/perl6/src/builtins/any-str.pir
index 791ff45..16980d9 100644
--- a/languages/perl6/src/builtins/any-str.pir
+++ b/languages/perl6/src/builtins/any-str.pir
@@ -519,8 +519,14 @@ B<Note:> partial implementation only
     len -= start
   len_done:
     $S0 = self
+    push_eh fail
     $S1 = substr $S0, start, len
+    pop_eh
     .return ($S1)
+  fail:
+    .get_results($P0)
+    pop_eh
+    .tailcall '!FAIL'($P0)
 .end
 
 =item trans()

@p6rt
Copy link
Author

p6rt commented Nov 17, 2008

From @moritz

On Thu Nov 13 16​:59​:19 2008, bacek wrote​:

On Sat Jun 21 21​:46​:33 2008, pmichaud wrote​:

Patch postponed for now -- instead of creating Failure objects directly
we'll have some sort of 'fail' function for PIR to use to catch and
return the exception (and that can honor 'use fatal').

Here it is.

Applied as r32781, thanks

@p6rt
Copy link
Author

p6rt commented Nov 17, 2008

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Nov 17, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant