The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral::NativeNumberSemantics - ECMAScript 262, Edition 5, lexical string numeric grammar default semantics package, using native perl representations

VERSION

version 0.015

DESCRIPTION

This modules provide a default semantics package for the actions associated to ECMAScript_262_5 lexical string numeric grammar, using native number representation, with the possible exceptions of positive zero and positive infinity: if one of them is not available natively, then the Math::BigFloat representation is used.

This module exports more methods, intended to provide a complete set of functions necessary for ECMAScript runtime.

The new() method returns an object hiding number implementation.

All method names starting with host_ return a value understandable only by the host.

All method names starting with is_ return a value understandable by perl, as well as the sign() and cmp() methods.

For every method, this module says if it should be overwriten in case of an alternate implementation. If there is no such mention this mean that the method in the package is only calling other methods. Therefore it is safe to use this module as a parent, provided that all methods marked as "should be overwriten", are as such.

new($class, %opts)

Instantiate a new object that has three members:

number

Initialized to $opts{number} or host's positive zero

length

Initialized to $opts{length} or host's positive zero

decimal

Initialized to a $opts{decimal} or a host's false value

These three members are independant values. "length" is used when evaluating a number with a dot character '.'. "decimal" is a flag setted by the grammar when the Mathematical value is done on a decimal literal. Unless stated, all methods are manipulating only the "number" component.

Should be overwriten in case of alternate implementation.

clone_init($self)

New instance that is a initialized clone of $self, like new() with no option.

clone($self)

Cloning of $self (i.e. copy of all $self's members). Returns a new instance.

Should be overwriten in case of alternate implementation, if internal member are not named _number, _length and _decimal and if simple assignment is not enough.

decimalOn($self)

Host implementation of $self's decimal setted to a true value. Returns $self.

Should be overwriten in case of alternate implementation, if internal member is not _decimal.

mul($self, $objmul)

Host implementation of $self's number multiplied by $objmul's number. Returns $self.

Should be overwriten in case of alternate implementation.

nan($self)

Host implementation of $self's number setted to nan, defaulting to Data::Float::nan if your host have it, Math::BigFloat's implementation otherwise. Returns $self.

Should be overwriten in case of alternate implementation.

pos_one($self)

Host implementation of $self's number setted to positive one, defaulting to +1. Returns $self.

Should be overwriten in case of alternate implementation.

neg_one($self)

Host implementation of $self's number setted to negative one, defaulting to -1. Returns $self.

Should be overwriten in case of alternate implementation.

pos_zero($self)

Host implementation of $self's number setted to positive zero, defaulting to Data::Float::pos_zero if your host have signed zeroes, 0 otherwise. Returns $self.

Should be overwriten in case of alternate implementation.

pos_inf($self)

Host implementation of $self's number setted to positive infinity, defaulting to Data::Float::pos_infinity if your host have infinity, otherwise a trial between (~0)**(~0) and {my $n = 2; $n *= $n while $n < $n*$n; $n}. Return $self.

Should be overwriten in case of alternate implementation.

pow($self, $powobj)

Host implementation of $self's number setted to 10 ** $powobj's number. Returns $self.

Should be overwriten in case of alternate implementation.

int($self, $string)

Host implementation of $self's number setted to positive integer represented in $string, length being initialized to the number of characters in $string. Returns $self.

Should be overwriten in case of alternate implementation.

hex($self, $string)

Host implementation of $self's number setted to positive hexadecimal integer represented in $string. Returns $self.

Should be overwriten in case of alternate implementation.

neg($self)

Host implementation of $self's number sign change. Returns $self.

Should be overwriten in case of alternate implementation.

abs($self)

Host implementation of absolute value applied to $self's number. Returns $self.

Should be overwriten in case of alternate implementation.

new_from_sign($self)

Host implementation of sign applied to $self. Returns a new instance initialized with neg_one() if $self's value is negative, pos_one() if $self's value is positive, nan() if $self's value is not a number.

new_from_cmp($self, $cmpobj)

Host implementation of comparison between $self and $cmpobj. Returns a new instance initialized with neg_one() if $self's value < $cmpobj's value, pos_one() if $self's value > $cmpobj's value, pos_zero() if $self's value == $cmpobj's value, nan() otherwise.

add($self, $addobj)

Host implementation of $addobj's number added to $self's number. Returns $self.

Should be overwriten in case of alternate implementation.

sub($self, $subobj)

Host implementation of $subobj's number substracted from $self's number. Returns $self.

Should be overwriten in case of alternate implementation.

inc_length($self)

Increase by one the length internal member of $self. This will be the host representation of a number of characters, used to evaluate internal number. Returns $self.

Should be overwriten in case of alternate implementation, if internal member is not named _length.

new_from_length($self)

Returns a new instance derived from the length internal member, initialized using $self->int(). Returns the new object instance.

Should be overwriten in case of alternate implementation, if internal member is not named _length.

sign($self)

Returns a perl's positive number if $self->host_value is a positive number, a perl's negative number if $self->host_value is a negative number, a perl's zero if $self->host_value is a zero, a perl's undef otherwise.

cmp($self, $cmpobj)

Alias for $self->new_from_cmp($cmpobj)->sign;

host_number($self)

Returns the internal $self's number hosted in $self.

Should be overwriten in case of alternate implementation, if internal member is not named _number.

host_value($self)

Returns the rounded internal $self's number hosted in $self.

Should be overwriten in case of alternate implementation.

is_zero($self)

Returns a perl's true or false if $self->host_value is zero. In case $self->host_value would be a blessed object, $self->host_value->is_zero() is returned if $self->host_value can do this method, otherwise undef is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_zero() method.

is_pos_one($self)

Returns a perl's true or false if $self->host_value is a +1. In case $self->host_value would be a blessed object, $self->host_value->is_one() is returned if $self->host_value can do this method, otherwise undef is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_one() method.

is_neg_one($self)

Returns a perl's true or false if $self->host_value is -1. In case $self->host_value would be a blessed object, $self->host_value->is_one('-') is returned if $self->host_value can do this method, otherwise undef is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_one('-') method.

is_pos($self)

Returns a perl's true or false if $self->host_value is a positive number. In case $self->host_value would be a blessed object, $self->host_value->is_pos() is returned if $self->host_value can do this method, otherwise undef is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_pos() method.

is_neg($self)

Returns a perl's true or false if $self->host_value is a negative number. In case $self->host_value would be a blessed object, $self->host_value->is_neg() is returned if $self->host_value can do this method, otherwise host's undefined value is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_neg() method.

is_inf($self)

Returns a perl's true or false if $self->host_value is infinite. In case $self->host_value would be a blessed object, $self->host_value->is_inf() is returned if $self->host_value can do this method, otherwise host's undefined value is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_inf() method.

is_nan($self)

Returns a perl's true or false if $self->host_value is not a number. In case $self->host_value would be a blessed object, $self->host_value->is_nan() is returned if $self->host_value can do this method, otherwise host's undefined is returned.

Should be overwriten in case of alternate implementation, if internal member is not named _number and is not an object supporting is_nan() method.

AUTHOR

Jean-Damien Durand <jeandamiendurand@free.fr>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Jean-Damien Durand.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.