Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created January 5, 2011 22:57
Show Gist options
  • Save tadzik/767187 to your computer and use it in GitHub Desktop.
Save tadzik/767187 to your computer and use it in GitHub Desktop.
.worry for nqp-rx
From ccdce95ff809fa6436cc85da6eeda7e63b0b1316 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= <tadzikes@gmail.com>
Date: Thu, 6 Jan 2011 00:54:24 +0100
Subject: [PATCH] Implemented <.worry>
---
src/cheats/hll-grammar.pir | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/cheats/hll-grammar.pir b/src/cheats/hll-grammar.pir
index b683e1d..16ffc30 100644
--- a/src/cheats/hll-grammar.pir
+++ b/src/cheats/hll-grammar.pir
@@ -360,6 +360,36 @@ position C<pos>.
.return ($P1)
.end
+.sub 'worry' :method
+ .param pmc args :slurpy
+
+ .local int pos
+ .local pmc target
+ pos = self.'pos'()
+ target = getattribute self, '$!target'
+
+ $P0 = get_hll_global ['HLL'], 'Compiler'
+ $I1 = $P0.'lineof'(target, pos)
+ inc $I1
+ push args, ' at line '
+ push args, $I1
+
+ $S0 = target
+ $S0 = substr $S0, pos, 10
+ $S0 = escape $S0
+ push args, ', near "'
+ push args, $S0
+ push args, "\"\n"
+
+ .local string message
+ message = join '', args
+
+ .local pmc serr
+ serr = getstderr
+
+ print serr, message
+ .return (0)
+.end
.sub 'starter' :method
.local pmc cur
--
1.7.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment