Skip to content

Commit

Permalink
Merge branch 'nom' into newio
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Feb 14, 2015
2 parents 8f6d7db + 98de201 commit 7418eeb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/core/Rational.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ my role Rational[::NuT, ::DeT] does Real {
$s ~= ($i+1).base($base) if $x == 0; # never happens?
}
}
$s ~= '.';
state @digits = '0'..'9', 'A'..'Z';
$s ~= @digits[@f].join;
if @f {
$s ~= '.';
state @digits = '0'..'9', 'A'..'Z';
$s ~= @digits[@f].join;
}
}
$s;
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/Temporal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,19 @@ my class DateTime does Dateish {
}
}

multi method new(Date :$date!, *%_) {
multi method new(Date:D :$date!, *%_) {
self.new(year => $date.year, month => $date.month,
day => $date.day, |%_)
}

multi method new(Instant $i, :$timezone=0, :&formatter=&default-formatter) {
multi method new(Instant:D $i, :$timezone=0, :&formatter=&default-formatter) {
my ($p, $leap-second) = $i.to-posix;
my $dt = self.new: floor($p - $leap-second).Int, :&formatter;
$dt.clone(second => ($dt.second + $p % 1 + $leap-second)
).in-timezone($timezone);
}

multi method new(Int $time is copy, :$timezone=0, :&formatter=&default-formatter) {
multi method new(Int:D $time is copy, :$timezone=0, :&formatter=&default-formatter) {
# Interpret $time as a POSIX time.
my $second = $time % 60; $time = $time div 60;
my $minute = $time % 60; $time = $time div 60;
Expand All @@ -258,7 +258,7 @@ my class DateTime does Dateish {
or X::Temporal::InvalidFormat.new(
invalid-str => $format,
target => 'DateTime',
format => 'an ISO 8601 timestamp (yyyy-mm-ddThh::mm::ssZ or yyyy-mm-ddThh::mm::ss+0100)',
format => 'an ISO 8601 timestamp (yyyy-mm-ddThh:mm:ssZ or yyyy-mm-ddThh:mm:ss+0100)',
).throw;
my $year = (+$0).Int;
my $month = (+$1).Int;
Expand All @@ -281,7 +281,7 @@ my class DateTime does Dateish {
:$second, :$timezone, :&formatter);
}

method now(:$timezone=$*TZ, :&formatter=&default-formatter) {
method now(:$timezone=$*TZ, :&formatter=&default-formatter) returns DateTime:D {
self.new(now, :$timezone, :&formatter)
}

Expand Down
42 changes: 42 additions & 0 deletions src/vm/moar/ops/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ static void rakudo_scalar_fetch(MVMThreadContext *tc, MVMObject *cont, MVMRegist
res->o = ((Rakudo_Scalar *)cont)->value;
}

static void rakudo_scalar_fetch_i(MVMThreadContext *tc, MVMObject *cont, MVMRegister *res) {
res->i64 = MVM_repr_get_int(tc, ((Rakudo_Scalar *)cont)->value);
}

static void rakudo_scalar_fetch_n(MVMThreadContext *tc, MVMObject *cont, MVMRegister *res) {
res->n64 = MVM_repr_get_num(tc, ((Rakudo_Scalar *)cont)->value);
}

static void rakudo_scalar_fetch_s(MVMThreadContext *tc, MVMObject *cont, MVMRegister *res) {
res->s = MVM_repr_get_str(tc, ((Rakudo_Scalar *)cont)->value);
}

MVMObject * get_nil();
MVMObject * get_mu();

Expand Down Expand Up @@ -149,6 +161,30 @@ static void rakudo_scalar_store(MVMThreadContext *tc, MVMObject *cont, MVMObject
finish_store(tc, cont, obj);
}

static void rakudo_scalar_store_i(MVMThreadContext *tc, MVMObject *cont, MVMint64 value) {
MVMObject *boxed;
MVMROOT(tc, cont, {
boxed = MVM_repr_box_int(tc, MVM_hll_current(tc)->int_box_type, value);
});
rakudo_scalar_store(tc, cont, boxed);
}

static void rakudo_scalar_store_n(MVMThreadContext *tc, MVMObject *cont, MVMnum64 value) {
MVMObject *boxed;
MVMROOT(tc, cont, {
boxed = MVM_repr_box_num(tc, MVM_hll_current(tc)->num_box_type, value);
});
rakudo_scalar_store(tc, cont, boxed);
}

static void rakudo_scalar_store_s(MVMThreadContext *tc, MVMObject *cont, MVMString *value) {
MVMObject *boxed;
MVMROOT(tc, cont, {
boxed = MVM_repr_box_str(tc, MVM_hll_current(tc)->str_box_type, value);
});
rakudo_scalar_store(tc, cont, boxed);
}

static void rakudo_scalar_store_unchecked(MVMThreadContext *tc, MVMObject *cont, MVMObject *obj) {
finish_store(tc, cont, obj);
}
Expand Down Expand Up @@ -180,7 +216,13 @@ static void rakudo_scalar_spesh(MVMThreadContext *tc, MVMSTable *st, MVMSpeshGra
static const MVMContainerSpec rakudo_scalar_spec = {
"rakudo_scalar",
rakudo_scalar_fetch,
rakudo_scalar_fetch_i,
rakudo_scalar_fetch_n,
rakudo_scalar_fetch_s,
rakudo_scalar_store,
rakudo_scalar_store_i,
rakudo_scalar_store_n,
rakudo_scalar_store_s,
rakudo_scalar_store_unchecked,
rakudo_scalar_spesh,
NULL,
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2015.01-40-gf7586fc
2015.01-42-g2776313

0 comments on commit 7418eeb

Please sign in to comment.