Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created December 3, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/ca7feb195fa7d68f58bb834567aea4b0 to your computer and use it in GitHub Desktop.
Save zoffixznet/ca7feb195fa7d68f58bb834567aea4b0 to your computer and use it in GitHub Desktop.
diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp
index d7595d8..7549249 100644
--- a/src/Perl6/Actions.nqp
+++ b/src/Perl6/Actions.nqp
@@ -4974,6 +4974,13 @@ class Perl6::Actions is HLL::Actions does STDActions {
my $val;
if nqp::can($ast,'has_compile_time_value') && $ast.has_compile_time_value {
$val := $ast.compile_time_value;
+ if $*NEGATE_VALUE {
+ my $neg-op := $*W.find_symbol(['&prefix:<->']);
+ nqp::say("Calling neg op " ~ $val.HOW.name($val) ~ " " ~ $val);
+ $val := $neg-op($val);
+ $*W.add_object($val);
+ nqp::say("Calling neg op " ~ $val.HOW.name($val) ~ " " ~ $val);
+ }
}
else { # for negatives
$val := (
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 3645905..29c7ebb 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -2946,8 +2946,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*IN_DECL := '';
[
| <value>
- | <[-−]> $<value>=\d+
| <sign> $<value>=['Inf'|'∞'] :my $*INF_VALUE := 1;
+ | [ <[-−]> :my $*NEGATE_VALUE := 1; ]? $<value>=<numish>
| <typename>
| where <.ws> <EXPR('i=')>
]
diff --git a/src/core/Numeric.pm b/src/core/Numeric.pm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment