[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-561-g341b23b
Benoit Sonntag
sonntag at icps.u-strasbg.fr
Wed Jan 6 04:14:31 UTC 2010
The following commit has been merged in the master branch:
commit 341b23b8ba23ecef3c8a6088d6712557a425b37f
Author: Benoit Sonntag <sonntag at icps.u-strasbg.fr>
Date: Wed Jan 6 05:13:57 2010 +0100
add http_server lib
diff --git a/lib/internal/portable/collection/hash_table_size.li b/lib/internal/portable/collection/hash_table_size.li
index 48933c4..3ede403 100644
--- a/lib/internal/portable/collection/hash_table_size.li
+++ b/lib/internal/portable/collection/hash_table_size.li
@@ -19,35 +19,35 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := HASH_TABLE_SIZE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Prime INTEGER list.";
- // Some useful features to deal with prime INTEGER values in order to select
- // an appropriate size for some hash table (used for example by the DICTIONARY
+ // Some useful features to deal with prime INTEGER values in order to select
+ // an appropriate size for some hash table (used for example by the DICTIONARY
// class as well as by the SET class).
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
- prime_number_ceiling integer:INTEGER :INTEGER <-
// A good prime number, large enough, and no smaller than `integer'.
( + result:INTEGER;
-
+
(integer <= 11).if {
// This seems to be a good minimum value to start hashing with.
result := 11;
}.elseif { integer <= 23 } then {
result := 23;
- }.elseif { integer <= 53 } then {
- result := 53;
+ }.elseif { integer <= 53 } then {
+ result := 53;
}.elseif { integer <= 97 } then {
result := 97;
}.elseif { integer <= 193 } then {
@@ -100,9 +100,8 @@ Section Public
result := 1610612741;
// This should be enough !
};
-
+
? {result >= integer};
-
+
result
);
-
\ No newline at end of file
diff --git a/lib/standard/collection/hashed_dictionary.li b/lib/standard/collection/hashed_dictionary.li
index d7966b7..a20916d 100644
--- a/lib/standard/collection/hashed_dictionary.li
+++ b/lib/standard/collection/hashed_dictionary.li
@@ -19,84 +19,84 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := HASHED_DICTIONARY(V,K);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := " Associative memory.\
\Values of type `V' are stored using Keys of type `K'.";
-
- // Efficient implementation of DICTIONARY using `hash_code' on keys.
-
+
+ // Efficient implementation of DICTIONARY using `hash_code' on keys.
+
Section Inherit
-
+
- parent_simple_dictionary:Expanded SIMPLE_DICTIONARY(V,K);
-
+
Section Public
// HASHED_DICTIONARY
-
+
+ buckets:NATIVE_ARRAY(HASHED_DICTIONARY_NODE(V,K));
// The `buckets' storage area is the primary hash table of `capacity'
// elements. To search some key, the first access is done in `buckets'
// using the remainder of the division of the key `hash_code' by
// `capacity'. In order to try to avoid clashes, `capacity' is always a
// prime number (selected using HASH_TABLE_SIZE).
-
+
Section Public
-
+
- default_size:INTEGER := 193;
// Default size for the storage area in number of items.
-
+
// Counting:
-
+
+ capacity:INTEGER;
// Of the `buckets' storage area.
-
+
+ count:INTEGER;
// Actual `count' of stored elements.
-
- //
+
+ //
// Basic access:
//
-
+
- has k:K :BOOLEAN <-
// Is there a value currently associated with key `k'?
( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
idx := k.hash_code % capacity;
- node := buckets.item idx;
+ node := buckets.item idx;
{(node = NULL) || {node.key == k}}.until_do {
node := node.next;
};
node != NULL
);
-
+
- at k:K :V <-
// Return the value associated to key `k'.
// (See also `reference_at' if V is a reference type.)
( + idx:INTEGER;
- + node:HASHED_DICTIONARY_NODE(V,K);
-
+ + node:HASHED_DICTIONARY_NODE(V,K);
+
idx := k.hash_code % capacity;
- node := buckets.item idx;
+ node := buckets.item idx;
{node.key == k}.until_do {
node := node.next;
};
node.item
);
-
+
- reference_at k:K :V <-
- // Return NULL or the value associated with key `k'. Actually, this
- // feature is useful when the type of values (the type E) is a
- // reference type, to avoid using `has' just followed by `at' to get
+ // Return NULL or the value associated with key `k'. Actually, this
+ // feature is useful when the type of values (the type E) is a
+ // reference type, to avoid using `has' just followed by `at' to get
// the corresponding value.
( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
+ result:V;
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) ||{node.key == k}}.until_do {
@@ -104,19 +104,19 @@ Section Public
};
(node != NULL).if {
result := node.item;
- };
+ };
result
);
- reference_at k:K with cmp:{(K,K); BOOLEAN} :V <-
- // Return NULL or the value associated with key `k'. Actually, this
- // feature is useful when the type of values (the type E) is a
- // reference type, to avoid using `has' just followed by `at' to get
+ // Return NULL or the value associated with key `k'. Actually, this
+ // feature is useful when the type of values (the type E) is a
+ // reference type, to avoid using `has' just followed by `at' to get
// the corresponding value.
( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
+ result:V;
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) ||{cmp.value (node.key,k)}}.until_do {
@@ -124,14 +124,14 @@ Section Public
};
(node != NULL).if {
result := node.item;
- };
+ };
result
);
-
+
- fast_has k:K :BOOLEAN <-
- ( + idx:INTEGER;
+ ( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) || {node.key = k}}.until_do {
@@ -141,9 +141,9 @@ Section Public
);
- fast_at k:K :V <-
- ( + idx:INTEGER;
+ ( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
{node.key = k}.until_do {
@@ -151,16 +151,16 @@ Section Public
};
node.item
);
-
+
- fast_reference_at k:K :V <-
- // Return NULL or the value associated with key `k'. Actually, this
- // feature is useful when the type of values (the type V) is a
- // reference type, to avoid using `has' just followed by `at' to get
+ // Return NULL or the value associated with key `k'. Actually, this
+ // feature is useful when the type of values (the type V) is a
+ // reference type, to avoid using `has' just followed by `at' to get
// the corresponding value.
( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
+ result:V;
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) || {node.key = k}}.until_do {
@@ -168,11 +168,11 @@ Section Public
};
( node != NULL ).if {
result := node.item;
- };
+ };
result
);
-
-Section Public
+
+Section Public
- put v:V to k:K <-
// Change some existing entry or `add' the new one. If there is
@@ -180,11 +180,11 @@ Section Public
// Otherwise overwrite the item associated with key `k'.
( + h, idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
h := k.hash_code;
idx := h % capacity;
node := buckets.item idx;
-
+
{(node = NULL) || {node.key == k}}.until_do {
node := node.next;
};
@@ -199,20 +199,20 @@ Section Public
cache_user := -1;
} else {
node.set_item v;
- };
+ };
);
-
+
- put v:V to k:K with cmp:{(K,K); BOOLEAN} <-
// Change some existing entry or `add' the new one. If there is
// as yet no key `k' in the dictionary, enter it with item `v'.
// Otherwise overwrite the item associated with key `k'.
( + h, idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
h := k.hash_code;
idx := h % capacity;
node := buckets.item idx;
-
+
{(node = NULL) || {cmp.value (node.key,k)}}.until_do {
node := node.next;
};
@@ -227,7 +227,7 @@ Section Public
cache_user := -1;
} else {
node.set_item v;
- };
+ };
);
- fast_put v:V to k:K <-
@@ -236,11 +236,11 @@ Section Public
// Otherwise overwrite the item associated with key `k'.
( + h, idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
h := k.hash_code;
idx := h % capacity;
node := buckets.item idx;
-
+
{(node = NULL) || {node.key = k}}.until_do {
node := node.next;
};
@@ -255,15 +255,15 @@ Section Public
cache_user := -1;
} else {
node.set_item v;
- };
+ };
);
-
+
- add v:V to k:K <-
// To add a new entry `k' with its associated value `v'. Actually, this
// is equivalent to call `put', but may run a little bit faster.
( + idx:INTEGER;
+ node:HASHED_DICTIONARY_NODE(V,K);
-
+
cache_user := -1;
(capacity = count ).if {
increase_capacity;
@@ -271,18 +271,18 @@ Section Public
idx := k.hash_code % capacity;
node:= new_node v to k next (buckets.item idx);
buckets.put node to idx;
- count := count + 1;
+ count := count + 1;
);
-
+
//
// Removing:
//
-
+
- remove k:K <-
// Remove entry `k' (which may exist or not before this call).
( + h, idx:INTEGER;
- + node, previous_node:HASHED_DICTIONARY_NODE(V,K);
-
+ + node, previous_node:HASHED_DICTIONARY_NODE(V,K);
+
cache_user := -1;
h := k.hash_code;
idx := h % capacity;
@@ -304,11 +304,11 @@ Section Public
previous_node.set_next (node.next);
};
};
- };
+ };
);
-
+
- fast_remove k:K <-
- ( + h, idx:INTEGER;
+ ( + h, idx:INTEGER;
+ node, previous_node:HASHED_DICTIONARY_NODE(V,K);
cache_user := -1;
@@ -323,7 +323,7 @@ Section Public
} else {
previous_node := node;
node := node.next;
- {(node = NULL) || {node.key = k}}.until_do {
+ {(node = NULL) || {node.key = k}}.until_do {
previous_node := node;
node := node.next;
};
@@ -334,34 +334,34 @@ Section Public
};
};
);
-
+
- clear <-
// Discard all items.
- (
+ (
cache_user := -1;
- count := 0;
+ count := 0;
buckets.set_all_with NULL until (capacity - 1);
)
- [
+ [
+? {capacity = Old capacity};
];
-
+
//
// To provide iterating facilities:
//
-
+
- item i:INTEGER :V <-
- (
+ (
set_cache_user i;
- cache_node.item
+ cache_node.item
);
-
+
- key index:INTEGER :K <-
- (
+ (
set_cache_user index;
- cache_node.key
+ cache_node.key
);
-
+
- key_map_in buffer:COLLECTION(K) <-
// Append in `buffer', all available keys (this may be useful to
// speed up the traversal).
@@ -369,17 +369,17 @@ Section Public
+ idx:INTEGER;
node := buckets.item idx;
- count.downto 1 do { i:INTEGER;
+ count.downto 1 do { i:INTEGER;
{node != NULL}.until_do {
idx := idx + 1;
? {idx < capacity};
node := buckets.item idx;
- };
+ };
buffer.add_last (node.key);
node := node.next;
- };
+ };
);
-
+
- item_map_in buffer:COLLECTION(V) <-
// Append in `buffer', all available items (this may be useful to
// speed up the traversal).
@@ -395,57 +395,57 @@ Section Public
};
buffer.add_last (node.item);
node := node.next;
- };
+ };
);
-
+
- copy other:SELF <-
// Reinitialize by copying all associations of `other'.
- (
+ (
clear;
(capacity < other.count).if {
with_capacity (other.count + 1);
}.elseif {capacity = 0} then {
make;
- };
-
+ };
+
1.to (other.count) do { i:INTEGER;
put (other.item i) to (other.key i);
- };
+ };
);
-
+
//
// Other features:
//
-
+
- internal_key k:K :K <-
// Retrieve the internal key object which correspond to the existing
// entry `k' (the one memorized into the `self' dictionary).
( + node:HASHED_DICTIONARY_NODE(V,K);
+ result:K;
-
+
node := buckets.item (k.hash_code % capacity);
result := node.key;
{result == k}.until_do {
node := node.next;
result := node.key;
- };
+ };
result
);
-
+
Section Private
-
+
- increase_capacity <-
// There is no more free slots:the dictionary must grow.
- [
+ [
-? {capacity = count};
]
- ( + idx, new_capacity,i:INTEGER;
+ ( + idx, new_capacity,i:INTEGER;
+ old_buckets:NATIVE_ARRAY(HASHED_DICTIONARY_NODE(V,K));
+ node1, node2:HASHED_DICTIONARY_NODE(V,K);
-
+
old_buckets := buckets;
new_capacity := HASH_TABLE_SIZE.prime_number_ceiling (capacity + 1);
-
+
buckets := NATIVE_ARRAY(HASHED_DICTIONARY_NODE(V,K)).create new_capacity;
i := capacity -1;
capacity := new_capacity;
@@ -457,30 +457,30 @@ Section Private
node1.set_next (buckets.item idx);
buckets.put node1 to idx;
node1 := node2;
- };
+ };
i := i - 1;
- };
+ };
cache_user := -1;
)
[
+? { count = Old count };
- +? { capacity > Old capacity };
+ +? { capacity > Old capacity };
];
-
+
- set_cache_user index:INTEGER <-
// Set the internal memory cache (`cache_user', `cache_node' and
// `cache_buckets') to the appropriate valid value.
[
-? { valid_index index };
]
- (
+ (
(index = cache_user + 1).if {
cache_user := index;
cache_node := cache_node.next;
{cache_node != NULL}.until_do {
cache_buckets := cache_buckets + 1;
cache_node := buckets.item cache_buckets;
- };
+ };
}.elseif {index = cache_user} then {
}.elseif {index = 1} then {
cache_user := 1;
@@ -489,21 +489,21 @@ Section Private
{cache_node != NULL}.until_do {
cache_buckets := cache_buckets + 1;
cache_node := buckets.item cache_buckets;
- };
+ };
} else {
set_cache_user 1;
{cache_user = index}.until_do {
set_cache_user (cache_user + 1);
- };
- };
+ };
+ };
)
- [
+ [
...
+? {cache_user = index};
+? {cache_buckets.in_range 0 to (capacity - 1)};
+? {cache_node != NULL};
];
-
+
+ cache_user:INTEGER;
// The last user's external index in range [1 .. `count'] (see `item'
// and `valid_index' for example) may be saved in `cache_user' otherwise
@@ -537,16 +537,16 @@ Section Private
(
HASHED_DICTIONARY_NODE(V,K).create v to k next nxt
);
-
+
Section Public
-
+
- create:SELF <-
( + result:SELF;
result := clone;
result.make;
result
);
-
+
- make <-
// Create an empty dictionary. Internal storage `capacity' of the
// dictionary is initialized using the `Default_size' value. Then,
@@ -556,11 +556,11 @@ Section Public
// `with_capacity' to save some execution time.
(
with_capacity default_size;
- )
- [
+ )
+ [
+? {capacity = default_size};
];
-
+
- with_capacity medium_size:INTEGER <-
// May be used to save some execution time if one is sure that
// storage size will rapidly become really bigger than `Default_size'.
@@ -571,7 +571,7 @@ Section Public
-? { medium_size > 0 };
]
( + new_capacity:INTEGER;
-
+
new_capacity := HASH_TABLE_SIZE.prime_number_ceiling medium_size;
buckets := NATIVE_ARRAY(HASHED_DICTIONARY_NODE(V,K)).create new_capacity;
capacity := new_capacity;
@@ -586,7 +586,7 @@ Section Public
//
// Invariant
//
-
+
// [
// -? {capacity > 0};
// -? {capacity >= count};
@@ -594,10 +594,10 @@ Section Public
// -? {(cache_user > 0) ->> {cache_node != NULL}};
// -? {(cache_user > 0) ->> {cache_buckets.in_range 0 to (capacity - 1)}}
// ];
-
-
- //------------------- OLD --------------------
-
+
+
+ //------------------- OLD --------------------
+
/*
+ cache_user :INTEGER;
@@ -606,61 +606,61 @@ Section Public
// -1 to indicate that the cache is not active. When the cache is
// active, the corresponding index in `buckets' is save in
// `cache_buckets' and the corresponding node in `cache_node'.
-
+
+ cache_node:HASHED_DICTIONARY_NODE[V,K];
// Meaningful only when `cache_user' is not -1.
-
+
+ cache_buckets:INTEGER;
// Meaningful only when `cache_user' is not -1.
-
-
-
+
+
+
- is_empty:BOOLEAN <- count = 0;
// Is it empty ?
-
+
- fast_has k:K :BOOLEAN <-
// Is there a value currently associated with key `k'?
(
+ idx:INTEGER;
+ node:DICTIONARY_NODE[V,K];
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
-
+
{ (node = NULL) || { node.key = k}}.until_do {
node := node.next;
};
node != NULL
);
-
+
- fast_at k:K :V <-
// Return the value associated to key `k'.
// (See also `reference_at' if V is a reference type.)
(
+ idx:INTEGER;
- + node:DICTIONARY_NODE[V,K];
-
+ + node:DICTIONARY_NODE[V,K];
+
? { fast_has k };
-
+
idx := k.hash_code % capacity;
node := buckets.item idx;
-
+
{ node.key = k}.until_do {
node := node.next;
};
node.item
);
-
-
+
+
- '@' Left 1 k:K :V <-
(
at k
);
-
-
+
+
// Looking and searching some value:
-
-
+
+
- occurrences v:V :INTEGER <-
// Number of occurrences using `equal'.
// See also `fast_occurrences' to chose the apropriate one.
@@ -670,86 +670,86 @@ Section Public
result := result + 1;
}; // end if
}; // end fo
-
+
? { result >= 0 };
-
+
result
);
-
-
+
+
- fast_occurrences v:V :INTEGER <-
// Number of occurrences using `='.
// See also `occurrences' to chose the apropriate one.
(
+ result:INTEGER;
-
+
1.to count do { i:INTEGER;
(v = item i ).if {
result := result + 1;
}; // end if
}; // end do
-
+
? { result >= 0 };
-
+
result
);
-
-
+
+
- key_at v:V :K <-
// Retrieve the key used for value `v' using `equal' for comparison.
(
+ i:INTEGER;
+ result:K;
-
+
? { occurrences v = 1};
i := 1;
{safe_equal (v,(item i))}.until_do {
i := i + 1;
};
result := cache_node.key;
-
+
? { equal ((at result) ,v) };
-
+
result
);
-
-
+
+
- fast_key_at v:V :K <-
// Retrieve the key used for value `v' using `=' for comparison.
(
- + i:INTEGER;
+ + i:INTEGER;
+ result:K;
-
+
? { fast_occurrences v = 1 };
i := 1;
{v = item(i)}.until_do {
i := i + 1;
};
result := cache_node.key;
-
+
? { at result = v };
-
+
result
);
-
+
- upper :INTEGER <-
(
count
);
-
-
+
+
- valid_index index:INTEGER :BOOLEAN <-
(
+ result:BOOLEAN;
-
+
result := (1 <= index) && {index <= count};
-
+
? { result = index.in_range lower to upper };
-
+
result
);
-
-
+
+
- '==' Right 60 other:SELF :BOOLEAN <-
// do both dictionaries have the same set of associations?
// Keys are compared with `==' and values are comnpared
@@ -757,7 +757,7 @@ Section Public
(
+ i:INTEGER;
+ result:BOOLEAN;
-
+
(Self = other ).if {
result := TRUE;
}.elseif { count = other.count } then {
@@ -775,19 +775,19 @@ Section Public
}; // end if
}; // end until_do
}; // end if
-
+
? { result ->> {count = other.count} };
-
+
result
);
-
-
+
+
- is_equal_map other:SELF :BOOLEAN <-
// Do both dictionaries have the same set of associations?
// Both keys and values are compared with `=='. See also `=='.
(
+ i:INTEGER;
- + k:K;
+ + k:K;
+ result:BOOLEAN;
(Self = other ).if {
result := TRUE;
@@ -807,7 +807,7 @@ Section Public
}; // end if
}; // end until_do
}; // end if
-
+
result
);
-*/
+*/
diff --git a/lib/standard/http/http_server.li b/lib/standard/http/http_server.li
new file mode 100644
index 0000000..a095ba0
--- /dev/null
+++ b/lib/standard/http/http_server.li
@@ -0,0 +1,217 @@
+///////////////////////////////////////////////////////////////////////////////
+// Lisaac Library //
+// //
+// LSIIT - ULP - CNRS - INRIA - FRANCE //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see <http://www.gnu.org/licenses/>. //
+// //
+// http://isaacproject.u-strasbg.fr/ //
+///////////////////////////////////////////////////////////////////////////////
+Section Header
+
+ + name := HTTP_SERVER;
+
+ - copyright := "2003-2010 Sonntag Benoit";
+
+ - author := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
+ - comment := "The main prototype";
+
+ - external :=
+`
+#include <sys/types.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/socket.h>
+
+struct sockaddr_in address;
+`;
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Private
+
+ //
+ // Parameters
+ //
+
+ + h_socket:INTEGER;
+
+ - queue_size:INTEGER := 5;
+
+ - buffer:STRING := STRING.create 1024;
+
+ //
+ // Error.
+ //
+
+ - socket_error:INTEGER := -1;
+
+ - error msg:ABSTRACT_STRING <-
+ (
+ msg.print; '\n'.print;
+ die_with_code 1;
+ );
+
+Section Public
+
+ - log:STRING := STRING.create 1024;
+
+ - listen port:INTEGER action act:{} <-
+ ( + h_server_socket,error,tmp:INTEGER;
+ + n_address_size:INTEGER;
+ + storage:NATIVE_ARRAY(CHARACTER);
+
+ n_address_size := `sizeof(address)`:INTEGER;
+ h_server_socket := `socket(AF_INET,SOCK_STREAM,0)`:INTEGER;
+ (h_server_socket = socket_error).if {
+ error "Error : create socket!";
+ };
+ `
+ address.sin_addr.s_addr=INADDR_ANY;
+ address.sin_port=htons(@port);
+ address.sin_family=AF_INET;
+ `;
+
+ error := `bind(@h_server_socket,(struct sockaddr*)&address,sizeof(address))`:INTEGER;
+ (error = socket_error).if {
+ error "Error : Bind()";
+ };
+ `getsockname(@h_server_socket, (struct sockaddr *) &address,(socklen_t *)&@n_address_size)`;
+
+ log.append "Opened socket as fd (";
+ h_server_socket.append_in log;
+ log.append ") on port (";
+ `ntohs(address.sin_port)`:INTEGER.append_in log;
+ log.append ") for stream i/o\n";
+
+ /*
+ "Server\
+ \\nsin_family = ".print;
+ `address.sin_family`:INTEGER.print;
+ "\nsin_addr.s_addr = ".print;
+ `address.sin_addr.s_addr`:INTEGER.print;
+ "\nsin_port = ".print;
+ `ntohs(address.sin_port)`:INTEGER.print;
+ '\n'.print;
+ "\nMaking a listen queue of ".print;
+ queue_size.print;
+ " elements".print;
+ */
+
+ // establish listen queue
+ tmp := queue_size;
+ (`listen(@h_server_socket, at tmp)`:INTEGER = socket_error).if {
+ error "Could not listen";
+ };
+ {
+ log.append "Waiting for a connection\n";
+ // get the connected socket
+ h_socket := `accept(@h_server_socket,(struct sockaddr*)&address,(socklen_t *)&@n_address_size)`:INTEGER;
+ log.append "Got a connection\n";
+ act.value;
+ }.endless_loop;
+ );
+
+ - send buf:ABSTRACT_STRING <-
+ ( + storage:NATIVE_ARRAY(CHARACTER);
+ + loc_h_socket,count:INTEGER;
+
+ log.append "send buffer\n";
+ storage := buf.to_external;
+ count := buf.count + 1;
+ loc_h_socket := h_socket;
+ `write(@loc_h_socket, at storage, at count)`;
+ );
+
+ - receive buf:STRING <-
+ // BSBS: Plutot faire un append que un copy
+ ( + loc_h_socket,capacity:INTEGER;
+ + storage:NATIVE_ARRAY(CHARACTER);
+
+ log.append "receive buffer\n";
+ storage := buf.to_external;
+ capacity := buf.capacity;
+ loc_h_socket := h_socket;
+ `read(@loc_h_socket, at storage, at capacity)`;
+ buf.from_external storage;
+ );
+
+ - close <-
+ // close socket
+ ( + loc_h_socket:INTEGER;
+ log.append "Closing the socket\n";
+ loc_h_socket := h_socket;
+ (`close(@loc_h_socket)`:INTEGER = socket_error).if {
+ error "Could not close socket";
+ };
+ );
+
+ - convert buf:STRING to_dictionary dico:HASHED_DICTIONARY(STRING,STRING) <-
+ ( + idx_start,idx_end,idx:INTEGER;
+ + key,value:STRING;
+ + sep:CHARACTER;
+
+ sep := ' ';
+ idx_start := buf.lower;
+ {
+ idx_end := buf.index_of '\n' since idx_start;
+ idx := buf.index_of sep since idx_start;
+ (idx < idx_end).if {
+ sep := ':';
+ key := buf.substring idx_start to (idx-1);
+ {buf.item (idx + 1) = ' '}.while_do {
+ idx := idx + 1;
+ };
+ {buf.item (idx_end - 1) <= ' '}.while_do {
+ idx_end := idx_end - 1;
+ };
+ value := buf.substring (idx+1) to (idx_end-1);
+ dico.put value to key;
+ };
+ idx_start := idx_end + 1;
+ }.do_while {idx_end <= buf.count};
+ );
+
+ //
+ // High level.
+ //
+
+ - send buf:ABSTRACT_STRING type_mime type:ABSTRACT_STRING <-
+ (
+ buffer.copy
+ "HTTP/1.1 200 OK\n\
+ \Date: ";
+ SYSTEM.get_current_date.append_in buffer;
+ buffer.add_last ' ';
+ SYSTEM.get_current_time.append_in buffer;
+ buffer.append "\n\
+ \Server: Lisaac httpd\n\
+ \Content-Length: ";
+ buf.count.append_in buffer;
+ buffer.append "\n\
+ \Connection: close\n\
+ \Content-type: ";
+ buffer.append type;
+ buffer.append "\n\n";
+ //
+ buffer.append buf;
+ buffer.append "\n\n";
+ send buffer;
+ );
diff --git a/lib/standard/http/mime.txt b/lib/standard/http/mime.txt
new file mode 100644
index 0000000..765cb8e
--- /dev/null
+++ b/lib/standard/http/mime.txt
@@ -0,0 +1,638 @@
+type_mime.add "application/x-bytecode.python" to "pyc";
+type_mime.add "application/acad" to "dwg";
+type_mime.add "application/arj" to "arj";
+type_mime.add "application/base64" to "mm";
+type_mime.add "application/base64" to "mme";
+type_mime.add "application/binhex" to "hqx";
+type_mime.add "application/binhex4" to "hqx4";
+type_mime.add "application/book" to "boo";
+type_mime.add "application/book" to "book";
+type_mime.add "application/cdf" to "cdf";
+type_mime.add "application/clariscad" to "ccad";
+type_mime.add "application/commonground" to "dp";
+type_mime.add "application/drafting" to "drw";
+type_mime.add "application/dsptype" to "tsp";
+type_mime.add "application/dxf" to "dxf";
+type_mime.add "application/envoy" to "evy";
+type_mime.add "application/excel" to "xl";
+type_mime.add "application/excel" to "xla";
+type_mime.add "application/excel" to "xlb";
+type_mime.add "application/excel" to "xlc";
+type_mime.add "application/excel" to "xld";
+type_mime.add "application/excel" to "xlk";
+type_mime.add "application/excel" to "xll";
+type_mime.add "application/excel" to "xlm";
+type_mime.add "application/excel" to "xls";
+type_mime.add "application/excel" to "xlt";
+type_mime.add "application/excel" to "xlv";
+type_mime.add "application/excel" to "xlw";
+type_mime.add "application/fractals" to "fif";
+type_mime.add "application/freeloader" to "frl";
+type_mime.add "application/futuresplash" to "spl";
+type_mime.add "application/gnutar" to "tgz";
+type_mime.add "application/groupwise" to "vew";
+type_mime.add "application/hlp" to "hlp";
+type_mime.add "application/hta" to "hta";
+type_mime.add "application/i-deas" to "unv";
+type_mime.add "application/iges" to "iges";
+type_mime.add "application/iges" to "igs";
+type_mime.add "application/inf" to "inf";
+type_mime.add "application/java" to "class";
+type_mime.add "application/java-byte-code" to "class";
+type_mime.add "application/lha" to "lha";
+type_mime.add "application/lzx" to "lzx";
+type_mime.add "application/mac-binary" to "bin";
+type_mime.add "application/mac-binhex" to "hqx";
+type_mime.add "application/mac-binhex40" to "hqx";
+type_mime.add "application/mac-compactpro" to "cpt";
+type_mime.add "application/macbinary" to "bin";
+type_mime.add "application/marc" to "mrc";
+type_mime.add "application/mbedlet" to "mbd";
+type_mime.add "application/mcad" to "mcd";
+type_mime.add "application/mime" to "aps";
+type_mime.add "application/mspowerpoint" to "pot";
+type_mime.add "application/mspowerpoint" to "pps";
+type_mime.add "application/mspowerpoint" to "ppt";
+type_mime.add "application/mspowerpoint" to "ppz";
+type_mime.add "application/msword" to "doc";
+type_mime.add "application/msword" to "dot";
+type_mime.add "application/msword" to "w6w";
+type_mime.add "application/msword" to "wiz";
+type_mime.add "application/msword" to "word";
+type_mime.add "application/mswrite" to "wri";
+type_mime.add "application/netmc" to "mcp";
+type_mime.add "application/octet-stream" to "a";
+type_mime.add "application/octet-stream" to "arc";
+type_mime.add "application/octet-stream" to "arj";
+type_mime.add "application/octet-stream" to "bin";
+type_mime.add "application/octet-stream" to "com";
+type_mime.add "application/octet-stream" to "dump";
+type_mime.add "application/octet-stream" to "exe";
+type_mime.add "application/octet-stream" to "lha";
+type_mime.add "application/octet-stream" to "lhx";
+type_mime.add "application/octet-stream" to "lzh";
+type_mime.add "application/octet-stream" to "lzx";
+type_mime.add "application/octet-stream" to "o";
+type_mime.add "application/octet-stream" to "psd";
+type_mime.add "application/octet-stream" to "saveme";
+type_mime.add "application/octet-stream" to "uu";
+type_mime.add "application/octet-stream" to "zoo";
+type_mime.add "application/oda" to "oda";
+type_mime.add "application/pdf" to "pdf";
+type_mime.add "application/pkcs-12" to "p12";
+type_mime.add "application/pkcs-crl" to "crl";
+type_mime.add "application/pkcs10" to "p10";
+type_mime.add "application/pkcs7-mime" to "p7c";
+type_mime.add "application/pkcs7-mime" to "p7m";
+type_mime.add "application/pkcs7-signature" to "p7s";
+type_mime.add "application/pkix-cert" to "cer";
+type_mime.add "application/pkix-cert" to "crt";
+type_mime.add "application/pkix-crl" to "crl";
+type_mime.add "application/plain" to "text";
+type_mime.add "application/postscript" to "ai";
+type_mime.add "application/postscript" to "eps";
+type_mime.add "application/postscript" to "ps";
+type_mime.add "application/powerpoint" to "ppt";
+type_mime.add "application/pro_eng" to "part";
+type_mime.add "application/pro_eng" to "prt";
+type_mime.add "application/ringing-tones" to "rng";
+type_mime.add "application/rtf" to "rtf";
+type_mime.add "application/rtf" to "rtx";
+type_mime.add "application/sdp" to "sdp";
+type_mime.add "application/sea" to "sea";
+type_mime.add "application/set" to "set";
+type_mime.add "application/sla" to "stl";
+type_mime.add "application/smil" to "smi";
+type_mime.add "application/smil" to "smil";
+type_mime.add "application/solids" to "sol";
+type_mime.add "application/sounder" to "sdr";
+type_mime.add "application/step" to "step";
+type_mime.add "application/step" to "stp";
+type_mime.add "application/streamingmedia" to "ssm";
+type_mime.add "application/toolbook" to "tbk";
+type_mime.add "application/vda" to "vda";
+type_mime.add "application/vnd.fdf" to "fdf";
+type_mime.add "application/vnd.hp-hpgl" to "hgl";
+type_mime.add "application/vnd.hp-hpgl" to "hpg";
+type_mime.add "application/vnd.hp-hpgl" to "hpgl";
+type_mime.add "application/vnd.hp-pcl" to "pcl";
+type_mime.add "application/vnd.ms-excel" to "xlb";
+type_mime.add "application/vnd.ms-excel" to "xlc";
+type_mime.add "application/vnd.ms-excel" to "xll";
+type_mime.add "application/vnd.ms-excel" to "xlm";
+type_mime.add "application/vnd.ms-excel" to "xls";
+type_mime.add "application/vnd.ms-excel" to "xlw";
+type_mime.add "application/vnd.ms-pki.certstore" to "sst";
+type_mime.add "application/vnd.ms-pki.pko" to "pko";
+type_mime.add "application/vnd.ms-pki.seccat" to "cat";
+type_mime.add "application/vnd.ms-pki.stl" to "stl";
+type_mime.add "application/vnd.ms-powerpoint" to "pot";
+type_mime.add "application/vnd.ms-powerpoint" to "ppa";
+type_mime.add "application/vnd.ms-powerpoint" to "pps";
+type_mime.add "application/vnd.ms-powerpoint" to "ppt";
+type_mime.add "application/vnd.ms-powerpoint" to "pwz";
+type_mime.add "application/vnd.ms-project" to "mpp";
+type_mime.add "application/vnd.nokia.configuration-message" to "ncm";
+type_mime.add "application/vnd.nokia.ringing-tone" to "rng";
+type_mime.add "application/vnd.rn-realmedia" to "rm";
+type_mime.add "application/vnd.rn-realplayer" to "rnx";
+type_mime.add "application/vnd.wap.wmlc" to "wmlc";
+type_mime.add "application/vnd.wap.wmlscriptc" to "wmlsc";
+type_mime.add "application/vnd.xara" to "web";
+type_mime.add "application/vocaltec-media-desc" to "vmd";
+type_mime.add "application/vocaltec-media-file" to "vmf";
+type_mime.add "application/wordperfect" to "wp";
+type_mime.add "application/wordperfect" to "wp5";
+type_mime.add "application/wordperfect" to "wp6";
+type_mime.add "application/wordperfect" to "wpd";
+type_mime.add "application/wordperfect6.0" to "w60";
+type_mime.add "application/wordperfect6.0" to "wp5";
+type_mime.add "application/wordperfect6.1" to "w61";
+type_mime.add "application/x-123" to "wk1";
+type_mime.add "application/x-aim" to "aim";
+type_mime.add "application/x-authorware-bin" to "aab";
+type_mime.add "application/x-authorware-map" to "aam";
+type_mime.add "application/x-authorware-seg" to "aas";
+type_mime.add "application/x-bcpio" to "bcpio";
+type_mime.add "application/x-binary" to "bin";
+type_mime.add "application/x-binhex40" to "hqx";
+type_mime.add "application/x-bsh" to "bsh";
+type_mime.add "application/x-bsh" to "sh";
+type_mime.add "application/x-bsh" to "shar";
+type_mime.add "application/x-bytecode.elisp (compiled elisp)" to "elc";
+type_mime.add "application/x-bzip" to "bz";
+type_mime.add "application/x-bzip2" to "boz";
+type_mime.add "application/x-bzip2" to "bz2";
+type_mime.add "application/x-cdf" to "cdf";
+type_mime.add "application/x-cdlink" to "vcd";
+type_mime.add "application/x-chat" to "cha";
+type_mime.add "application/x-chat" to "chat";
+type_mime.add "application/x-cmu-raster" to "ras";
+type_mime.add "application/x-cocoa" to "cco";
+type_mime.add "application/x-compactpro" to "cpt";
+type_mime.add "application/x-compress" to "z";
+type_mime.add "application/x-compressed" to "gz";
+type_mime.add "application/x-compressed" to "tgz";
+type_mime.add "application/x-compressed" to "z";
+type_mime.add "application/x-compressed" to "zip";
+type_mime.add "application/x-conference" to "nsc";
+type_mime.add "application/x-cpio" to "cpio";
+type_mime.add "application/x-cpt" to "cpt";
+type_mime.add "application/x-csh" to "csh";
+type_mime.add "application/x-deepv" to "deepv";
+type_mime.add "application/x-director" to "dcr";
+type_mime.add "application/x-director" to "dir";
+type_mime.add "application/x-director" to "dxr";
+type_mime.add "application/x-dvi" to "dvi";
+type_mime.add "application/x-elc" to "elc";
+type_mime.add "application/x-envoy" to "env";
+type_mime.add "application/x-envoy" to "evy";
+type_mime.add "application/x-esrehber" to "es";
+type_mime.add "application/x-excel" to "xla";
+type_mime.add "application/x-excel" to "xlb";
+type_mime.add "application/x-excel" to "xlc";
+type_mime.add "application/x-excel" to "xld";
+type_mime.add "application/x-excel" to "xlk";
+type_mime.add "application/x-excel" to "xll";
+type_mime.add "application/x-excel" to "xlm";
+type_mime.add "application/x-excel" to "xls";
+type_mime.add "application/x-excel" to "xlt";
+type_mime.add "application/x-excel" to "xlv";
+type_mime.add "application/x-excel" to "xlw";
+type_mime.add "application/x-frame" to "mif";
+type_mime.add "application/x-freelance" to "pre";
+type_mime.add "application/x-gsp" to "gsp";
+type_mime.add "application/x-gss" to "gss";
+type_mime.add "application/x-gtar" to "gtar";
+type_mime.add "application/x-gzip" to "gz";
+type_mime.add "application/x-gzip" to "gzip";
+type_mime.add "application/x-hdf" to "hdf";
+type_mime.add "application/x-helpfile" to "help";
+type_mime.add "application/x-helpfile" to "hlp";
+type_mime.add "application/x-httpd-imap" to "imap";
+type_mime.add "application/x-ima" to "ima";
+type_mime.add "application/x-internett-signup" to "ins";
+type_mime.add "application/x-inventor" to "iv";
+type_mime.add "application/x-ip2" to "ip";
+type_mime.add "application/x-java-class" to "class";
+type_mime.add "application/x-java-commerce" to "jcm";
+type_mime.add "application/x-javascript" to "js";
+type_mime.add "application/x-koan" to "skd";
+type_mime.add "application/x-koan" to "skm";
+type_mime.add "application/x-koan" to "skp";
+type_mime.add "application/x-koan" to "skt";
+type_mime.add "application/x-ksh" to "ksh";
+type_mime.add "application/x-latex" to "latex";
+type_mime.add "application/x-latex" to "ltx";
+type_mime.add "application/x-lha" to "lha";
+type_mime.add "application/x-lisp" to "lsp";
+type_mime.add "application/x-livescreen" to "ivy";
+type_mime.add "application/x-lotus" to "wq1";
+type_mime.add "application/x-lotusscreencam" to "scm";
+type_mime.add "application/x-lzh" to "lzh";
+type_mime.add "application/x-lzx" to "lzx";
+type_mime.add "application/x-mac-binhex40" to "hqx";
+type_mime.add "application/x-macbinary" to "bin";
+type_mime.add "application/x-mathcad" to "mcd";
+type_mime.add "application/x-meme" to "mm";
+type_mime.add "application/x-midi" to "mid";
+type_mime.add "application/x-midi" to "midi";
+type_mime.add "application/x-mif" to "mif";
+type_mime.add "application/x-mix-transfer" to "nix";
+type_mime.add "application/x-mplayer2" to "asx";
+type_mime.add "application/x-msexcel" to "xla";
+type_mime.add "application/x-msexcel" to "xls";
+type_mime.add "application/x-msexcel" to "xlw";
+type_mime.add "application/x-mspowerpoint" to "ppt";
+type_mime.add "application/x-navi-animation" to "ani";
+type_mime.add "application/x-navidoc" to "nvd";
+type_mime.add "application/x-navimap" to "map";
+type_mime.add "application/x-navistyle" to "stl";
+type_mime.add "application/x-netcdf" to "cdf";
+type_mime.add "application/x-netcdf" to "nc";
+type_mime.add "application/x-newton-compatible-pkg" to "pkg";
+type_mime.add "application/x-nokia-9000-communicator-add-on-software" to "aos";
+type_mime.add "application/x-omc" to "omc";
+type_mime.add "application/x-omcdatamaker" to "omcd";
+type_mime.add "application/x-omcregerator" to "omcr";
+type_mime.add "application/x-pagemaker" to "pm4";
+type_mime.add "application/x-pagemaker" to "pm5";
+type_mime.add "application/x-pcl" to "pcl";
+type_mime.add "application/x-pixclscript" to "plx";
+type_mime.add "application/x-pkcs10" to "p10";
+type_mime.add "application/x-pkcs12" to "p12";
+type_mime.add "application/x-pkcs7-certificates" to "spc";
+type_mime.add "application/x-pkcs7-certreqresp" to "p7r";
+type_mime.add "application/x-pkcs7-mime" to "p7c";
+type_mime.add "application/x-pkcs7-mime" to "p7m";
+type_mime.add "application/x-pkcs7-signature" to "p7a";
+type_mime.add "application/x-pointplus" to "css";
+type_mime.add "application/x-portable-anymap" to "pnm";
+type_mime.add "application/x-project" to "mpc";
+type_mime.add "application/x-project" to "mpt";
+type_mime.add "application/x-project" to "mpv";
+type_mime.add "application/x-project" to "mpx";
+type_mime.add "application/x-qpro" to "wb1";
+type_mime.add "application/x-rtf" to "rtf";
+type_mime.add "application/x-sdp" to "sdp";
+type_mime.add "application/x-sea" to "sea";
+type_mime.add "application/x-seelogo" to "sl";
+type_mime.add "application/x-sh" to "sh";
+type_mime.add "application/x-shar" to "sh";
+type_mime.add "application/x-shar" to "shar";
+type_mime.add "application/x-shockwave-flash" to "swf";
+type_mime.add "application/x-sit" to "sit";
+type_mime.add "application/x-sprite" to "spr";
+type_mime.add "application/x-sprite" to "sprite";
+type_mime.add "application/x-stuffit" to "sit";
+type_mime.add "application/x-sv4cpio" to "sv4cpio";
+type_mime.add "application/x-sv4crc" to "sv4crc";
+type_mime.add "application/x-tar" to "tar";
+type_mime.add "application/x-tbook" to "sbk";
+type_mime.add "application/x-tbook" to "tbk";
+type_mime.add "application/x-tcl" to "tcl";
+type_mime.add "application/x-tex" to "tex";
+type_mime.add "application/x-texinfo" to "texi";
+type_mime.add "application/x-texinfo" to "texinfo";
+type_mime.add "application/x-troff" to "roff";
+type_mime.add "application/x-troff" to "t";
+type_mime.add "application/x-troff" to "tr";
+type_mime.add "application/x-troff-man" to "man";
+type_mime.add "application/x-troff-me" to "me";
+type_mime.add "application/x-troff-ms" to "ms";
+type_mime.add "application/x-troff-msvideo" to "avi";
+type_mime.add "application/x-ustar" to "ustar";
+type_mime.add "application/x-visio" to "vsd";
+type_mime.add "application/x-visio" to "vst";
+type_mime.add "application/x-visio" to "vsw";
+type_mime.add "application/x-vnd.audioexplosion.mzz" to "mzz";
+type_mime.add "application/x-vnd.ls-xpix" to "xpix";
+type_mime.add "application/x-vrml" to "vrml";
+type_mime.add "application/x-wais-source" to "src";
+type_mime.add "application/x-wais-source" to "wsrc";
+type_mime.add "application/x-winhelp" to "hlp";
+type_mime.add "application/x-wintalk" to "wtk";
+type_mime.add "application/x-world" to "svr";
+type_mime.add "application/x-world" to "wrl";
+type_mime.add "application/x-wpwin" to "wpd";
+type_mime.add "application/x-wri" to "wri";
+type_mime.add "application/x-x509-ca-cert" to "cer";
+type_mime.add "application/x-x509-ca-cert" to "crt";
+type_mime.add "application/x-x509-ca-cert" to "der";
+type_mime.add "application/x-x509-user-cert" to "crt";
+type_mime.add "application/x-zip-compressed" to "zip";
+type_mime.add "application/xml" to "xml";
+type_mime.add "application/zip" to "zip";
+type_mime.add "audio/aiff" to "aif";
+type_mime.add "audio/aiff" to "aifc";
+type_mime.add "audio/aiff" to "aiff";
+type_mime.add "audio/basic" to "au";
+type_mime.add "audio/basic" to "snd";
+type_mime.add "audio/it" to "it";
+type_mime.add "audio/make" to "funk";
+type_mime.add "audio/make" to "my";
+type_mime.add "audio/make" to "pfunk";
+type_mime.add "audio/make.my.funk" to "pfunk";
+type_mime.add "audio/mid" to "rmi";
+type_mime.add "audio/midi" to "kar";
+type_mime.add "audio/midi" to "mid";
+type_mime.add "audio/midi" to "midi";
+type_mime.add "audio/mod" to "mod";
+type_mime.add "audio/mpeg" to "m2a";
+type_mime.add "audio/mpeg" to "mp2";
+type_mime.add "audio/mpeg" to "mpa";
+type_mime.add "audio/mpeg" to "mpg";
+type_mime.add "audio/mpeg" to "mpga";
+type_mime.add "audio/mpeg3" to "mp3";
+type_mime.add "audio/nspaudio" to "la";
+type_mime.add "audio/nspaudio" to "lma";
+type_mime.add "audio/s3m" to "s3m";
+type_mime.add "audio/tsp-audio" to "tsi";
+type_mime.add "audio/tsplayer" to "tsp";
+type_mime.add "audio/vnd.qcelp" to "qcp";
+type_mime.add "audio/voc" to "voc";
+type_mime.add "audio/voxware" to "vox";
+type_mime.add "audio/wav" to "wav";
+type_mime.add "audio/x-adpcm" to "snd";
+type_mime.add "audio/x-aiff" to "aif";
+type_mime.add "audio/x-aiff" to "aifc";
+type_mime.add "audio/x-aiff" to "aiff";
+type_mime.add "audio/x-au" to "au";
+type_mime.add "audio/x-gsm" to "gsd";
+type_mime.add "audio/x-gsm" to "gsm";
+type_mime.add "audio/x-jam" to "jam";
+type_mime.add "audio/x-liveaudio" to "lam";
+type_mime.add "audio/x-mid" to "mid";
+type_mime.add "audio/x-mid" to "midi";
+type_mime.add "audio/x-midi" to "mid";
+type_mime.add "audio/x-midi" to "midi";
+type_mime.add "audio/x-mod" to "mod";
+type_mime.add "audio/x-mpeg" to "mp2";
+type_mime.add "audio/x-mpeg-3" to "mp3";
+type_mime.add "audio/x-mpequrl" to "m3u";
+type_mime.add "audio/x-nspaudio" to "la";
+type_mime.add "audio/x-nspaudio" to "lma";
+type_mime.add "audio/x-pn-realaudio" to "ra";
+type_mime.add "audio/x-pn-realaudio" to "ram";
+type_mime.add "audio/x-pn-realaudio" to "rm";
+type_mime.add "audio/x-pn-realaudio" to "rmm";
+type_mime.add "audio/x-pn-realaudio" to "rmp";
+type_mime.add "audio/x-pn-realaudio-plugin" to "ra";
+type_mime.add "audio/x-pn-realaudio-plugin" to "rmp";
+type_mime.add "audio/x-pn-realaudio-plugin" to "rpm";
+type_mime.add "audio/x-psid" to "sid";
+type_mime.add "audio/x-realaudio" to "ra";
+type_mime.add "audio/x-twinvq" to "vqf";
+type_mime.add "audio/x-twinvq-plugin" to "vqe";
+type_mime.add "audio/x-twinvq-plugin" to "vql";
+type_mime.add "audio/x-vnd.audioexplosion.mjuicemediafile" to "mjf";
+type_mime.add "audio/x-voc" to "voc";
+type_mime.add "audio/x-wav" to "wav";
+type_mime.add "audio/xm" to "xm";
+type_mime.add "chemical/x-pdb" to "pdb";
+type_mime.add "chemical/x-pdb" to "xyz";
+type_mime.add "drawing/x-dwf (old)" to "dwf";
+type_mime.add "i-world/i-vrml" to "ivr";
+type_mime.add "image/bmp" to "bm";
+type_mime.add "image/bmp" to "bmp";
+type_mime.add "image/cmu-raster" to "ras";
+type_mime.add "image/cmu-raster" to "rast";
+type_mime.add "image/fif" to "fif";
+type_mime.add "image/florian" to "flo";
+type_mime.add "image/florian" to "turbot";
+type_mime.add "image/g3fax" to "g3";
+type_mime.add "image/gif" to "gif";
+type_mime.add "image/ief" to "ief";
+type_mime.add "image/ief" to "iefs";
+type_mime.add "image/jpeg" to "jfif";
+type_mime.add "image/jpeg" to "jpe";
+type_mime.add "image/jpeg" to "jpeg";
+type_mime.add "image/jpeg" to "jpg";
+type_mime.add "image/jutvision" to "jut";
+type_mime.add "image/naplps" to "nap";
+type_mime.add "image/naplps" to "naplps";
+type_mime.add "image/pict" to "pic";
+type_mime.add "image/pict" to "pict";
+type_mime.add "image/pjpeg" to "jfif";
+type_mime.add "image/pjpeg" to "jpe";
+type_mime.add "image/pjpeg" to "jpeg";
+type_mime.add "image/pjpeg" to "jpg";
+type_mime.add "image/png" to "png";
+type_mime.add "image/tiff" to "tif";
+type_mime.add "image/tiff" to "tiff";
+type_mime.add "image/vasa" to "mcf";
+type_mime.add "image/vnd.dwg" to "dwg";
+type_mime.add "image/vnd.dwg" to "dxf";
+type_mime.add "image/vnd.dwg" to "svf";
+type_mime.add "image/vnd.fpx" to "fpx";
+type_mime.add "image/vnd.net-fpx" to "fpx";
+type_mime.add "image/vnd.rn-realflash" to "rf";
+type_mime.add "image/vnd.rn-realpix" to "rp";
+type_mime.add "image/vnd.wap.wbmp" to "wbmp";
+type_mime.add "image/vnd.xiff" to "xif";
+type_mime.add "image/x-cmu-raster" to "ras";
+type_mime.add "image/x-dwg" to "dwg";
+type_mime.add "image/x-dwg" to "dxf";
+type_mime.add "image/x-dwg" to "svf";
+type_mime.add "image/x-icon" to "ico";
+type_mime.add "image/x-jg" to "art";
+type_mime.add "image/x-jps" to "jps";
+type_mime.add "image/x-niff" to "nif";
+type_mime.add "image/x-niff" to "niff";
+type_mime.add "image/x-pcx" to "pcx";
+type_mime.add "image/x-pict" to "pct";
+type_mime.add "image/x-portable-anymap" to "pnm";
+type_mime.add "image/x-portable-bitmap" to "pbm";
+type_mime.add "image/x-portable-graymap" to "pgm";
+type_mime.add "image/x-portable-greymap" to "pgm";
+type_mime.add "image/x-portable-pixmap" to "ppm";
+type_mime.add "image/x-quicktime" to "qif";
+type_mime.add "image/x-quicktime" to "qti";
+type_mime.add "image/x-quicktime" to "qtif";
+type_mime.add "image/x-rgb" to "rgb";
+type_mime.add "image/x-tiff" to "tif";
+type_mime.add "image/x-tiff" to "tiff";
+type_mime.add "image/x-windows-bmp" to "bmp";
+type_mime.add "image/x-xbitmap" to "xbm";
+type_mime.add "image/x-xbm" to "xbm";
+type_mime.add "image/x-xpixmap" to "pm";
+type_mime.add "image/x-xpixmap" to "xpm";
+type_mime.add "image/x-xwd" to "xwd";
+type_mime.add "image/x-xwindowdump" to "xwd";
+type_mime.add "image/xbm" to "xbm";
+type_mime.add "image/xpm" to "xpm";
+type_mime.add "message/rfc822" to "mht";
+type_mime.add "message/rfc822" to "mhtml";
+type_mime.add "message/rfc822" to "mime";
+type_mime.add "model/iges" to "iges";
+type_mime.add "model/iges" to "igs";
+type_mime.add "model/vnd.dwf" to "dwf";
+type_mime.add "model/vrml" to "vrml";
+type_mime.add "model/vrml" to "wrl";
+type_mime.add "model/vrml" to "wrz";
+type_mime.add "model/x-pov" to "pov";
+type_mime.add "multipart/x-gzip" to "gzip";
+type_mime.add "multipart/x-ustar" to "ustar";
+type_mime.add "multipart/x-zip" to "zip";
+type_mime.add "music/crescendo" to "mid";
+type_mime.add "music/crescendo" to "midi";
+type_mime.add "music/x-karaoke" to "kar";
+type_mime.add "paleovu/x-pv" to "pvu";
+type_mime.add "text/asp" to "asp";
+type_mime.add "text/css" to "css";
+type_mime.add "text/html" to "acgi";
+type_mime.add "text/html" to "htm";
+type_mime.add "text/html" to "html";
+type_mime.add "text/html" to "htmls";
+type_mime.add "text/html" to "htx";
+type_mime.add "text/html" to "shtml";
+type_mime.add "text/mcf" to "mcf";
+type_mime.add "text/pascal" to "pas";
+type_mime.add "text/plain" to "c";
+type_mime.add "text/plain" to "cc";
+type_mime.add "text/plain" to "com";
+type_mime.add "text/plain" to "conf";
+type_mime.add "text/plain" to "cxx";
+type_mime.add "text/plain" to "def";
+type_mime.add "text/plain" to "f";
+type_mime.add "text/plain" to "f90";
+type_mime.add "text/plain" to "for";
+type_mime.add "text/plain" to "g";
+type_mime.add "text/plain" to "h";
+type_mime.add "text/plain" to "hh";
+type_mime.add "text/plain" to "idc";
+type_mime.add "text/plain" to "jav";
+type_mime.add "text/plain" to "java";
+type_mime.add "text/plain" to "list";
+type_mime.add "text/plain" to "log";
+type_mime.add "text/plain" to "lst";
+type_mime.add "text/plain" to "m";
+type_mime.add "text/plain" to "mar";
+type_mime.add "text/plain" to "pl";
+type_mime.add "text/plain" to "sdml";
+type_mime.add "text/plain" to "text";
+type_mime.add "text/plain" to "txt";
+type_mime.add "text/richtext" to "rt";
+type_mime.add "text/richtext" to "rtf";
+type_mime.add "text/richtext" to "rtx";
+type_mime.add "text/scriplet" to "wsc";
+type_mime.add "text/sgml" to "sgm";
+type_mime.add "text/sgml" to "sgml";
+type_mime.add "text/tab-separated-values" to "tsv";
+type_mime.add "text/uri-list" to "uni";
+type_mime.add "text/uri-list" to "unis";
+type_mime.add "text/uri-list" to "uri";
+type_mime.add "text/uri-list" to "uris";
+type_mime.add "text/vnd.abc" to "abc";
+type_mime.add "text/vnd.fmi.flexstor" to "flx";
+type_mime.add "text/vnd.rn-realtext" to "rt";
+type_mime.add "text/vnd.wap.wml" to "wml";
+type_mime.add "text/vnd.wap.wmlscript" to "wmls";
+type_mime.add "text/webviewhtml" to "htt";
+type_mime.add "text/x-asm" to "asm";
+type_mime.add "text/x-asm" to "s";
+type_mime.add "text/x-audiosoft-intra" to "aip";
+type_mime.add "text/x-c" to "c";
+type_mime.add "text/x-c" to "cc";
+type_mime.add "text/x-c" to "cpp";
+type_mime.add "text/x-component" to "htc";
+type_mime.add "text/x-fortran" to "f";
+type_mime.add "text/x-fortran" to "f77";
+type_mime.add "text/x-fortran" to "f90";
+type_mime.add "text/x-fortran" to "for";
+type_mime.add "text/x-h" to "h";
+type_mime.add "text/x-h" to "hh";
+type_mime.add "text/x-java-source" to "jav";
+type_mime.add "text/x-java-source" to "java";
+type_mime.add "text/x-la-asf" to "lsx";
+type_mime.add "text/x-m" to "m";
+type_mime.add "text/x-pascal" to "p";
+type_mime.add "text/x-script" to "hlb";
+type_mime.add "text/x-script.csh" to "csh";
+type_mime.add "text/x-script.elisp" to "el";
+type_mime.add "text/x-script.guile" to "scm";
+type_mime.add "text/x-script.ksh" to "ksh";
+type_mime.add "text/x-script.lisp" to "lsp";
+type_mime.add "text/x-script.perl" to "pl";
+type_mime.add "text/x-script.perl-module" to "pm";
+type_mime.add "text/x-script.phyton" to "py";
+type_mime.add "text/x-script.rexx" to "rexx";
+type_mime.add "text/x-script.scheme" to "scm";
+type_mime.add "text/x-script.sh" to "sh";
+type_mime.add "text/x-script.tcl" to "tcl";
+type_mime.add "text/x-script.tcsh" to "tcsh";
+type_mime.add "text/x-script.zsh" to "zsh";
+type_mime.add "text/x-server-parsed-html" to "shtml";
+type_mime.add "text/x-server-parsed-html" to "ssi";
+type_mime.add "text/x-setext" to "etx";
+type_mime.add "text/x-sgml" to "sgm";
+type_mime.add "text/x-sgml" to "sgml";
+type_mime.add "text/x-speech" to "spc";
+type_mime.add "text/x-speech" to "talk";
+type_mime.add "text/x-uil" to "uil";
+type_mime.add "text/x-uuencode" to "uu";
+type_mime.add "text/x-uuencode" to "uue";
+type_mime.add "text/x-vcalendar" to "vcs";
+type_mime.add "text/xml" to "xml";
+type_mime.add "video/animaflex" to "afl";
+type_mime.add "video/avi" to "avi";
+type_mime.add "video/avs-video" to "avs";
+type_mime.add "video/dl" to "dl";
+type_mime.add "video/fli" to "fli";
+type_mime.add "video/gl" to "gl";
+type_mime.add "video/mpeg" to "m1v";
+type_mime.add "video/mpeg" to "m2v";
+type_mime.add "video/mpeg" to "mp2";
+type_mime.add "video/mpeg" to "mp3";
+type_mime.add "video/mpeg" to "mpa";
+type_mime.add "video/mpeg" to "mpe";
+type_mime.add "video/mpeg" to "mpeg";
+type_mime.add "video/mpeg" to "mpg";
+type_mime.add "video/msvideo" to "avi";
+type_mime.add "video/quicktime" to "moov";
+type_mime.add "video/quicktime" to "mov";
+type_mime.add "video/quicktime" to "qt";
+type_mime.add "video/vdo" to "vdo";
+type_mime.add "video/vivo" to "viv";
+type_mime.add "video/vivo" to "vivo";
+type_mime.add "video/vnd.rn-realvideo" to "rv";
+type_mime.add "video/vnd.vivo" to "viv";
+type_mime.add "video/vnd.vivo" to "vivo";
+type_mime.add "video/vosaic" to "vos";
+type_mime.add "video/x-amt-demorun" to "xdr";
+type_mime.add "video/x-amt-showrun" to "xsr";
+type_mime.add "video/x-atomic3d-feature" to "fmf";
+type_mime.add "video/x-dl" to "dl";
+type_mime.add "video/x-dv" to "dif";
+type_mime.add "video/x-dv" to "dv";
+type_mime.add "video/x-fli" to "fli";
+type_mime.add "video/x-gl" to "gl";
+type_mime.add "video/x-isvideo" to "isu";
+type_mime.add "video/x-motion-jpeg" to "mjpg";
+type_mime.add "video/x-mpeg" to "mp2";
+type_mime.add "video/x-mpeg" to "mp3";
+type_mime.add "video/x-mpeq2a" to "mp2";
+type_mime.add "video/x-ms-asf" to "asf";
+type_mime.add "video/x-ms-asf" to "asx";
+type_mime.add "video/x-ms-asf-plugin" to "asx";
+type_mime.add "video/x-msvideo" to "avi";
+type_mime.add "video/x-qtc" to "qtc";
+type_mime.add "video/x-scm" to "scm";
+type_mime.add "video/x-sgi-movie" to "movie";
+type_mime.add "video/x-sgi-movie" to "mv";
+type_mime.add "windows/metafile" to "wmf";
+type_mime.add "www/mime" to "mime";
+type_mime.add "x-conference/x-cooltalk" to "ice";
+type_mime.add "x-music/x-midi" to "mid";
+type_mime.add "x-music/x-midi" to "midi";
+type_mime.add "x-world/x-3dmf" to "3dm";
+type_mime.add "x-world/x-3dmf" to "3dmf";
+type_mime.add "x-world/x-3dmf" to "qd3";
+type_mime.add "x-world/x-3dmf" to "qd3d";
+type_mime.add "x-world/x-svr" to "svr";
+type_mime.add "x-world/x-vrml" to "vrml";
+type_mime.add "x-world/x-vrml" to "wrl";
+type_mime.add "x-world/x-vrml" to "wrz";
+type_mime.add "x-world/x-vrt" to "vrt";
+type_mime.add "xgl/drawing" to "xgz";
+type_mime.add "xgl/movie" to "xmz";
diff --git a/lib/standard/io/command_line.li b/lib/standard/io/command_line.li
index be71c4a..d8342ed 100644
--- a/lib/standard/io/command_line.li
+++ b/lib/standard/io/command_line.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COMMAND_LINE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Interface Command line (Unix).";
- /*
+ /*
Section Inherit
-
+
- parent_traversable:TRAVERSABLE(STRING) := TRAVERSABLE(STRING);
*/
Section Private
- c_item idx:INTEGER :NATIVE_ARRAY(CHARACTER) <- `arg_vector[@idx]`:NATIVE_ARRAY(CHARACTER);
-
+
- c_count:INTEGER <- `arg_count`:INTEGER;
-
+
- args:FAST_ARRAY(STRING) :=
( + result:FAST_ARRAY(STRING);
+ arg:NATIVE_ARRAY(CHARACTER);
+ str:STRING;
-
+
result := FAST_ARRAY(STRING).create_with_capacity c_count;
- 0.to (c_count - 1) do { j:INTEGER;
+ 0.to (c_count - 1) do { j:INTEGER;
arg := c_item j;
str := STRING.create (arg.fast_first_index_of '\0' until 1024);
str.from_external_copy arg;
- result.add_last str;
- };
+ result.add_last str;
+ };
result
);
-
+
Section Public
- count:INTEGER <- args.count;
@@ -61,9 +61,9 @@ Section Public
- upper:INTEGER <- args.upper;
- item i:INTEGER :STRING <- args.item i;
-
+
- executable_name:STRING <- args.first;
-
+
diff --git a/lib/standard/kernel/block.li b/lib/standard/kernel/block.li
index 54dc1e7..d3f52ae 100644
--- a/lib/standard/kernel/block.li
+++ b/lib/standard/kernel/block.li
@@ -19,45 +19,45 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := BLOCK;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Block instruction library { ... } .";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
//
// Conditional :
//
-
+
- Self:{BOOLEAN} '||' Left 10 other:{BOOLEAN} :BOOLEAN <-
(
value || other
);
-
+
- Self:{BOOLEAN} '&&' Left 20 other:{BOOLEAN} :BOOLEAN <-
(
value && other
);
-
+
- Self:{}.if test:BOOLEAN <-
(
test.if_true {
value;
};
);
-
+
//
// Loop :
//
-
+
- Self:{}.endless_loop <-
(
(`1`:BOOLEAN{TRUE,FALSE}).if {
@@ -65,43 +65,43 @@ Section Public
endless_loop;
};
);
-
+
- Self:{BOOLEAN}.while_do body:{} <-
( //? {body!=NULL};
-
+
value.if {
body.value;
while_do body;
};
);
-
+
- Self:{}.do_while test:{BOOLEAN} <-
( //? {test!=NULL};
-
+
value;
test.value.if {
do_while test;
};
);
-
+
- Self:{BOOLEAN}.until_do body:{} <-
( // ? {body!=NULL};
-
+
(! value).if {
body.value;
until_do body;
};
);
-
+
- Self:{}.do_until test:{BOOLEAN} <-
( //? {test!=NULL};
-
+
value;
(! test.value).if {
do_until test;
};
);
-
+
- Self:{BOOLEAN}.while_do body:{} ensure test:{BOOLEAN} <-
// Mix loop version beetween `while_do' and `do_while'
(
@@ -112,7 +112,7 @@ Section Public
};
};
);
-
+
/*
- until_do body:BLOCK or_until test:BLOCK <-
(
@@ -124,91 +124,90 @@ Section Public
};
);
*/
-
+
//
// Debug: Require / Ensure / Check
//
-
+
- Self:{BOOLEAN} '?' msg:STRING_CONSTANT <-
// User assertion with message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
- ((debug_level >=10) && {! value}).if {
- crash_on ptr with_message msg;
+ ((debug_level >=10) && {! value}).if {
+ crash_on ptr with_message msg;
};
);
-
+
- '?' Self:{BOOLEAN} <-
// User assertion without message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
- ((debug_level >=10) && {! value}).if {
- crash_on ptr with_message "User assertion violated.";
+ ((debug_level >=10) && {! value}).if {
+ crash_on ptr with_message "User assertion violated.";
};
);
-
+
- Self:{BOOLEAN} '-?' msg:STRING_CONSTANT <-
// Require assertion with message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
((debug_level >= 5) && {! value}).if {
- crash_on ptr with_message msg;
+ crash_on ptr with_message msg;
};
);
-
+
- '-?' Self:{BOOLEAN} <-
// Require assertion without message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
((debug_level >= 5) && {! value}).if {
- crash_on ptr with_message "Require assertion violated.";
+ crash_on ptr with_message "Require assertion violated.";
};
);
-
+
- Self:{BOOLEAN} '+?' msg:STRING_CONSTANT <-
// Ensure assertion with message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
((debug_level >= 15) && {! value}).if {
- crash_on ptr with_message msg;
+ crash_on ptr with_message msg;
};
);
-
+
- '+?' Self:{BOOLEAN} <-
// Require assertion without message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
((debug_level >= 15) && {! value}).if {
- crash_on ptr with_message "Ensure assertion violated.";
+ crash_on ptr with_message "Ensure assertion violated.";
};
);
- Self:{BOOLEAN} '?#' val:INTEGER <-
// Other assertion without message.
( + ptr:POINTER;
-
+
ptr := top_runtime_stack;
((debug_level >= val) && {! value}).if {
- crash_on ptr with_message "Assertion violated.";
+ crash_on ptr with_message "Assertion violated.";
};
);
-
+
//
// Code debug.
//
-
+
- '!' Self:{BOOLEAN} <-
(
- (debug_level >=10).if {
- value;
+ (debug_level >=10).if {
+ value;
};
);
-
-
-
\ No newline at end of file
+
+
diff --git a/lib/standard/string/abstract_string.li b/lib/standard/string/abstract_string.li
index db371af..8bd44a5 100644
--- a/lib/standard/string/abstract_string.li
+++ b/lib/standard/string/abstract_string.li
@@ -19,63 +19,63 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ABSTRACT_STRING;
- export := STRING;
-
+
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Generic prototype for STRING and STRING_CONSTANT";
-
+
Section Inherit
-
+
- parent_hashable:HASHABLE := HASHABLE;
-
+
- parent_comparable:COMPARABLE := COMPARABLE;
-
+
Section Public //ABSTRACT_STRING, ABSTRACT_ENTRY
-
+
+ storage:NATIVE_ARRAY(CHARACTER);
// Collection containing characters
-
+
Section Public
-
+
+ count:INTEGER;
// size
-
- - lower:INTEGER := 1;
-
+
+ - lower:INTEGER := 1;
+
- upper:INTEGER <- count;
// size
-
+
- capacity:INTEGER <- count;
// size
-
+
//
// Access.
//
-
+
- item index:INTEGER :CHARACTER <-
// Character at position `index'.
// * Require: index is valid
[
-? {valid_index index};
]
- (
+ (
storage.item (index - 1)
);
-
+
- Self:SELF '@' Left 1 index:INTEGER :CHARACTER <-
// Character at position `index'.
(
item index
);
-
+
//
// Switch case :
//
-
+
- when value:ABSTRACT_STRING then block:{} :ABSTRACT_STRING <-
// When `Self' equal `value', execute `block'
(
@@ -93,7 +93,7 @@ Section Public
- case value:ABSTRACT_STRING then block:{} :ABSTRACT_STRING <-
// * See: `when_then'
( + result :ABSTRACT_STRING;
-
+
((Self != ABSTRACT_STRING) && {Self ~= value}).if {
block.value;
result := ABSTRACT_STRING;
@@ -106,7 +106,7 @@ Section Public
- case_if test:{BOOLEAN} then block:{} :ABSTRACT_STRING <-
// If `test' is true then `block'
( + result :ABSTRACT_STRING;
-
+
((Self != ABSTRACT_STRING) && test).if {
block.value;
result := ABSTRACT_STRING;
@@ -125,18 +125,18 @@ Section Public
//
// Testing.
//
-
+
- valid_index index:INTEGER :BOOLEAN <-
// True when `index' is valid (i.e., inside actual bounds).
( index.in_range lower to count );
-
+
- is_empty : BOOLEAN <- count = 0;
-
+
- hash_code: INTEGER <-
// Return a hashcode
( + result:INTEGER;
-
+
1.to count do { i:INTEGER;
result := (5 * result) + (item i).code;
};
@@ -145,16 +145,16 @@ Section Public
};
result
);
-
+
- Self:SELF '<' other:SELF :BOOLEAN <- Self ~< other;
-
+
- Self:SELF '~>' other:ABSTRACT_STRING :BOOLEAN <- other ~< Self;
-
+
- Self:SELF '~<' other:ABSTRACT_STRING :BOOLEAN <-
// Is Current less than `other' ?
( + i: INTEGER;
+ result: BOOLEAN;
-
+
i := 1;
{(count < i) || {other.count < i} || {item i != other.item i}}.until_do {
i := i + 1;
@@ -170,12 +170,12 @@ Section Public
};
result
);
-
+
- Self:SELF '!<' other:ABSTRACT_STRING :BOOLEAN <-
// Is Current less than `other' ? But, the `upper' to `lower' comparaison
( + i1,i2: INTEGER;
+ result:BOOLEAN;
-
+
i1 := upper;
i2 := other.upper;
{(i1 < lower) || {i2 < other.lower} || {item i1 != other.item i2}}.until_do {
@@ -193,7 +193,7 @@ Section Public
};
result
);
-
+
- compare other:ABSTRACT_STRING :INTEGER <-
// Compare alphabetically `Self' to `other'
( + i: INTEGER;
@@ -219,10 +219,10 @@ Section Public
};
};
};
-
+
result
);
-
+
- same_as other:ABSTRACT_STRING :BOOLEAN <-
// Case insensitive `=='.
( + s1, s2:NATIVE_ARRAY(CHARACTER);
@@ -247,7 +247,7 @@ Section Public
};
result
);
-
+
- Self:SELF '==' Left 40 other:E :BOOLEAN <-
// Has Current the same text as `other' ?
( + same:ABSTRACT_STRING;
@@ -268,45 +268,45 @@ Section Public
};
result
);
-
+
- item_code i:INTEGER :INTEGER <-
// Code of character at position `i'.
(
? { valid_index i};
storage.item (i - 1).code
);
-
+
- index_of ch:CHARACTER since start_index:INTEGER :INTEGER <-
// Index of first occurrence of `c' at or after `start_index',
// result = count + 1, if none.
( + result:INTEGER;
? { start_index.in_range 1 to (count + 1)};
-
+
result := start_index;
-
+
{(result > count) || {ch = item result}}.until_do {
result := result + 1;
};
-
+
result
);
-
+
- last_index_of ch:CHARACTER since start_index:INTEGER :INTEGER <-
// Index of first occurrence of `c' at or before `start_index',
// 0 if none.
( + result:INTEGER;
? {start_index.in_range 0 to upper};
-
+
result := start_index;
-
+
{(result < lower) || {ch = item result}}.until_do {
result := result - 1;
};
-
- ? {(result != 0) ->> {item result = ch}};
+
+ ? {(result != 0) ->> {item result = ch}};
result
);
-
+
- fast_index_of ch:CHARACTER :INTEGER <-
// Gives the index of the first occurrence `ch' or
// 0 if none.
@@ -315,7 +315,7 @@ Section Public
? {(result != count + 1) ->> {item result = ch}};
result
);
-
+
- index_of ch:CHARACTER :INTEGER <-
// Gives the index of the first occurrence of 'ch' or
// 0 if none.
@@ -323,70 +323,70 @@ Section Public
fast_index_of ch
);
- - first_index_of c:CHARACTER :INTEGER <-
+ - first_index_of c:CHARACTER :INTEGER <-
// Index of first occurrence of `c' at index 1 or after index 1.
(
fast_index_of c
);
-
+
- fast_last_index_of ch:CHARACTER :INTEGER <-
// Gives the index of the last occurrence `ch' or
// 0 if none.
(+ result:INTEGER;
- result := 1 + storage.fast_reverse_index_of ch from (upper-1);
-
- ? {(result != 0) ->> {item result = ch}};
+ result := 1 + storage.fast_reverse_index_of ch from (upper-1);
+
+ ? {(result != 0) ->> {item result = ch}};
result
);
-
+
- last_index_of c:CHARACTER :INTEGER <-
// Index of last occurrence of `c' at index upper or before index upper.
(
fast_last_index_of c
);
-
+
- first_difference_index other:ABSTRACT_STRING :INTEGER <-
// First difference index with `other'.
// if `other' is equal `Self', return `upper' + 1
[ -? {other != NULL}; ]
( + result:INTEGER;
-
+
(Self = other).if {
result := upper + 1;
} else {
result := lower;
{
- (result <= upper) &&
- {result <= other.upper} &&
+ (result <= upper) &&
+ {result <= other.upper} &&
{item result = other.item result}
}.while_do {
result := result + 1;
- };
+ };
};
result
);
-
+
- has ch:CHARACTER :BOOLEAN <- storage.fast_has ch until (count - 1);
// True if `ch' is in the STRING.
-
+
- has_substring other:ABSTRACT_STRING :BOOLEAN <-
// True if `other' is in the STRING.
( first_substring_index other != 0 );
-
+
- occurrences c:CHARACTER :INTEGER <-
// Number of times character `c' appears in the string.
(
storage.fast_occurrences c until (count - 1)
);
-
+
- has_suffix s:ABSTRACT_STRING :BOOLEAN <-
// True if suffix of `Current' is `s'.
(
+ result:BOOLEAN;
+ i1,i2:INTEGER;
-
+
? { s != NULL };
-
+
(s.count <= count).if {
i1 := count - s.count + 1;
i2 := 1;
@@ -396,18 +396,18 @@ Section Public
};
result := i1 > count;
};
-
+
result
);
-
+
- has_prefix p:ABSTRACT_STRING :BOOLEAN <-
// True if prefix of `Current' is `p'.
(
+ result:BOOLEAN;
+ i:INTEGER;
-
+
? { p != NULL };
-
+
( p.count <= count ).if {
i := p.count;
{ (i = 0) || { item i != p.item i}}.until_do {
@@ -415,19 +415,19 @@ Section Public
};
result := i = 0;
};
-
+
result
);
-
+
// Testing and Conversion:
-
+
- is_boolean:BOOLEAN <-
// does self represent a BOOLEAN?
// valid BOOLEANS are "TRUE" and "FALSE".
(
(Self == "TRUE") || { Self == "FALSE"}
);
-
+
- to_boolean:BOOLEAN <-
// Boolean value;
// "true" yields true, "false" yields false (what a surprise).
@@ -435,7 +435,7 @@ Section Public
?{ is_boolean };
Self == "TRUE"
);
-
+
- is_bit:BOOLEAN <-
// True when the contents is a sequence of bits (i.e., mixed
// characters `0' and characters `1').
@@ -471,15 +471,15 @@ Section Public
+ negative: BOOLEAN;
+ result:BOOLEAN;
+ cc: CHARACTER;
-
+
// state 0: nothing read.
// state 1: "+" or "-" read.
// state 2: in the number.
// state 3: after the number.
// state 4: error.
-
+
i := 1;
-
+
{ (state = 4) || {i > count}}.until_do {
cc := item i;
( state = 0).if {
@@ -523,20 +523,20 @@ Section Public
};
}.elseif { state = 3 } then {
cc.is_separator.if {
- } else {
+ } else {
state := 4;
};
};
-
+
i := i + 1;
};
( (state != 0) && { state != 4}).if {
result := TRUE;
};
-
+
result
);
-
+
- is_integer_64:BOOLEAN <-
// Does self represent an INTEGER_64?
// `Result' is true if and only if the following two conditions hold:
@@ -558,15 +558,15 @@ Section Public
+ negative: BOOLEAN;
+ result:BOOLEAN;
+ cc: CHARACTER;
-
+
// state 0: nothing read.
// state 1: "+" or "-" read.
// state 2: in the number.
// state 3: after the number.
// state 4: error.
-
+
i := 1;
-
+
{ (state = 4) || {i > count}}.until_do {
cc := item i;
( state = 0).if {
@@ -610,20 +610,20 @@ Section Public
};
}.elseif { state = 3 } then {
cc.is_separator.if {
- } else {
+ } else {
state := 4;
};
};
-
+
i := i + 1;
};
( (state != 0) && { state != 4}).if {
result := TRUE;
};
-
+
result
);
-
+
- to_integer:INTEGER <-
// self must look like an INTEGER.
(
@@ -631,7 +631,7 @@ Section Public
+ cc: CHARACTER;
+ negative: BOOLEAN;
+ result:INTEGER;
-
+
? { is_integer };
// state 0: nothing read.
// state 1: "+" or "-" read.
@@ -675,13 +675,13 @@ Section Public
// cc.is_separator
i := count; // terminate the loop
};
-
+
i := i + 1;
};
-
+
result
);
-
+
- to_integer_64:INTEGER_64 <-
// self must look like an INTEGER.
(
@@ -689,7 +689,7 @@ Section Public
+ cc: CHARACTER;
+ negative: BOOLEAN;
+ result:INTEGER_64;
-
+
? { is_integer };
// state 0: nothing read.
// state 1: "+" or "-" read.
@@ -733,13 +733,13 @@ Section Public
// cc.is_separator
i := count; // terminate the loop
};
-
+
i := i + 1;
};
-
+
result
);
-
+
- is_hexadecimal :BOOLEAN <-
( + j:INTEGER;
+ result:BOOLEAN;
@@ -765,7 +765,7 @@ Section Public
- is_octal :BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
- (is_empty).if_false {
+ (is_empty).if_false {
j := lower;
{(j > upper) || {! item j.is_octal_digit}}.until_do {
j:=j+1;
@@ -778,7 +778,7 @@ Section Public
- to_octal:INTEGER_64 <-
( + result:INTEGER_64;
? {is_octal};
-
+
lower.to upper do { j:INTEGER;
result := (result << 3) | item j.octal_value;
};
@@ -804,7 +804,7 @@ Section Public
- to_binary :INTEGER_64 <-
( + result:INTEGER_64;
? {is_bit};
-
+
lower.to upper do { j:INTEGER;
result := result << 1;
(item j = '1').if {
@@ -813,7 +813,7 @@ Section Public
};
result
);
-
+
- is_real_16_16:BOOLEAN <-
// Does self represent an REAl_16_16 ?
// `Result' is true if and only if the following two conditions hold:
@@ -837,17 +837,17 @@ Section Public
+ result:BOOLEAN;
+ cc: CHARACTER;
+ d:INTEGER;
-
+
// state 0: nothing read.
// state 1: "+" or "-" read.
// state 2: in the number before the point
// state 3: in the number after the point
// state 4: after the number.
// state 5: error.
-
+
i := 1;
d := 1;
-
+
{ (state = 5) || {i > count}}.until_do {
cc := item i;
( state = 0).if {
@@ -899,7 +899,7 @@ Section Public
state := 5;
};
};
-
+
i := i + 1;
};
negative.if {
@@ -908,24 +908,24 @@ Section Public
( (state != 0) && { state != 5}).if {
result := TRUE;
};
-
+
result
);
-
+
- to_real_16_16:REAL_16_16 <-
(
+ i, state, value_int: INTEGER;
+ value:REAL_16_16;
- + negative: BOOLEAN;
+ + negative: BOOLEAN;
+ cc: CHARACTER;
+ d:INTEGER;
-
+
// state 0: nothing read.
// state 1: "+" or "-" read.
// state 2: in the number before the point
// state 3: in the number after the point
// state 4: after the number.
-
+
i := 1;
d := 1;
@@ -951,7 +951,7 @@ Section Public
cc.is_digit.if {
value_int := value_int * 10 + cc.decimal_value;
}.elseif { cc = '.' } then {
- state := 3;
+ state := 3;
value := value_int.to_real_16_16;
} else { // cc is separator
value := value_int.to_real_16_16;
@@ -968,25 +968,25 @@ Section Public
// cc is separator
i := count; // terminate the loop
};
-
+
i := i + 1;
};
-
+
(state = 2).if {
value := value_int.to_real_16_16;
};
-
+
negative.if {
value := - value;
};
-
+
value
);
-
+
//
// Modification:
//
-
+
- Self:SELF '+' other:ABSTRACT_STRING :STRING_BUFFER <-
// Create a new STRING which is the concatenation of
// `self' and `other'.
@@ -1002,7 +1002,7 @@ Section Public
[
+? {Result.count = count + other.count};
];
-
+
- as_lower:STRING <-
// New object with all letters in lower case.
(
@@ -1012,7 +1012,7 @@ Section Public
result.to_lower;
result
);
-
+
- as_upper:STRING <-
// New object with all letters in upper case.
(
@@ -1021,18 +1021,18 @@ Section Public
result.copy Self;
result.to_upper;
result
- );
-
+ );
+
// Other features:
-
+
- first:CHARACTER <-
// Access to the very `first' character.
(
+ result:CHARACTER;
//? {! is_empty};
-
+
result := storage.item 0;
-
+
//? { result == item 1};
result
);
@@ -1042,13 +1042,13 @@ Section Public
(
+ result:CHARACTER;
? {! is_empty};
-
+
result := storage.item (count - 1);
-
+
? { result = item count};
result
);
-
+
- substring start_index:INTEGER to end_index:INTEGER :STRING <-
// New string consisting of items [`start_index'.. `end_index'].
[
@@ -1059,71 +1059,71 @@ Section Public
( + c:INTEGER;
+ result:STRING;
-
+
c := end_index - start_index + 1;
result := STRING.create c;
result.set_count c;
result.storage.slice_copy storage to 0 from (start_index - 1) to (end_index - 1);
-
+
result
)
[
+? { Result.count = end_index - start_index + 1 };
];
-
- - substring_begin start:INTEGER to_begin end:INTEGER :STRING <-
+
+ - substring_begin start:INTEGER to_begin end:INTEGER :STRING <-
(
substring start to end
);
-
+
- substring_begin start:INTEGER to_end end:INTEGER :STRING <-
(
substring start to (upper-end-1)
);
-
+
- substring_end start:INTEGER to_end end:INTEGER :STRING <-
(
substring (upper-start-1) to (upper-end-1)
);
-
+
- substring_index (other:ABSTRACT_STRING,start_index:INTEGER) :INTEGER <-
// Position of the first occurrence of `other' at or after 1
// or 0 f none.
( + i,s,result:INTEGER;
-
+
//? {! other.is_empty };
? { (start_index >=1) && { start_index <= count + 1 }};
-
+
s := start_index;
{(result != 0) || {(s + other.count - 1) > count }}.until_do {
i := 1;
{(i > other.count) || {item (s + i - 1) != other.item i}}.until_do {
i := i + 1;
};
-
+
(i > other.count).if {
result := s;
} else {
s := s + 1;
};
};
-
+
result
);
-
+
- first_substring_index other:ABSTRACT_STRING :INTEGER <-
// Position of the first occurrence of `other' at or after 1
// or 0 if none.
(
? {! other.is_empty };
-
+
substring_index (other,1)
);
//
// Splitting a STRING:
//
-
+
- partition sep:ABSTRACT_STRING from start_index:INTEGER :(STRING, STRING, STRING) <-
[
-? {sep != NULL};
@@ -1167,13 +1167,13 @@ Section Public
result.copy split_buffer;
};
};
-
+
result
)
[
+? { (Result != NULL) ->> { ! Result.is_empty }};
];
-
+
- split_str sep:ABSTRACT_STRING in words:COLLECTION(STRING) <-
// Same jobs as `split_str' but result is appended in `words'.
[
@@ -1184,7 +1184,7 @@ Section Public
// i first character of the next word
// j-1 last character of the next word
// j first character of the next separator
-
+
i := 1;
{ j := substring_index(sep, i); j != 0 }.while_do {
words.add_last (substring i to (j-1));
@@ -1207,10 +1207,10 @@ Section Public
};
};
? { (result != NULL) ->> { ! result.is_empty }};
-
+
result
);
-
+
- split_in words:COLLECTION(STRING) <-
// Same jobs as `split' but result is appended in `words'.
(
@@ -1218,7 +1218,7 @@ Section Public
// state = 0: waiting next word.
// state = 1: inside a new word.
+ c: CHARACTER;
-
+
? { words != NULL};
old_count := words.count;
(count > 0).if {
@@ -1234,7 +1234,7 @@ Section Public
(! c.is_separator).if {
string_buffer.append_character c;
} else {
- words.add_last (string_buffer.twin);
+ words.add_last (string_buffer.twin);
state := 0;
};
};
@@ -1243,10 +1243,10 @@ Section Public
words.add_last (string_buffer.twin);
};
};
-
+
? { (words.count) >= old_count };
);
-
+
- split_at sep:CHARACTER :ARRAY(STRING) <-
// Split the string at characters `c' into an array of words.
(
@@ -1259,13 +1259,13 @@ Section Public
result.copy split_buffer;
};
};
-
+
result
)
[
+? { (Result != NULL) ->> { ! Result.is_empty }};
];
-
+
- split_at sep:CHARACTER in words:COLLECTION(STRING) <-
// Same jobs as `split' but result is appended in `words'.
(
@@ -1273,7 +1273,7 @@ Section Public
// state = 0: waiting next word.
// state = 1: inside a new word.
+ c: CHARACTER;
-
+
? { words != NULL};
old_count := words.count;
(count > 0).if {
@@ -1289,7 +1289,7 @@ Section Public
(c != sep).if {
string_buffer.append_character c;
} else {
- words.add_last (string_buffer.twin);
+ words.add_last (string_buffer.twin);
state := 0;
};
};
@@ -1298,15 +1298,15 @@ Section Public
words.add_last (string_buffer.twin);
};
};
-
+
? { (words.count) >= old_count };
);
-
+
- get_new_iterator:ITERATOR(CHARACTER) <-
(
ITERATOR_ON_STRING(CHARACTER).create Self
);
-
+
- same_string other:ABSTRACT_STRING :BOOLEAN <-
// Do self and other have the same character sequence?
// Useful in proper descendants of STRING.
@@ -1314,25 +1314,25 @@ Section Public
? { other != NULL };
Self == other.to_string
);
-
+
- to_string:STRING <-
// New STRING having the same character sequence as self.
// Useful in proper descendants of STRING.
(
STRING.create_from_string Self
);
-
+
- string_buffer:STRING := STRING.create 256; // Private, temporary once buffer.
-
+
- split_buffer:ARRAY(STRING) := ARRAY(STRING).create_with_capacity 4 lower 1;
-
+
//
// Display.
//
-
- - print <-
- (
- IO.put_string Self;
+
+ - print <-
+ (
+ IO.put_string Self;
);
- printline <-
@@ -1340,23 +1340,23 @@ Section Public
IO.put_string Self;
IO.put_string "\n";
);
-
+
- fast_print <-
(
SYSTEM_IO.print_string Self;
);
-
+
- println <-
[ -? {storage.item count = '\0'}; ]
(
to_external.println;
);
-
+
//
// The guru section
//
-
- - to_external:NATIVE_ARRAY(CHARACTER) <-
+
+ - to_external:NATIVE_ARRAY(CHARACTER) <-
// Gives C access to the internal `storage' (may be dangerous).
// To be compatible with C, a null character is added at the end
// of the internal `storage'. This extra null character is not
diff --git a/lib/standard/time/date.li b/lib/standard/time/date.li
index a40961d..d4aea1a 100644
--- a/lib/standard/time/date.li
+++ b/lib/standard/time/date.li
@@ -19,61 +19,61 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded DATE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Date";
-
+
- type := `unsigned long`;
-
+
- default := `0`:DATE;
-
+
Section Insert
-
- - parent_object:OBJECT := OBJECT;
-
+
+ - parent_object:OBJECT := OBJECT;
+
Section Private
-
+
- to_raw:UINTEGER_32 <-
(
CONVERT(SELF,UINTEGER_32).on Self
);
-
+
Section Public
-
+
- Self:SELF '>' Right 60 other:SELF :BOOLEAN <- to_raw > other.to_raw;
-
+
- Self:SELF '<' Right 60 other:SELF :BOOLEAN <- to_raw < other.to_raw;
-
+
- Self:SELF '>=' Right 60 other:SELF :BOOLEAN <- to_raw >= other.to_raw;
-
+
- Self:SELF '<=' Right 60 other:SELF :BOOLEAN <- to_raw <= other.to_raw;
-
+
- year :UINTEGER_16 <-
- (
+ (
(to_raw >> 16).to_uinteger_16
);
-
+
- month:UINTEGER_8 <-
(
- ((to_raw & 0FF00h)>>8).to_uinteger_8
+ ((to_raw & 0FF00h)>>8).to_uinteger_8
);
-
+
- day :UINTEGER_8 <-
(
- (to_raw & 01Fh).to_uinteger_8
+ (to_raw & 01Fh).to_uinteger_8
);
-
+
- week_day :UINTEGER_8 <-
(
((to_raw >> 5) & 0111b).to_uinteger_8
);
-
-
+
+
Section Public
-
+
- create (y:UINTEGER_16,m,d,wd:UINTEGER_8) :DATE <-
( + date:UINTEGER_32;
? { m.in_range 1 to 12};
@@ -85,14 +85,14 @@ Section Public
date := date | (wd << 5);
CONVERT(UINTEGER_32,SELF).on date
);
-
+
- to_string:STRING <-
( + result:STRING;
result := STRING.create 13;
append_in result;
result
);
-
+
- append_in str:STRING <-
(
week_day
@@ -124,7 +124,7 @@ Section Public
str.add_last '/';
month.append_in str format 2 with '0';
str.add_last '/';
- year.append_in str format 4;
+ year.append_in str format 4;
);
- append_short_in str:STRING <-
@@ -133,7 +133,7 @@ Section Public
str.add_last '/';
month.append_in str format 2 with '0';
str.add_last '/';
- (year % 100).append_in str format 2 with '0';
+ (year % 100).append_in str format 2 with '0';
);
- append_short2_in str:STRING <-
@@ -142,9 +142,9 @@ Section Public
str.add_last '/';
month.append_in str format 2 with '0';
str.add_last '/';
- year.append_in str format 4 with '0';
+ year.append_in str format 4 with '0';
);
-
+
- print <-
(
to_string.print;
diff --git a/src/code_life/expr.li b/src/code_life/expr.li
index 58e5b30..4e99ce2 100644
--- a/src/code_life/expr.li
+++ b/src/code_life/expr.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR;
- copyright := "2003-2007 Benoit Sonntag";
@@ -27,33 +27,33 @@ Section Header
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all expression";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
- cardinality:INTEGER <- 1;
-
+
//
// Comparison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <- FALSE;
-
+
- Self:SELF '!~=' Right 60 other:EXPR :BOOLEAN <- ! (Self ~= other);
-
+
//
// Type.
//
-
- - static_type:TYPE_FULL <-
- (
- deferred;
+
+ - static_type:TYPE_FULL <-
+ (
+ deferred;
NULL
- );
-
+ );
+
- get_type t:TYPES_TMP <- deferred;
//
@@ -61,28 +61,28 @@ Section Public
//
- is_constant:BOOLEAN <- FALSE;
-
+
//
// Check type.
//
-
- - check_type t:TYPE_FULL with p:POSITION :EXPR <-
- ( + result:EXPR;
+
+ - check_type t:TYPE_FULL with p:POSITION :EXPR <-
+ ( + result:EXPR;
+ local:VARIABLE;
- + instr:INSTR;
+ + instr:INSTR;
+ rec:EXPR;
+ slot_name:STRING_CONSTANT;
- + slot_msg:SLOT;
+ + slot_msg:SLOT;
+ node:NODE;
+ args:FAST_ARRAY(EXPR);
+ ts:ITM_TYPE_SIMPLE;
-
+
? {static_type != NULL};
? {t != NULL};
-
- (t.affect_with static_type).if {
+
+ (t.affect_with static_type).if {
result := Self;
- } else {
+ } else {
? {list_current != NULL};
(static_type.is_export_to t).if {
// Auto-export.
@@ -91,10 +91,10 @@ Section Public
list_current.add_last instr;
//
slot_name := ALIAS_STR.get (TYPE.last_cast_name);
- slot_msg := static_type.get_slot slot_name;
- (slot_msg = NULL).if {
+ slot_msg := static_type.get_slot slot_name;
+ (slot_msg = NULL).if {
string_tmp.clear;
- static_type.append_name_in string_tmp;
+ static_type.append_name_in string_tmp;
string_tmp.append " -> ";
t.append_name_in string_tmp;
string_tmp.append ". Slot `";
@@ -108,24 +108,24 @@ Section Public
POSITION.send_error;
//semantic_error p,string_tmp;
};
- (slot_msg.argument_count != 1).if {
+ (slot_msg.argument_count != 1).if {
semantic_error (slot_msg.position,"No argument for this slot.");
};
- ts ?= slot_msg.result_type;
- ((ts = NULL) || {ts.to_run_for (t.raw) != t}).if {
- string_tmp.copy "Type result `";
- slot_msg.result_type.append_in string_tmp;
+ ts ?= slot_msg.result_type;
+ ((ts = NULL) || {ts.to_run_for (t.raw) != t}).if {
+ string_tmp.copy "Type result `";
+ slot_msg.result_type.append_in string_tmp;
string_tmp.append "' is incorrect (Used for auto-conversion to `";
- t.append_name_in string_tmp;
+ t.append_name_in string_tmp;
string_tmp.append "').";
POSITION.put_error semantic text string_tmp;
slot_msg.position.put_position;
position.put_position;
- POSITION.send_error;
+ POSITION.send_error;
};
//
rec := local.read position;
- node := NODE.new_read position slot slot_msg
+ node := NODE.new_read position slot slot_msg
receiver rec self rec intern FALSE;
list_current.add_last node;
//
@@ -137,16 +137,16 @@ Section Public
list_current.add_last instr;
//
slot_name := ALIAS_STR.get (TYPE.last_cast_name);
- slot_msg := t.get_slot slot_name;
- (slot_msg = NULL).if {
+ slot_msg := t.get_slot slot_name;
+ (slot_msg = NULL).if {
string_tmp.clear;
t.append_name_in string_tmp;
string_tmp.append " <- ";
- static_type.append_name_in string_tmp;
+ static_type.append_name_in string_tmp;
string_tmp.append ". Slot `";
string_tmp.append slot_name;
string_tmp.append "' not found in `";
- t.append_name_in string_tmp;
+ t.append_name_in string_tmp;
string_tmp.append "'.";
POSITION.put_error semantic text string_tmp;
p.put_position;
@@ -157,9 +157,9 @@ Section Public
(slot_msg.argument_count != 2).if {
semantic_error (slot_msg.position,"Incorrect argument for this slot.");
};
- ts ?= slot_msg.result_type;
- ((ts = NULL) || {ts != ITM_TYPE_PARAMETER.type_self}).if {
- string_tmp.copy "Type result `";
+ ts ?= slot_msg.result_type;
+ ((ts = NULL) || {ts != ITM_TYPE_PARAMETER.type_self}).if {
+ string_tmp.copy "Type result `";
slot_msg.result_type.append_in string_tmp;
string_tmp.append "' is incorrect (Used for auto-conversion to `";
t.append_name_in string_tmp;
@@ -167,22 +167,19 @@ Section Public
POSITION.put_error semantic text string_tmp;
slot_msg.position.put_position;
position.put_position;
- POSITION.send_error;
+ POSITION.send_error;
};
//
args := FAST_ARRAY(EXPR).create_with_capacity 2;
args.add_last (PROTOTYPE_CST.create position type t);
args.add_last (local.read position);
- node := NODE.new_read position slot slot_msg
+ node := NODE.new_read position slot slot_msg
receiver (args.first.my_copy) with args intern FALSE;
list_current.add_last node;
//
result := node.result_expr;
} else {
- // Type Error
- t.prototype.filename.print; '='.print;
- static_type.prototype.filename.print; '\n'.print;
-
+ // Type Error
string_tmp.copy "Type `";
t.append_name_in string_tmp;
string_tmp.append "' is invalid with `";
@@ -190,33 +187,33 @@ Section Public
string_tmp.append "'.";
POSITION.put_error semantic text string_tmp;
p.put_position;
- position.put_position;
- POSITION.send_error;
+ position.put_position;
+ POSITION.send_error;
};
};
- result
+ result
);
-
+
//
// Execute.
//
-
+
- execute:INSTR <-
(
execute_unlink
);
-
+
- execute_link:EXPR <-
(
deferred;
NULL
);
//[ ? {Result != NULL}; ];
-
+
- execute_unlink:INSTR <-
(
deferred;
NULL
);
-
+
diff --git a/src/item/itm_external.li b/src/item/itm_external.li
index 9f7babb..e67770b 100644
--- a/src/item/itm_external.li
+++ b/src/item/itm_external.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_EXTERNAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "External C without type result";
-
+
Section Inherit
-
+
+ parent_itm_extern:Expanded ITM_EXTERN;
-
+
Section Public
//
// Constructor
//
-
+
- create p:POSITION text n:STRING_CONSTANT :SELF <-
( + result:SELF;
result := clone;
result.make p text n;
result
);
-
+
- make p:POSITION text n:STRING_CONSTANT <-
(
position := p;
@@ -54,15 +54,15 @@ Section Public
//
// Runnable
//
-
- - to_run_expr:EXPR <-
+
+ - to_run_expr:EXPR <-
( + result:EXPR;
+ lst_acc:FAST_ARRAY(EXPR);
+ num:INTEGER;
+ exp1,exp2,exp3:EXPR;
+ left,right:EXPR;
+ type:TYPE_FULL;
-
+
extern.is_integer.if {
num := extern.to_integer;
(num > 31).if {
@@ -114,24 +114,24 @@ Section Public
}
.when 9 then { // put OBJECT to INTEGER.
exp1 := profil_slot.argument_list.first .read position;
- exp2 := profil_slot.argument_list.item 1.read position;
- exp3 := profil_slot.argument_list.item 2.read position;
+ exp2 := profil_slot.argument_list.item 1.read position;
+ exp3 := profil_slot.argument_list.item 2.read position;
result := PUT_TO.create position base exp1 index exp3 value exp2;
}
.when 10 then { // item INTEGER -> OBJECT.
exp1 := profil_slot.argument_list.first .read position;
- exp2 := profil_slot.argument_list.item 1.read position;
+ exp2 := profil_slot.argument_list.item 1.read position;
result := ITEM.create position base exp1 index exp2;
- }
+ }
.when 11 then { // debug_level -> INTEGER.
result := INTEGER_CST.create position value debug_level_option type (type_integer.default);
}
.when 12 then { // object_size -> INTEGER.
- result := SIZE_OF.create position receiver
+ result := SIZE_OF.create position receiver
(profil_slot.argument_list.first.type);
}
.when 13 then { // CONVERT SRC TO DST.on src:SRC :DST.
- type := profil_slot.result_list.first.type;
+ type := profil_slot.result_list.first.type;
exp2 := profil_slot.argument_list.second.read position;
result := CAST.create type value exp2;
}
@@ -144,13 +144,13 @@ Section Public
};
}
.when 15 then { // is_cop_type:BOOLEAN
- type := profil_slot.argument_list.first.type;
- (type.prototype.style = '-').if {
+ type := profil_slot.argument_list.first.type;
+ (type.prototype.style = '-').if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
};
- }
+ }
.when 16 then { // LIST.upper:INTEGER
not_yet_implemented;
}
@@ -161,20 +161,20 @@ Section Public
result := INTEGER_CST.create position value inline_level type (type_integer.default);
}
.when 19 then { // compiler_optimization -> BOOLEAN.
- (is_optimization).if {
+ (is_optimization).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
};
}
- .when 20 then { // compiler_built_on -> STRING_CONSTANT.
+ .when 20 then { // compiler_built_on -> STRING_CONSTANT.
string_tmp.clear;
SYSTEM.get_current_date.append_in string_tmp;
string_tmp.add_last ' ';
SYSTEM.get_current_time.append_in string_tmp;
result := STRING_CST.create position text (ALIAS_STR.get string_tmp) length (string_tmp.count);
}
- .when 21 then { // forall_data action:{ E; }
+ .when 21 then { // forall_data action:{ E; }
//result := forall_data_product;
}
.when 22 to 31 then { // FREE
@@ -182,20 +182,20 @@ Section Public
};
} else {
lst_acc := get_access;
- result := EXTERNAL_C.create position text last_code
+ result := EXTERNAL_C.create position text last_code
access lst_acc persistant TRUE type (TYPE_VOID.default);
};
result
);
-
+
Section Private
-
+
//
// Reflexivity
//
-
+
- forall_data_product:EXPR <-
( + type:TYPE_FULL;
type := profil_slot.argument_list.first.type;
-
+
);
\ No newline at end of file
--
Lisaac compiler
More information about the Lisaac-commits
mailing list