forked from parrot/cardinal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify src/parser/actions.pm to return CardinalFloat instead Float:
to keep ruby class inheritances add new classes: CardinalNumeric CardinalFloat add new methods: Integer#chr Integer#even Integer#odd Float#to_f Float#zero fixme: Cardinal#round round does not return C<self> see ruby-1.9.2-p180/numeric.c:3188 also src/classes/Integer.pir:326
- Loading branch information
Daehyub Kim
committed
May 15, 2011
1 parent
a6751a2
commit c4f6029
Showing
11 changed files
with
193 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# $Id$ | ||
|
||
=head1 NAME | ||
|
||
src/classes/Float.pir - Cardinal CardinalFloat class and related functions | ||
|
||
=head1 Methods | ||
|
||
=over | ||
|
||
=item onload() | ||
|
||
initialize CardinalFloat and it's inheritance | ||
=cut | ||
.namespace ['CardinalFloat'] | ||
.sub 'onload' :anon :load :init | ||
.local pmc cardinalmeta, floatproto | ||
cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA' | ||
floatproto = cardinalmeta.'new_class'('CardinalFloat', 'parent'=>'parrot;Float CardinalNumeric') | ||
cardinalmeta.'register'('Float', 'parent'=>'CardinalObject', 'protoobject'=>floatproto) | ||
.end | ||
=item to_f() | ||
return C<self> | ||
=cut | ||
.sub 'to_f' :method | ||
.return (self) | ||
.end | ||
=item zero?() | ||
return true when if C<self> is 0.0 | ||
=cut | ||
.sub 'zero?' :method | ||
eq self, 0.0, is_zero | ||
$P0 = get_hll_global 'false' | ||
goto done | ||
is_zero: | ||
$P0 = get_hll_global 'true' | ||
done: | ||
.return ($P0) | ||
.end | ||
=back | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# $Id$ | ||
|
||
=head1 NAME | ||
|
||
src/classes/Numeric.pir - Cardinal CardinalNumeric class and related functions | ||
|
||
=cut | ||
|
||
.namespace ['CardinalNumeric'] | ||
|
||
.sub 'onload' :anon :load :init | ||
.local pmc cardinalmeta, numericproto | ||
cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA' | ||
numericproto = cardinalmeta.'new_class'('CardinalNumeric', 'parent'=>'CardinalObject') | ||
.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'Test' | ||
include Test | ||
|
||
plan 1 | ||
|
||
a = 1.0 | ||
is a, 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'Test' | ||
include Test | ||
|
||
plan 2 | ||
|
||
a = 0.0 | ||
is a.zero?, true | ||
|
||
b = 1.0 | ||
is b.zero?, false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'Test' | ||
include Test | ||
|
||
plan 2 | ||
|
||
a = 0.even? | ||
is a, true | ||
|
||
b = 1.even? | ||
is b, false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'Test' | ||
include Test | ||
|
||
plan 2 | ||
|
||
a = 1.odd? | ||
is a, true | ||
|
||
b = 2.odd? | ||
is b, false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'Test' | ||
include Test | ||
|
||
plan 3 | ||
|
||
a = 1.round | ||
is a, 1 | ||
|
||
skip 'round with positive ndigit', 'pir' | ||
skip 'round with negative ndigit', 'pir' |