[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-411-g04e13f1
ontologiae
ontologiae at ordinateur-de-ontologiae.local
Tue Aug 18 19:52:55 UTC 2009
The following commit has been merged in the master branch:
commit 10aee637ac103357ae7cf094efe04e12678b7e89
Author: ontologiae <ontologiae at ordinateur-de-ontologiae.local>
Date: Tue Aug 18 21:51:40 2009 +0200
number doc update
diff --git a/lib/number/integer.li b/lib/number/integer.li
index 125777e..04eeea0 100644
--- a/lib/number/integer.li
+++ b/lib/number/integer.li
@@ -42,7 +42,7 @@ Section Header
Section Insert
- - parent_numeric:NUMERIC := NUMERIC;
+ - inherit_numeric:NUMERIC := NUMERIC;
Section Public
@@ -50,19 +50,28 @@ Section Public
// Range.
//
- - maximum:UINTEGER_64 <- 07FFFFFFFh.to_raw_uinteger_64;
-
- - minimum:INTEGER_64 <- (- 07FFFFFFFh).to_raw_integer_64;
-
+ - maximum:UINTEGER_64 <-
+ // Maximum of integer
+ 07FFFFFFFh.to_raw_uinteger_64;
+
+ - minimum:INTEGER_64 <-
+ // Minimum of integer
+ (- 07FFFFFFFh).to_raw_integer_64;
+
//
// Binary Operator.
//
- - Self:SELF '%' Left 100 other:SELF :SELF <- Self - ((Self / other) * other);
+ - Self:SELF '%' Left 100 other:SELF :SELF <-
+ // Modulo
+ Self - ((Self / other) * other);
- - Self:SELF '%#' Left 100 other:INTEGER :SELF <- Self % other;
+ - Self:SELF '%#' Left 100 other:INTEGER :SELF <-
+ // Modulo
+ Self % other;
- Self:SELF '**' Right 120 exp:SELF :SELF <-
+ // Power
( + result:SELF;
(exp = 0).if {
@@ -137,33 +146,51 @@ Section Public
// Facility typing.
//
- - kb:SELF <- Self << 10;
-
- - mb:SELF <- Self << 20;
-
- - gb:SELF <- Self << 30;
-
- - tb:SELF <- Self << 40;
+ - kb:SELF <-
+ // Self in Kilobyte (ie. 1kb = 1024 bytes)
+ Self << 10;
+ - mb:SELF <-
+ // Self in megabytes
+ Self << 20;
+
+ - gb:SELF <-
+ // Self in gigabytes
+ Self << 30;
+
+ - tb:SELF <-
+ // Self in terabytes
+ Self << 40;
+
//
// Logic Operator
//
- - Self:SELF '&' Left 100 other:SELF :SELF <- `6`;
-
- - Self:SELF '|' Left 80 other:SELF :SELF <- ~(~Self & ~other);
-
- - Self:SELF '^' Left 80 other:SELF :SELF <- (~Self & other) | (Self & ~other);
+ - Self:SELF '&' Left 100 other:SELF :SELF <-
+ // AND operator
+ `6`;
+
+ - Self:SELF '|' Left 80 other:SELF :SELF <-
+ // OR operator
+ ~(~Self & ~other);
- - Self:SELF '>>' Left 100 other:INTEGER :SELF <- `7`;
+ - Self:SELF '^' Left 80 other:SELF :SELF <-
+ // XOR operator
+ (~Self & other) | (Self & ~other);
- - Self:SELF '<<' Left 100 other:INTEGER :SELF <- `8`;
+ - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
+ // Shift right
+ `7`;
+
+ - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
+ // Shift left
+ `8`;
//
// Unary operator
//
- - '~' Self:SELF :SELF <- -Self - SELF.one; //(-SELF.one) - Self;
+ - '~' Self:SELF :SELF <- -Self - SELF.one;
//
// Test.
@@ -180,6 +207,7 @@ Section Public
);
- is_power_2:BOOLEAN <-
+ // TRUE is Self is power of 2
( + val:SELF;
+ result:BOOLEAN;
@@ -198,6 +226,7 @@ Section Public
//
- sqrt:SELF <-
+ // Square root
( + r,x:SELF;
x:=(Self + 1) >> 1;
@@ -208,9 +237,13 @@ Section Public
r
);
- - Self:SELF '!' :SELF <- factorial;
+ - Self:SELF '!' :SELF <-
+ // Factorial. Use it like "45!;" or "bar!.print;"
+ factorial;
- factorial:SELF <-
+ // Factorial
+ // * Require: Self >= 0
[
-? {Self >= 0};
]
@@ -226,6 +259,8 @@ Section Public
);
- fibonacci:SELF <-
+ // Fibonacci
+ // * Require: Self >= 0
[
-? {Self >= 0};
]
@@ -239,12 +274,19 @@ Section Public
result
);
- - is_odd:BOOLEAN <- (Self & 1) = 1; // Is odd ?
-
- - is_even:BOOLEAN <- ! is_odd; // Is even ?
-
+ - is_odd:BOOLEAN <-
+ // Is odd ?
+ (Self & 1) = 1;
+
+ - is_even:BOOLEAN <-
+ // Is even ?
+ ! is_odd;
+
- gcd other:SELF :SELF <-
// Great Common Divisor of `self' and `other'.
+ // * Require: Self >= 0
+ // * Require: `other' >= 0
+ // * Ensure:
[
-? {Self >= 0};
-? {other >= 0};
@@ -378,7 +420,7 @@ Section Public
// Convert the hexadecimal view of `self' into a new allocated
// STRING. For example, if `self' is -1 the new STRING is
// "FFFFFFFF" on a 32 bit machine.
- // Note: see also `to_hexadecimal_in' to save memory.
+ // * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
result := STRING.create 8;
@@ -390,7 +432,7 @@ Section Public
// Convert the hexadecimal view of `self' into a new allocated
// STRING. For example, if `self' is -1 the new STRING is
// "FFFFFFFF" on a 32 bit machine.
- // Note: see also `to_hexadecimal_in' to save memory.
+ // * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
result := STRING.create 8;
@@ -452,6 +494,7 @@ Section Public
- to_binary_in buffer:STRING format s:INTEGER <-
// Append in `buffer' the equivalent of `to_binary_string'. No new STRING
// creation during the process.
+ // * Require: buffer not null
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
@@ -479,13 +522,16 @@ Section Public
// Hashing:
//
- - hash_code:INTEGER <- to_integer_32.hash_code; // BSBS: Il faut revoir => Depending processor
+ - hash_code:INTEGER <-
+ // Hash code
+ to_integer_32.hash_code; // BSBS: Il faut revoir => Depending processor
//
// Print
//
- print <-
+ // Print
(
(Self = 0).if {
'0'.print;
@@ -499,6 +545,7 @@ Section Public
- print_positif <-
// Display this number without memory.
+ // * Require: Self >= 0
[ -? {Self >=# 0}; ]
( + char:CHARACTER;
+ val:SELF;
diff --git a/lib/number/integer_big.e_to_li b/lib/number/integer_big.e_to_li
old mode 100755
new mode 100644
diff --git a/lib/number/low_level/numeric.li b/lib/number/low_level/numeric.li
index 19802a1..7a6657d 100644
--- a/lib/number/low_level/numeric.li
+++ b/lib/number/low_level/numeric.li
@@ -126,20 +126,27 @@ Section Public
//
- when value:SELF then block:{} :SELF <-
+ // when `value' equals `Self', execute `block'
+ // You can chain "when ... then ..." between them like : <br/>
+ // bar.when 1 then { // code }.when 2 then { // code 2 }
(
(Self = value).if block;
Self
);
- when value1:SELF or value2:SELF then block:{} :SELF <-
+ // when `value1' or `value2' equal `Self', execute `block'
(
((Self = value1) || {Self = value2}).if block;
Self
);
- when first_value:SELF to last_value:SELF then block:{} :SELF <-
- ( ? {first_value <= last_value};
-
+ // Execute `block' when `Self' is in range of `first_value' to `last_value'
+ [
+ ?- {first_value <= last_value}; //PAPA: debug manager ou contrat ?
+ ]
+ (
((Self >= first_value) && {Self <= last_value}).if block;
Self
);
@@ -149,6 +156,7 @@ Section Public
//
- to limit_up:SELF do blc:{SELF;} <-
+ // Classical loop from `Self' to `limit_up'
(
(Self <= limit_up).if {
blc.value Self;
@@ -157,6 +165,7 @@ Section Public
);
- downto limit_down:SELF do blc:{SELF;} <-
+ // Classical backward loop from `Self' to `limit_up'
(
(Self >= limit_down).if {
blc.value Self;
@@ -165,6 +174,7 @@ Section Public
);
- to limit_up:SELF by step:SELF do blc:{SELF;} <-
+ // Classical loop from `Self' to `limit_up' stepping `step'
(
(Self <= limit_up).if {
blc.value Self;
@@ -173,6 +183,7 @@ Section Public
);
- downto limit_down:SELF by step:SELF do blc:{SELF;} <-
+ // Classical backward loop from `Self' to `limit_up' stepping `step'
(
(Self >= limit_down).if {
blc.value Self;
@@ -185,7 +196,7 @@ Section Public
//
- abs:SELF <-
- // Absolute value of `self'.
+ // Absolute value of `Self'.
( + result:SELF;
(Self < 0).if {
@@ -197,6 +208,7 @@ Section Public
);
- min other:SELF :SELF <-
+ // Minimum between value of `Self' and `other'
( + result:SELF;
(Self > other).if {
@@ -208,6 +220,7 @@ Section Public
);
- max other:SELF :SELF <-
+ // Maximum between value of `Self' and `other'
( + result:SELF;
(Self > other).if {
@@ -225,7 +238,7 @@ Section Public
- to_string:STRING <-
// Convert the decimal view of `self' into a new allocated STRING.
// For example, if `self' is -1 the new STRING is -1.
- // Note: see also `append_in' to save memory.
+ // * See: `append_in' to save memory.
( + result:STRING;
result := STRING.create 11;
@@ -233,7 +246,9 @@ Section Public
result
);
- - to_boolean:BOOLEAN <- Self != 0;
+ - to_boolean:BOOLEAN <-
+ // TRUE if `Self' not zero
+ Self != 0;
- append_in buffer:STRING <- deferred;
// Append in the `buffer' the equivalent of `to_string'. No new STRING
@@ -242,7 +257,9 @@ Section Public
- to_string_format s:SELF :STRING <-
// Same as `to_string' but the result is on `s' character and the
// number is right aligned.
- // Note: see `append_in_format' to save memory.
+ // * Require: s size large enough for `Self'
+ // * Ensure: `s' >= of size of stringed `Self'
+ // * See: `append_in_format' to save memory.
[
-? {to_string.count <= s};
]
@@ -269,6 +286,9 @@ Section Public
// Append the equivalent of `to_string_format' at the end of
// `str'. Thus you can save memory because no other
// STRING is allocate for the job.
+ // * Require: str not null
+ // * Require: `s' >= of size of stringed `Self'
+ // * Ensure: size of `str' is equal to former `str' size plus `s'
[
-? {str != NULL};
-? {to_string.count <= s};
@@ -288,6 +308,7 @@ Section Public
//
- print <-
+ // Print
(
string_tmp.clear;
append_in string_tmp;
@@ -295,6 +316,7 @@ Section Public
);
- print_format s:SELF <-
+ // Print with format size `s'
(
string_tmp.clear;
append_in string_tmp format s;
@@ -302,6 +324,7 @@ Section Public
);
- print_format s:SELF with c:CHARACTER <-
+ // Print with format size `s' replacing blank character by `c'
(
string_tmp.clear;
append_in string_tmp format s with c;
diff --git a/lib/number/real.li b/lib/number/real.li
index f1ce82e..bf2a321 100644
--- a/lib/number/real.li
+++ b/lib/number/real.li
@@ -35,7 +35,7 @@ Section Header
Section Insert
- - parent_numeric:NUMERIC := NUMERIC;
+ - inherit_numeric:NUMERIC := NUMERIC;
Section Public
@@ -47,25 +47,34 @@ Section Public
);
- pi :SELF <- 3.14159265358979323846;
+ // Pi number
- atan :SELF <- `atan(@Self)`:SELF;
+ // Arctangent
- sqrt :SELF <- `sqrt(@Self)`:SELF;
+ // Square root
- log :SELF <- `log(@Self)`:SELF;
+ // Logarithm
- sin :SELF <- `sin(@Self)`:SELF;
+ // Sinus
- cos :SELF <- `cos(@Self)`:SELF;
+ // Cosinus
- pow exp:SELF :SELF <- `pow(@Self, at exp)`:SELF;
+ // Power
- Self:SELF '**' Right 120 exp:SELF :SELF <-
+ // Power
(
Self.pow exp
);
- Self:SELF '^' Right 120 exp:SELF :SELF <-
+ // Power
(
Self.pow exp
);
@@ -100,6 +109,7 @@ Section Public
//
- Self:SELF '~=' other:SELF :BOOLEAN <-
+ // Equal, close to 0.001
(
(Self - other).abs < 0.001
);
@@ -113,13 +123,14 @@ Section Public
//
- append_in buffer:STRING <-
+ // Append `Self' decimal representation in `buffer' with 4 decimal
(
append_in buffer decimal 4;
);
- to_string : STRING <-
- // *French, Slot, Description : Renvoi une chaîne représentant le nombre en base 10
- // *English, Slot, Description : String of the number in base 10
+ // * French: Renvoi une chaîne représentant le nombre en base 10
+ // String of the number in base 10
( + result : STRING;
result := STRING.create 0;
append_in result;
@@ -132,6 +143,7 @@ Section Public
);
- append_in buffer:STRING format n:INTEGER with c:CHARACTER decimal d:INTEGER <-
+ // String of the number in base 10 with `c' replacing blanck
[
-? {n >= 3};
]
@@ -143,6 +155,7 @@ Section Public
);
- append_in buffer:STRING decimal n:INTEGER <-
+ // String of the number in base 10 with 4 decimal
( + val:SELF;
+ val_10:INTEGER;
+ char:CHARACTER;
@@ -191,6 +204,7 @@ Section Public
);
- scientific_append_in buffer:STRING <-
+ // Scientific number representation
( + val:SELF;
+ val_10:INTEGER;
+ exp_10:INTEGER;
@@ -253,6 +267,7 @@ Section Public
);
- print_decimal s:INTEGER <-
+ // print with `s' decimal
(
string_tmp.clear;
append_in string_tmp decimal s;
diff --git a/lib/number/uinteger.li b/lib/number/uinteger.li
index 5428b51..7607a83 100644
--- a/lib/number/uinteger.li
+++ b/lib/number/uinteger.li
@@ -142,27 +142,36 @@ Section Public
//
- kb:SELF <- Self << 10;
-
+ // Self in Kilobyte (ie. 1kb = 1024 bytes)
+
- mb:SELF <- Self << 20;
-
+ // Self in megabytes
+
- gb:SELF <- Self << 30;
-
+ // Self in gigabytes
+
- tb:SELF <- Self << 40;
-
+ // Self in terabytes
+
//
// Logic Operator
//
- Self:SELF '&' Left 100 other:SELF :SELF <- `6`;
-
+ // AND operator
+
- Self:SELF '|' Left 80 other:SELF :SELF <- ~(~Self & ~other);
-
+ // OR operator
+
- Self:SELF '^' Left 80 other:SELF :SELF <- (~Self & other) | (Self & ~other);
+ // XOR operator
- Self:SELF '>>' Left 100 other:INTEGER :SELF <- `7`;
+ // Shift right
- Self:SELF '<<' Left 100 other:INTEGER :SELF <- `8`;
-
+ // Shift left
+
//
// Unary operator
//
@@ -184,6 +193,7 @@ Section Public
);
- is_power_2:BOOLEAN <-
+ // TRUE is Self is power of 2
( + val:SELF;
+ result:BOOLEAN;
@@ -202,6 +212,7 @@ Section Public
//
- sqrt:SELF <-
+ // Square root
( + r,x:SELF;
x:=(Self + 1) >> 1;
@@ -213,8 +224,11 @@ Section Public
);
- Self:SELF '!' :SELF <- factorial;
+ // Factorial. Use it like "45!;" or "bar!.print;"
- factorial:SELF <-
+ // Factorial.
+ // * Require: Self >= 0
[
-? {Self >= 0};
]
@@ -230,6 +244,8 @@ Section Public
);
- fibonacci:SELF <-
+ // Fibonacci
+ // * Require: Self >= 0
[
-? {Self >= 0};
]
@@ -382,7 +398,7 @@ Section Public
// Convert the hexadecimal view of `self' into a new allocated
// STRING. For example, if `self' is -1 the new STRING is
// "FFFFFFFF" on a 32 bit machine.
- // Note: see also `to_hexadecimal_in' to save memory.
+ // * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
result := STRING.create 8;
@@ -394,7 +410,7 @@ Section Public
// Convert the hexadecimal view of `self' into a new allocated
// STRING. For example, if `self' is -1 the new STRING is
// "FFFFFFFF" on a 32 bit machine.
- // Note: see also `to_hexadecimal_in' to save memory.
+ // * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
result := STRING.create 8;
--
Lisaac compiler
More information about the Lisaac-commits
mailing list