[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-562-g80c8930
Mildred Ki'Lya
silkensedai at online.fr
Wed Feb 10 21:01:50 UTC 2010
The following commit has been merged in the master branch:
commit 80c8930ff594d2f17a7afb1defd010236a5b9f1e
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Wed Feb 10 14:15:46 2010 +0100
Remove trailing spaces
diff --git a/install_lisaac.li b/install_lisaac.li
index f0d1fbe..f90a820 100644
--- a/install_lisaac.li
+++ b/install_lisaac.li
@@ -20,58 +20,58 @@
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := INSTALL_LISAAC;
- comment := "Configure the system file and the PATH";
-
+
- external := `#include <unistd.h>`;
-
+
Section Inherit
-
+
- parent_object:OBJECT <- OBJECT;
-
-Section Private
-
+
+Section Private
+
- is_release:BOOLEAN := FALSE;
-
+
//
- // Independance File System
+ // Independance File System
//
-
- - open_read n:ABSTRACT_STRING :POINTER <-
+
+ - open_read n:ABSTRACT_STRING :POINTER <-
( + buf:NATIVE_ARRAY(CHARACTER);
string_tmp.copy n;
buf := string_tmp.to_external;
- `fopen((char*)@buf,"rb")`:(POINTER)
+ `fopen((char*)@buf,"rb")`:(POINTER)
);
- - open_write n:ABSTRACT_STRING :POINTER <-
+ - open_write n:ABSTRACT_STRING :POINTER <-
( + buf:NATIVE_ARRAY(CHARACTER);
string_tmp.copy n;
buf := string_tmp.to_external;
`fopen((char*)@buf,"wb")`:(POINTER)
);
-
- - read f:POINTER in buf:STRING size sz:INTEGER :INTEGER <-
+
+ - read f:POINTER in buf:STRING size sz:INTEGER :INTEGER <-
( + ptr:NATIVE_ARRAY(CHARACTER);
+ result:INTEGER;
- ptr := buf.to_external;
+ ptr := buf.to_external;
result := `fread((void *)(@ptr),(size_t)(1), (size_t)(@sz),(FILE*)(@f))`:(INTEGER);
buf.from_external ptr;
result
);
- - write f:POINTER with buf:STRING size sz:INTEGER :INTEGER <-
+ - write f:POINTER with buf:STRING size sz:INTEGER :INTEGER <-
( + ptr:NATIVE_ARRAY(CHARACTER);
+ result:INTEGER;
- ptr := buf.to_external;
+ ptr := buf.to_external;
result := `fwrite((void *)(@ptr),(size_t)(1), (size_t)(@sz),(FILE*)(@f))`:(INTEGER);
result
);
-
+
- close p:POINTER <- `fclose((FILE*)(@p))`;
-
+
- file_size p:POINTER :INTEGER <-
( + result:INTEGER;
`fseek((FILE*)(@p),0,SEEK_END)`;
@@ -84,31 +84,31 @@ Section Private
( + p:NATIVE_ARRAY(CHARACTER);
+ stream:POINTER;
+ result:BOOLEAN;
-
+
p := new_path.to_external;
stream := `fopen((char*)@p,"w+b")`:POINTER;
(result := (stream != NULL)).if {
- close stream;
+ close stream;
};
result
);
-
+
//
// Tools management.
//
-
+
- string_tmp:STRING := STRING.create 256;
- string_tmp2:STRING := STRING.create 256;
-
+
- error st:ABSTRACT_STRING <-
(
"Error: ".print;
st.print;
die_with_code exit_failure_code;
);
-
- - step_count:INTEGER;
-
+
+ - step_count:INTEGER;
+
- title str:ABSTRACT_STRING count mx:INTEGER <-
(
step_count := step_count + 1;
@@ -129,11 +129,11 @@ Section Private
'='.print;
};
'\n'.print;
- );
-
+ );
+
- question str:ABSTRACT_STRING :CHARACTER <-
( + result:CHARACTER;
-
+
str.print;
" (y/n) ".print;
{(result != 'y') && {result != 'n'}}.while_do {
@@ -142,7 +142,7 @@ Section Private
IO.read_character;
result
);
-
+
- menu t:ABSTRACT_STRING text txt:ABSTRACT_STRING count n:INTEGER :INTEGER <-
( + result,tmp:INTEGER;
'\n'.print;
@@ -156,7 +156,7 @@ Section Private
tmp := IO.last_string.to_integer;
(tmp.in_range 0 to n).if {
result := tmp;
- } else {
+ } else {
"Incorrect range [0-".print;
n.print;
"]\n".print;
@@ -167,26 +167,26 @@ Section Private
}.do_while {result = -1};
result
);
-
- - update file:ABSTRACT_STRING idf id:STRING_CONSTANT
+
+ - update file:ABSTRACT_STRING idf id:STRING_CONSTANT
with new_text:ABSTRACT_STRING confirmation conf:BOOLEAN <-
( + index:INTEGER;
+ old_buffer,input:STRING;
+ std_file:POINTER;
+ size_file:INTEGER;
-
+
" A `".print;
file.print;
-
+
std_file := open_read file;
- (std_file != NULL).if {
+ (std_file != NULL).if {
// Update file.
size_file := file_size std_file;
input := STRING.create (size_file + new_text.count);
read std_file in input size size_file;
- close std_file;
- //
- index := input.first_substring_index id;
+ close std_file;
+ //
+ index := input.first_substring_index id;
(index != 0).if {
// Update configuration.
old_buffer := STRING.create 200;
@@ -208,25 +208,25 @@ Section Private
" New value is:\n".print;
};
} else {
- "' file has been updated with:\n".print;
+ "' file has been updated with:\n".print;
index := input.upper + 1;
};
new_text.print;
- // Append configuration.
- input.insert_string new_text to index;
+ // Append configuration.
+ input.insert_string new_text to index;
} else {
// Creation file.
- "' file has been created with:\n".print;
- new_text.print;
+ "' file has been created with:\n".print;
+ new_text.print;
input := new_text;
(! make_file file).if {
error "Not create file!";
};
- };
-
- ((! conf) || {question " Confirmation ?" = 'y'}).if {
- (conf).if {
- '\n'.print;
+ };
+
+ ((! conf) || {question " Confirmation ?" = 'y'}).if {
+ (conf).if {
+ '\n'.print;
};
std_file := open_write file;
(std_file = NULL).if {
@@ -236,8 +236,8 @@ Section Private
close std_file;
};
);
-
- - execute str:ABSTRACT_STRING :BOOLEAN <-
+
+ - execute str:ABSTRACT_STRING :BOOLEAN <-
( + result:BOOLEAN;
(ENVIRONMENT.execute_command str != 0).if {
"Error: execute `".print;
@@ -247,60 +247,60 @@ Section Private
result := TRUE;
};
result
- );
-
+ );
+
//
// Global variable.
//
-
+
- path_current:STRING;
- path_home :STRING;
- shell :STRING;
- system :STRING_CONSTANT;
- - file :STRING;
+ - file :STRING;
- comment :STRING_CONSTANT;
- path :STRING_CONSTANT;
- path_next :STRING_CONSTANT;
-
+
//
// Constant for environment variable & path.
//
-
+
- system_unix_bash:STRING_CONSTANT := "Unix - bash";
- system_unix_tcsh:STRING_CONSTANT := "Unix - tcsh";
- system_unix_zsh :STRING_CONSTANT := "Unix - zsh";
- system_unix_bsd :STRING_CONSTANT := "Unix - BSD or Mac";
- system_windows :STRING_CONSTANT := "Windows - DOS";
- system_unknown :STRING_CONSTANT := "Unknown";
-
+
- file_bashrc :STRING_CONSTANT := "/.bashrc";
- file_cshrc :STRING_CONSTANT := "/.cshrc";
- file_zshenv :STRING_CONSTANT := "/.zshenv";
- file_profile :STRING_CONSTANT := "/.profile";
- file_autoexec :STRING_CONSTANT := "C:\\autoexec.bat";
- file_msdos_sys:STRING_CONSTANT := "C:\\msdos.sys";
-
+
- comment_windows :STRING_CONSTANT := "\r\nREM **** LISAAC COMPILER ****\r\n";
- comment_unix :STRING_CONSTANT := "\n# **** LISAAC COMPILER ****\n";
-
+
- path_bash :STRING_CONSTANT := "export PATH=";
- path_tcsh :STRING_CONSTANT := "set path=(";
- path_windows:STRING_CONSTANT := "set path=";
-
+
- path_bash_next :STRING_CONSTANT := "/bin:$PATH\n\n";
- path_tcsh_next :STRING_CONSTANT := "/bin $path)\n\n";
- path_windows_next:STRING_CONSTANT := "\\bin;%path%\r\n\r\n";
-
+
//
// Detect system and install environment variables.
//
-
+
- detect_system <-
- ( + std_file :POINTER;
-
+ ( + std_file :POINTER;
+
//
// Detect system
- //
+ //
(shell != NULL).if {
file := STRING.create_from_string path_home;
(shell.is_empty).if {
@@ -310,14 +310,14 @@ Section Private
// Unix - bash
file.append file_bashrc;
system := system_unix_bash;
- comment := comment_unix;
+ comment := comment_unix;
path := path_bash;
path_next := path_bash_next;
}.elseif {shell.has_substring "tcsh"} then {
// Unix - tcsh
file.append file_cshrc;
system := system_unix_tcsh;
- comment := comment_unix;
+ comment := comment_unix;
path := path_tcsh;
path_next := path_tcsh_next;
}.elseif {shell.has_substring "zsh"} then {
@@ -331,7 +331,7 @@ Section Private
// Unknown
" Shell not recognized: ".print;
shell.print;
- '\n'.print;
+ '\n'.print;
system := system_unknown;
};
} else {
@@ -342,36 +342,36 @@ Section Private
close std_file;
file := STRING.create_from_string file_autoexec;
system := system_windows;
- comment := comment_windows;
+ comment := comment_windows;
path := path_windows;
path_next := path_windows_next;
} else {
// Unknown
system := system_unknown;
- };
- };
-
+ };
+ };
+
" System detect: ".print;
system.print;
);
-
+
- install_make_lip <-
(
- (system != system_unknown).if {
+ (system != system_unknown).if {
(system = system_windows).if {
- ENVIRONMENT.execute_command "copy make.lip.sample make.lip";
- update "make.lip" idf " + target" with
- " + target:STRING := \"windows\";\n" confirmation FALSE;
+ ENVIRONMENT.execute_command "copy make.lip.sample make.lip";
+ update "make.lip" idf " + target" with
+ " + target:STRING := \"windows\";\n" confirmation FALSE;
//
- "\n Note: Use `mingw' for Windows.\n".print;
+ "\n Note: Use `mingw' for Windows.\n".print;
} else {
- ENVIRONMENT.execute_command "cp make.lip.sample make.lip";
- update "make.lip" idf " + target" with
- " + target:STRING := \"unix\";\n" confirmation FALSE;
- };
+ ENVIRONMENT.execute_command "cp make.lip.sample make.lip";
+ update "make.lip" idf " + target" with
+ " + target:STRING := \"unix\";\n" confirmation FALSE;
+ };
(is_release).if_false {
"\n Directory for library repository: ".print;
- IO.read_line;
+ IO.read_line;
'\n'.print;
string_tmp2.copy " + lib_extra:STRING := \"";
string_tmp2.append (IO.last_string);
@@ -381,26 +381,26 @@ Section Private
string_tmp2.append "/*";
};
string_tmp2.append "\";\n";
- update "make.lip" idf " + lib_extra" with
+ update "make.lip" idf " + lib_extra" with
string_tmp2 confirmation TRUE;
- update "make.lip" idf " + lib_unstable" with
+ update "make.lip" idf " + lib_unstable" with
" + lib_unstable:STRING := \"\";\n" confirmation FALSE;
};
};
- '\n'.print;
+ '\n'.print;
);
-
- - install_variable <-
+
+ - install_variable <-
( + new_text :STRING;
-
+
title "Fix target variable in `make.lip'." count 5;
install_make_lip;
//
// Installation environment variable
//
-
+
title "Installation of environment variables." count 5;
-
+
(system = system_unknown).if {
// Fail.
" Auto-install fail !\n\
@@ -410,20 +410,20 @@ Section Private
"\\bin;%path%\n\n".print;
} else {
// Creation environment variables.
- new_text := STRING.create_from_string comment;
+ new_text := STRING.create_from_string comment;
new_text.append path;
new_text.append path_current;
new_text.append path_next;
update file idf comment with new_text confirmation TRUE;
};
-
+
//
// Installation Library path
//
-
+
title "Installation of Lisaac library path." count 5;
new_text := STRING.create_from_string path_current;
- (system = system_windows).if {
+ (system = system_windows).if {
new_text.replace_all '\\' with '/';
};
new_text.prepend "#define LISAAC_DIRECTORY \"";
@@ -433,28 +433,28 @@ Section Private
update "src/path.h" idf "#define LISAAC_DIRECTORY" with new_text confirmation FALSE;
'\n'.print;
);
-
+
//
// Install Editor.
//
-
+
- lisaac_mode_comment :STRING_CONSTANT := ";; **** LISAAC MODE ****";
- lisaac_mode_path :STRING_CONSTANT := "\n(setq load-path (cons \"";
- - lisaac_mode_path_end:STRING_CONSTANT := "/editor/emacs/\" load-path))\n";
- - lisaac_mode :STRING_CONSTANT :=
+ - lisaac_mode_path_end:STRING_CONSTANT := "/editor/emacs/\" load-path))\n";
+ - lisaac_mode :STRING_CONSTANT :=
"(add-to-list 'auto-mode-alist '(\"\\\\.li\\\\'\" . lisaac-mode))\n\
\(add-to-list 'auto-mode-alist '(\"\\\\.lip\\\\'\" . lisaac-mode))\n\
\(autoload 'lisaac-mode \"lisaac-mode\" \"Major mode for Lisaac Programs\" t)\n\n";
-
+
- lisaac_vim:STRING_CONSTANT :=
"\nsyntax on \n\
\filetype plugin on \n\
\filetype indent on \n\
\au BufNewFile,BufRead *.li setf lisaac\n";
-
+
- install_emacs <-
( + file_name, new_text:STRING;
-
+
file_name := STRING.create 100;
(path_home = NULL).if {
file_name.copy "C:";
@@ -474,21 +474,21 @@ Section Private
);
- install_kate <-
- (
+ (
(system = system_windows).if {
" Sorry, not Kate editor for windows.".print;
} else {
- ENVIRONMENT.execute_command "mkdir -p ~/.kde/share/apps/katepart/syntax";
+ ENVIRONMENT.execute_command "mkdir -p ~/.kde/share/apps/katepart/syntax";
string_tmp.copy "cp -f editor/kate/lisaac_v2.xml ~/.kde/share/apps/katepart/syntax/.";
" `".print;
string_tmp.print;
"'\t".print;
- (ENVIRONMENT.execute_command string_tmp != 0).if {
+ (ENVIRONMENT.execute_command string_tmp != 0).if {
"\n Sorry, auto-install fail !\n\
\ You can to read the `editor/kate/README' file.".print;
} else {
- "OK.".print;
- };
+ "OK.".print;
+ };
};
);
@@ -499,22 +499,22 @@ Section Private
// TODO: Fix this since gvim exists on windows system
(system = system_windows).if {
" Sorry, not Vim editor for windows.\n\n".print;
- } else {
+ } else {
ENVIRONMENT.execute_command "mkdir -p ~/.vim/syntax";
ENVIRONMENT.execute_command "mkdir -p ~/.vim/indent";
- ENVIRONMENT.execute_command "mkdir -p ~/.vim/backup";
- ENVIRONMENT.execute_command "mkdir -p ~/.vim/temp";
-
+ ENVIRONMENT.execute_command "mkdir -p ~/.vim/backup";
+ ENVIRONMENT.execute_command "mkdir -p ~/.vim/temp";
+
// Syntax hilightning support
string_tmp.copy "cp -f editor/vim/syntax/lisaac.vim ~/.vim/syntax/";
" `".print;
string_tmp.print;
"'\t".print;
- (ENVIRONMENT.execute_command string_tmp != 0).if {
+ (ENVIRONMENT.execute_command string_tmp != 0).if {
"\n Sorry, auto-install fail !\n\
\ You can read the `editor/vim/install_vim_plugin.sh' file.\n".print;
} else {
- "OK.\n".print;
+ "OK.\n".print;
};
// Syntax indentation support
@@ -522,11 +522,11 @@ Section Private
" `".print;
string_tmp.print;
"'\t".print;
- (ENVIRONMENT.execute_command string_tmp != 0).if {
+ (ENVIRONMENT.execute_command string_tmp != 0).if {
"\n Sorry, auto-install fail !\n\
\ You can read the `editor/vim/install_vim_plugin.sh' file.\n".print;
} else {
- "OK.\n".print;
+ "OK.\n".print;
};
// Install ~/.vimrc file
@@ -534,7 +534,7 @@ Section Private
"\n It is recommanded to install the default vimrc file provided by the \n\
\ lisaac installer. \n\n\
\ If you choose not doing this action, your vimrc will only be updated \n\
- \ Do you want to install the default config provided by lisaac installer ?";
+ \ Do you want to install the default config provided by lisaac installer ?";
(char = 'n').if {
file_name := STRING.create 100;
(path_home = NULL).if {
@@ -542,57 +542,57 @@ Section Private
} else {
file_name.copy path_home;
};
- file_name.append "/.vimrc";
+ file_name.append "/.vimrc";
update file_name idf lisaac_vim with lisaac_vim confirmation TRUE;
} else {
string_tmp.copy "cp -f editor/vim/vimrc ~/.vimrc";
" `".print;
string_tmp.print;
"'\t".print;
- (ENVIRONMENT.execute_command string_tmp != 0).if {
+ (ENVIRONMENT.execute_command string_tmp != 0).if {
"\n Sorry, auto-install fail !\n\
\ You can read the `editor/vim/install_vim_plugin.sh' file.\n".print;
} else {
- "OK.\n".print;
+ "OK.\n".print;
};
};
};
);
-
+
- install_hippoedit <-
(
(system = system_windows).if {
- string_tmp.copy
+ string_tmp.copy
"copy editor/hippoedit/lisaac_spec.xml \"C:\\Program Files\\HippoEDIT\\data\\syntax\"";
//
" Execute: `".print;
string_tmp.print;
- "'\t".print;
- (ENVIRONMENT.execute_command string_tmp != 0).if {
+ "'\t".print;
+ (ENVIRONMENT.execute_command string_tmp != 0).if {
"Fail!".print;
} else {
- "Ok.".print;
+ "Ok.".print;
};
} else {
" Sorry, Hippoedit editor is only for Windows.".print;
};
);
-
+
- install_eclipse <-
- (
+ (
" Prerequisite: you need the Eclipse package installed.\n\
\ Use the Eclipse Update Manager to install the Lisaac Mode with the URL:\n\
\ http://isaacproject.u-strasbg.fr/eclipse/update/\n\n\
- \ Please, read `editor/eclipse/README' file for further information.\n".print;
+ \ Please, read `editor/eclipse/README' file for further information.\n".print;
);
-
-
+
+
//
// Install Compiler
//
-
+
- compile_file n:STRING_CONSTANT <-
- (
+ (
string_tmp.copy "gcc -U_FORTIFY_SOURCE -O2 bin/";
string_tmp.append n;
string_tmp.append ".c -o bin/";
@@ -607,13 +607,13 @@ Section Private
".c' file.\n".print;
};
'\n'.print;
- );
-
+ );
+
- compile_shorter is_root:BOOLEAN <-
( + rm,compile:STRING_CONSTANT;
-
+
" Compile `shorter' tools for your system (please wait ...)\n".print;
- (is_root).if {
+ (is_root).if {
compile := "lisaac src/make.lip -shorter -q -boost -o bin/shorter -gcc -Ibin/.";
} else {
(system = system_windows).if {
@@ -624,69 +624,69 @@ Section Private
compile := "bin/lisaac src/make.lip -shorter -q -boost -o bin/shorter -gcc -Isrc/.";
};
};
- (ENVIRONMENT.execute_command compile = 0).if {
- " Shorter ok!\n".print;
+ (ENVIRONMENT.execute_command compile = 0).if {
+ " Shorter ok!\n".print;
(rm != NULL).if {
- ENVIRONMENT.execute_command rm;
+ ENVIRONMENT.execute_command rm;
};
} else {
" Sorry, `shorter' not ready...\n".print;
};
'\n'.print;
);
-
+
//
// Build lib doc.
//
-
+
- build_lib <-
- (
- string_tmp.clear;
+ (
+ string_tmp.clear;
(system = system_windows).if {
- ENVIRONMENT.execute_command "mkdir doc\\html";
+ ENVIRONMENT.execute_command "mkdir doc\\html";
string_tmp.copy "bin\\shorter -d -f belinda -o doc\\html";
// BSBS: A ajouter internal mais sur le meme run shorter
} else {
- ENVIRONMENT.execute_command "mkdir -p doc/html";
+ ENVIRONMENT.execute_command "mkdir -p doc/html";
string_tmp.copy "bin/shorter -d -f belinda -o doc/html";
- };
+ };
" Execute: `".print;
string_tmp.print;
"'\t".print;
(ENVIRONMENT.execute_command string_tmp = 0).if {
" OK\n\n\
- \ Note: you'll find this documentation in `doc/html/index.html'\n".print;
+ \ Note: you'll find this documentation in `doc/html/index.html'\n".print;
} else {
" Fail!\n".print;
};
);
-
+
- user_install <-
( + choice,choice2:INTEGER;
-
+
{
- choice := menu "Menu." text
+ choice := menu "Menu." text
"1- Compiler & Shorter Installation.\n\
- \2- Editor Installation.\n\
+ \2- Editor Installation.\n\
\3- Build the librarie documentation (HTML).\n\
\0- Exit." count 3;
-
- choice
- .when 1 then {
+
+ choice
+ .when 1 then {
step_count := 0;
-
- install_variable;
-
- title "Compilation of Lisaac compiler." count 5;
+
+ install_variable;
+
+ title "Compilation of Lisaac compiler." count 5;
"*---------------------------------------------------------*\n\
\| Note: You need at least 768MB of memory. |\n\
\*---------------------------------------------------------*\n".print;
compile_file "lisaac";
-
- title "Compilation of Shorter tool." count 5;
-
+
+ title "Compilation of Shorter tool." count 5;
+
compile_shorter FALSE;
-
+
"Welcome to the Lisaac World ! \n\
\============================= \n\
\ Installation successfull. \n\
@@ -709,23 +709,23 @@ Section Private
\5- eFTE.\n\
\6- Eclipse.\n\
\0- Exit menu." count 6;
- choice2
+ choice2
.when 1 then {
title "Installation of `lisaac-mode' for Emacs." count 0;
- install_emacs;
+ install_emacs;
}
.when 2 then {
title "Installation of `lisaac.vim' for Vim." count 0;
- install_vim;
+ install_vim;
}
.when 3 then {
title "Installation of `lisaac_v2.xml' for Kate." count 0;
- install_kate;
+ install_kate;
}
.when 4 then {
title "Installation of `lisaac_spec.xml' for Hippoedit." count 0;
install_hippoedit;
- }
+ }
.when 5 then {
title "Installation of eFTE mode." count 0;
" Note: eFTE Lisaac mode is native.\n\
@@ -738,17 +738,17 @@ Section Private
}.do_while {choice2 != 0};
}
.when 3 then {
- title "Build the librarie documentation with Shorter (HTML format)." count 0;
+ title "Build the librarie documentation with Shorter (HTML format)." count 0;
build_lib;
};
}.do_while {choice != 0};
);
-
+
- path_bin:ABSTRACT_STRING := "/usr/bin";
- path_lib:ABSTRACT_STRING := "/usr/lib/lisaac";
- path_doc:ABSTRACT_STRING := "/usr/share/lisaac";
- path_man:ABSTRACT_STRING := "/usr/share/man/man1";
-
+
- ask_path msg:ABSTRACT_STRING default val:ABSTRACT_STRING :ABSTRACT_STRING <-
( + result:STRING;
+ car:CHARACTER;
@@ -758,31 +758,31 @@ Section Private
"] ? (y/n) ".print;
car := IO.read_character;
IO.read_character;
- (car.to_lower = 'y').if {
- result := val;
- } else {
+ (car.to_lower = 'y').if {
+ result := val;
+ } else {
"\n new path : ".print;
- IO.read_word;
+ IO.read_word;
result := IO.last_string;
result.remove_first 1;
};
result
- );
-
+ );
+
- system_install <-
( + path:ABSTRACT_STRING;
+ create:{ (ABSTRACT_STRING,ABSTRACT_STRING,ABSTRACT_STRING,BOOLEAN); };
-
+
// path.h
string_tmp2.copy "#define LISAAC_DIRECTORY \"";
string_tmp2.append path_lib;
string_tmp2.append "\"\n";
- update "bin/path.h" idf "#define LISAAC_DIRECTORY"
+ update "bin/path.h" idf "#define LISAAC_DIRECTORY"
with string_tmp2 confirmation FALSE;
// compile
compile_file "lisaac";
//
- create := { (msg,cpy,dft:ABSTRACT_STRING,ask:BOOLEAN);
+ create := { (msg,cpy,dft:ABSTRACT_STRING,ask:BOOLEAN);
(ask).if {
path := ask_path msg default dft;
} else {
@@ -792,9 +792,9 @@ Section Private
string_tmp.append path;
execute string_tmp;
string_tmp.copy cpy;
- string_tmp.append path;
- execute string_tmp;
- };
+ string_tmp.append path;
+ execute string_tmp;
+ };
//
create.value (" binary path","cp bin/lisaac ",path_bin,TRUE);
//
@@ -819,35 +819,35 @@ Section Private
\| `install_lisaac' in user mode. |\n\
\*---------------------------------------------------------*\n".print;
);
-
+
Section Public
-
+
- main <-
( + cwd:NATIVE_ARRAY(CHARACTER);
- + choice:INTEGER;
+ + choice:INTEGER;
"\t\t================================\n\
- \\t\t= Auto-Install Lisaac Compiler =\n\
+ \\t\t= Auto-Install Lisaac Compiler =\n\
\\t\t================================\n\n".print;
string_tmp.clear;
cwd := string_tmp.to_external;
`getcwd(@cwd,255)`;
string_tmp.from_external cwd;
-
+
path_current := STRING.create (string_tmp.count);
- path_current.copy string_tmp;
+ path_current.copy string_tmp;
path_home := ENVIRONMENT.get_environment_variable "HOME";
shell := ENVIRONMENT.get_environment_variable "SHELL";
-
+
title "Detection system." count 0;
detect_system;
-
+
(system != system_windows).if {
- choice := menu "Menu." text
+ choice := menu "Menu." text
"1- User installation.\n\
\2- System installation (root).\n\
\0- Exit." count 2;
choice
- .when 1 then {
+ .when 1 then {
user_install;
}
.when 2 then {
@@ -855,6 +855,6 @@ Section Public
};
} else {
user_install;
- };
+ };
"\nBye.\n\n".print;
);
diff --git a/lib/internal/os_support/dos/file_system/entry.li b/lib/internal/os_support/dos/file_system/entry.li
index dd87406..7728c3f 100644
--- a/lib/internal/os_support/dos/file_system/entry.li
+++ b/lib/internal/os_support/dos/file_system/entry.li
@@ -19,23 +19,23 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ENTRY;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:= "http://IsaacOS.com";
- - author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
+ - author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
- comment := "Entry ANSI";
-
+
Section Inherit
-
+
+ parent_abstract_entry:Expanded ABSTRACT_ENTRY;
-
-Section Public
-
+
+Section Public
+
//
// Physical implementation.
//
@@ -61,35 +61,35 @@ Section Public
`}`;
result
);
-
+
- physical_remove_directory:BOOLEAN <-
( + p:NATIVE_ARRAY(CHARACTER);
p := path.to_external;
`rmdir(@p)`:(INTEGER) = 0
);
-
+
- physical_remove_file:BOOLEAN <-
( + p:NATIVE_ARRAY(CHARACTER);
p := path.to_external;
`remove(@p)`:(INTEGER) = 0
);
-
+
- physical_rename old_path:ABSTRACT_STRING with new_path:ABSTRACT_STRING :BOOLEAN <-
( + old_p,new_p:NATIVE_ARRAY(CHARACTER);
old_p := old_path.to_external;
new_p := new_path.to_external;
`rename(@old_p, at new_p)`:(INTEGER) = 0
);
-
+
//
// Time / Date: Unix -> Lisaac
//
-
+
- to_date t:POINTER :DATE <-
( + result:DATE;
+ wd,md,m:UINTEGER_8;
+ y:UINTEGER_16;
-
+
y := `((struct tm *)@t)->tm_year`:UINTEGER_16 + 1900;
m := `((struct tm *)@t)->tm_mon` :UINTEGER_8 + 1;
md := `((struct tm *)@t)->tm_mday`:UINTEGER_8;
@@ -97,15 +97,15 @@ Section Public
(! wd.in_range 1 to 7).if { // Bug in UNIX ?
wd := 1;
};
- result := DATE.create (y,m,md,wd)
+ result := DATE.create (y,m,md,wd)
);
- to_time t:POINTER :TIME <-
(
- TIME.create
+ TIME.create
((`((struct tm *)@t)->tm_hour`:UINTEGER_8),
(`((struct tm *)@t)->tm_min` :UINTEGER_8),
(`((struct tm *)@t)->tm_sec` :UINTEGER_8),
0)
);
-
+
diff --git a/lib/internal/os_support/dos/video/bitmap_8.li b/lib/internal/os_support/dos/video/bitmap_8.li
index fd51051..58bb746 100644
--- a/lib/internal/os_support/dos/video/bitmap_8.li
+++ b/lib/internal/os_support/dos/video/bitmap_8.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := BITMAP_8;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Bitmap 8 bits";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
-
+
Section Inherit
-
+
+ parent_bitmap:Expanded BITMAP;
-
+
Section Public
-
+
- pixel_geometry:PIXEL := PIXEL_8;
-
-Section Private
-
+
+Section Private
+
//
// Data.
//
-
+
// Mapping memory bitmap.
+ image:FAST_ARRAY(BMP_LINE_8);
-
+
- get_line y:INTEGER :BMP_LINE <-
(
image.item y
);
-
+
//
- // Creation.
+ // Creation.
//
- make (w,h:INTEGER) <-
@@ -65,13 +65,13 @@ Section Private
image.put (BMP_LINE_8.create w) to y;
};
clipping_off;
- );
-
+ );
+
- make (w,h:INTEGER) at offset_begin:UINTEGER_32 bytes_per_line lx:INTEGER <-
( + offset:UINTEGER_32;
-
+
width := w;
- height := h;
+ height := h;
image := FAST_ARRAY(BMP_LINE_8).create h;
offset:=offset_begin;
0.to (image.upper) do { y:INTEGER;
@@ -80,8 +80,8 @@ Section Private
};
clipping_off;
);
-
-
+
+
diff --git a/lib/internal/os_support/dos/video/bmp_line_8.li b/lib/internal/os_support/dos/video/bmp_line_8.li
index c941f5a..4e87d37 100644
--- a/lib/internal/os_support/dos/video/bmp_line_8.li
+++ b/lib/internal/os_support/dos/video/bmp_line_8.li
@@ -19,68 +19,68 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := BMP_LINE_8;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Bitmap line 8 bits";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
Section Inherit
-
+
+ parent_bmp_line:Expanded BMP_LINE;
-
+
Section Private
-
+
+ storage:MAP_NATIVE_ARRAY(PIXEL_8);
-
+
- get_storage:NATIVE_ARRAY(UINTEGER_8) <- NATIVE_ARRAY(UINTEGER_8).force_conversion storage;
-
+
- make n:INTEGER <-
- (
+ (
capacity := n;
- upper := n - 1;
- storage := MAP_NATIVE_ARRAY(PIXEL_8).calloc n;
+ upper := n - 1;
+ storage := MAP_NATIVE_ARRAY(PIXEL_8).calloc n;
);
-
+
- make_with_capacity n:INTEGER <-
(
capacity := n;
upper := -1;
- storage := MAP_NATIVE_ARRAY(PIXEL_8).calloc n;
+ storage := MAP_NATIVE_ARRAY(PIXEL_8).calloc n;
);
-
+
- make n:INTEGER at offset:UINTEGER_32 <-
- (
+ (
capacity := n;
- upper := n - 1;
- storage := MAP_NATIVE_ARRAY(PIXEL_8).force_conversion offset;
+ upper := n - 1;
+ storage := MAP_NATIVE_ARRAY(PIXEL_8).force_conversion offset;
);
Section Public
-
+
- pixel_geometry:PIXEL := PIXEL_8;
-
+
//
// Put.
//
-
- - put (r,g,b:UINTEGER_8) from idx_begin:INTEGER to idx_end:INTEGER <-
- ( + pixel:PIXEL_8;
+
+ - put (r,g,b:UINTEGER_8) from idx_begin:INTEGER to idx_end:INTEGER <-
+ ( + pixel:PIXEL_8;
? {idx_begin<=idx_end};
? {idx_begin>=0};
? {idx_end.in_range 0 to upper};
-
+
PIXEL_24.color (r,g,b);
pixel := PIXEL_24.to_pixel_8;
idx_begin.to idx_end do { n:INTEGER;
storage.item n.copy pixel;
};
);
-
+
- put bmp:BMP_LINE offset ofs:INTEGER from idx_begin:INTEGER to idx_end:INTEGER <-
( + offset:INTEGER;
+ pixel:PIXEL_8;
@@ -88,8 +88,8 @@ Section Public
? {idx_begin >= 0};
? {idx_end.in_range 0 to upper};
? {ofs >= 0};
- ? {(ofs + (idx_end - idx_begin)) <= bmp.upper};
-
+ ? {(ofs + (idx_end - idx_begin)) <= bmp.upper};
+
offset := ofs;
idx_begin.to idx_end do { n:INTEGER;
pixel := bmp.item_8 offset;
@@ -97,15 +97,15 @@ Section Public
offset := offset + 1;
};
);
-
+
//
// Get.
//
-
+
- item n:INTEGER :PIXEL <-
( ? {n.in_range 0 to upper};
storage.item n
);
-
+
diff --git a/lib/internal/os_support/dos/video/event_system.li b/lib/internal/os_support/dos/video/event_system.li
index 60c1b8b..325d290 100644
--- a/lib/internal/os_support/dos/video/event_system.li
+++ b/lib/internal/os_support/dos/video/event_system.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EVENT_SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "X11 - Event System";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
-Section Public
- - make <-
+Section Public
+
+ - make <-
(
// Nothing.
);
-
+
- get_event <-
- (
+ (
KEYBOARD.get_scan;
MOUSE.get_new_event;
);
-
-
+
+
diff --git a/lib/internal/os_support/dos/video/keyboard.li b/lib/internal/os_support/dos/video/keyboard.li
index 166a033..a0d6353 100644
--- a/lib/internal/os_support/dos/video/keyboard.li
+++ b/lib/internal/os_support/dos/video/keyboard.li
@@ -23,22 +23,22 @@ Section Header
+ name := KEYBOARD;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:="http://IsaacOS.com";
- author :="Boutet Jerome (boutet at loria.fr),Sonntag Benoit (bsonntag at loria.fr)";
- comment :="Keyboard for DOS - AZERTY";
- - version := 1;
+ - version := 1;
- date :="2003/04";
-
+
Section Inherit
-
+
+ parent_input_keyboard:Expanded INPUT_KEYBOARD;
Section Private
-
- + e_code:BOOLEAN; // TRUE If extended mode
-
+
+ + e_code:BOOLEAN; // TRUE If extended mode
+
// Lower case.
- cmin:STRING_CONSTANT := "\0d\&\"\39d\(-_
)=\1d\\2d\azertyuiop^$\3d\^qsdfghjklmý^*wxcvbn,;:!^*^ ";
// Upper case.
@@ -46,27 +46,27 @@ Section Private
- cmm:STRING_CONSTANT := "\27d\\8d\\9d\\13d\"; // 0:Echap 1:Del 2:Tab 3:Enter
- caltgr:STRING_CONSTANT := "'~#{[|`\\^@]}";
-
+
// Num keyb.
- keynum0:STRING_CONSTANT := "789-456+1230."; // from 70-82
- keynum1:STRING_CONSTANT := "BUA\0d\LMR\0d\ELZIS"; // Without NumLock
-
+
// Extended keyboard from 88 to 102
- - ext_key:STRING_CONSTANT := "\55d\\28d\\52d\\27d\\70d\\78d\\81d\\82d\\76d\\74d\\71d\\79d\\80d\\72d\\54d\";
+ - ext_key:STRING_CONSTANT := "\55d\\28d\\52d\\27d\\70d\\78d\\81d\\82d\\76d\\74d\\71d\\79d\\80d\\72d\\54d\";
- buf_extk:STRING_CONSTANT := "\13d\BEISRLUDZAH";
-Section Public
-
+Section Public
+
- old_scan:UINTEGER_8;
-
+
//
// Get Character (Interrupt #21)
//
- get_scan <-
( + cu,scancode,tmp:UINTEGER_8;
-
- scancode:=SYSTEM.itemb 60h;
+
+ scancode:=SYSTEM.itemb 60h;
(scancode != old_scan).if {
old_scan := scancode;
cu:=getcode (scancode-1);
@@ -76,7 +76,7 @@ Section Public
"Reboot ...\n".print;
die_with_code exit_failure_code;
};
-
+
tmp:=(p_end+1)&003h;
buffer_event.item p_end.make ((cmd.to_uinteger_16<<8)|cu);
(((tmp+2)&3)!=p_beg).if {
@@ -86,30 +86,30 @@ Section Public
};
};
);
-
+
Section Private
-
+
- send_cmd (comm,dta:UINTEGER_8) <-
- // Send a command to keyboard
+ // Send a command to keyboard
(
// Empty buffer
{ ((SYSTEM.itemb 64h) & 2) != 0}.while_do {
- SYSTEM.itemb 60h;
- };
+ SYSTEM.itemb 60h;
+ };
// Send command
- SYSTEM.putb comm to 60h;
+ SYSTEM.putb comm to 60h;
// Waiting for answer
- { ((SYSTEM.itemb 64h) & 1) == 0}.while_do {};
+ { ((SYSTEM.itemb 64h) & 1) == 0}.while_do {};
// Read answer
- SYSTEM.itemb 60h;
+ SYSTEM.itemb 60h;
// Send data
- SYSTEM.putb dta to 60h;
+ SYSTEM.putb dta to 60h;
// Waiting for answer
- { ((SYSTEM.itemb 64h) & 1) == 0}.while_do {};
+ { ((SYSTEM.itemb 64h) & 1) == 0}.while_do {};
// Read answer
- SYSTEM.itemb 60h;
+ SYSTEM.itemb 60h;
);
-
+
- light <-
(
send_cmd (0EDh,(((cmd & 80h)>>7)|((cmd & 40h)>>5)|((cmd & 20h)>>3)));
@@ -117,7 +117,7 @@ Section Private
- keyup cu:UINTEGER_8 :UINTEGER_8 <-
( + result:UINTEGER_8;
- cmd := cmd & 0F7h; // Deactivate the cmd bit
+ cmd := cmd & 0F7h; // Deactivate the cmd bit
bin_code.put ((bin_code.item (cu>>3)) & ~(1<<(cu&7))) to (cu>>3);
// Analyze: for deactivate the cmd
((cu == 28) || {cu == 89}).if {
@@ -128,9 +128,9 @@ Section Private
cmd := cmd & (~02h);
}.elseif { cu == 55 } then {
// Alt
- cmd := cmd & (~04h);
+ cmd := cmd & (~04h);
result := ascii_code;
- ascii_code := 0;
+ ascii_code := 0;
}.elseif { (cu == 41) || { cu == 53} } then {
// Shift 1 or Shift 2
cmd := cmd & (~10h);
@@ -150,7 +150,7 @@ Section Private
cmd := cmd | 02h;
}.elseif { cu == 55 } then {
// Alt
- cmd := cmd | 04h;
+ cmd := cmd | 04h;
}.elseif { (cu == 41) || { cu == 53} } then {
// Shift 1 or Shift 2
cmd := cmd | 10h;
@@ -189,7 +189,7 @@ Section Private
} else {
cmd := cmd | 08h;
result := cmm.item (cu2+1).to_uinteger_8;
- };
+ };
};
}.elseif {cu <= 67} then {
cmd := cmd | 08h; // F1 to F10 = cmd
@@ -221,11 +221,11 @@ Section Private
result := '/'.to_uinteger_8;
} else {
cmd := cmd | 08h;
- result := buf_extk.item (cu-90).to_uinteger_8;
+ result := buf_extk.item (cu-90).to_uinteger_8;
};
result
);
-
+
- getcode cu:UINTEGER_8 :UINTEGER_8 <-
// Translate Scan Code -> cmd.ASCII
( + j:INTEGER;
@@ -264,8 +264,8 @@ Section Private
};
result
);
-
-
+
+
diff --git a/lib/internal/os_support/dos/video/mouse.li b/lib/internal/os_support/dos/video/mouse.li
index a333ee3..10c6d01 100644
--- a/lib/internal/os_support/dos/video/mouse.li
+++ b/lib/internal/os_support/dos/video/mouse.li
@@ -23,77 +23,77 @@ Section Header
+ name := MOUSE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:="http://IsaacOS.com";
- author :="Sonntag Benoit (bsonntag at loria.fr)";
- comment :="Mouse for DOS.";
-
+
- external := `union REGS __in_mouse;`;
-
+
Section Inherit
+ parent_input:Expanded INPUT;
-
+
+ parent_window:Expanded AREA;
-
+
Section Public
- set (x,y:INTEGER) with (left_new,right_new:BOOLEAN) <-
( + tmp:UINTEGER_8;
+ x_new, y_new:INTEGER;
-
+
y_new := y.max y_minimum.min y_maximum;
x_new := x.max x_minimum.min x_maximum;
-
+
tmp:=(p_end+1)&003h;
buffer_event.item p_end.make (x_new,y_new) button (left_new,right_new);
(((tmp+2)&3)!=p_beg).if {
p_end:=tmp;
};
-
+
get_event;
-
+
// Update status.
x_current:=x_new;
y_current:=y_new;
right:=right_new;
- left :=left_new;
+ left :=left_new;
);
-
+
Section Public
-
+
+ x_minimum:INTEGER;
+ x_maximum:INTEGER;
-
+
+ y_minimum:INTEGER;
+ y_maximum:INTEGER;
-
+
+ x_current:INTEGER;
- + y_current:INTEGER;
-
+ + y_current:INTEGER;
+
+ right:BOOLEAN;
+ left:BOOLEAN;
-
+
Section Private
-
+
+ buffer_event:MAP_FAST_ARRAY(EVENT_MOUSE);
- p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
- p_end:UINTEGER_8; // Pointer on the buffer (end)
-
+
Section Public
-
+
//
// Creation / Initialisation.
//
-
+
- make <-
(
//
// Mouse hardware configuration.
//
//display_on;
-
+
x_maximum := VIDEO.x_max;
y_maximum := VIDEO.y_max;
@@ -104,38 +104,38 @@ Section Public
0.to 3 do { j:INTEGER;
buffer_event.item j.set_prev (buffer_event.item ((j-1)&3));
};
-
+
mask := FAST_ARRAY(UINTEGER_16).create 16;
make (INTERFACE.screen) from (x_current,y_current) size (16,16);
);
-
+
- get_event <-
( + p:INTEGER;
+ evt:EVENT_MOUSE;
-
+
p := p_beg;
{ p != p_end }.while_do {
evt := buffer_event.item p;
(list_client.lower).to (list_client.upper) do { j:INTEGER;
list_client.item j.receive (buffer_event.item p);
- };
+ };
p := (p + 1) & 03h;
- };
+ };
);
-
+
- acknowledge <-
(
p_beg := (p_beg+1) & 03h;
);
-
+
- display_on <- `__in_mouse.w.ax=0x01; int386(0x33,&__in_mouse,&__in_mouse)`;
- display_off <- `__in_mouse.w.ax=0x02; int386(0x33,&__in_mouse,&__in_mouse)`;
-
+
- get_new_event <-
( + b,x,y:INTEGER;
+ new_r,new_l,is_move:BOOLEAN;
-
+
`__in_mouse.w.ax=0x03; int386(0x33,&__in_mouse,&__in_mouse)`;
b:=`__in_mouse.w.bx`:INTEGER;
x:=`__in_mouse.w.cx`:INTEGER / 2;
@@ -151,14 +151,14 @@ Section Public
set (x,y) with (new_l,new_r);
};
);
-
+
//
// Display.
//
-
+
// BSBS: A refaire avec une bitmap en dehors contenant le dessin avec une couleur de mask!!
- // Plus simple, plus puissant, plus rapide !
-
+ // Plus simple, plus puissant, plus rapide !
+
+ mask:FAST_ARRAY(UINTEGER_16);
- pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
@@ -172,42 +172,42 @@ Section Public
parent_window.pixel_hard (x,y) color col;
);
-
+
- line_h_hard (x0,y0:INTEGER) until x1:INTEGER color col:UINTEGER_32 <-
( + m:UINTEGER_16;
? {x0<16};
? {y0<16};
? {x1<16};
-
+
m:=mask.item y0;
x0.to x1 do { xx:INTEGER;
m:=m | (1<<xx);
};
-
+
mask.put m to y0;
parent_window.line_h_hard (x0,y0) until x1 color col;
);
- - slave_pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
+ - slave_pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
( + m:UINTEGER_16;
-
+
m:=mask.item y;
((m & (1<<x))=0).if {
parent_window.pixel_hard (x,y) color col;
};
);
-
- - slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER color col:UINTEGER_32 <-
+
+ - slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER color col:UINTEGER_32 <-
( + m:UINTEGER_16;
-
+
m:=mask.item y;
x1.to x2 do { xx:INTEGER;
((m & (1<<xx))=0).if {
parent_window.pixel_hard (xx,y) color col;
};
};
- );
-
+ );
+
- slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER image line:BMP_LINE offset ofs:INTEGER <-
( + m:UINTEGER_16;
+ col:UINTEGER_32;
@@ -216,17 +216,17 @@ Section Public
m:=mask.item y;
x1.to x2 do { xx:INTEGER;
((m & (1<<xx))=0).if {
- col := line.get_color ofs_img;
+ col := line.get_color ofs_img;
parent_window.pixel_hard (xx,y) color col;
- };
+ };
ofs_img := ofs_img + 1;
};
);
-
+
- draw (x0,y0:INTEGER) to (x1,y1:INTEGER) <-
(
clipping (x0,y0) to (x1,y1);
-
+
color white;
poly_move_to (1,1);
poly_line_to (9,9);
@@ -234,10 +234,10 @@ Section Public
poly_line_to (8,14);
poly_line_to (5,14);
poly_line_to (5,9);
- poly_line_to (1,9);
- poly_move_to (1,1);
+ poly_line_to (1,9);
+ poly_move_to (1,1);
poly_trace;
-
+
color red;
line_v (0,0) until 10;
line_h (1,10) until 4;
@@ -247,12 +247,11 @@ Section Public
line_h (7,10) until 10;
line (1,0) to (10,9);
);
-
+
- get_object (x,y:INTEGER) :AREA <-
(
NULL
);
-
-
-
-
\ No newline at end of file
+
+
+
diff --git a/lib/internal/os_support/dos/video/pixel_8.li b/lib/internal/os_support/dos/video/pixel_8.li
index 4082c09..a671974 100644
--- a/lib/internal/os_support/dos/video/pixel_8.li
+++ b/lib/internal/os_support/dos/video/pixel_8.li
@@ -19,44 +19,44 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PIXEL_8;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Pixel 8 bits (RR-VVV-BBB)";
-
+
- bibliography:= "http://IsaacOS.com";
-
+
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
-
+
Section Inherit
-
+
- parent_pixel:PIXEL := PIXEL;
-
+
Section Mapping
-
+
+ real_color:UINTEGER_8;
-
+
Section Public
-
+
- red:UINTEGER_8 <- real_color & 11000000b;
-
+
- green:UINTEGER_8 <- (real_color & 00111000b) << 2;
-
+
- blue:UINTEGER_8 <- real_color << 5;
-
+
- color col:UINTEGER_32 <-
(
real_color := (((col >> 16).to_uinteger_8) &11000000b) | ((((col & 00FF00h) >> 10).to_uinteger_8)&00111000b) | (((col & 0000FFh).to_uinteger_8) >>5);
);
-
+
- color_rgb (r,g,b:UINTEGER_8) <-
(
real_color := (r &11000000b) | (g&00111000b) | (b >>5);
);
-
- - size:UINTEGER_8 := 8;
+
+ - size:UINTEGER_8 := 8;
- red_size:UINTEGER_8 := 2;
- red_pos:UINTEGER_8 := 6;
- green_size:UINTEGER_8 := 3;
@@ -65,14 +65,14 @@ Section Public
- blue_pos:UINTEGER_8 := 0;
- reserved_size:UINTEGER_8 :=0;
- reserved_pos:UINTEGER_8 :=0;
-
- - copy other:SELF <-
+
+ - copy other:SELF <-
(
real_color := other.real_color;
);
-
+
- to_pixel_8:PIXEL_8 <- Self;
-
+
diff --git a/lib/internal/os_support/dos/video/video.li b/lib/internal/os_support/dos/video/video.li
index a6d344c..13ad3e8 100644
--- a/lib/internal/os_support/dos/video/video.li
+++ b/lib/internal/os_support/dos/video/video.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := VIDEO;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Driver video - For DOS -";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
-
- - external :=
+
+ - external :=
`
-#include <stdio.h>
+#include <stdio.h>
#include <dos.h>
#include <dpmi.h>
#include <pc.h>
@@ -40,7 +40,7 @@ Section Header
unsigned short __desc_video;
void __init_video_320x200()
{ union REGS in;
-
+
__desc_video=__dpmi_allocate_ldt_descriptors(1);
__djgpp_map_physical_memory((void *)0xA0000, 64000,0xA0000);
__dpmi_set_segment_base_address(__desc_video,0xA0000);
@@ -51,47 +51,47 @@ void __init_video_320x200()
};
void __init_video_text()
{ union REGS in;
-
+
in.w.ax=0x03;
int86(0x10,&in,&in);
};
`;
-
-
+
+
Section Inherit
-
+
+ parent_bitmap:Expanded BITMAP;
-
+
Section Public
-
+
- message str:ABSTRACT_STRING <-
(
str.print;
);
-
+
- is_active:BOOLEAN;
- make (w,h:INTEGER) <-
- (
+ (
? {w = 320};
? {h = 200};
-
+
// Init BITMAP:
width := w;
height := h;
-
+
//
// Init mode 320x200.
//
`__init_video_320x200()`;
-
+
//
// Init palette.
//
SYSTEM.putb 0 to 3C8h;
0.to 255 do { j:INTEGER;
+ r,g,b,c:UINTEGER_8;
-
+
c:=j.to_uinteger_8;
r:=(c&11000000b)>>2;
g:=(c&00111000b);
@@ -106,7 +106,7 @@ Section Public
- pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
( + col8:UINTEGER_8;
+ ofs:INTEGER;
- col8 :=
+ col8 :=
(((col >> 16).to_uinteger_8) & 11000000b) | // Red
(((col >> 10).to_uinteger_8) & 00111000b) | // Green
(((col >> 5).to_uinteger_8) & 00000111b); // Blue
@@ -115,7 +115,7 @@ Section Public
`_farpokeb(__desc_video, at ofs, at col8)`;
//MOUSE.display_on;
);
-
+
- line_h_hard (x,y:INTEGER) until x1:INTEGER color col:UINTEGER_32 <-
( + col8:UINTEGER_8;
+ ofs:INTEGER;
@@ -140,7 +140,7 @@ Section Public
col8 := (((col >> 16).to_uinteger_8) &11000000b) | ((((col & 00FF00h) >> 10).to_uinteger_8)&00111000b) | (((col & 0000FFh).to_uinteger_8) >>5);
`_farpokeb(__desc_video, at j, at col8)`;
ofs_img2:=ofs_img2+1;
- };
+ };
//MOUSE.display_on;
);
diff --git a/lib/internal/os_support/unix/file_system/directory_unix.li b/lib/internal/os_support/unix/file_system/directory_unix.li
index 7ef87ae..c30be62 100644
--- a/lib/internal/os_support/unix/file_system/directory_unix.li
+++ b/lib/internal/os_support/unix/file_system/directory_unix.li
@@ -19,72 +19,72 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=DIRECTORY_UNIX;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:="http://IsaacOS.com";
-
+
- author :="Benoit Sonntag (bsonntag at loria.fr)";
-
+
- comment :="Directory management";
-
- - external :=
+
+ - external :=
`
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
`;
-
+
Section Inherit
-
+
+ parent_entry_unix:Expanded ENTRY_UNIX;
-
+
+ parent_directory:Expanded DIRECTORY;
-
+
Section Public
-
+
- is_open:BOOLEAN <- ( list != NULL);
-
+
//
// Scanning
//
-
+
- open:BOOLEAN <-
( + p,n:NATIVE_ARRAY(CHARACTER);
+ dir,dirent:POINTER;
+ new_entry:ENTRY;
+ result:BOOLEAN;
+ i:INTEGER;
-
+
(list = NULL).if {
list := LINKED_LIST(ENTRY).create;
} else {
list.clear;
};
-
+
p := path.to_external;
- dir := `opendir(@p)`:POINTER;
+ dir := `opendir(@p)`:POINTER;
(dir != NULL).if {
- result := TRUE;
+ result := TRUE;
{
dirent := `readdir(@dir)`:POINTER;
(dirent != NULL).if {
- n := `((struct dirent *)@dirent)->d_name`:NATIVE_ARRAY(CHARACTER);
+ n := `((struct dirent *)@dirent)->d_name`:NATIVE_ARRAY(CHARACTER);
string_tmp.clear;
i := 0;
- {n.item i = '\0'}.until_do {
+ {n.item i = '\0'}.until_do {
string_tmp.add_last (n.item i);
i := i + 1;
};
(string_tmp !== ".".to_string).if {
string_tmp.add_first '/';
- string_tmp.prepend path;
- reduce_path string_tmp;
- new_entry := get_entry string_tmp;
- (new_entry = NULL).if {
- "WARNING: ".print; string_tmp.print; " no readable!\n".print;
+ string_tmp.prepend path;
+ reduce_path string_tmp;
+ new_entry := get_entry string_tmp;
+ (new_entry = NULL).if {
+ "WARNING: ".print; string_tmp.print; " no readable!\n".print;
//result := FALSE;
} else {
(new_entry.path.count >= path.count).if {
@@ -98,41 +98,41 @@ Section Public
};
result
);
-
+
Section DIRECTORY
-
+
- physical_get_entry new_path:ABSTRACT_STRING :ENTRY <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ result:ENTRY;
-
+
pe := new_path.to_external;
// #ifdef __MINGW_H ( voir sous winmerde )
`#ifndef __USE_LARGEFILE64
`;
- `{ struct stat t`;
- (`stat(@pe,&t)`:INTEGER = 0).if {
+ `{ struct stat t`;
+ (`stat(@pe,&t)`:INTEGER = 0).if {
(`S_ISDIR(t.st_mode)`:INTEGER = 0).if {
// File.
result := FILE_UNIX.clone;
} else {
// Directory.
result := DIRECTORY_UNIX.clone;
- };
+ };
result.set_path new_path;
alias.put result to (result.path); // with { (e1,e2:ABSTRACT_STRING); e1 ~=e2 };
};
`}`;
`#else
`;
- `{ struct stat64 t`;
- (`stat64(@pe,&t)`:INTEGER = 0).if {
+ `{ struct stat64 t`;
+ (`stat64(@pe,&t)`:INTEGER = 0).if {
(`S_ISDIR(t.st_mode)`:INTEGER = 0).if {
// File.
result := FILE_UNIX.clone;
} else {
// Directory.
result := DIRECTORY_UNIX.clone;
- };
+ };
result.set_path new_path;
alias.put result to (result.path); //with { (e1,e2:ABSTRACT_STRING); e1 ~=e2 };
};
@@ -141,7 +141,7 @@ Section DIRECTORY
`;
result
);
-
+
- physical_make_directory new_path:ABSTRACT_STRING :BOOLEAN <-
( + pa:NATIVE_ARRAY(CHARACTER);
pa := new_path.to_external;
@@ -152,7 +152,7 @@ Section DIRECTORY
( + pa:NATIVE_ARRAY(CHARACTER);
+ stream:POINTER;
+ result:BOOLEAN;
-
+
pa := new_path.to_external;
stream := `fopen((char*)@pa,"w+b")`:POINTER;
(stream != NULL).if {
@@ -166,7 +166,7 @@ Section DIRECTORY
pa := p.to_external;
`remove(@pa)`:(INTEGER) = 0
);
-
+
- physical_move old_path:ABSTRACT_STRING to new_path:ABSTRACT_STRING :BOOLEAN <-
( + old_p,new_p:NATIVE_ARRAY(CHARACTER);
old_p := old_path.to_external;
diff --git a/lib/internal/os_support/unix/file_system/entry_unix.li b/lib/internal/os_support/unix/file_system/entry_unix.li
index f89d4b3..55c8a10 100644
--- a/lib/internal/os_support/unix/file_system/entry_unix.li
+++ b/lib/internal/os_support/unix/file_system/entry_unix.li
@@ -19,116 +19,116 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ENTRY_UNIX;
- copyright := "2003-2008 Benoit Sonntag";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
- comment := "Entry ANSI C";
-
+
Section Inherit
-
+
+ parent_entry:Expanded ENTRY;
-
-Section Public
-
- - access:UINTEGER_16 <-
+
+Section Public
+
+ - access:UINTEGER_16 <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ result:UINTEGER_16;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
+ `{ struct stat t; stat(@pe,&t)`;
result := `t.st_mode`:UINTEGER_16 & 111_111_111b;
`}`;
result
);
-
- - access_time:TIME <-
+
+ - access_time:TIME <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:TIME;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_atime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_atime))`:POINTER;
result := to_time tt;
`}`;
result
);
-
- - access_date:DATE <-
+
+ - access_date:DATE <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:DATE;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_atime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_atime))`:POINTER;
result := to_date tt;
`}`;
result
);
-
- - update_time:TIME <-
+
+ - update_time:TIME <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:TIME;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_mtime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_mtime))`:POINTER;
result := to_time tt;
`}`;
result
);
-
- - update_date:DATE <-
+
+ - update_date:DATE <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:DATE;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_mtime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_mtime))`:POINTER;
result := to_date tt;
`}`;
result
);
-
+
- create_time:TIME <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:TIME;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_ctime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_ctime))`:POINTER;
result := to_time tt;
`}`;
result
);
-
+
- create_date:DATE <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:DATE;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_ctime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_ctime))`:POINTER;
result := to_date tt;
`}`;
result
);
-
-Section Private
-
+
+Section Private
+
//
// Time / Date: Unix -> Lisaac
//
-
+
- to_date t:POINTER :DATE <-
( + result:DATE;
+ wd,md,m:UINTEGER_8;
+ y:UINTEGER_16;
-
+
y := `((struct tm *)@t)->tm_year`:UINTEGER_16 + 1900;
m := `((struct tm *)@t)->tm_mon` :UINTEGER_8 + 1;
md := `((struct tm *)@t)->tm_mday`:UINTEGER_8;
@@ -136,15 +136,15 @@ Section Private
(! wd.in_range 1 to 7).if { // Bug in UNIX ?
wd := 1;
};
- result := DATE.create (y,m,md,wd)
+ result := DATE.create (y,m,md,wd)
);
- to_time t:POINTER :TIME <-
(
- TIME.create
+ TIME.create
((`((struct tm *)@t)->tm_hour`:UINTEGER_8),
(`((struct tm *)@t)->tm_min` :UINTEGER_8),
(`((struct tm *)@t)->tm_sec` :UINTEGER_8),
0)
);
-
+
diff --git a/lib/internal/os_support/unix/file_system/file_system.li b/lib/internal/os_support/unix/file_system/file_system.li
index b92fd70..7a41d96 100644
--- a/lib/internal/os_support/unix/file_system/file_system.li
+++ b/lib/internal/os_support/unix/file_system/file_system.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=FILE_SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment :="File System manager for Unix.";
-
+
- external := `#include <unistd.h>`; // For `getcwd'
-
-Section Inherit
-
+
+Section Inherit
+
+ parent_directory:DIRECTORY <-
- ( + cwd:NATIVE_ARRAY(CHARACTER);
+ ( + cwd:NATIVE_ARRAY(CHARACTER);
+ result:DIRECTORY;
-
+
DIRECTORY.string_tmp.clear;
cwd := DIRECTORY.string_tmp.to_external;
`getcwd(@cwd,255)`;
DIRECTORY.string_tmp.from_external cwd;
-
+
result ?= DIRECTORY_UNIX.physical_get_entry (DIRECTORY.string_tmp);
DIRECTORY.alias.put result to (result.path);
? {result != NULL};
parent_directory := result
);
-
-
+
+
diff --git a/lib/internal/os_support/unix/file_system/file_unix.li b/lib/internal/os_support/unix/file_system/file_unix.li
index 6ebe4d8..d6968f6 100644
--- a/lib/internal/os_support/unix/file_system/file_unix.li
+++ b/lib/internal/os_support/unix/file_system/file_unix.li
@@ -19,102 +19,102 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FILE_UNIX;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "File management";
-
+
Section Inherit
-
+
+ parent_entry_unix:Expanded ENTRY_UNIX;
-
+
+ parent_file:Expanded FILE;
-
-Section Private
-
+
+Section Private
+
+ stream:POINTER; // Unix file pointer (FILE *).
Section Public
-
+
//
// Physical implementation.
//
-
+
- is_open:BOOLEAN <- stream != NULL;
-
+
- size:UINTEGER_32 <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ result:UINTEGER_32;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
+ `{ struct stat t; stat(@pe,&t)`;
result := `t.st_size`:UINTEGER_32;
`}`;
result
);
-
+
- cursor:UINTEGER_32 <-
- ( + str:POINTER;
- str := stream;
+ ( + str:POINTER;
+ str := stream;
`ftell((FILE *)@str)`:UINTEGER_32
);
-
+
- set_cursor n:UINTEGER_32 <-
[
...
-? {stream != NULL};
-? {n <= size};
]
- ( + str:POINTER;
- str := stream;
+ ( + str:POINTER;
+ str := stream;
`fseek((FILE*)(@str), at n,SEEK_SET)`;
- );
-
+ );
+
- open:BOOLEAN <-
[
-? {stream = NULL};
]
- ( + pa:NATIVE_ARRAY(CHARACTER);
-
+ ( + pa:NATIVE_ARRAY(CHARACTER);
+
pa := path.to_external;
- stream := `fopen((char*)@pa,"r+b")`:(POINTER);
+ stream := `fopen((char*)@pa,"r+b")`:(POINTER);
stream != NULL
- );
+ );
- open_read_only:BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
+ ( + pa:NATIVE_ARRAY(CHARACTER);
pa := path.to_external;
- stream := `fopen((char*)@path_pointer,"rb")`:(POINTER);
+ stream := `fopen((char*)@path_pointer,"rb")`:(POINTER);
stream != NULL
- );
-
+ );
+
- close <-
[
-? {stream != NULL};
]
( + str:POINTER;
-
- str := stream;
- `fclose((FILE*)(@str))`;
+
+ str := stream;
+ `fclose((FILE*)(@str))`;
stream := NULL;
);
-
-Section FILE
-
+
+Section FILE
+
- physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
// return size read or 0 if end of input (-1 on error => exception ?)
- ( + str:POINTER;
- str := stream;
+ ( + str:POINTER;
+ str := stream;
`fread((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
);
-
+
- physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
// return size read or 0 if end of input (-1 on error => exception ?)
( + str:POINTER;
- str := stream;
+ str := stream;
`fwrite((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
);
-
-
+
+
diff --git a/lib/internal/os_support/unix/system/clock.li b/lib/internal/os_support/unix/system/clock.li
index da3cb05..4407bce 100644
--- a/lib/internal/os_support/unix/system/clock.li
+++ b/lib/internal/os_support/unix/system/clock.li
@@ -23,7 +23,7 @@ Section Header
+ name := CLOCK;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:="http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
@@ -31,45 +31,45 @@ Section Header
- comment :="X11 - Clock management.";
- date :="2003/04";
-
+
- external := `#include <time.h>`;
-
-Section Inherit
-
+
+Section Inherit
+
- parent_input:INPUT := INPUT;
-
-Section Public
-
+
+Section Public
+
- date:DATE <-
- ( + wd,d,mo:UINTEGER_8;
+ ( + wd,d,mo:UINTEGER_8;
+ y:UINTEGER_16;
-
- `{
+
+ `{
struct tm *t; time_t tt;
tt = time(NULL);
- t = localtime(&tt)`;
+ t = localtime(&tt)`;
wd := `t->tm_wday`:UINTEGER_8 + 1;
d := `t->tm_mday`:UINTEGER_8;
mo := `t->tm_mon` :UINTEGER_8 + 1;
- y := `t->tm_year`:UINTEGER_16 + 1900;
+ y := `t->tm_year`:UINTEGER_16 + 1900;
`}`;
DATE.create (y,mo,d,wd)
);
-
+
- time:TIME <-
( + s,m,h:UINTEGER_8;
-
- `{
+
+ `{
struct tm *t; time_t tt;
tt = time(NULL);
- t = localtime(&tt)`;
+ t = localtime(&tt)`;
h := `t->tm_hour`:UINTEGER_8;
m := `t->tm_min` :UINTEGER_8;
- s := `t->tm_sec` :UINTEGER_8;
- `}`;
+ s := `t->tm_sec` :UINTEGER_8;
+ `}`;
TIME.create (h,m,s,0)
);
-
+
- make <-
(
// Nothing.
diff --git a/lib/internal/os_support/unix/system/environment.li b/lib/internal/os_support/unix/system/environment.li
index 4e25a04..a2c955e 100644
--- a/lib/internal/os_support/unix/system/environment.li
+++ b/lib/internal/os_support/unix/system/environment.li
@@ -19,11 +19,11 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ENVIRONMENT;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Execute system command and to get/set environment variables.";
Section Public
@@ -38,7 +38,7 @@ Section Public
+ result:STRING;
+ p:NATIVE_ARRAY(CHARACTER);
? { variable != NULL };
-
+
p := basic_getenv(variable.to_external);
(p != NULL).if {
result := STRING.clone;
@@ -54,7 +54,7 @@ Section Public
? { value != NULL };
basic_putenv (variable,value);
);
-
+
- execute_command system_command_line:ABSTRACT_STRING :INTEGER <-
// To execute a `system_command_line' as for example, "ls -l" on UNIX.
// The `Result' depends of the actual operating system. As an exemple,
@@ -69,7 +69,7 @@ Section Public
(
execute_command (system_command_line);
);
-
+
Section Private
- basic_getenv environment_variable:NATIVE_ARRAY(CHARACTER) :NATIVE_ARRAY(CHARACTER) <-
@@ -77,12 +77,12 @@ Section Private
(
`getenv((char*)@environment_variable)`:NATIVE_ARRAY(CHARACTER)
);
-
+
- basic_putenv (variable,value:ABSTRACT_STRING) <-
// To implement `set_environment_variable'.
(
+ v:NATIVE_ARRAY(CHARACTER);
-
+
v := NATIVE_ARRAY(CHARACTER).calloc (variable.count + value.count + 2);
v.copy_from (variable.to_external) until (variable.upper);
v.put '=' to (variable.count);
@@ -90,7 +90,7 @@ Section Private
v.put '\0' to (variable.count + 1 + value.count);
`putenv((char*)@v)`;
);
-
+
- basic_system_execute_command system_command_line:NATIVE_ARRAY(CHARACTER) :INTEGER <-
(
`system(((char*)(@system_command_line)))`:(INTEGER)
diff --git a/lib/internal/os_support/unix/system/float_processor.li b/lib/internal/os_support/unix/system/float_processor.li
index 1a5a13f..afa16fd 100644
--- a/lib/internal/os_support/unix/system/float_processor.li
+++ b/lib/internal/os_support/unix/system/float_processor.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FLOAT_PROCESSOR;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,14 +32,14 @@ Section Inherit
- parent_object:OBJECT := OBJECT;
Section Public
-
+
- init; // Compatibility IsaacOS.
-
- - atan n:REAL :REAL <- `atanf(@n)`:REAL;
- - atan_32 n:REAL_32 :REAL_32 <- `atanf(@n)`:REAL_32;
+
+ - atan n:REAL :REAL <- `atanf(@n)`:REAL;
+ - atan_32 n:REAL_32 :REAL_32 <- `atanf(@n)`:REAL_32;
- atan_64 n:REAL_64 :REAL_64 <- `atan(@n)`:REAL_64;
- atan_80 n:REAL_80 :REAL_80 <- `atanl(@n)`:REAL_80;
-
+
- sqrt n:REAL :REAL <- `sqrtf(@n)`:REAL;
- sqrt_32 n:REAL_32 :REAL_32 <- `sqrtf(@n)`:REAL_32;
- sqrt_64 n:REAL_64 :REAL_64 <- `sqrt(@n)`:REAL_64;
@@ -65,4 +65,3 @@ Section Public
- pow_64 (n,exp:REAL_64) :REAL_64 <- `pow(@n, at exp)`:REAL_64;
- pow_80 (n,exp:REAL_80) :REAL_80 <- `powl(@n, at exp)`:REAL_80;
-
\ No newline at end of file
diff --git a/lib/internal/os_support/unix/system/processor.li b/lib/internal/os_support/unix/system/processor.li
index dea8594..57ceff1 100644
--- a/lib/internal/os_support/unix/system/processor.li
+++ b/lib/internal/os_support/unix/system/processor.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PROCESSOR;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Processor object.";
Section Public
-
+
- to_intel_ulong v:UINTEGER_64 :UINTEGER_64 <- deferred;
-
+
- to_intel_uint v:UINTEGER_32 :UINTEGER_32 <- deferred;
-
+
- to_intel_ushort v:UINTEGER_16 :UINTEGER_16 <- deferred;
-
+
- to_motorola_ulong v:UINTEGER_64 :UINTEGER_64 <-
- (
+ (
(v << 56) | ((v & 0FF00h) << 40) | ((v & 0FF0000h) << 24) | ((v & 0FF000000h) << 8) |
(v >> 56) | ((v >> 40) & 0FF00h) | ((v >> 24) & 0FF0000h) | ((v >> 8) & 0FF000000h)
);
-
+
- to_motorola_uint v:UINTEGER_32 :UINTEGER_32 <-
(
- (v << 24) | ((v & 0FF00h) << 8) | ((v >> 8) & 0FF00h) | (v >> 24)
+ (v << 24) | ((v & 0FF00h) << 8) | ((v >> 8) & 0FF00h) | (v >> 24)
);
-
+
- to_motorola_int v:INTEGER :INTEGER <-
(
// Conversion in uxxx to cut the sign
- (v << 24) | (((v & 0FF00h) << 8).to_uinteger_16) | (((v >> 8) & 0FF00h).to_uinteger_16) | ((v >> 24).to_uinteger_8)
+ (v << 24) | (((v & 0FF00h) << 8).to_uinteger_16) | (((v >> 8) & 0FF00h).to_uinteger_16) | ((v >> 24).to_uinteger_8)
);
-
+
- to_motorola_ushort v:UINTEGER_16 :UINTEGER_16 <-
(
(v << 8) | (v >> 8)
diff --git a/lib/internal/os_support/unix/system/system.li b/lib/internal/os_support/unix/system/system.li
index 0af6ad4..4515e7c 100644
--- a/lib/internal/os_support/unix/system/system.li
+++ b/lib/internal/os_support/unix/system/system.li
@@ -19,58 +19,58 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Generic System Object (methods).";
- external := `#include <time.h>`;
Section Public
-
+
- get_current_date:DATE <-
- ( + wd,d,mo:UINTEGER_8;
+ ( + wd,d,mo:UINTEGER_8;
+ y:UINTEGER_16;
-
- `{
+
+ `{
struct tm *t; time_t tt;
tt = time(NULL);
- t = localtime(&tt)`;
+ t = localtime(&tt)`;
wd := `t->tm_wday`:UINTEGER_8 + 1;
d := `t->tm_mday`:UINTEGER_8;
mo := `t->tm_mon` :UINTEGER_8 + 1;
- y := `t->tm_year`:UINTEGER_16 + 1900;
+ y := `t->tm_year`:UINTEGER_16 + 1900;
`}`;
DATE.create (y,mo,d,wd)
);
-
+
- get_current_time:TIME <-
( + s,m,h:UINTEGER_8;
-
- `{
+
+ `{
struct tm *t; time_t tt;
tt = time(NULL);
- t = localtime(&tt)`;
+ t = localtime(&tt)`;
h := `t->tm_hour`:UINTEGER_8;
m := `t->tm_min` :UINTEGER_8;
- s := `t->tm_sec` :UINTEGER_8;
- `}`;
+ s := `t->tm_sec` :UINTEGER_8;
+ `}`;
TIME.create (h,m,s,0)
);
//
//
//
-
+
- is_ansi:BOOLEAN := TRUE;
-
+
- exit code:INTEGER <- `exit(@code)`;
-
+
- putb value:UINTEGER_8 to port:UINTEGER_16 <-
// Write in port
- (
+ (
`{ unsigned short val;
val = @value;
asm
@@ -78,7 +78,7 @@ Section Public
"movw %0,%%dx \n\
movw %1,%%ax \n\
outb %%al,%%dx "
- : /* No output */
+ : /* No output */
:"r"(@port), "r"(val)
:"%ax","%dx"
);
@@ -102,26 +102,26 @@ Section Public
`}`;
result
);
-
+
- get_universal_time:UINTEGER_64 <-
(
`(unsigned long long)time(NULL)`:UINTEGER_64
);
// Memory Management
-
+
- memory:MEMORY := MEMORY;
-
+
- get_begin_memory:POINTER;
-
- - get_memory_capacity:UINTEGER_CPU <-
+
+ - get_memory_capacity:UINTEGER_CPU <-
( + cap:UINTEGER_CPU;
+ mem,new_mem:POINTER;
cap := 32.mb;
{
cap := cap * 2;
mem := new_mem;
- new_mem := `realloc(@mem, at cap)`:POINTER;
+ new_mem := `realloc(@mem, at cap)`:POINTER;
}.do_until {(new_mem = NULL) || {(cap >> 20) = 2048}}; // BSBS: BUG COMPILO 0.13
(new_mem = NULL).if {
cap := cap / 2;
@@ -131,10 +131,10 @@ Section Public
get_begin_memory := mem;
//
cap
- );
-
+ );
+
Section SYSTEM,MEMORY
-
+
- realloc_c (beg:UINTEGER_32,nb:INTEGER) :UINTEGER_32 <-
( + result:UINTEGER_32;
result := `(unsigned long)realloc((void *)@beg, at nb+15)`:UINTEGER_32;
@@ -149,9 +149,9 @@ Section SYSTEM,MEMORY
? {result != 0};
result
);
-
-Section ISAAC
-
+
+Section ISAAC
+
- make <-
// Isaac compatibility.
(
diff --git a/lib/internal/os_support/unix/system/system_io.li b/lib/internal/os_support/unix/system/system_io.li
index 153aa23..3ee4020 100644
--- a/lib/internal/os_support/unix/system/system_io.li
+++ b/lib/internal/os_support/unix/system/system_io.li
@@ -19,17 +19,17 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SYSTEM_IO;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment := "Lower level for Input / Output";
-
+
- external := `
#include <stdio.h>
#include <stdlib.h>
-
+
/* Hardware 'print_char' */
void print_char(char car)
{
@@ -45,7 +45,7 @@ int die_with_code(int code)
`;
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
Section Public
@@ -55,14 +55,13 @@ Section Public
(
`fputc((int)@byte,stdout)`;
);
-
+
- print_error_char byte:CHARACTER <-
// Low level buffered error output.
(
`fputc((int)@byte,stderr)`;
- );
-
+ );
+
- get_char :CHARACTER <- `fgetc(stdin)`:(CHARACTER);
-
+
- eof:CHARACTER <- `EOF`:CHARACTER;
-
\ No newline at end of file
diff --git a/lib/internal/os_support/unix/video/event_system.li b/lib/internal/os_support/unix/video/event_system.li
index 3d3d7a1..5cc1298 100644
--- a/lib/internal/os_support/unix/video/event_system.li
+++ b/lib/internal/os_support/unix/video/event_system.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EVENT_SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "X11 - Event System";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
-Section Public
-
+
+Section Public
+
- x_root:INTEGER;
- y_root:INTEGER;
-
+
- sleep n:INTEGER <-
// Milisecond
(
`usleep(@n * 1000)`;
);
-
- - make <-
+
+ - make <-
( + mask:UINTEGER_32;
-
+
mask := `ExposureMask`:UINTEGER_32;
mask := mask | `KeyPressMask|KeyReleaseMask`:UINTEGER_32;
mask := mask | `ButtonPressMask|ButtonReleaseMask|PointerMotionMask`:UINTEGER_32;
mask := mask | `ClientMessage`:UINTEGER_32;
//mask := mask | `ResizeRedirectMask`:UINTEGER_32;
mask := mask | `StructureNotifyMask`:UINTEGER_32;
- `XSelectInput(display,window, at mask)`;
+ `XSelectInput(display,window, at mask)`;
);
-
+
- get_event <-
( //+ nb_ev:INTEGER;
+ type:INTEGER;
+ x0,y0,x1,y1:INTEGER;
-
- TIMER.get_event;
- `{ XEvent ev`;
- (`XPending(display)`:INTEGER != 0).if {
+
+ TIMER.get_event;
+ `{ XEvent ev`;
+ (`XPending(display)`:INTEGER != 0).if {
`XNextEvent(display,&ev)`;
type := `ev.type`:INTEGER;
-
+
type
//
// Event Window
@@ -73,7 +73,7 @@ Section Public
x0 := `ev.xexpose.x`:INTEGER;
y0 := `ev.xexpose.y`:INTEGER;
x1 := x0 + `ev.xexpose.width` :INTEGER - 1;
- y1 := y0 + `ev.xexpose.height`:INTEGER - 1;
+ y1 := y0 + `ev.xexpose.height`:INTEGER - 1;
DESK.physical_screen.redraw (x0,y0) to (x1,y1);
}
.when `ResizeRequest`:INTEGER then {
@@ -81,32 +81,32 @@ Section Public
x1 := `ev.xresizerequest.width`:INTEGER;
y1 := `ev.xresizerequest.height`:INTEGER;
`XResizeWindow(display,window, at x1, at y1)`;
-
+
VIDEO.pixel_hard (x1,10) color 0FF0000h;
-
+
DESK.resize_window (x1,y1);
}
-
+
.when `ConfigureNotify`:INTEGER then {
// Resize X Window
x1 := `ev.xconfigure.width`:INTEGER;
- y1 := `ev.xconfigure.height`:INTEGER;
+ y1 := `ev.xconfigure.height`:INTEGER;
DESK.resize_window (x1,y1);
}
-
+
//
// Event Keyboard
//
- .when `KeyPress`:INTEGER then {
+ .when `KeyPress`:INTEGER then {
KEYBOARD.key `ev.xkey.keycode`:UINTEGER_8 press TRUE;
}
.when `KeyRelease`:INTEGER then {
KEYBOARD.key `ev.xkey.keycode`:UINTEGER_8 press FALSE;
- }
+ }
//
// Event Mouse
//
- .when `ButtonPress`:INTEGER then {
+ .when `ButtonPress`:INTEGER then {
x_root := `ev.xmotion.x_root`:INTEGER;
y_root := `ev.xmotion.y_root`:INTEGER;
(`ev.xbutton.button`:INTEGER = 1).if {
@@ -132,9 +132,9 @@ Section Public
};
`}`;
);
-
-
-
+
+
+
diff --git a/lib/internal/os_support/unix/video/keyboard.li b/lib/internal/os_support/unix/video/keyboard.li
index 6466ff5..7a0adcc 100644
--- a/lib/internal/os_support/unix/video/keyboard.li
+++ b/lib/internal/os_support/unix/video/keyboard.li
@@ -23,36 +23,36 @@ Section Header
+ name := KEYBOARD;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="X11 - Keyboard Driver";
- - version := 1;
+ - version := 1;
- date :="2003/04";
-
+
Section Inherit
+ parent_input_keyboard:Expanded INPUT_KEYBOARD;
Section Private
-
+
// Lower case.
- lower_case:STRING_CONSTANT := "&é\"'(-è_çà)=\8\\9\azertyuiop^$\13\ qsdfghjklmù *wxcvbn,;:!";
// Upper case.
- upper_case:STRING_CONSTANT := "1234567890°+\8\\9\AZERTYUIOP\"£\13\ QSDFGHJKLM% µWXCVBN?./§";
-
+
// Num lock.
- num_on :STRING_CONSTANT := "789-456+1230.";
- num_off:STRING_CONSTANT := "BUA-L\0R+EDZIS";
-
+
// AltGr.
- alt_gr:STRING_CONSTANT := "¹~#{[|`\\^@]}";
-
+
// Extension key.
- ext_key:STRING_CONSTANT := "BUAL REDZIS HP";
-
+
- keyup cu:UINTEGER_8 :UINTEGER_8 <-
- ( + result,pcu:UINTEGER_8;
-
+ ( + result,pcu:UINTEGER_8;
+
// Patch 64bits
((UINTEGER_CPU.object_size = 8) && {
(cu = 111) || {cu = 113} || {cu = 114} || {cu = 116}
@@ -62,12 +62,12 @@ Section Private
} else {
pcu := cu - 12;
};
- } else {
+ } else {
pcu := cu;
- };
+ };
// End patch
-
- cmd := cmd & 0F7h; // Deactivate the cmd bit
+
+ cmd := cmd & 0F7h; // Deactivate the cmd bit
//bin_code.put ((bin_code.item (pcu>>3)) & ~(1<<(pcu&7))) to (pcu>>3);
// Analyze: for deactivate the cmd
((pcu = 37) || {pcu = 109}).if {
@@ -78,9 +78,9 @@ Section Private
cmd := cmd & (~02h);
}.elseif { pcu = 64 } then {
// Alt
- cmd := cmd & (~04h);
+ cmd := cmd & (~04h);
result := ascii_code;
- ascii_code := 0;
+ ascii_code := 0;
}.elseif { (pcu = 50) || { pcu = 62} } then {
// Shift 1 or Shift 2
cmd := cmd & (~10h);
@@ -90,7 +90,7 @@ Section Private
- keydown cu:UINTEGER_8 :UINTEGER_8 <-
( + result,pcu:UINTEGER_8;
-
+
// Patch 64bits
((UINTEGER_CPU.object_size = 8) && {
(cu = 111) || {cu = 113} || {cu = 114} || {cu = 116}
@@ -100,11 +100,11 @@ Section Private
} else {
pcu := cu - 12;
};
- } else {
+ } else {
pcu := cu;
- };
+ };
// End patch
-
+
//bin_code.put ((bin_code.item (pcu>>3)) | (~(1<<(pcu&7)))) to (pcu>>3); // Activate key
// Analyze: for activate the cmd
((pcu = 37) || {pcu = 109}).if {
@@ -115,10 +115,10 @@ Section Private
cmd := cmd | 02h;
}.elseif { pcu = 64 } then {
// Alt
- cmd := cmd | 04h;
+ cmd := cmd | 04h;
}.elseif { pcu = 65 } then {
// Space
- result := ' '.to_uinteger_8;
+ result := ' '.to_uinteger_8;
}.elseif { (pcu = 50) || { pcu = 62} } then {
// Shift 1 or Shift 2
cmd := cmd | 10h;
@@ -151,13 +151,13 @@ Section Private
};
(result <= 13).if {
cmd := cmd | 08h;
- };
+ };
}.elseif {pcu = 63} then {
result := '*'.to_uinteger_8;
}.elseif {pcu.in_range 67 to 76} then {
cmd := cmd | 08h; // F1 to F10 = cmd
result := pcu - 67 + 'a'.to_uinteger_8; // 'a' to 'j'
- }.elseif {pcu.in_range 79 to 91} then {
+ }.elseif {pcu.in_range 79 to 91} then {
((cmd & 40h) = 0).if {
// Ver num off
result := num_off.item (pcu-78).to_uinteger_8;
@@ -172,7 +172,7 @@ Section Private
result := 0;
};
};
- }.elseif {(pcu = 95) || {pcu = 96}} then {
+ }.elseif {(pcu = 95) || {pcu = 96}} then {
cmd := cmd | 08h; // F11 to F12 = cmd
result := pcu - 95 + 'k'.to_uinteger_8; // 'k' to 'l'
}.elseif {pcu = 94} then {
@@ -183,13 +183,13 @@ Section Private
};
}.elseif {pcu.in_range 97 to 111} then {
cmd := cmd | 08h;
- result := ext_key.item (pcu-96).to_uinteger_8;
+ result := ext_key.item (pcu-96).to_uinteger_8;
}.elseif {pcu = 112} then {
result := '/'.to_uinteger_8;
};
result
);
-
+
diff --git a/lib/internal/os_support/unix/video/mouse.li b/lib/internal/os_support/unix/video/mouse.li
index 9832532..40ece71 100644
--- a/lib/internal/os_support/unix/video/mouse.li
+++ b/lib/internal/os_support/unix/video/mouse.li
@@ -19,75 +19,75 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := MOUSE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "X11 - Mouse driver";
-
+
Section Inherit
-
+
+ parent_input:Expanded INPUT;
-
+
+ parent_window:Expanded AREA; // MASK
-
+
Section Public
-
+
- set (x,y:INTEGER) with (left_new,right_new:BOOLEAN) <-
( + tmp:UINTEGER_8;
+ x_new, y_new:INTEGER;
-
+
y_new := y.max y_minimum.min y_maximum;
x_new := x.max x_minimum.min x_maximum;
-
+
tmp:=(p_end+1)&003h;
buffer_event.item p_end.make (x_new,y_new) button (left_new,right_new);
(((tmp+2)&3)!=p_beg).if {
p_end:=tmp;
};
-
+
get_event;
-
+
// Update status.
x_current:=x_new;
y_current:=y_new;
right :=right_new;
- left :=left_new;
+ left :=left_new;
);
-
+
Section Public
-
+
+ x_minimum:INTEGER;
- x_maximum:INTEGER <- VIDEO.x_max;
-
+
+ y_minimum:INTEGER;
- - y_maximum:INTEGER <- VIDEO.y_max;
-
+ - y_maximum:INTEGER <- VIDEO.y_max;
+
+ x_current:INTEGER;
- + y_current:INTEGER;
-
+ + y_current:INTEGER;
+
+ right:BOOLEAN;
+ left :BOOLEAN;
-
+
Section Private
-
+
+ buffer_event:FAST_ARRAY(EVENT_MOUSE);
- p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
- p_end:UINTEGER_8; // Pointer on the buffer (end)
-
+
Section Public
-
+
//
// Creation / Initialisation.
//
-
+
- make <-
( + new_event:EVENT_MOUSE;
-
+
is_actif := TRUE;
-
+
//
// Software configuration.
//
@@ -100,43 +100,43 @@ Section Public
};
};
buffer_event.first.set_prev new_event;
-
+
// MASK
mask := FAST_ARRAY(UINTEGER_16).create 16;
make (DESK.physical_screen) from (x_current,y_current) size (16,16);
);
-
+
- get_event <-
( + p:INTEGER;
+ evt:EVENT_MOUSE;
-
+
p := p_beg;
(p != p_end).if {
((x_current != x_window) || {y_current != y_window}).if {
set_position (x_current,y_current);
};
{ p != p_end }.while_do {
- evt := buffer_event.item p;
+ evt := buffer_event.item p;
(list_client.lower).to (list_client.upper) do { j:INTEGER;
list_client.item j.receive (buffer_event.item p);
- };
+ };
p := (p + 1) & 03h;
- };
+ };
};
);
-
+
- acknowledge <-
(
p_beg := (p_beg+1) & 03h;
);
-
+
//
// Display.
//
-
+
// BSBS: A refaire avec une bitmap en dehors contenant le dessin avec une couleur de mask!!
// Plus simple, plus puissant, plus rapide !
-
+
+ mask:FAST_ARRAY(UINTEGER_16);
- pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
@@ -149,42 +149,42 @@ Section Public
mask.put m to y;
parent_window.pixel_hard (x,y) color col;
);
-
+
- line_h_hard (x0,y0:INTEGER) until x1:INTEGER color col:UINTEGER_32 <-
( + m:UINTEGER_16;
? {x0<16};
? {y0<16};
? {x1<16};
-
+
m:=mask.item y0;
x0.to x1 do { xx:INTEGER;
m:=m | (1<<xx);
};
-
+
mask.put m to y0;
parent_window.line_h_hard (x0,y0) until x1 color col;
);
- - slave_pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
+ - slave_pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
( + m:UINTEGER_16;
-
+
m:=mask.item y;
((m & (1<<x))=0).if {
parent_window.pixel_hard (x,y) color col;
};
);
-
- - slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER color col:UINTEGER_32 <-
+
+ - slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER color col:UINTEGER_32 <-
( + m:UINTEGER_16;
-
+
m:=mask.item y;
x1.to x2 do { xx:INTEGER;
((m & (1<<xx))=0).if {
parent_window.pixel_hard (xx,y) color col;
};
};
- );
-
+ );
+
- slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER image line:ABSTRACT_BMP_LINE offset ofs:INTEGER <-
( + m:UINTEGER_16;
+ col:UINTEGER_32;
@@ -193,17 +193,17 @@ Section Public
m:=mask.item y;
x1.to x2 do { xx:INTEGER;
((m & (1<<xx))=0).if {
- col := line.get_color ofs_img;
+ col := line.get_color ofs_img;
parent_window.pixel_hard (xx,y) color col;
- };
+ };
ofs_img := ofs_img + 1;
};
);
-
+
- draw (x0,y0:INTEGER) to (x1,y1:INTEGER) <-
(
clipping (x0,y0) to (x1,y1);
-
+
color white;
poly_move_to (1,1);
poly_line_to (9,9);
@@ -211,10 +211,10 @@ Section Public
poly_line_to (8,14);
poly_line_to (5,14);
poly_line_to (5,9);
- poly_line_to (1,9);
- poly_move_to (1,1);
+ poly_line_to (1,9);
+ poly_move_to (1,1);
poly_trace;
-
+
color red;
line_v (0,0) until 10;
line_h (1,10) until 4;
@@ -224,16 +224,16 @@ Section Public
line_h (7,10) until 10;
line (1,0) to (10,9);
);
-
+
- get_object (x,y:INTEGER) :AREA <-
(
NULL
);
-
+
//
// Extern robot.
//
-
+
- extern_event_move (x,y:INTEGER) <-
(
`XTestFakeMotionEvent(display,-1, at x, at y,1)`;
@@ -242,28 +242,28 @@ Section Public
- extern_event_left_down <-
(
- `XTestFakeButtonEvent(display,1,True,1)`;
+ `XTestFakeButtonEvent(display,1,True,1)`;
`XFlush(display)`;
);
- extern_event_left_up <-
(
- `XTestFakeButtonEvent(display,1,False,1)`;
+ `XTestFakeButtonEvent(display,1,False,1)`;
`XFlush(display)`;
);
-
+
- extern_event_right_down <-
(
- `XTestFakeButtonEvent(display,3,True,1)`;
+ `XTestFakeButtonEvent(display,3,True,1)`;
`XFlush(display)`;
);
- extern_event_right_up <-
(
- `XTestFakeButtonEvent(display,3,False,1)`;
+ `XTestFakeButtonEvent(display,3,False,1)`;
`XFlush(display)`;
);
-
+
- extern_get_mouse:(INTEGER,INTEGER,BOOLEAN,BOOLEAN) <-
( + x,y,mask:INTEGER;
+ l,r:BOOLEAN;
@@ -273,11 +273,11 @@ Section Public
x := `winx`:INTEGER;
y := `winy`:INTEGER;
mask := `mask`:INTEGER;
- `}`;
+ `}`;
l := (mask & 100h)!=0;
r := (mask & 400h)!=0;
x,y,l,r
- );
+ );
diff --git a/lib/internal/os_support/unix/video/timer.li b/lib/internal/os_support/unix/video/timer.li
index f65a6ee..45f9162 100644
--- a/lib/internal/os_support/unix/video/timer.li
+++ b/lib/internal/os_support/unix/video/timer.li
@@ -23,44 +23,44 @@ Section Header
+ name := TIMER;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Unix - Timer management.";
- - version := 1;
+ - version := 1;
- date :="2003/04";
-
- - external :=
+
+ - external :=
`
#include <signal.h>
#define __BEGIN_INTERRUPT__
#define __END_INTERRUPT__
XEvent timer_ev;
`;
-
-Section Inherit
-
+
+Section Inherit
+
+ parent_input:Expanded INPUT;
-
+
Section Private
-
+
- timer_count:UINTEGER_32;
-
+
- buffer_event:FAST_ARRAY(EVENT_TIMER);
-
+
- p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
-
+
- p_end:UINTEGER_8; // Pointer on the buffer (end)
-
-Section Interrupt
-
- - timer_interrupt <-
- ( + tmp:UINTEGER_8;
-
+
+Section Interrupt
+
+ - timer_interrupt <-
+ ( + tmp:UINTEGER_8;
+
timer_count := timer_count + 1;
-
+
tmp:=(p_end+1)&003h;
- buffer_event.item p_end.make timer_count;
+ buffer_event.item p_end.make timer_count;
(((tmp+2)&3)!=p_beg).if {
p_end:=tmp;
};
@@ -78,15 +78,15 @@ Section Interrupt
// "BREAK!!!!!\n".print;
};
*/
- `ualarm(50000,0)`;
+ `ualarm(50000,0)`;
);
-
+
Section Public
- make <-
( + hdle:POINTER;
+ new_event:EVENT_TIMER;
-
+
is_actif := TRUE;
//
// Software configuration.
@@ -100,7 +100,7 @@ Section Public
};
};
buffer_event.first.set_prev new_event;
-
+
hdle := timer_interrupt;
`signal(SIGALRM, at hdle)`;
`ualarm(500000,0)`;
@@ -114,25 +114,25 @@ Section Public
- get_event <-
( + p:INTEGER;
+ evt:EVENT_TIMER;
-
+
p := p_beg;
{ p != p_end }.while_do {
- evt := buffer_event.item p;
+ evt := buffer_event.item p;
(list_client.lower).to (list_client.upper) do { j:INTEGER;
buffer_event.item p.set_destination NULL;
list_client.item j.receive (buffer_event.item p);
- };
+ };
p := (p + 1) & 03h;
- };
+ };
);
-
+
- clear <-
(
p_beg := p_end;
);
-
-/*
+
+/*
//Other solution :
void catcher( int sig ) {
@@ -147,12 +147,12 @@ int main( int argc, char *argv[] ) {
signal(SIGALRM,catcher);
- value.it_interval.tv_sec = 1;
- value.it_interval.tv_usec = 0;
- value.it_value.tv_sec = 1;
- value.it_value.tv_usec = 0;
+ value.it_interval.tv_sec = 1;
+ value.it_interval.tv_usec = 0;
+ value.it_value.tv_sec = 1;
+ value.it_value.tv_usec = 0;
- setitimer(ITIMER_REAL, &value, NULL);
+ setitimer(ITIMER_REAL, &value, NULL);
while (1) {
if (old_time != time_count) {
diff --git a/lib/internal/os_support/unix/video/video.li b/lib/internal/os_support/unix/video/video.li
index 087efa8..92fee68 100644
--- a/lib/internal/os_support/unix/video/video.li
+++ b/lib/internal/os_support/unix/video/video.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := VIDEO;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "X11 Driver video - Xlib -";
-
+
- lip <-
(
add_lib "-lX11";
);
-
- - external :=
+
+ - external :=
`
#include <X11/Xlib.h>
// For Frame buffer.
-//#include <X11/extensions/XTest.h>
+//#include <X11/extensions/XTest.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <fcntl.h>
@@ -49,42 +49,42 @@ XImage *ximage=NULL;
`;
Section Inherit
-
+
+ parent_bitmap:Expanded BITMAP(PIXEL_24);
-
+
Section Public //VIDEO
-
+
- line_tmp:ABSTRACT_BMP_LINE;
-
+
Section Public
-
+
- screen_width:INTEGER;
- screen_height:INTEGER;
-
+
- message str:ABSTRACT_STRING <-
- (
+ (
"Message : ".print; str.print; '\n'.print;
);
-
+
- is_active:BOOLEAN;
-
+
- planes:UINTEGER_32;
-
+
- resize (w,h:INTEGER) <-
(
width := w;
height := h;
clipping_off;
);
-
+
- make_size (w,h:INTEGER) <-
( + data:NATIVE_ARRAY(UINTEGER_8);
+ w_max:INTEGER;
-
+
// Init BITMAP:
width := w;
height := h;
-
+
// Creation Server X:
`display = XOpenDisplay(NULL)`;
// Screen Default:
@@ -92,54 +92,54 @@ Section Public
// Init Graphic context:
`gc = DefaultGC(display,DefaultScreen(display))`;
// Creation Window:
- `window = XCreateSimpleWindow(display,RootWindow(display,DefaultScreen(display)), 0,0, at w, at h,2,0,0)`;
+ `window = XCreateSimpleWindow(display,RootWindow(display,DefaultScreen(display)), 0,0, at w, at h,2,0,0)`;
// Event manager:
//XSelectInput(display,window,ExposureMask);
// Title window:
- `XStoreName(display,window,"X-Isaac")`;
+ `XStoreName(display,window,"X-Isaac")`;
// Display Window:
`XMapWindow(display,window)`;
-
+
planes := `PlanesOfScreen(screen)`:UINTEGER_32;
"Video mode: ".print;
planes.print; "bits\n".print;
-
+
screen_width := w_max := `WidthOfScreen(screen)`:INTEGER;
screen_height := `HeightOfScreen(screen)`:INTEGER;
-
+
planes
.when 15 then {
line_tmp := BMP_LINE(PIXEL_15).create w_max;
data := line_tmp.get_storage;
`ximage = XCreateImage(display,None,15,ZPixmap,0,(char *)@data, at w_max,1,16,0)`;
}
- .when 16 then {
- line_tmp := BMP_LINE(PIXEL_16).create w_max;
+ .when 16 then {
+ line_tmp := BMP_LINE(PIXEL_16).create w_max;
data := line_tmp.get_storage;
`ximage = XCreateImage(display,None,16,ZPixmap,0,(char *)@data, at w_max,1,16,0)`;
}
- .when 24 then {
- line_tmp := BMP_LINE(PIXEL_32).create w_max;
+ .when 24 then {
+ line_tmp := BMP_LINE(PIXEL_32).create w_max;
data := line_tmp.get_storage;
`ximage = XCreateImage(display,None,24,ZPixmap,0,(char *)@data, at w_max,1,32,0)`;
}
- .when 32 then {
- line_tmp := BMP_LINE(PIXEL_32).create w_max;
+ .when 32 then {
+ line_tmp := BMP_LINE(PIXEL_32).create w_max;
data := line_tmp.get_storage;
`ximage = XCreateImage(display,None,32,ZPixmap,0,(char *)@data, at w_max,1,32,0)`;
};
-
+
is_active := TRUE;
);
-
+
- auto_make <-
(
make_size (800,600);
);
-
+
- close <-
(
? {is_active};
@@ -149,27 +149,27 @@ Section Public
? {! is_active};
);
- //
+ //
// Redefine Low level Bitmap.
//
-
+
Section Public
-
+
- pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
( + real_col:UINTEGER_32;
+ m:UINTEGER_8;
-
+
VIDEO.planes
- .when 15 then {
+ .when 15 then {
real_col := PIXEL_15.get_raw col;
}
- .when 16 then {
- real_col := PIXEL_16.get_raw col;
+ .when 16 then {
+ real_col := PIXEL_16.get_raw col;
}
- .when 24 then {
- real_col := PIXEL_24.get_raw col;
+ .when 24 then {
+ real_col := PIXEL_24.get_raw col;
}
- .when 32 then {
+ .when 32 then {
real_col := PIXEL_32.get_raw col;
};
m := mode;
@@ -177,22 +177,22 @@ Section Public
`XSetFunction(display,gc,(int)@m)`;
`XDrawPoint(display,window,gc, at x, at y)`;
);
-
+
- line_h_hard (x0,y0:INTEGER) until x1:INTEGER color col:UINTEGER_32 <-
( + real_col:UINTEGER_32;
+ m:UINTEGER_8;
-
+
VIDEO.planes
- .when 15 then {
+ .when 15 then {
real_col := PIXEL_15.get_raw col;
}
- .when 16 then {
- real_col := PIXEL_16.get_raw col;
+ .when 16 then {
+ real_col := PIXEL_16.get_raw col;
}
- .when 24 then {
- real_col := PIXEL_24.get_raw col;
+ .when 24 then {
+ real_col := PIXEL_24.get_raw col;
}
- .when 32 then {
+ .when 32 then {
real_col := PIXEL_32.get_raw col;
};
m := mode;
@@ -200,45 +200,45 @@ Section Public
`XSetFunction(display,gc,(int)@m)`;
`XDrawLine(display,window,gc, at x0, at y0, at x1, at y0)`;
);
-
- - line_h_hard (x0,y0:INTEGER) until x1:INTEGER
+
+ - line_h_hard (x0,y0:INTEGER) until x1:INTEGER
image line:ABSTRACT_BMP_LINE offset ofs:INTEGER <-
( + len:INTEGER;
- len := x1 - x0;
+ len := x1 - x0;
VIDEO.line_tmp.put line offset ofs from 0 to len;
`XPutImage(display,window,gc, ximage, 0, 0, @x0, @y0, @len+1, 1)`;
);
-
+
- get_pixel_hard (x,y:INTEGER) :PIXEL <-
(
not_yet_implemented;
);
-
+
//
// Frame buffer.
//
-
+
- open_frame_buffer <-
( + fb,w,h:INTEGER;
-
+
fb := `open("/dev/fb0", O_RDWR)`:INTEGER;
(fb = 0).if {
"Error: cannot open framebuffer device.\n".print;
die_with_code 0;
};
-
+
w := screen_width;
h := screen_height;
view_screen := `mmap(0, @w*@h*3, PROT_READ | PROT_WRITE,MAP_SHARED, at fb, 0)`:
NATIVE_ARRAY(UINTEGER_8);
-
+
(CONVERT(NATIVE_ARRAY(UINTEGER_8),INTEGER).on view_screen = -1).if {
"Error: failed to map framebuffer device to memory.\n".print;
die_with_code 0;
};
);
-
+
- get_pixel_screen (x,y:INTEGER) :UINTEGER_32 <-
[
-? {x.in_range 0 to (screen_width -1)};
@@ -254,48 +254,48 @@ Section Public
};
*/
ofs := (y * screen_width + x) * 4;
- (view_screen.item ofs .to_uinteger_32 ) |
+ (view_screen.item ofs .to_uinteger_32 ) |
(view_screen.item (ofs+1).to_uinteger_32 << 8) |
- (view_screen.item (ofs+2).to_uinteger_32 << 16)
+ (view_screen.item (ofs+2).to_uinteger_32 << 16)
);
-
+
- set_pixel_screen (x,y:INTEGER) color col:UINTEGER_32 <-
( + ofs:INTEGER;
-
+
ofs := (y * screen_width + x) * 4;
view_screen.put ((col >> 16).to_uinteger_8) to (ofs+2);
view_screen.put (((col >> 8) & 0FFh).to_uinteger_8) to (ofs+1);
- view_screen.put ((col & 0FFh).to_uinteger_8) to (ofs+0);
+ view_screen.put ((col & 0FFh).to_uinteger_8) to (ofs+0);
);
-
+
Section Private
-
+
- view_screen:NATIVE_ARRAY(UINTEGER_8);
/* A voir pour bloquer la size minimum
-
-// pointer to the size hints structure.
+
+// pointer to the size hints structure.
XSizeHints* win_size_hints = XAllocSizeHints();
if (!win_size_hints) {
fprintf(stderr, "XAllocSizeHints - out of memory\n");
exit(1);
}
-// initialize the structure appropriately.
-// first, specify which size hints we want to fill in.
-// in our case - setting the minimal size as well as the initial size.
+// initialize the structure appropriately.
+// first, specify which size hints we want to fill in.
+// in our case - setting the minimal size as well as the initial size.
win_size_hints->flags = PSize | PMinSize;
-// next, specify the desired limits.
-// in our case - make the window's size at least 300x200 pixels.
-// and make its initial size 400x250.
+// next, specify the desired limits.
+// in our case - make the window's size at least 300x200 pixels.
+// and make its initial size 400x250.
win_size_hints->min_width = 300;
win_size_hints->min_height = 200;
win_size_hints->base_width = 400;
win_size_hints->base_height = 250;
-// pass the size hints to the window manager.
+// pass the size hints to the window manager.
XSetWMNormalHints(display, win, win_size_hints);
-// finally, we can free the size hints structure.
+// finally, we can free the size hints structure.
XFree(win_size_hints);
*/
\ No newline at end of file
diff --git a/lib/internal/os_support/unix/video_ascii/bitmap_ascii.li b/lib/internal/os_support/unix/video_ascii/bitmap_ascii.li
index 4e018c3..41719fd 100644
--- a/lib/internal/os_support/unix/video_ascii/bitmap_ascii.li
+++ b/lib/internal/os_support/unix/video_ascii/bitmap_ascii.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := BITMAP_ASCII;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Bitmap for text mode";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
-
+
Section Inherit
-
+
+ parent_bitmap_generic:Expanded BITMAP;
-
+
Section Public
-
+
- pixel_geometry:PIXEL := PIXEL_ASCII;
-
-Section Public
-
+
+Section Public
+
//
// Data.
//
-
+
// Mapping memory bitmap.
+ image:FAST_ARRAY(BMP_LINE_ASCII);
-
+
- get_line y:INTEGER :BMP_LINE <-
( //? {y < height};
image.item y
);
-
+
//
- // Creation.
+ // Creation.
//
- make (w,h:INTEGER) <-
@@ -65,13 +65,13 @@ Section Public
image.put (BMP_LINE_ASCII.create w) to y;
};
clipping_off;
- );
-
+ );
+
- make (w,h:INTEGER) at offset_begin:UINTEGER_32 bytes_per_line lx:INTEGER <-
( + offset:UINTEGER_32;
-
+
width := w;
- height := h;
+ height := h;
image := FAST_ARRAY(BMP_LINE_ASCII).create h;
offset:=offset_begin;
0.to (image.upper) do { y:INTEGER;
@@ -80,7 +80,7 @@ Section Public
};
clipping_off;
);
-
+
- print <-
(
0.to (height - 1) do {h:INTEGER;
@@ -88,5 +88,5 @@ Section Public
'\n'.print;
};
);
-
+
diff --git a/lib/internal/os_support/unix/video_ascii/bmp_line_ascii.li b/lib/internal/os_support/unix/video_ascii/bmp_line_ascii.li
index 039d14c..2991a07 100644
--- a/lib/internal/os_support/unix/video_ascii/bmp_line_ascii.li
+++ b/lib/internal/os_support/unix/video_ascii/bmp_line_ascii.li
@@ -19,65 +19,65 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := BMP_LINE_ASCII;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Bitmap line for text mode";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
Section Inherit
-
+
+ parent_bmp_line:Expanded BMP_LINE;
-
+
Section Public
-
+
+ storage:MAP_NATIVE_ARRAY(PIXEL_ASCII);
-
+
- get_storage:NATIVE_ARRAY(UINTEGER_8) <- NATIVE_ARRAY(UINTEGER_8).force_conversion storage;
-
+
- make n:INTEGER <-
- (
+ (
capacity := n;
- upper := n - 1;
- storage := MAP_NATIVE_ARRAY(PIXEL_ASCII).calloc n;
+ upper := n - 1;
+ storage := MAP_NATIVE_ARRAY(PIXEL_ASCII).calloc n;
);
-
+
- make_with_capacity n:INTEGER <-
(
capacity := n;
upper := -1;
- storage := MAP_NATIVE_ARRAY(PIXEL_ASCII).calloc n;
+ storage := MAP_NATIVE_ARRAY(PIXEL_ASCII).calloc n;
);
-
+
- make n:INTEGER at offset:UINTEGER_32 <-
- (
+ (
capacity := n;
- upper := n - 1;
- storage := MAP_NATIVE_ARRAY(PIXEL_ASCII).force_conversion offset;
+ upper := n - 1;
+ storage := MAP_NATIVE_ARRAY(PIXEL_ASCII).force_conversion offset;
);
Section Public
-
+
- pixel_geometry:PIXEL := PIXEL_ASCII;
-
+
//
// Put.
//
-
- - put col:UINTEGER_32 from idx_begin:INTEGER to idx_end:INTEGER <-
+
+ - put col:UINTEGER_32 from idx_begin:INTEGER to idx_end:INTEGER <-
( ? {idx_begin<=idx_end};
? {idx_begin>=0};
? {idx_end.in_range 0 to upper};
-
+
idx_begin.to idx_end do { n:INTEGER;
storage.item n.color col;
};
);
-
+
- put bmp:BMP_LINE offset ofs:INTEGER from idx_begin:INTEGER to idx_end:INTEGER <-
( + offset:INTEGER;
+ pixel:PIXEL_ASCII;
@@ -85,7 +85,7 @@ Section Public
? {idx_begin >= 0};
? {idx_end.in_range 0 to upper};
? {ofs >= 0};
- ? {(ofs + (idx_end - idx_begin)) <= bmp.upper};
+ ? {(ofs + (idx_end - idx_begin)) <= bmp.upper};
offset := ofs;
idx_begin.to idx_end do { n:INTEGER;
pixel := bmp.item_ascii offset;
@@ -93,17 +93,17 @@ Section Public
offset := offset + 1;
};
);
-
+
//
// Get.
//
-
+
- item n:INTEGER :PIXEL <-
( ? {n.in_range 0 to upper};
-
+
storage.item n
);
-
+
- print <-
(
0.to upper do { i:INTEGER;
diff --git a/lib/internal/os_support/unix/video_ascii/pixel_ascii.li b/lib/internal/os_support/unix/video_ascii/pixel_ascii.li
index 8ebfd96..7e491a7 100644
--- a/lib/internal/os_support/unix/video_ascii/pixel_ascii.li
+++ b/lib/internal/os_support/unix/video_ascii/pixel_ascii.li
@@ -19,79 +19,79 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PIXEL_ASCII;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Version Generic ASCII";
-
+
- bibliography:= "http://IsaacOS.com";
-
+
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
-
+
Section Inherit
-
+
- parent_pixel:PIXEL := PIXEL;
-
+
Section Mapping
-
+
+ char:CHARACTER;
-
+
Section Public
-
- - red:UINTEGER_8 <-
+
+ - red:UINTEGER_8 <-
( + result:UINTEGER_8;
-
+
char
.when ' ' then { result := 31; }
- .when '.' then { result := 63; }
+ .when '.' then { result := 63; }
.when '-' then { result := 95; }
.when '=' then { result := 127; }
.when '+' then { result := 159; }
.when '*' then { result := 191; }
- .when '%' then { result := 223; }
+ .when '%' then { result := 223; }
.when '#' then { result := 255; };
result
);
-
+
- green:UINTEGER_8 <- red;
- blue:UINTEGER_8 <- red;
-
- - color col:UINTEGER_32 :UINTEGER_32 <-
+
+ - color col:UINTEGER_32 :UINTEGER_32 <-
( + gray:UINTEGER_32;
-
+
gray := ((col >> 16)+ ((col & 00FF00h)>>8)+ ((col & 0000FFh) >> 3))/3;
gray
.when 0 to 31 then { char := ' '; }
- .when 32 to 63 then { char := '.'; }
+ .when 32 to 63 then { char := '.'; }
.when 64 to 95 then { char := '-'; }
.when 96 to 127 then { char := '='; }
.when 128 to 159 then { char := '+'; }
.when 160 to 191 then { char := '*'; }
- .when 192 to 223 then { char := '%'; }
+ .when 192 to 223 then { char := '%'; }
.when 224 to 255 then { char := '#'; };
col
);
-
- - color_rgb (r,g,b:UINTEGER_8) <-
+
+ - color_rgb (r,g,b:UINTEGER_8) <-
( + gray:INTEGER;
-
+
gray := (r.to_integer+g+b)/3;
gray
.when 0 to 31 then { char := ' '; }
- .when 32 to 63 then { char := '.'; }
+ .when 32 to 63 then { char := '.'; }
.when 64 to 95 then { char := '-'; }
.when 96 to 127 then { char := '='; }
.when 128 to 159 then { char := '+'; }
.when 160 to 191 then { char := '*'; }
- .when 192 to 223 then { char := '%'; }
+ .when 192 to 223 then { char := '%'; }
.when 224 to 255 then { char := '#'; };
);
-
- - size:UINTEGER_8 := 8;
- - red_size:UINTEGER_8 := 3;
+
+ - size:UINTEGER_8 := 8;
+ - red_size:UINTEGER_8 := 3;
- red_pos:UINTEGER_8 := 0;
- green_size:UINTEGER_8 := 3;
- green_pos:UINTEGER_8 := 3;
@@ -99,12 +99,12 @@ Section Public
- blue_pos:UINTEGER_8 := 6;
- reserved_size:UINTEGER_8 := 0;
- reserved_pos:UINTEGER_8 := 0;
-
- - copy other:SELF <-
+
+ - copy other:SELF <-
(
color_rgb ((other.red),(other.green),(other.blue));
);
-
+
- print <-
(
(char=0).if {
@@ -112,7 +112,7 @@ Section Public
};
char.print;
);
-
+
- set_char c:CHARACTER <-
(
char := c;
diff --git a/lib/internal/os_support/unix/video_ascii/video.li b/lib/internal/os_support/unix/video_ascii/video.li
index 1350ddf..a0fe153 100644
--- a/lib/internal/os_support/unix/video_ascii/video.li
+++ b/lib/internal/os_support/unix/video_ascii/video.li
@@ -19,30 +19,30 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := VIDEO;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Generic Driver video - Text mode -";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
-
+
Section Inherit
-
+
+ parent_bitmap:Expanded BITMAP_ASCII;
-
+
Section Public
-
+
- is_active:BOOLEAN;
-
+
- create <-
- (
+ (
make (190,80);
is_active := TRUE;
);
-
+
- display_screen <-
(
0.to (height-1) do { y:INTEGER;
@@ -66,7 +66,7 @@ Section Public
'\n'.print;
};
);
-
+
- close <-
(
? {is_active};
diff --git a/lib/internal/os_support/windows/file_system/directory_unix.li b/lib/internal/os_support/windows/file_system/directory_unix.li
index 3bd6a15..713ebd1 100644
--- a/lib/internal/os_support/windows/file_system/directory_unix.li
+++ b/lib/internal/os_support/windows/file_system/directory_unix.li
@@ -19,18 +19,18 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=DIRECTORY_UNIX;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- bibliography:="http://IsaacOS.com";
-
+
- author :="Benoit Sonntag (bsonntag at loria.fr)";
-
+
- comment :="Directory management";
-
- - external :=
+
+ - external :=
`
#include <dirent.h>
#include <sys/stat.h>
@@ -39,40 +39,40 @@ Section Header
WIN32_FIND_DATA data;
HANDLE hfile;
`;
-
+
Section Inherit
-
+
+ parent_entry_unix:Expanded ENTRY_UNIX;
-
+
+ parent_directory:Expanded DIRECTORY;
-
+
Section Public
-
+
//
// Physical implementation.
//
-
+
//
// Scanning
//
- is_open:BOOLEAN <- ( list != NULL);
-
+
//
// Scanning
//
-
+
- open:BOOLEAN <-
( + p,n:NATIVE_ARRAY(CHARACTER);
+ new_entry:ENTRY;
+ result:BOOLEAN;
+ i:INTEGER;
-
+
(list = NULL).if {
list := LINKED_LIST(ENTRY).create;
} else {
list.clear;
};
-
+
string_tmp.copy path;
string_tmp.append "\\*.*";
p := string_tmp.to_external;
@@ -80,10 +80,10 @@ Section Public
(`hfile != INVALID_HANDLE_VALUE`:BOOLEAN{TRUE,FALSE}).if {
result := TRUE;
{
- n := `data.cFileName`:NATIVE_ARRAY(CHARACTER);
+ n := `data.cFileName`:NATIVE_ARRAY(CHARACTER);
string_tmp.clear;
i := 0;
- {n.item i = '\0'}.until_do {
+ {n.item i = '\0'}.until_do {
string_tmp.add_last (n.item i);
i := i + 1;
};
@@ -107,41 +107,41 @@ Section Public
};
result
);
-
+
Section DIRECTORY
-
+
- physical_get_entry new_path:ABSTRACT_STRING :ENTRY <-
// Same UNIX
( + pe:NATIVE_ARRAY(CHARACTER);
+ result:ENTRY;
-
+
pe := new_path.to_external;
`#ifdef __MINGW_H
`;
- `{ struct stat t`;
- (`stat(@pe,&t)`:INTEGER = 0).if {
+ `{ struct stat t`;
+ (`stat(@pe,&t)`:INTEGER = 0).if {
(`S_ISDIR(t.st_mode)`:INTEGER = 0).if {
// File.
result := FILE_UNIX.clone;
} else {
// Directory.
result := DIRECTORY_UNIX.clone;
- };
+ };
result.set_path new_path;
alias.put result to (result.path); // with { (e1,e2:ABSTRACT_STRING); e1 ~=e2 };
};
`}`;
`#else
`;
- `{ struct stat64 t`;
- (`stat64(@pe,&t)`:INTEGER = 0).if {
+ `{ struct stat64 t`;
+ (`stat64(@pe,&t)`:INTEGER = 0).if {
(`S_ISDIR(t.st_mode)`:INTEGER = 0).if {
// File.
result := FILE_UNIX.clone;
} else {
// Directory.
result := DIRECTORY_UNIX.clone;
- };
+ };
result.set_path new_path;
alias.put result to (result.path); //with { (e1,e2:ABSTRACT_STRING); e1 ~=e2 };
};
@@ -150,7 +150,7 @@ Section DIRECTORY
`;
result
);
-
+
- physical_make_directory new_path:ABSTRACT_STRING :BOOLEAN <-
( + p:NATIVE_ARRAY(CHARACTER);
p := new_path.to_external;
@@ -162,7 +162,7 @@ Section DIRECTORY
( + p:NATIVE_ARRAY(CHARACTER);
+ stream:POINTER;
+ result:BOOLEAN;
-
+
p := new_path.to_external;
stream := `fopen((char*)@p,"w+b")`:POINTER;
(stream != NULL).if {
@@ -177,7 +177,7 @@ Section DIRECTORY
pa := p.to_external;
`remove(@pa)`:(INTEGER) = 0
);
-
+
- physical_move old_path:ABSTRACT_STRING to new_path:ABSTRACT_STRING :BOOLEAN <-
// Same UNIX
( + old_p,new_p:NATIVE_ARRAY(CHARACTER);
diff --git a/lib/internal/os_support/windows/file_system/entry_unix.li b/lib/internal/os_support/windows/file_system/entry_unix.li
index f89d4b3..55c8a10 100644
--- a/lib/internal/os_support/windows/file_system/entry_unix.li
+++ b/lib/internal/os_support/windows/file_system/entry_unix.li
@@ -19,116 +19,116 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ENTRY_UNIX;
- copyright := "2003-2008 Benoit Sonntag";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
- comment := "Entry ANSI C";
-
+
Section Inherit
-
+
+ parent_entry:Expanded ENTRY;
-
-Section Public
-
- - access:UINTEGER_16 <-
+
+Section Public
+
+ - access:UINTEGER_16 <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ result:UINTEGER_16;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
+ `{ struct stat t; stat(@pe,&t)`;
result := `t.st_mode`:UINTEGER_16 & 111_111_111b;
`}`;
result
);
-
- - access_time:TIME <-
+
+ - access_time:TIME <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:TIME;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_atime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_atime))`:POINTER;
result := to_time tt;
`}`;
result
);
-
- - access_date:DATE <-
+
+ - access_date:DATE <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:DATE;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_atime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_atime))`:POINTER;
result := to_date tt;
`}`;
result
);
-
- - update_time:TIME <-
+
+ - update_time:TIME <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:TIME;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_mtime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_mtime))`:POINTER;
result := to_time tt;
`}`;
result
);
-
- - update_date:DATE <-
+
+ - update_date:DATE <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:DATE;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_mtime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_mtime))`:POINTER;
result := to_date tt;
`}`;
result
);
-
+
- create_time:TIME <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:TIME;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_ctime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_ctime))`:POINTER;
result := to_time tt;
`}`;
result
);
-
+
- create_date:DATE <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ tt:POINTER;
+ result:DATE;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_ctime))`:POINTER;
+ `{ struct stat t; stat(@pe,&t)`;
+ tt := `localtime(&(t.st_ctime))`:POINTER;
result := to_date tt;
`}`;
result
);
-
-Section Private
-
+
+Section Private
+
//
// Time / Date: Unix -> Lisaac
//
-
+
- to_date t:POINTER :DATE <-
( + result:DATE;
+ wd,md,m:UINTEGER_8;
+ y:UINTEGER_16;
-
+
y := `((struct tm *)@t)->tm_year`:UINTEGER_16 + 1900;
m := `((struct tm *)@t)->tm_mon` :UINTEGER_8 + 1;
md := `((struct tm *)@t)->tm_mday`:UINTEGER_8;
@@ -136,15 +136,15 @@ Section Private
(! wd.in_range 1 to 7).if { // Bug in UNIX ?
wd := 1;
};
- result := DATE.create (y,m,md,wd)
+ result := DATE.create (y,m,md,wd)
);
- to_time t:POINTER :TIME <-
(
- TIME.create
+ TIME.create
((`((struct tm *)@t)->tm_hour`:UINTEGER_8),
(`((struct tm *)@t)->tm_min` :UINTEGER_8),
(`((struct tm *)@t)->tm_sec` :UINTEGER_8),
0)
);
-
+
diff --git a/lib/internal/os_support/windows/file_system/file_system.li b/lib/internal/os_support/windows/file_system/file_system.li
index b92fd70..7a41d96 100644
--- a/lib/internal/os_support/windows/file_system/file_system.li
+++ b/lib/internal/os_support/windows/file_system/file_system.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=FILE_SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment :="File System manager for Unix.";
-
+
- external := `#include <unistd.h>`; // For `getcwd'
-
-Section Inherit
-
+
+Section Inherit
+
+ parent_directory:DIRECTORY <-
- ( + cwd:NATIVE_ARRAY(CHARACTER);
+ ( + cwd:NATIVE_ARRAY(CHARACTER);
+ result:DIRECTORY;
-
+
DIRECTORY.string_tmp.clear;
cwd := DIRECTORY.string_tmp.to_external;
`getcwd(@cwd,255)`;
DIRECTORY.string_tmp.from_external cwd;
-
+
result ?= DIRECTORY_UNIX.physical_get_entry (DIRECTORY.string_tmp);
DIRECTORY.alias.put result to (result.path);
? {result != NULL};
parent_directory := result
);
-
-
+
+
diff --git a/lib/internal/os_support/windows/file_system/file_unix.li b/lib/internal/os_support/windows/file_system/file_unix.li
index 6ebe4d8..d6968f6 100644
--- a/lib/internal/os_support/windows/file_system/file_unix.li
+++ b/lib/internal/os_support/windows/file_system/file_unix.li
@@ -19,102 +19,102 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FILE_UNIX;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "File management";
-
+
Section Inherit
-
+
+ parent_entry_unix:Expanded ENTRY_UNIX;
-
+
+ parent_file:Expanded FILE;
-
-Section Private
-
+
+Section Private
+
+ stream:POINTER; // Unix file pointer (FILE *).
Section Public
-
+
//
// Physical implementation.
//
-
+
- is_open:BOOLEAN <- stream != NULL;
-
+
- size:UINTEGER_32 <-
( + pe:NATIVE_ARRAY(CHARACTER);
+ result:UINTEGER_32;
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
+ `{ struct stat t; stat(@pe,&t)`;
result := `t.st_size`:UINTEGER_32;
`}`;
result
);
-
+
- cursor:UINTEGER_32 <-
- ( + str:POINTER;
- str := stream;
+ ( + str:POINTER;
+ str := stream;
`ftell((FILE *)@str)`:UINTEGER_32
);
-
+
- set_cursor n:UINTEGER_32 <-
[
...
-? {stream != NULL};
-? {n <= size};
]
- ( + str:POINTER;
- str := stream;
+ ( + str:POINTER;
+ str := stream;
`fseek((FILE*)(@str), at n,SEEK_SET)`;
- );
-
+ );
+
- open:BOOLEAN <-
[
-? {stream = NULL};
]
- ( + pa:NATIVE_ARRAY(CHARACTER);
-
+ ( + pa:NATIVE_ARRAY(CHARACTER);
+
pa := path.to_external;
- stream := `fopen((char*)@pa,"r+b")`:(POINTER);
+ stream := `fopen((char*)@pa,"r+b")`:(POINTER);
stream != NULL
- );
+ );
- open_read_only:BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
+ ( + pa:NATIVE_ARRAY(CHARACTER);
pa := path.to_external;
- stream := `fopen((char*)@path_pointer,"rb")`:(POINTER);
+ stream := `fopen((char*)@path_pointer,"rb")`:(POINTER);
stream != NULL
- );
-
+ );
+
- close <-
[
-? {stream != NULL};
]
( + str:POINTER;
-
- str := stream;
- `fclose((FILE*)(@str))`;
+
+ str := stream;
+ `fclose((FILE*)(@str))`;
stream := NULL;
);
-
-Section FILE
-
+
+Section FILE
+
- physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
// return size read or 0 if end of input (-1 on error => exception ?)
- ( + str:POINTER;
- str := stream;
+ ( + str:POINTER;
+ str := stream;
`fread((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
);
-
+
- physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
// return size read or 0 if end of input (-1 on error => exception ?)
( + str:POINTER;
- str := stream;
+ str := stream;
`fwrite((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
);
-
-
+
+
diff --git a/lib/internal/os_support/windows/video/event_system.li b/lib/internal/os_support/windows/video/event_system.li
index 94f8e7c..201bde2 100644
--- a/lib/internal/os_support/windows/video/event_system.li
+++ b/lib/internal/os_support/windows/video/event_system.li
@@ -19,18 +19,18 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EVENT_SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "X11 - Event System";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
-
- - external :=
-`
+
+ - external :=
+`
void (*get_event)()=NULL;
int event_num;
int event_p1;
@@ -40,9 +40,9 @@ int event_p4;
unsigned char buf[50];
-HDC hdc_glob;
+HDC hdc_glob;
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
+{
PAINTSTRUCT ps;
HDC hdc_old;
RECT rect;
@@ -54,9 +54,9 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
get_event();
return 0;
// Create
- case WM_CREATE:
+ case WM_CREATE:
return 0;
-
+
// Repaint
case WM_PAINT:
event_num = 0;
@@ -65,18 +65,18 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
event_p1 = ps.rcPaint.left;
event_p2 = ps.rcPaint.top;
event_p3 = ps.rcPaint.right;
- event_p4 = ps.rcPaint.bottom;
- get_event();
+ event_p4 = ps.rcPaint.bottom;
+ get_event();
EndPaint(hwnd, &ps);
hdc_glob = hdc_old;
return 0;
-
+
// Destroy
case WM_DESTROY:
PostQuitMessage(0);
exit(0);
return 0;
-
+
// Mouse
case WM_MOUSEMOVE:
event_num = 1;
@@ -89,7 +89,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
event_num = 2;
get_event();
return 0;
- case WM_LBUTTONUP:
+ case WM_LBUTTONUP:
event_num = 3;
get_event();
return 0;
@@ -97,13 +97,13 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
event_num = 4;
get_event();
return 0;
- case WM_RBUTTONUP:
+ case WM_RBUTTONUP:
event_num = 5;
get_event();
return 0;
-
+
// Kayboard
- case WM_KEYDOWN:
+ case WM_KEYDOWN:
//sprintf(buf,"KeyDown : %c(%d) ,%lx ",wParam,wParam,lParam);
//TextOutA(hdc_glob,10,100,buf,strlen(buf));
event_num = 10;
@@ -111,7 +111,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
event_p2 = lParam;
get_event();
return 0;
-
+
case WM_CHAR:
//sprintf(buf,"Char : %c(%d) ,%lx ",wParam,wParam,lParam);
//TextOutA(hdc_glob,10,120,buf,strlen(buf));
@@ -120,8 +120,8 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
event_p2 = lParam;
get_event();
return 0;
-
- case WM_KEYUP:
+
+ case WM_KEYUP:
//sprintf(buf,"KeyUp : %c(%d) ,%lx ",wParam,wParam,lParam);
//TextOutA(hdc_glob,10,140,buf,strlen(buf));
event_num = 12;
@@ -137,19 +137,19 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
`;
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
-Section Interrupt
-
+
+Section Interrupt
+
- get_physical_event <-
( + p1,p2,p3,p4:INTEGER;
-
+
p1 := `event_p1`:INTEGER;
p2 := `event_p2`:INTEGER;
p3 := `event_p3`:INTEGER;
p4 := `event_p4`:INTEGER;
-
+
`event_num`:INTEGER
//
// Event Window
@@ -199,22 +199,22 @@ Section Interrupt
TIMER.get_event;
};
);
-
-Section Public
-
+
+Section Public
+
- sleep n:INTEGER <-
// Milisecond
(
`sleep(@n)`;
);
-
- - make <-
+
+ - make <-
( + ptr:POINTER;
-
+
ptr := get_physical_event;
`get_event = @ptr`;
);
-
+
- get_event <-
(
`
@@ -223,8 +223,8 @@ Section Public
DispatchMessage(&msg_glob);
`;
);
-
-
+
+
diff --git a/lib/internal/os_support/windows/video/keyboard.li b/lib/internal/os_support/windows/video/keyboard.li
index 9dc38d6..dfd2195 100644
--- a/lib/internal/os_support/windows/video/keyboard.li
+++ b/lib/internal/os_support/windows/video/keyboard.li
@@ -23,28 +23,28 @@ Section Header
+ name := KEYBOARD;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Windows (Win32) - RSXNT - Keyboard Driver";
- - version := 2;
-
+ - version := 2;
+
Section Inherit
+ parent_input_keyboard:Expanded INPUT_KEYBOARD;
Section Private
-
+
- keyup cu:UINTEGER_8 :UINTEGER_8 <-
( + result:UINTEGER_8;
-
+
result := cu;
- cmd := cmd & 0F7h; // Deactivate the cmd bit
-
+ cmd := cmd & 0F7h; // Deactivate the cmd bit
+
cu
.when 8 then { cmd := cmd | 8; }
.when 13 then { cmd := cmd | 8; };
-
-
+
+
result
);
@@ -63,10 +63,10 @@ Section Private
.when 4Bh then { result := 'L'.to_uinteger_8; }
.when 4Dh then { result := 'R'.to_uinteger_8; };
cmd := cmd | 8;
-
+
result
);
-
+
diff --git a/lib/internal/os_support/windows/video/mouse.li b/lib/internal/os_support/windows/video/mouse.li
index 1af2510..2d4a708 100644
--- a/lib/internal/os_support/windows/video/mouse.li
+++ b/lib/internal/os_support/windows/video/mouse.li
@@ -19,82 +19,82 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := MOUSE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "X11 - Mouse driver";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Benoit Sonntag (bsonntag at loria.fr)";
-
+
Section Inherit
-
+
+ parent_input:Expanded INPUT;
-
+
Section Public
-
+
- set (x,y:INTEGER) with (left_new,right_new:BOOLEAN) <-
( + tmp:UINTEGER_8;
+ x_new, y_new:INTEGER;
-
+
y_new := y.max y_minimum.min y_maximum;
x_new := x.max x_minimum.min x_maximum;
-
+
tmp:=(p_end+1)&003h;
buffer_event.item p_end.make (x_new,y_new) button (left_new,right_new);
(((tmp+2)&3)!=p_beg).if {
p_end:=tmp;
};
-
+
get_event;
-
+
// Update status.
x_current:=x_new;
y_current:=y_new;
right:=right_new;
- left :=left_new;
+ left :=left_new;
);
-
+
Section Public
-
+
+ x_minimum:INTEGER;
+ x_maximum:INTEGER;
-
+
+ y_minimum:INTEGER;
+ y_maximum:INTEGER;
-
+
+ x_current:INTEGER;
- + y_current:INTEGER;
-
+ + y_current:INTEGER;
+
+ right:BOOLEAN;
+ left:BOOLEAN;
-
+
Section Private
-
+
+ buffer_event:FAST_ARRAY(EVENT_MOUSE);
- p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
- p_end:UINTEGER_8; // Pointer on the buffer (end)
-
+
Section Public
-
+
//
// Creation / Initialisation.
//
-
+
- make <-
( + new_event:EVENT_MOUSE;
-
+
is_actif := TRUE;
//
// Mouse hardware configuration.
//
-
+
x_maximum := VIDEO.x_max;
y_maximum := VIDEO.y_max;
-
+
//
// Software configuration.
//
@@ -108,28 +108,28 @@ Section Public
};
buffer_event.first.set_prev new_event;
);
-
+
- get_event <-
( + p:INTEGER;
+ evt:EVENT_MOUSE;
-
+
p := p_beg;
{ p != p_end }.while_do {
evt := buffer_event.item p;
(list_client.lower).to (list_client.upper) do { j:INTEGER;
list_client.item j.receive (buffer_event.item p);
- };
+ };
p := (p + 1) & 03h;
- };
+ };
);
-
+
- acknowledge <-
(
p_beg := (p_beg+1) & 03h;
);
-
-
-
+
+
+
diff --git a/lib/internal/os_support/windows/video/timer.li b/lib/internal/os_support/windows/video/timer.li
index ccb93a5..d22d170 100644
--- a/lib/internal/os_support/windows/video/timer.li
+++ b/lib/internal/os_support/windows/video/timer.li
@@ -26,41 +26,41 @@ Section Header
- comment :="Windows - Timer management.";
- - version := 1;
-
-Section Inherit
-
+ - version := 1;
+
+Section Inherit
+
+ parent_input:Expanded INPUT;
-
+
Section Private
-
+
- timer_count:UINTEGER_32;
-
+
+ buffer_event:FAST_ARRAY(EVENT_TIMER);
-
+
- p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
-
+
- p_end:UINTEGER_8; // Pointer on the buffer (end)
-
-Section Public
-
- - timer_interrupt <-
- ( + tmp:UINTEGER_8;
-
+
+Section Public
+
+ - timer_interrupt <-
+ ( + tmp:UINTEGER_8;
+
timer_count := timer_count + 1;
-
+
tmp:=(p_end+1)&003h;
- buffer_event.item p_end.make timer_count;
+ buffer_event.item p_end.make timer_count;
(((tmp+2)&3)!=p_beg).if {
p_end:=tmp;
- };
+ };
);
-
+
Section Public
- make <-
( + new_event:EVENT_TIMER;
-
+
is_actif := TRUE;
//
// Software configuration.
@@ -74,9 +74,9 @@ Section Public
};
};
buffer_event.first.set_prev new_event;
-
- //hdle := timer_interrupt;
-
+
+ //hdle := timer_interrupt;
+
`SetTimer(hwnd_glob, 0, 50, NULL)`;
);
@@ -88,13 +88,13 @@ Section Public
- get_event <-
( + p:INTEGER;
+ evt:EVENT_TIMER;
-
+
p := p_beg;
{ p != p_end }.while_do {
evt := buffer_event.item p;
(list_client.lower).to (list_client.upper) do { j:INTEGER;
list_client.item j.receive (buffer_event.item p);
- };
+ };
p := (p + 1) & 03h;
- };
+ };
);
diff --git a/lib/internal/os_support/windows/video/video.li b/lib/internal/os_support/windows/video/video.li
index 19ae932..ae80046 100644
--- a/lib/internal/os_support/windows/video/video.li
+++ b/lib/internal/os_support/windows/video/video.li
@@ -19,11 +19,11 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := VIDEO;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Video Driver for Windows";
- lip <-
@@ -31,12 +31,12 @@ Section Header
add_lib "-lgdi32";
);
- - external :=
+ - external :=
`
#include <windows.h>
#define main main_std
-#define __BEGIN_INTERRUPT__
+#define __BEGIN_INTERRUPT__
#define __END_INTERRUPT__
#define lstat stat
@@ -59,38 +59,38 @@ LPSTR lpCmdLine, int nCmdShow)
nCmdShow_glob = nCmdShow;
main(0,NULL);
return 0;
-};
+};
`;
Section Inherit
-
+
+ parent_bitmap:Expanded BITMAP(PIXEL_24);
-
+
Section Public
// Section VIDEO
-
- - line_tmp:ABSTRACT_BMP_LINE;
-
+
+ - line_tmp:ABSTRACT_BMP_LINE;
+
Section Public
-
+
- message str:ABSTRACT_STRING <-
( + msg:NATIVE_ARRAY(CHARACTER);
msg := str.to_external;
`MessageBox(hwnd_glob, at msg, "Message", MB_OK)`;
);
-
+
- is_active:BOOLEAN;
-
- - planes:UINTEGER_32;
-
+
+ - planes:UINTEGER_32;
+
- size_pixel:INTEGER;
-
+
- make_size (w,h:INTEGER) <-
- (
+ (
// Init BITMAP:
width := w;
height := h;
-
+
EVENT_SYSTEM.make;
`
wc_glob.style = 0;
@@ -112,14 +112,14 @@ Section Public
hdc_glob = GetDC(hwnd_glob);
ShowWindow(hwnd_glob, nCmdShow_glob);
UpdateWindow(hwnd_glob);
-
+
//pen = CreatePen(PS_SOLID,1,0x151515);
//SelectObject(hdc_glob,pen);
-
-
+
+
hdcbmp = CreateCompatibleDC(hdc_glob);
`;
-
+
planes := `GetDeviceCaps(hdc_glob, BITSPIXEL) * GetDeviceCaps(hdc_glob, PLANES)`:UINTEGER_32;
planes
@@ -128,49 +128,49 @@ Section Public
line_tmp := BMP_LINE(PIXEL_15).create w;
`Bmp = CreateBitmap(@w, 1, 1, 15, NULL)`;
}
- .when 16 then {
+ .when 16 then {
size_pixel := 2;
- line_tmp := BMP_LINE(PIXEL_16).create w;
+ line_tmp := BMP_LINE(PIXEL_16).create w;
`Bmp = CreateBitmap(@w, 1, 1, 16, NULL)`;
}
- .when 24 then {
+ .when 24 then {
size_pixel := 3;
- line_tmp := BMP_LINE(PIXEL_24).create w;
+ line_tmp := BMP_LINE(PIXEL_24).create w;
`Bmp = CreateBitmap(@w, 1, 1, 24, NULL)`;
}
- .when 32 then {
+ .when 32 then {
size_pixel := 4;
- line_tmp := BMP_LINE(PIXEL_32).create w;
+ line_tmp := BMP_LINE(PIXEL_32).create w;
`Bmp = CreateBitmap(@w, 1, 1, 32, NULL)`;
};
`SelectObject(hdcbmp, Bmp)`;
is_active := TRUE;
);
-
+
- auto_make <-
(
make_size (800,600);
);
-
+
- close <-
(
? {is_active};
is_active := FALSE;
? {! is_active};
);
-
+
Section Public
-
- //
+
+ //
// Redefine Low level Bitmap.
//
-
+
- pixel_hard (x,y:INTEGER) color col:UINTEGER_32 <-
( + real_col:UINTEGER_32;
real_col := ((col>>16) & 0000FFh) | ((col<<16) & 0FF0000h) | (col & 00FF00h);
- `SetPixel(hdc_glob, at x, at y, at real_col)`;
+ `SetPixel(hdc_glob, at x, at y, at real_col)`;
);
-
+
- line_h_hard (x0,y0:INTEGER) until x1:INTEGER color col:UINTEGER_32 <-
( + real_col:UINTEGER_32;
+ pen:UINTEGER_32;
@@ -181,21 +181,21 @@ Section Public
`LineTo(hdc_glob, at x1+1, at y0)`;
`DeleteObject((HPEN)@pen)`;
);
-
- - line_h_hard (x0,y0:INTEGER) until x1:INTEGER
+
+ - line_h_hard (x0,y0:INTEGER) until x1:INTEGER
image line:ABSTRACT_BMP_LINE offset ofs:INTEGER <-
( + len:INTEGER;
+ data:NATIVE_ARRAY(UINTEGER_8);
+ sz_pix:INTEGER;
len := x1 - x0;
VIDEO.line_tmp.put line offset ofs from 0 to len;
-
+
sz_pix := VIDEO.size_pixel;
data := VIDEO.line_tmp.get_storage;
- `SetBitmapBits(Bmp,(@len+1)*@sz_pix, at data)`;
+ `SetBitmapBits(Bmp,(@len+1)*@sz_pix, at data)`;
`BitBlt(hdc_glob, @x0, @y0, at len+1,1, hdcbmp, 0, 0, SRCCOPY)`;
);
-
+
- get_pixel_hard (x,y:INTEGER) :PIXEL <-
(
not_yet_implemented;
diff --git a/lib/internal/portable/collection/any_avl_dictionary_node.li b/lib/internal/portable/collection/any_avl_dictionary_node.li
index 19f94fd..e071b9b 100644
--- a/lib/internal/portable/collection/any_avl_dictionary_node.li
+++ b/lib/internal/portable/collection/any_avl_dictionary_node.li
@@ -19,13 +19,13 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ANY_AVL_DICTIONARY_NODE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
+
diff --git a/lib/internal/portable/collection/any_avl_set_node.li b/lib/internal/portable/collection/any_avl_set_node.li
index 813da61..e4d996e 100644
--- a/lib/internal/portable/collection/any_avl_set_node.li
+++ b/lib/internal/portable/collection/any_avl_set_node.li
@@ -24,8 +24,7 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
\ No newline at end of file
diff --git a/lib/internal/portable/collection/any_hashed_bijective_dictionary_node.li b/lib/internal/portable/collection/any_hashed_bijective_dictionary_node.li
index af0abfc..b79665f 100644
--- a/lib/internal/portable/collection/any_hashed_bijective_dictionary_node.li
+++ b/lib/internal/portable/collection/any_hashed_bijective_dictionary_node.li
@@ -24,8 +24,7 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
\ No newline at end of file
diff --git a/lib/internal/portable/collection/any_hashed_dictionary_node.li b/lib/internal/portable/collection/any_hashed_dictionary_node.li
index 1b29794..70698ed 100644
--- a/lib/internal/portable/collection/any_hashed_dictionary_node.li
+++ b/lib/internal/portable/collection/any_hashed_dictionary_node.li
@@ -24,8 +24,7 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
\ No newline at end of file
diff --git a/lib/internal/portable/collection/any_hashed_set_node.li b/lib/internal/portable/collection/any_hashed_set_node.li
index cf89429..b3d4a4b 100644
--- a/lib/internal/portable/collection/any_hashed_set_node.li
+++ b/lib/internal/portable/collection/any_hashed_set_node.li
@@ -24,8 +24,7 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
\ No newline at end of file
diff --git a/lib/internal/portable/collection/any_linked_list_node.li b/lib/internal/portable/collection/any_linked_list_node.li
index db279c0..e839bef 100644
--- a/lib/internal/portable/collection/any_linked_list_node.li
+++ b/lib/internal/portable/collection/any_linked_list_node.li
@@ -24,8 +24,7 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
\ No newline at end of file
diff --git a/lib/internal/portable/collection/any_two_way_linked_list_node.li b/lib/internal/portable/collection/any_two_way_linked_list_node.li
index fac74bb..9f0a135 100644
--- a/lib/internal/portable/collection/any_two_way_linked_list_node.li
+++ b/lib/internal/portable/collection/any_two_way_linked_list_node.li
@@ -24,8 +24,7 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
\ No newline at end of file
diff --git a/lib/internal/portable/collection/arrayed.li b/lib/internal/portable/collection/arrayed.li
index d57b4d4..1ce030a 100644
--- a/lib/internal/portable/collection/arrayed.li
+++ b/lib/internal/portable/collection/arrayed.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ARRAYED;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Generic collection";
-
+
// BSBS: A revoir cela doit rentrer ARRAYED_COLLECTION (mais il faut voir avec STRING)
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
- lower:INTEGER <- deferred;
- upper:INTEGER <- deferred;
- count:INTEGER <- deferred;
- capacity:INTEGER <- deferred;
-
- - element_sizeof:INTEGER <-
+
+ - element_sizeof:INTEGER <-
// The size in number of bytes for type `E'.
- (
+ (
deferred;
0
);
-
+
- add_last_buffer buf:FAST_ARRAY(UINTEGER_8) from beg:INTEGER to end:INTEGER <-
(
deferred;
);
-
+
- item_byte idx:INTEGER offset ofs:INTEGER :UINTEGER_8 <-
(
deferred;
@@ -62,13 +62,13 @@ Section Public
(
deferred;
);
-
+
- set_count new_count:INTEGER <-
(
deferred;
);
-
- - to_native_array_uinteger_8:NATIVE_ARRAY(UINTEGER_8) <-
+
+ - to_native_array_uinteger_8:NATIVE_ARRAY(UINTEGER_8) <-
(
deferred;
NULL
diff --git a/lib/internal/portable/collection/arrayed_collection.li b/lib/internal/portable/collection/arrayed_collection.li
index f93049f..082e834 100644
--- a/lib/internal/portable/collection/arrayed_collection.li
+++ b/lib/internal/portable/collection/arrayed_collection.li
@@ -19,31 +19,31 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ARRAYED_COLLECTION(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Common root for ARRAY(V) and FAST_ARRAY(V).";
-
+
Section Inherit
-
+
- parent_arrayed:ARRAYED := ARRAYED;
-
+
- parent_collection:COLLECTION(V) := COLLECTION(V);
-
+
Section Public //ARRAYED_COLLECTION, BMP_FILE, TYPES
-
+
+ storage:NATIVE_ARRAY(V);
// Internal access to storage location.
-
+
Section Public
-
- - element_sizeof:INTEGER <-
+
+ - element_sizeof:INTEGER <-
// The size in number of bytes for type `E'.
( + result:INTEGER;
-
+
(V.is_expanded_type).if {
result := V.object_size;
} else {
@@ -51,13 +51,13 @@ Section Public
};
result
);
-
+
+ capacity:INTEGER;
// Internal storage capacity in number of item.
-
+
+ upper:INTEGER;
// Upper index bound.
-
+
- subarray min:INTEGER to max:INTEGER :SELF <-
// New collection consisting of items at indexes in [`min' .. `max'].
// Result has the same dynamic type as `Current'.
@@ -67,28 +67,28 @@ Section Public
-? { max <= upper };
-? { min <= max + 1 };
]
- (
+ (
deferred;
NULL
)
- [
+ [
+? { same_dynamic_type result };
+? { result.count = max - min + 1 };
+? { result.lower = min | (result.lower = 0) };
];
-
+
//
// Implementation of deferred:
//
-
+
- first:V <- storage.item 0;
-
+
- second:V <- storage.item 1;
-
+
- last :V <- item upper;
-
+
- add element:V to index:INTEGER <-
- (
+ (
(index = upper + 1).if {
add_last element;
} else {
@@ -97,43 +97,43 @@ Section Public
put element to index;
};
);
-
+
- remove_last <-
- (
- upper := upper - 1;
+ (
+ upper := upper - 1;
);
-
+
- remove_tail n:INTEGER <-
(
upper := upper - n;
);
-
+
- replace_all old_value:V with new_value:V <-
- (
- storage.replace_all old_value with new_value until (count - 1);
+ (
+ storage.replace_all old_value with new_value until (count - 1);
);
-
+
- fast_replace_all old_value:V with new_value:V <-
- (
- storage.fast_replace_all old_value with new_value until (count - 1);
+ (
+ storage.fast_replace_all old_value with new_value until (count - 1);
);
-
+
- reverse <-
( + i,j:INTEGER;
-
+
i := lower;
- j := upper;
+ j := upper;
{i >= j}.until_do {
swap i with j;
i := i + 1;
j := j - 1;
};
- );
-
+ );
+
//
// Interfacing with C:
//
-
+
- to_external:POINTER <-
// Gives C access into the internal `storage' of the ARRAY.
// Result is pointing the element at index `lower'.
@@ -143,11 +143,11 @@ Section Public
[
-? {! is_empty};
]
- (
+ (
storage.to_pointer
)
[
- +? {Result.is_not_null};
+ +? {Result.is_not_null};
];
- to_native_array:NATIVE_ARRAY(V) <-
@@ -159,48 +159,48 @@ Section Public
[
-? {! is_empty};
]
- (
+ (
storage
)
[
- +? {Result.is_not_null};
+ +? {Result.is_not_null};
];
-
+
Section ARRAYED_COLLECTION
-
+
- set_upper new_upper:INTEGER <-
(
upper := new_upper;
);
-
+
//
// invariant
//
-
+
// [
// -? {capacity >= (upper - lower + 1)};
// -? {(capacity > 0) ->> {storage.is_not_null}};
// ];
Section Public
-
+
- set_count new_count:INTEGER <-
(
upper := new_count + lower - 1;
);
- - to_native_array_uinteger_8:NATIVE_ARRAY(UINTEGER_8) <-
+ - to_native_array_uinteger_8:NATIVE_ARRAY(UINTEGER_8) <-
(
CONVERT(NATIVE_ARRAY(V),NATIVE_ARRAY(UINTEGER_8)).on storage
);
-
+
- add_last_buffer buf:FAST_ARRAY(UINTEGER_8) from beg:INTEGER to end:INTEGER <-
( + tab:NATIVE_ARRAY(UINTEGER_8);
+ pos_beg,size,new_capacity:INTEGER;
pos_beg := count * element_sizeof; // + ofs_buf;
size := end - beg + 1;
-
+
new_capacity := (pos_beg + end - beg + element_sizeof) / element_sizeof;
(capacity < new_capacity).if {
"cap:".print;
@@ -210,7 +210,7 @@ Section Public
"Crash !\n".print;
crash;
};
-
+
tab := CONVERT(NATIVE_ARRAY(V),NATIVE_ARRAY(UINTEGER_8)).on storage;
tab.copy (buf.storage + beg) to pos_beg until size;
//ofs_buf := (pos_beg + size) % element_sizeof;
diff --git a/lib/internal/portable/collection/avl_constants.li b/lib/internal/portable/collection/avl_constants.li
index 8e77d3d..a636d7a 100644
--- a/lib/internal/portable/collection/avl_constants.li
+++ b/lib/internal/portable/collection/avl_constants.li
@@ -24,13 +24,13 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
Section SELF
-
+
- balanced:INTEGER := 0;
- imbalanced_left:INTEGER := -1;
diff --git a/lib/internal/portable/collection/avl_dictionary_node.li b/lib/internal/portable/collection/avl_dictionary_node.li
index ab49e46..ec45c54 100644
--- a/lib/internal/portable/collection/avl_dictionary_node.li
+++ b/lib/internal/portable/collection/avl_dictionary_node.li
@@ -24,23 +24,23 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Auxiliary class to implement AVL_DICTIONARY.";
-
+
Section Inherit
-
+
+ parent_avl_tree_node:Expanded AVL_TREE_NODE(K);
-
+
- parent_any_avl_dictionary_node:ANY_AVL_DICTIONARY_NODE := ANY_AVL_DICTIONARY_NODE;
-
+
Section Public
-
+
- key:K <- item;
-
+
- set_key i:K <- set_item i;
-
+
Section AVL_DICTIONARY, AVL_DICTIONARY_NODE
-
+
+ value:V;
- set_value v:V <-
@@ -54,7 +54,7 @@ Section AVL_DICTIONARY, AVL_DICTIONARY_NODE
- fast_at k:K :AVL_DICTIONARY_NODE(V, K) <-
// Is element `e' in the tree?
( + result:AVL_DICTIONARY_NODE(V, K);
-
+
(key = k).if {
result := Self;
}.elseif {key == k /*SAFE_EQUAL(K).test key and k*/} then {
@@ -63,7 +63,7 @@ Section AVL_DICTIONARY, AVL_DICTIONARY_NODE
}.elseif {k < key} then {
(left != NULL).if {
result := left.fast_at k;
- };
+ };
} else {
(right != NULL).if {
result := right.fast_at k;
@@ -84,7 +84,7 @@ Section AVL_DICTIONARY, AVL_DICTIONARY_NODE
- key_at v:V :K <-
( + result:K;
-
+
(v == value /*SAFE_EQUAL(V).test v and value*/).if {
result := key;
}.elseif {left != NULL} then {
@@ -97,19 +97,19 @@ Section AVL_DICTIONARY, AVL_DICTIONARY_NODE
- fast_key_at v:V :K <-
( + result:K;
-
+
(v = value).if {
result := key;
}.elseif {left != NULL} then {
- result := left.fast_key_at v;
+ result := left.fast_key_at v;
}.elseif {right != NULL} then {
result := right.fast_key_at v;
};
result
);
-
+
Section AVL_DICTIONARY_NODE
-
+
- occurrences v:V start cnt:INTEGER :INTEGER <-
( + result:INTEGER;
@@ -152,15 +152,15 @@ Section AVL_DICTIONARY
//
// Creation:
//
-
+
- create (v:V,k:K) :SELF <-
( + result:SELF;
-
+
result := clone;
result.make (v,k);
result
);
-
+
- make (v:V,k:K) <-
(
set_balance balanced;
diff --git a/lib/internal/portable/collection/avl_set_node.li b/lib/internal/portable/collection/avl_set_node.li
index bcdecdc..5441356 100644
--- a/lib/internal/portable/collection/avl_set_node.li
+++ b/lib/internal/portable/collection/avl_set_node.li
@@ -19,37 +19,37 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := AVL_SET_NODE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Auxiliary class to implement AVL_SET.";
-
+
// This a classic implementation of an AVL tree (balanced tree first
// designed by Adelson-Velskii and Landis, 1960)
-
+
Section Inherit
-
+
+ parent_avl_tree_node:Expanded AVL_TREE_NODE(V);
-
+
- parent_any_avl_set_node:ANY_AVL_SET_NODE := ANY_AVL_SET_NODE;
Section AVL_SET
-
+
//
// Creation:
//
-
+
- create i:V :SELF <-
( + result:SELF;
-
+
result := clone;
result.make i;
result
);
-
+
- make i:V <-
(
set_balance balanced;
@@ -60,6 +60,6 @@ Section AVL_SET
[
+? {item = i};
];
-
+
diff --git a/lib/internal/portable/collection/avl_tree.li b/lib/internal/portable/collection/avl_tree.li
index c52cd7c..2ed1b84 100644
--- a/lib/internal/portable/collection/avl_tree.li
+++ b/lib/internal/portable/collection/avl_tree.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := AVL_TREE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
// Definition of a mathematical set of comparable objects. All common
// operations on mathematical sets are available.
Section Insert
-
+
- parent_avl_constants:AVL_CONSTANTS := AVL_CONSTANTS;
Section Public
-
+
- debug_string:STRING <-
( + result:STRING;
-
+
(root = NULL).if {
result := "NULL";
} else {
@@ -48,13 +48,13 @@ Section Public
);
+ count:INTEGER;
-
+
Section Public
-
+
//
// Adding and removing:
//
-
+
- remove e:V <-
(
root := do_remove (root, e);
@@ -66,7 +66,7 @@ Section Public
);
Section SELF
-
+
+ root:AVL_TREE_NODE(V);
+ rebalance:BOOLEAN;
@@ -85,7 +85,7 @@ Section SELF
- fast_do_insert n:AVL_TREE_NODE(V) :AVL_TREE_NODE(V) <-
( + result:AVL_TREE_NODE(V);
-
+
(n = NULL).if {
result := new_node;
set_value_and_key result;
@@ -104,7 +104,7 @@ Section SELF
result := n;
};
} else {
- ? {item_memory > n.item};
+ ? {item_memory > n.item};
n.set_right (do_insert (n.right));
(rebalance).if {
result := right_grown n;
@@ -122,7 +122,7 @@ Section SELF
- do_insert n:AVL_TREE_NODE(V) :AVL_TREE_NODE(V) <-
( + result:AVL_TREE_NODE(V);
-
+
(n = NULL).if {
result := new_node;
set_value_and_key result;
@@ -144,7 +144,7 @@ Section SELF
result := n;
};
} else {
- ? {item_memory == n.item};
+ ? {item_memory == n.item};
result := n;
set_value result;
rebalance := FALSE;
@@ -164,7 +164,7 @@ Section SELF
-? {node_height (n.right) - node_height (n.left) + 1 = n.balance};
]
( + result:AVL_TREE_NODE(V);
-
+
(n.balance)
.when imbalanced_left then {
(n.left.balance = imbalanced_left).if {
@@ -205,7 +205,7 @@ Section SELF
+? {Result != NULL};
+? {Result.balance = node_height (Result.right) - node_height (Result.left)};
+? {
- rebalance = (node_height Result > 1 +
+ rebalance = (node_height Result > 1 +
Old node_height (n.right).max (node_height (n.left) - 1))
};
];
@@ -217,7 +217,7 @@ Section SELF
-? {node_height (n.right) - 1 - node_height (n.left) = n.balance};
]
( + result:AVL_TREE_NODE(V);
-
+
(n.balance)
.when imbalanced_right then {
(n.right.balance = imbalanced_right).if {
@@ -237,7 +237,7 @@ Section SELF
n.set_balance balanced;
n.right.set_balance imbalanced_right;
};
-
+
n.right.left.set_balance balanced;
n.set_right (n.right.rotate_right);
};
@@ -259,14 +259,14 @@ Section SELF
+? {Result != NULL};
+? {Result.balance = node_height (Result.right) - node_height (Result.left)};
+? {
- rebalance = (node_height Result > 1 +
+ rebalance = (node_height Result > 1 +
Old node_height (n.left).max (node_height (n.right) - 1))
};
];
- fast_do_remove (n:AVL_TREE_NODE(V),e:V) :AVL_TREE_NODE(V) <-
( + result:AVL_TREE_NODE(V);
-
+
(n = NULL).if {
rebalance := FALSE;
}.elseif {e = n.item} then {
@@ -292,7 +292,7 @@ Section SELF
result := n;
};
} else {
- ? {e > n.item};
+ ? {e > n.item};
n.set_right (do_remove (n.right, e));
(rebalance).if {
result := right_shrunk n;
@@ -303,7 +303,7 @@ Section SELF
result
)
[
- +? {Result = NULL ||
+ +? {Result = NULL ||
{Result.balance = node_height (Result.right) - node_height (Result.left)}
};
+? {rebalance = (node_height Result < Old node_height n)};
@@ -311,7 +311,7 @@ Section SELF
- do_remove (n:AVL_TREE_NODE(V),e:V) :AVL_TREE_NODE(V) <-
( + result:AVL_TREE_NODE(V);
-
+
(n = NULL).if {
rebalance := FALSE;
}.elseif {e < n.item} then {
@@ -356,7 +356,7 @@ Section SELF
-? {n2 != NULL};
]
( + result:AVL_TREE_NODE(V);
-
+
(n2.right = NULL).if {
result := n2.left;
exchange_and_discard (n1, n2);
@@ -371,7 +371,7 @@ Section SELF
result
)
[
- +? {Result = NULL ||
+ +? {Result = NULL ||
{Result.balance = node_height (Result.right) - node_height (Result.left)}};
+? {rebalance = (node_height Result < Old node_height n2)};
];
@@ -383,7 +383,7 @@ Section SELF
-? {node_height (n.right) - node_height (n.left) - 1 = n.balance};
]
( + result:AVL_TREE_NODE(V);
-
+
(n.balance)
.when imbalanced_left then {
n.set_balance balanced;
@@ -410,7 +410,7 @@ Section SELF
n.set_balance imbalanced_left;
n.right.set_balance balanced;
};
-
+
n.right.left.set_balance balanced;
n.set_right (n.right.rotate_right);
}
@@ -427,10 +427,10 @@ Section SELF
};
result
)
- [
+ [
+? {Result != NULL};
+? {Result.balance = node_height (Result.right) - node_height (Result.left)};
- +? {rebalance = (node_height Result < 1 +
+ +? {rebalance = (node_height Result < 1 +
Old node_height (n.right).max (node_height (n.left) + 1))};
];
@@ -441,7 +441,7 @@ Section SELF
-? {node_height (n.right) + 1 - node_height (n.left) = n.balance};
]
( + result:AVL_TREE_NODE(V);
-
+
(n.balance)
.when imbalanced_right then {
n.set_balance balanced;
@@ -467,7 +467,7 @@ Section SELF
.when imbalanced_left then {
n.set_balance imbalanced_right;
n.left.set_balance balanced;
- };
+ };
n.left.right.set_balance balanced;
n.set_left (n.left.rotate_left);
}
@@ -487,7 +487,7 @@ Section SELF
[
+? {Result != NULL};
+? {Result.balance = node_height (Result.right) - node_height (Result.left)};
- +? {rebalance = (node_height Result < 1 +
+ +? {rebalance = (node_height Result < 1 +
Old node_height (n.left).max (node_height (n.right) + 1))};
];
@@ -504,7 +504,7 @@ Section SELF
+? {count = Old count - 1};
+? {rebalance};
];
-
+
- clear_nodes node:AVL_TREE_NODE(V) <-
(
(node.left != NULL).if {
@@ -518,19 +518,19 @@ Section SELF
- node_height node:AVL_TREE_NODE(V) :INTEGER <-
( + result:INTEGER;
-
+
(node != NULL).if {
result := node.height;
};
result
);
-
-Section Public
-
+
+Section Public
+
//
// Looking and searching:
//
-
+
- has e:V :BOOLEAN <-
// Is element `e' in the set?
(
@@ -544,11 +544,11 @@ Section Public
);
Section SELF
-
+
//
// Iterating internals:
//
-
+
- build_map <-
[
"build_needed" -? {map_dirty};
@@ -568,13 +568,13 @@ Section SELF
// Elements in a row for iteration. See `build_map'.
+ map_dirty:BOOLEAN;
- // True when the map needs to be built again for the iterators.
+ // True when the map needs to be built again for the iterators.
// See `build_map'.
Section SELF
-
+
- new_node:AVL_TREE_NODE(V) <-
- (
+ (
a_new_node
);
@@ -583,7 +583,7 @@ Section SELF
deferred;
NULL
);
-
+
- discard_node n:AVL_TREE_NODE(V) <-
[
-? {n != NULL};
@@ -591,11 +591,11 @@ Section SELF
(
deferred;
);
-
- //
+
+ //
// invariant
//
-
+
// [
// -? {map != NULL};
// -? {(! map_dirty) -> (map.count = count)};
diff --git a/lib/internal/portable/collection/avl_tree_node.li b/lib/internal/portable/collection/avl_tree_node.li
index ac08fc3..485e159 100644
--- a/lib/internal/portable/collection/avl_tree_node.li
+++ b/lib/internal/portable/collection/avl_tree_node.li
@@ -19,23 +19,23 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := AVL_TREE_NODE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Auxiliary class to implement AVL_SET.";
-
- // This a classic implementation of an AVL tree (balanced tree first designed
+
+ // This a classic implementation of an AVL tree (balanced tree first designed
// by Adelson-Velskii and Landis (hence A.V.L.), 1960)
Section Insert
-
+
- parent_avl_constants:AVL_CONSTANTS := AVL_CONSTANTS;
Section Public
-
+
- out_in_tagged_out_memory <-
(
item.out_in_tagged_out_memory;
@@ -54,9 +54,9 @@ Section Public
tagged_out_memory.add_last ')';
);
-Section Public
+Section Public
//AVL_TREE_NODE, AVL_TREE
-
+
+ left:AVL_TREE_NODE(V);
+ right:AVL_TREE_NODE(V);
@@ -70,7 +70,7 @@ Section Public
- count:INTEGER <-
( + result:INTEGER;
-
+
result := 1;
(left != NULL).if {
result := result + left.count;
@@ -83,7 +83,7 @@ Section Public
- height:INTEGER <-
( + result:INTEGER;
-
+
(left != NULL).if {
result := left.height;
};
@@ -101,7 +101,7 @@ Section Public
(left != NULL).if {
left.map_in map;
};
- map.add_last Self;
+ map.add_last Self;
(right != NULL).if {
right.map_in map;
};
@@ -113,7 +113,7 @@ Section Public
- has e:V :BOOLEAN <-
// Is element `e' in the tree?
( + result:BOOLEAN;
-
+
result := item == e; //SAFE_EQUAL(V).test item and e;
(! result).if {
(e < item).if {
@@ -123,12 +123,12 @@ Section Public
};
};
result
- );
+ );
- fast_has e:V :BOOLEAN <-
// Is element `e' in the tree?
( + result:BOOLEAN;
-
+
result := item = e;
((! result) && {! item == e /*SAFE_EQUAL(V).test item and e*/}).if {
(e < item).if {
@@ -146,7 +146,7 @@ Section Public
- at e:V :AVL_TREE_NODE(V) <-
// Is element `e' in the tree?
( + result:AVL_TREE_NODE(V);
-
+
(item == e /*SAFE_EQUAL(V).test item and e*/).if {
result := Self;
}.elseif {e < item} then {
@@ -206,16 +206,16 @@ Section Public
];
Section AVL_TREE, AVL_DICTIONARY, AVL_SET
-
+
//
// Rotations:
//
-
+
- rotate_right:AVL_TREE_NODE(V) <-
// Proceeds to some reorganisation and returns the upper node.
( + result:AVL_TREE_NODE(V);
+ left_right:AVL_TREE_NODE(V);
-
+
result := left;
left_right := left.right;
left.set_right Self;
@@ -230,14 +230,14 @@ Section AVL_TREE, AVL_DICTIONARY, AVL_SET
// Proceeds to some reorganisation and returns the upper node.
( + result:AVL_TREE_NODE(V);
+ right_left:AVL_TREE_NODE(V);
-
+
result := right;
right_left := right.left;
- right.set_left Self;
+ right.set_left Self;
set_right right_left;
result
- )
+ )
[
+? {Result != NULL};
];
-
+
diff --git a/lib/internal/portable/collection/collection.li b/lib/internal/portable/collection/collection.li
index abdbdc7..855257f 100644
--- a/lib/internal/portable/collection/collection.li
+++ b/lib/internal/portable/collection/collection.li
@@ -19,73 +19,73 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COLLECTION(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Pierre-Alexandre Voye";
- - comment := "Common abstract definition of a sequenceable collection of objects.";
+ - comment := "Common abstract definition of a sequenceable collection of objects.";
- // Such a collection is traversable using a simple INTEGER index from `lower'
- // to `upper' using `item'. All COLLECTIONs are resizable thanks to
- // `add_last' / `remove_last', `add_first' / `remove_first' as well as
- // `add' / `remove' .<br/> <br/>
+ // Such a collection is traversable using a simple INTEGER index from `lower'
+ // to `upper' using `item'. All COLLECTIONs are resizable thanks to
+ // `add_last' / `remove_last', `add_first' / `remove_first' as well as
+ // `add' / `remove' .<br/> <br/>
//
- // This abstraction provides feature to view a COLLECTION as a stack
- // (as an example by using `add_last', `last', and `remove_last').
+ // This abstraction provides feature to view a COLLECTION as a stack
+ // (as an example by using `add_last', `last', and `remove_last').
// One can also use a COLLECTION as a queue (as an example, by using
- // `add_last', `first' and `remove_first').<br/> <br/>
- //
- // The Lisaac standard library provides five implementations of COLLECTION:
- // ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST. <br/> Except for creations all
- // implementations have exactly the same behavior. Switching from one
- // implementation to another only change the memory used and the execution
- // time (see header comment of ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST
- // for more details).<br/> <br/>
-
+ // `add_last', `first' and `remove_first').<br/> <br/>
+ //
+ // The Lisaac standard library provides five implementations of COLLECTION:
+ // ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST. <br/> Except for creations all
+ // implementations have exactly the same behavior. Switching from one
+ // implementation to another only change the memory used and the execution
+ // time (see header comment of ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST
+ // for more details).<br/> <br/>
+
Section Inherit
-
+
// - parent_storage:STORAGE := STORAGE;
-
- - parent_traversable:TRAVERSABLE(V) := TRAVERSABLE(V);
-
+
+ - parent_traversable:TRAVERSABLE(V) := TRAVERSABLE(V);
+
Section Public
-
+
//
// Accessing:
//
-
- - item i:INTEGER :V <-
+
+ - item i:INTEGER :V <-
// Item at the corresponding index `i'.
// * Description en Francais : Item à l'index `i'
// * See: `lower', `upper', `valid_index', `put', `swap'
// * Require : None
- // * Ensure : None
+ // * Ensure : None
( + result:V;
-
+
deferred;
result
);
-
+
//
// Writing:
//
-
+
- put element:V to i:INTEGER <-
// Make `element' the item at index `i'.
// * See: `lower', `upper', `valid_index', `item', `swap', `force'.
[
- -? { valid_index i };
+ -? { valid_index i };
]
- (
+ (
deferred;
)
[
+? { item i = element };
+? { count = Old count};
];
-
+
- swap i1:INTEGER with i2:INTEGER <-
// Swap item at index `i1' with item at index `i2'.
// * See: `item', `put'.
@@ -94,7 +94,7 @@ Section Public
-? { valid_index i2 };
]
( + tmp:V;
-
+
tmp := item i1;
put (item i2) to i1;
put tmp to i2;
@@ -104,17 +104,17 @@ Section Public
+? { item i2 = Old item i1 };
+? { count = Old count };
];
-
+
- set_all_with v:V <-
// Set all items with value `v'.
// * See: `set_slice_with'.
- (
+ (
deferred;
)
[
+? { count = Old count };
];
-
+
- set_slice lower_index:INTEGER to upper_index:INTEGER with v:V <-
// Set all items in range [`lower_index' .. `upper_index'] with `v'.
// * See: `set_all_with'.
@@ -122,40 +122,40 @@ Section Public
-? { lower_index <= upper_index };
-? { valid_index lower_index };
-? { valid_index upper_index };
- ]
- (
+ ]
+ (
lower_index.to upper_index do { i:INTEGER;
put v to i;
- };
+ };
)
[
+? { count = Old count };
];
-
+
- clear_all <-
// Set every item to its default value.
- // The `count' is not affected
+ // The `count' is not affected
// see also `clear', `all_default'.
( + value:V;
-
+
set_all_with value;
- )
+ )
[
"Stable upper." +? { upper = Old upper };
"Stable lower." +? { lower = Old lower };
+? { all_default };
];
-
+
//
// Adding:
//
-
+
- add_first element:V <-
// Add a new item in first position : `count' is increased by
// one and all other items are shifted right.
//
// * See: `add_last', `first', `last', `add'.
- (
+ (
deferred;
)
[
@@ -164,12 +164,12 @@ Section Public
-? { lower = Old lower };
-? { upper = 1 + Old upper };
];
-
+
- add_last element:V <-
// Add a new item at the end : `count' is increased by one.
//
// * See: `add_first', `last', `first', `add'.
- (
+ (
deferred;
)
[
@@ -178,7 +178,7 @@ Section Public
+? { lower = Old lower };
+? { upper = 1 + Old upper };
];
-
+
- add element:V to index:INTEGER <-
// Add a new `element' at rank `index' : `count' is increased
// by one and range [`index' .. `upper'] is shifted right
@@ -188,7 +188,7 @@ Section Public
[
-? { index.in_range lower to (upper + 1)};
]
- (
+ (
deferred;
)
[
@@ -196,7 +196,7 @@ Section Public
+? { count = 1 + Old count };
+? { upper = 1 + Old upper };
];
-
+
- append_collection other:COLLECTION(V) <-
// Append `other' to Current.
//
@@ -204,15 +204,15 @@ Section Public
[
-? { other != NULL };
]
- (
- (other.lower).to (other.upper) do { i:INTEGER;
+ (
+ (other.lower).to (other.upper) do { i:INTEGER;
add_last (other.item i);
- };
+ };
)
[
+? { count = other.count + Old count };
];
-
+
- copy_collection other:COLLECTION(V) <-
// Copy `other' to Current.
//
@@ -220,26 +220,26 @@ Section Public
[
-? { other != NULL };
]
- ( + same:SELF;
-
+ ( + same:SELF;
+
same ?= other;
(same != NULL).if {
copy same;
- } else {
+ } else {
clear;
- (other.lower).to (other.upper) do { i:INTEGER;
+ (other.lower).to (other.upper) do { i:INTEGER;
add_last (other.item i);
- };
+ };
};
)
[
+? { count = other.count };
- ];
-
+ ];
+
//
// Modification:
//
-
+
- force element:V to index:INTEGER <-
// Make `element' the item at `index', enlarging the collection if
// necessary (new bounds except `index' are initialized with
@@ -249,37 +249,37 @@ Section Public
[
+? { index >= lower};
]
- (
+ (
deferred;
)
[
-? { upper = index.max (Old upper) };
-? { item index = element };
];
-
+
- copy other:SELF <-
// Reinitialize by copying all the items of `other'.
(
deferred;
);
-
+
- from_collection model:COLLECTION(V) <-
// Initialize the current object with the contents of `model'.
[
-? { model != NULL };
"Useful work." -? {model != Self};
]
- (
+ (
deferred;
)
[
+? { count = model.count };
];
-
+
//
// Removing:
//
-
+
- remove_first <-
// Remove the `first' element of the collection.
//
@@ -287,14 +287,14 @@ Section Public
[
-? { ! is_empty };
]
- (
- deferred;
+ (
+ deferred;
)
[
+? { count = Old count - 1};
+? {(lower = Old lower + 1) ^ (upper = Old upper - 1)};
];
-
+
- remove_head n:INTEGER <-
// Remove the `n' elements of the collection.
//
@@ -310,7 +310,7 @@ Section Public
+? { count = Old count - n };
+? {(lower = Old lower + n) ^ (upper = Old upper - n)};
];
-
+
- remove index:INTEGER <-
// Remove the item at position `index'. Followings items
// are shifted left by one position.
@@ -319,14 +319,14 @@ Section Public
[
-? { valid_index index };
]
- (
- deferred;
+ (
+ deferred;
)
[
+? { count = Old count - 1};
+? { upper = Old upper - 1};
];
-
+
- remove_last <-
// Remove the `last' item.
//
@@ -334,14 +334,14 @@ Section Public
[
-? {! is_empty};
]
- (
- deferred;
+ (
+ deferred;
)
[
+? { count = Old count - 1 };
+? { upper = Old upper - 1 };
];
-
+
- remove_tail n:INTEGER <-
// Remove the last `n' item(s).
//
@@ -357,7 +357,7 @@ Section Public
+? {count = Old count - n};
+? {upper = Old upper - n};
];
-
+
- clear <-
// Discard all items in order to make it `is_empty'.
//
@@ -368,27 +368,27 @@ Section Public
[
"Is empty." +? { count = 0 };
];
-
+
//
// Looking and Searching:
//
-
+
- has x:V :BOOLEAN <-
// Look for `x' using `equal' for comparison.
- //
+ //
// * See: `fast_has', `index_of start', `fast_index_of start'.
(
valid_index (first_index_of x)
);
-
+
- fast_has x:V :BOOLEAN <-
// Look for `x' using basic `=' for comparison.
- //
+ //
// * See: `has', `fast_index_of start', `index_of start'.
(
valid_index (fast_first_index_of x)
);
-
+
- first_index_of element:V :INTEGER <-
// Give the index of the first occurrence of `element' using
// `==' for comparison.
@@ -397,31 +397,31 @@ Section Public
// * Parameter:
// `element' : element to search.
// * Require: `element' not null.
- // * Ensure: Very good fonction
+ // * Ensure: Very good fonction
//
- // * See: `fast_first_index_of', `index_of start', `last_index_of',
+ // * See: `fast_first_index_of', `index_of start', `last_index_of',
// `reverse_index_of'.
- //
- // * Description en Francais: Donne l'index de la premiere occurence de `element'
+ //
+ // * Description en Francais: Donne l'index de la premiere occurence de `element'
// en utilisant `==' pour la comparaison.
// Renvoi `upper + 1' lorsque `element' est absent.
//
- // * Parametre:
+ // * Parametre:
// `element' : L'element que l'on veut chercher.
- // * Necessite: `element' pas null.
- // * Voir: `fast_first_index_of', `index_of', `last_index_of',
+ // * Necessite: `element' pas null.
+ // * Voir: `fast_first_index_of', `index_of', `last_index_of',
// `reverse_index_of'.
- (
+ (
deferred;
0
)
[
"Definition." +? {Result = index_of element start lower};
- ];
-
+ ];
+
- index_of element:V start start_index:INTEGER :INTEGER <-
- // Using `is_equal' for comparison, gives the index of the first occurrence
- // of `element' at or after `start_index'. Answer `upper + 1' when `element'
+ // Using `is_equal' for comparison, gives the index of the first occurrence
+ // of `element' at or after `start_index'. Answer `upper + 1' when `element'
// when the search fail.
//
// * See: `fast_index_of', `reverse_index_of', `first_index_of'.
@@ -434,11 +434,11 @@ Section Public
//+? {valid_index Result ->> { SAFE_EQUAL(V).test element with (item Result)}};
+? {valid_index Result ->> {element == item Result}};
];
-
+
- reverse_index_of element:V start start_index:INTEGER :INTEGER <-
- // Using `is_equal' for comparison, gives the index of the first occurrence of
- // `element' at or before `start_index'. Search is done in reverse direction,
- // which means from the `start_index' down to the `lower' index .
+ // Using `is_equal' for comparison, gives the index of the first occurrence of
+ // `element' at or before `start_index'. Search is done in reverse direction,
+ // which means from the `start_index' down to the `lower' index .
// Answer `lower -1' when the search fail.
//
// * See: `fast_reverse_index_of', `last_index_of', `index_of'.
@@ -455,9 +455,9 @@ Section Public
];
- last_index_of element:V :INTEGER <-
- // Using `is_equal' for comparison, gives the index of the last occurrence
- // of `element' at or before `upper'. Search is done in reverse direction,
- // which means from the `upper' down to the `lower' index . Answer `lower -1'
+ // Using `is_equal' for comparison, gives the index of the last occurrence
+ // of `element' at or before `upper'. Search is done in reverse direction,
+ // which means from the `upper' down to the `lower' index . Answer `lower -1'
// when the search fail.
//
// * See: `fast_last_index_of', `reverse_index_of', `index_of'.
@@ -469,7 +469,7 @@ Section Public
];
- fast_first_index_of element:V :INTEGER <-
- // Give the index of the first occurrence of `element' using basic `='
+ // Give the index of the first occurrence of `element' using basic `='
// for comparison. Answer `upper + 1' when `element' is not inside.
//
// * See: `first_index_of', `last_index_of', `fast_last_index_of'.
@@ -482,8 +482,8 @@ Section Public
];
- fast_index_of element:V start start_index:INTEGER :INTEGER <-
- // Using basic `=' for comparison, gives the index of the first occurrence
- // of `element' at or after `start_index'. Answer `upper + 1' when `element'
+ // Using basic `=' for comparison, gives the index of the first occurrence
+ // of `element' at or after `start_index'. Answer `upper + 1' when `element'
// when the search fail.
//
// * See: `index_of', `fast_reverse_index_of', `fast_first_index_of'.
@@ -497,9 +497,9 @@ Section Public
];
- fast_reverse_index_of element:V start start_index:INTEGER :INTEGER <-
- // Using basic `=' comparison, gives the index of the first occurrence
- // of `element' at or before `start_index'. Search is done in reverse
- // direction, which means from the `start_index' down to the `lower'
+ // Using basic `=' comparison, gives the index of the first occurrence
+ // of `element' at or before `start_index'. Search is done in reverse
+ // direction, which means from the `start_index' down to the `lower'
// index . Answer `lower -1' when the search fail.
//
// * See: `reverse_index_of', `fast_index_of', `fast_last_index_of'.
@@ -516,9 +516,9 @@ Section Public
];
- fast_last_index_of element:V :INTEGER <-
- // Using basic `=' for comparison, gives the index of the last occurrence
- // of `element' at or before `upper'. Search is done in reverse direction,
- // which means from the `upper' down to the `lower' index . Answer `lower -1'
+ // Using basic `=' for comparison, gives the index of the last occurrence
+ // of `element' at or before `upper'. Search is done in reverse direction,
+ // which means from the `upper' down to the `lower' index . Answer `lower -1'
// when the search fail.
//
// * See: `fast_reverse_index_of', `last_index_of'.
@@ -528,24 +528,24 @@ Section Public
[
"Definition." +? {Result = fast_reverse_index_of element start upper};
];
-
+
//
// Looking and comparison:
//
-
+
- Self:SELF '==' Right 60 other:E :BOOLEAN <-
// Do both collections have the same `lower', `upper', and
// items?
// The basic `=' is used for comparison of items.
//
// * See: `is_equal_map', `same_items'.
- (
+ (
deferred;
FALSE
)
[ + same:SELF;
same ?= other;
- +? {(same = NULL) || {Result ->> {(lower = same.lower) & (upper = same.upper)}} };
+ +? {(same = NULL) || {Result ->> {(lower = same.lower) & (upper = same.upper)}} };
];
- Self:SELF '~=' Right 60 other:COLLECTION(V) :BOOLEAN <-
@@ -554,38 +554,38 @@ Section Public
// The basic `=' is used for comparison of items.
//
// * See: `is_equal_map', `same_items'.
- (
+ (
deferred;
FALSE
)
- [
- +? { Result ->> {(lower = other.lower) & (upper = other.upper)} };
+ [
+ +? { Result ->> {(lower = other.lower) & (upper = other.upper)} };
];
-
+
- is_equal_map other:SELF :BOOLEAN <-
// Do both collections have the same `lower', `upper', and
// items?
// Feature `==' is used for comparison of items.
//
// * See: `==', `same_items'.
- (
+ (
deferred;
FALSE
)
[
- +? { result -> ((lower = other.lower) & (upper = other.upper)) };
+ +? { result -> ((lower = other.lower) & (upper = other.upper)) };
];
-
+
- all_default:BOOLEAN <-
// Do all items have their type's default value?
// Note: for non NULL items, the test is performed with the `is_default' predicate.
//
// * See: `clear_all'.
- (
+ (
deferred;
FALSE
);
-
+
- same_items other:COLLECTION(V) :BOOLEAN <-
// Do both collections have the same items? The basic `=' is used
// for comparison of items and indices are not considered (for
@@ -598,7 +598,7 @@ Section Public
]
( + result:BOOLEAN;
+ i,j:INTEGER;
-
+
(count = other.count).if {
result := TRUE;
i := lower;
@@ -607,52 +607,52 @@ Section Public
result := (item i = other.item j);
i := i + 1;
j := j + 1;
- };
- };
+ };
+ };
result
)
[
- +? { result -> (count = other.count)};
+ +? { result -> (count = other.count)};
];
-
+
- occurrences element:V :INTEGER <-
// Number of occurrences of `element' using `equal' for comparison.
- //
+ //
// * See: `fast_occurrences', `index_of'.
- (
+ (
deferred;
0
)
[
+? { result >= 0 };
];
-
+
- fast_occurrences element:V :INTEGER <-
// Number of occurrences of `element' using basic `=' for comparison.
- //
+ //
// * See: `occurrences', `index_of'.
- (
+ (
deferred;
0
)
- [
+ [
+? { result >= 0 };
];
-
+
//
// Printing:
//
-
+
- fill_tagged_out_memory <-
( + i:INTEGER;
+ v:V;
-
+
tagged_out_memory.append "lower: ";
lower.append_in tagged_out_memory;
tagged_out_memory.append " upper: ";
upper.append_in tagged_out_memory;
tagged_out_memory.append " [";
-
+
i := lower;
{(i > upper) || {tagged_out_memory.count > 2048}}.until_do {
v := item i;
@@ -660,24 +660,24 @@ Section Public
tagged_out_memory.append "NULL";
} else {
v.out_in_tagged_out_memory;
- };
+ };
(i < upper).if {
tagged_out_memory.add_last ' ';
- };
+ };
i := i + 1;
- };
+ };
(i <= upper).if {
tagged_out_memory.append " ...";
- };
+ };
tagged_out_memory.add_last ']';
);
-
+
//
// Agents based features:
//
-
+
- foreach action:{V; } <- do_all action;
-
+
- do_all action:{V; } <-
// Apply `action' to every item of `Self'.
//
@@ -687,12 +687,12 @@ Section Public
action.value (item i);
};
);
-
+
- foreach action:{V; } while test:{V; BOOLEAN} <-
// Apply `action' to every item of `Self' while test is true
( + i:INTEGER;
+ tst:BOOLEAN;
-
+
i := lower;
{(i <= upper) && {test.value (item i)}}.while_do {
action.value (item i);
@@ -704,7 +704,7 @@ Section Public
// Apply `action' to every item of `Self' until test is true
( + i:INTEGER;
+ tst:BOOLEAN;
-
+
i := lower;
{(i <= upper) && {! test.value (item i)}}.while_do {
action.value (item i);
@@ -718,18 +718,18 @@ Section Public
test.value (item i).if {
action.value (item i);
};
- };
+ };
);
-
+
- is_all test:{V; BOOLEAN} :BOOLEAN <- for_all test;
-
+
- for_all test:{V; BOOLEAN} :BOOLEAN <-
// Do all items satisfy `test'?
//
// * See: `do_all', `exists'.
( + i:INTEGER;
+ result:BOOLEAN;
-
+
result := TRUE;
i := lower;
{(! result) || {i > upper}}.until_do {
@@ -738,14 +738,14 @@ Section Public
};
result
);
-
+
- exists test:{V; BOOLEAN} :BOOLEAN <-
// Does at least one item satisfy `test'?
//
// * See: `do_all', `for_all'.
( + i:INTEGER;
+ result:BOOLEAN;
-
+
i := lower;
{(result) || {i > upper}}.until_do {
result := test.value (item i);
@@ -753,11 +753,11 @@ Section Public
};
result
);
-
- //
+
+ //
// Traditionals features (in functional languages)
//
-
+
- filter test:{V; BOOLEAN} in other:SELF <-
// Filter all element which `test' element is true and put the result in `other'
// * Require : `other' not null
@@ -765,7 +765,7 @@ Section Public
-? { other != NULL };
]
( + elt:V;
-
+
lower.to upper do { j:INTEGER;
elt := item j;
(test.value elt).if {
@@ -787,16 +787,16 @@ Section Public
( + result,elt:V;
+ is_end:BOOLEAN;
+ j:INTEGER;
-
- j := lower;
+
+ j := lower;
{(j <= upper) && {is_end}}.while_do {
elt := item j;
(is_end := test.value elt).if {
result := elt;
};
- j := j + 1;
- };
-
+ j := j + 1;
+ };
+
result
);
@@ -813,19 +813,19 @@ Section Public
- fold_right function:{(V,V);} with element:V :V <-
// fold left with function `function' beginning with `element'
( + result:V;
-
+
result := element;
upper.downto lower do { j:INTEGER;
result := function.value (result,item j);
};
result
);
-
+
- merge other:SELF with test:{(V,V); BOOLEAN} :SELF<-
// Return the intersection between `Self' and `other' according to `test' function
( + result:SELF;
+ elt:V;
-
+
result := SELF.create 0;
(other.lower).to (other.upper) do { i:INTEGER;
lower.to upper do { j:INTEGER;
@@ -841,12 +841,12 @@ Section Public
//
// Other features
//
-
+
- unique:SELF <-
// Remove every duplicated element in the collection
// Only the first duplicate will be kept
( + j,i:INTEGER;
-
+
j := lower;
{j <= upper}.while_do {
i := upper;
@@ -859,12 +859,12 @@ Section Public
j := j + 1;
};
);
-
+
- fast_unique:SELF <-
// Remove every duplicated element in the collection
// Only the first duplicate will be kept
( + j,i:INTEGER;
-
+
j := lower;
{j <= upper}.while_do {
i := upper;
@@ -883,27 +883,27 @@ Section Public
// using `equal' for comparison.
//
// * See: `fast_replace_all', `move'.
- (
+ (
deferred;
)
[
+? { count = Old count};
+? { (! SAFE_EQUAL(V).test old_value with new_value) ->> {occurrences old_value = 0}};
- ];
-
+ ];
+
- fast_replace_all old_value:V with new_value:V <-
// Replace all occurrences of the element `old_value' by `new_value'
// using operator `=' for comparison.
//
// * See: `replace_all', `move'.
- (
+ (
deferred;
)
[
+? { count = Old count };
+? { (old_value != new_value) ->> {occurrences old_value = 0}};
- ];
-
+ ];
+
- move lower_index:INTEGER to upper_index:INTEGER by distance:INTEGER <-
// Move range `lower_index' .. `upper_index' by `distance'
// positions. Negative distance moves towards lower indices.
@@ -917,25 +917,25 @@ Section Public
-? { valid_index (upper_index + distance) };
]
( + default_value:V;
-
+
(distance != 0).if {
- (distance < 0).if {
+ (distance < 0).if {
lower_index.to upper_index do { i:INTEGER;
put (item i) to (i + distance);
put default_value to i;
- };
+ };
} else {
upper_index.downto lower_index do { i:INTEGER;
put (item i) to (i + distance);
put default_value to i;
- };
+ };
};
- };
+ };
)
[
+? {count = Old count};
];
-
+
- slice min:INTEGER to max:INTEGER :SELF <-
// New collection consisting of items at indexes in [`min'..`max'].
// Result has the same dynamic type as `Current'.
@@ -946,13 +946,13 @@ Section Public
// * require: `min' inferior or equal to `max' + 1
// * ensure: `Self' is same dynamic type of Result
// * ensure: Result size is equal to `max' - `min' + 1
- // * ensure: Result first element index is same as `Self' first element index
+ // * ensure: Result first element index is same as `Self' first element index
[
-? { lower <= min };
-? { max <= upper };
-? { min <= max + 1 };
]
- (
+ (
deferred;
NULL
)
@@ -961,21 +961,21 @@ Section Public
+? { Result.count = max - min + 1};
+? { Result.lower = lower };
];
-
+
- reverse <-
// Reverse the order of the elements.
(
deferred;
)
- [
+ [
+? { count = Old count };
];
-
+
//
// Invariant.
//
-
+
// [
// -? { lower <= upper + 1 };
// ];
-
+
diff --git a/lib/internal/portable/collection/collection2.li b/lib/internal/portable/collection/collection2.li
index 48c2371..2b81b6e 100644
--- a/lib/internal/portable/collection/collection2.li
+++ b/lib/internal/portable/collection/collection2.li
@@ -19,92 +19,92 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COLLECTION2(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Abstract definition of a 2 dimensional collection of elements of type E.";
-
- // The Lisaac standard library provides two implementations of COLLECTION2:
+
+ // The Lisaac standard library provides two implementations of COLLECTION2:
// ARRAY2 and FAST_ARRAY2.
// All implementations have exactly the same behavior. Switching from one implementation to
// another only change the memory used and the execution time.
-
+
Section Inherit
-
+
- parent_safe_equal:SAFE_EQUAL(V) := SAFE_EQUAL(V);
-
+
Section Public
-
+
//
// Indexing:
//
-
+
- lower1:INTEGER <-
// First Lower index bounds.
(
deferred;
0
);
-
+
- lower2 :INTEGER <-
// Second Lower index bounds.
(
deferred;
0
);
-
+
- line_minimum:INTEGER <- lower1;
// Equivalent of `lower1'.
- column_minimum:INTEGER <- lower2;
// Equivalent of `lower2'.
-
+
- upper1:INTEGER <-
// First Upper index bounds.
(
deferred;
0
);
-
+
- upper2 :INTEGER <-
// Second Upper index bounds.
- (
+ (
deferred;
0
);
-
+
- line_maximum:INTEGER <- upper1;
// Equivalent of `upper1'.
- column_maximum:INTEGER <- upper2;
// Equivalent of `upper2'.
-
+
//
// Reading:
//
-
+
- item (line, column:INTEGER) :V <-
[ -? { valid_index (line,column) }; ]
( + result:V;
-
+
deferred;
result
);
-
+
//
// Writing:
//
-
+
- put element:V to (line, column:INTEGER) <-
[ -? { valid_index (line,column) }; ]
(
deferred;
)
[ +? { item (line,column) = element}; ];
-
+
- force element:V to (line, column:INTEGER) <-
// Put `element' at position (`line',`column'). Collection is
// resized first when (`line',`column') is not inside current
@@ -120,63 +120,63 @@ Section Public
+? { item (line,column) = element };
+? { count >= Old count };
];
-
+
//
// Index validity:
//
-
- - valid_line line:INTEGER :BOOLEAN <-
+
+ - valid_line line:INTEGER :BOOLEAN <-
(
(lower1 <= line) && { line <= upper1}
)
[
+? { Result = ((lower1 <= line) && { line <= upper1 }) };
];
-
+
- valid_index1 line:INTEGER :BOOLEAN <-
(
valid_line line
);
-
- - valid_column column:INTEGER :BOOLEAN <-
- (
- (lower2 <= column) && {column <= upper2}
+
+ - valid_column column:INTEGER :BOOLEAN <-
+ (
+ (lower2 <= column) && {column <= upper2}
)
- [
+ [
+? { Result = ((lower2 <= column) && {column <= upper2}) };
];
-
+
- valid_index2 column:INTEGER :BOOLEAN <-
(
valid_column column
);
-
+
- valid_index (line, column:INTEGER) :BOOLEAN <-
(
- (lower1 <= line ) && {line <= upper1 } &&
+ (lower1 <= line ) && {line <= upper1 } &&
{lower2 <= column} && {column <= upper2}
)
- [
+ [
+? { Result = ((valid_line line) && {valid_column column}) };
];
-
+
//
// Counting:
//
-
+
- count1:INTEGER <-
// Size of the first dimension.
(
deferred;
0
- )
+ )
[
+? { Result = upper1 - lower1 + 1 };
];
-
+
- line_count:INTEGER <- count1;
// Equivalent of `count1'.
-
+
- count2 :INTEGER <-
// Size of the second dimension.
(
@@ -186,10 +186,10 @@ Section Public
[
+? { Result = upper2 - lower2 + 1 };
];
-
+
- column_count :INTEGER <- count2;
// Equivalent of `count2'.
-
+
- count:INTEGER <-
// Total number of elements.
(
@@ -199,7 +199,7 @@ Section Public
[
+? { Result = line_count * column_count };
];
-
+
- swap (line1, column1:INTEGER) with (line2, column2:INTEGER) <-
// Swap the element at index (`line1',`column1') with the
// the element at index (`line2',`column2').
@@ -215,7 +215,7 @@ Section Public
+? { item (line2,column2) = Old item (line1,column1) };
+? { count = Old count };
];
-
+
- set_all_with v:V <-
// Set all item with value `v'.
(
@@ -224,22 +224,22 @@ Section Public
[
+? { count = Old count };
];
-
+
- clear_all <-
// Set all items to default values.
( + value:V;
-
+
set_all_with value;
)
[
+? { count = Old count };
+? { all_default };
];
-
+
//
// Creating or initializing:
//
-
+
- from_collection2 model:COLLECTION2(V) <-
// Uses `model' to initialize Current.
[ -? { model != NULL }; ]
@@ -250,7 +250,7 @@ Section Public
+? { count1 = model.count1 };
+? { count2 = model.count2 };
];
-
+
- from_model model:COLLECTION(COLLECTION(V)) <-
// The `model' is used to fill line by line Current.
// Assume all sub-collections of `model' have the same
@@ -266,7 +266,7 @@ Section Public
+? { count1 = model.count };
+? { count2 = model.first.count };
];
-
+
- copy_collection other:COLLECTION2(V) <-
// Copy `other' to Current.
//
@@ -274,27 +274,27 @@ Section Public
[
-? { other != NULL };
]
- ( + same:SELF;
-
+ ( + same:SELF;
+
same ?= other;
(same != NULL).if {
copy same;
- } else {
+ } else {
not_yet_implemented;
};
);
-
+
//
// Looking and comparison:
//
-
+
- all_default:BOOLEAN <-
// Do all items have their type's default value?
(
deferred
FALSE
);
-
+
- Self:SELF '==' other:COLLECTION2(V) :BOOLEAN <-
// Do both collections have the same `lower1', `lower2', `upper1' and `upper2', and items?
// The basic `=' is used for comparison of items.
@@ -302,10 +302,10 @@ Section Public
// See also `is_equal_map'.
( + line, column:INTEGER;
+ result:BOOLEAN;
-
+
(
- (lower1 = other.lower1) &&
- {upper1 = other.upper1} &&
+ (lower1 = other.lower1) &&
+ {upper1 = other.upper1} &&
{lower2 = other.lower2} &&
{upper2 = other.upper2}
).if {
@@ -329,10 +329,10 @@ Section Public
//
// See also `is_equal'.
( + line, column:INTEGER;
-
+
(
- (lower1 = other.lower1) &&
- {upper1 = other.upper1} &&
+ (lower1 = other.lower1) &&
+ {upper1 = other.upper1} &&
{lower2 = other.lower2} &&
{upper2 = other.upper2}
).if {
@@ -348,16 +348,16 @@ Section Public
};
};
result
- );
-
+ );
+
//
// Printing:
//
-
+
- fill_tagged_out_memory <-
( + line:INTEGER;
+v:V;
-
+
tagged_out_memory.append "lower1:";
lower1.append_in tagged_out_memory;
tagged_out_memory.append " upper1:";
@@ -367,34 +367,34 @@ Section Public
tagged_out_memory.append " upper2:";
upper2.append_in tagged_out_memory;
tagged_out_memory.append " [\n";
-
+
line := lower1;
{ (line > upper1) || { tagged_out_memory.count > 4096 }}.until_do {
tagged_out_memory.append(once "line ");
line.append_in(tagged_out_memory);
tagged_out_memory.append(once "\t:");
-
+
lower2.to upper2 do { column:INTEGER;
v := item (line,column);
(v = NULL).if {
tagged_out_memory.append(once "NULL");
} else {
v.out_in_tagged_out_memory;
- };
+ };
tagged_out_memory.add_last ' ';
- };
+ };
tagged_out_memory.add_last '\n';
line := line + 1;
- };
+ };
(valid_line line).if {
tagged_out_memory.append(once "......\n");
- };
+ };
);
-
+
//
// Miscellaneous features:
//
-
+
- occurrences elt:V :INTEGER <-
// Number of occurrences using `equal'.
//
@@ -404,7 +404,7 @@ Section Public
0
)
[ +? { Result >= 0 }; ];
-
+
- fast_occurrences elt:V :INTEGER <-
// Number of occurrences using `='.
//
@@ -414,7 +414,7 @@ Section Public
0
)
[ +? { Result >= 0 }; ];
-
+
- has x:V :BOOLEAN <-
// Search if a element x is in the array using `equal'.
//
@@ -423,14 +423,14 @@ Section Public
deferred;
FALSE
);
-
+
- fast_has x:V :BOOLEAN <-
// Search if a element x is in the array using `='.
(
deferred;
FALSE
);
-
+
- replace_all old_value:V with new_value:V <-
// Replace all occurences of the element `old_value' by `new_value'
// using `equal' for comparison.
@@ -439,11 +439,11 @@ Section Public
(
deferred;
)
- [
+ [
+? { count = Old count };
+? { occurrences old_value = 0 };
];
-
+
- fast_replace_all old_value:V with new_value:V <-
// Replace all occurences of the element `old_value' by `new_value'
// using operator `=' for comparison.
@@ -456,36 +456,35 @@ Section Public
+? { count = Old count };
+? { fast_occurrences old_value = 0 };
];
-
+
- sub_collection2 (line_min,column_min:INTEGER) to (line_max,column_max:INTEGER) :SELF <-
// Create a new object using selected area of `Current'.
[
-? { valid_index (line_min,column_min) };
-? { valid_index (line_max,column_max) };
]
- (
+ (
deferred;
NULL
)
- [
+ [
+? { result != NULL };
];
-
+
- set_area (line_min,column_min:INTEGER) to (line_max,column_max:INTEGER) with element:V <-
// Set all the elements of the selected area rectangle with `element'.
[
-? { valid_index (line_min,column_min) };
-? { valid_index (line_max,column_max) };
]
- (
+ (
line_min.to line_max do { line:INTEGER;
column_min.to column_max do { column:INTEGER;
put element to (line,column);
- };
- };
+ };
+ };
)
[
+? { count = Old count };
];
-
-
\ No newline at end of file
+
diff --git a/lib/internal/portable/collection/collection3.li b/lib/internal/portable/collection/collection3.li
index 561bd5f..47448db 100644
--- a/lib/internal/portable/collection/collection3.li
+++ b/lib/internal/portable/collection/collection3.li
@@ -19,108 +19,108 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COLLECTION3(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Abstract definition of a 3 dimensional collection of elements of type E.";
-
- // The Lisaac standard library provides two implementations of COLLECTION3: ARRAY3
- // and FAST_ARRAY3. All implementations have exactly the same behavior.
- // Switching from one implementation to another only change the memory
+
+ // The Lisaac standard library provides two implementations of COLLECTION3: ARRAY3
+ // and FAST_ARRAY3. All implementations have exactly the same behavior.
+ // Switching from one implementation to another only change the memory
// used and the execution time.
-
+
Section Inherit
-
+
- parent_safe_equal:SAFE_EQUAL(V) := SAFE_EQUAL(V);
-
+
Section Public
-
+
- lower1:INTEGER <-
// Lower index bound for dimension 1.
(
deferred;
0
);
-
+
- lower2:INTEGER <-
// Lower index bound for dimension 2.
(
deferred;
0
);
-
+
- lower3:INTEGER <-
// Lower index bound for dimension 3.
(
deferred;
0
);
-
+
- line_minimum:INTEGER <- lower1;
// Equivalent of `lower1'.
-
+
- column_minimum:INTEGER <- lower2;
// Equivalent of `lower2'.
-
+
- depth_minimum:INTEGER <- lower3;
// Equivalent of `lower3'.
-
+
- upper1:INTEGER <-
// Upper index bound for dimension 1.
(
deferred;
0
);
-
+
- upper2:INTEGER <-
// Upper index bound for dimension 2.
(
deferred;
0
);
-
+
- upper3:INTEGER <-
// Upper index bound for dimension 3.
(
deferred;
0
);
-
+
- line_maximum:INTEGER <- upper1;
// Equivalent of `upper1'.
-
+
- column_maximum:INTEGER <- upper2;
// Equivalent of `upper2'.
-
+
- depth_maximum:INTEGER <- upper3;
// Equivalent of `upper3'.
-
+
//
// Reading:
//
- item (line, column, depth:INTEGER) :V <-
[ -? { valid_index (line,column,depth) }; ]
- ( + result:V;
-
+ ( + result:V;
+
deferred;
result
);
-
+
//
// Writing:
//
- put element:V to (line, column, depth:INTEGER) <-
[ -? {valid_index (line,column,depth) }; ]
- (
+ (
deferred;
)
[ +? { item(line,column,depth) = element}; ];
-
+
- force element:V to (line, column, depth:INTEGER) <-
// Put `element' at position (`line',`column',`depth').
// Collection is resized first when (`line',`column',`depth')
@@ -138,46 +138,46 @@ Section Public
+? { item (line,column,depth) = element };
+? { count >= Old count };
];
-
+
//
// Index validity:
//
-
+
- valid_line line:INTEGER :BOOLEAN <-
(
(lower1 <= line) && {line <= upper1}
)
[ +? {Result = (lower1 <= line) && {line <= upper1}}; ];
-
+
- valid_index1 line:INTEGER :BOOLEAN <- valid_line line;
-
+
- valid_column column:INTEGER :BOOLEAN <-
(
(lower2 <= column) && {column <= upper2}
)
[ +? {Result = (lower2 <= column) && {column <= upper2}}; ];
-
+
- valid_index2 column:INTEGER :BOOLEAN <- valid_column column;
-
+
- valid_depth depth:INTEGER :BOOLEAN <-
(
(lower3 <= depth) && {depth <= upper3}
)
[ +? {Result = (lower3 <= depth) && {depth <= upper3}}; ];
-
+
- valid_index3 depth:INTEGER :BOOLEAN <- valid_depth depth;
-
+
- valid_index (line, column, depth:INTEGER) :BOOLEAN <-
(
- (lower1 <= line ) && {line <= upper1} && {lower2 <= column} &&
+ (lower1 <= line ) && {line <= upper1} && {lower2 <= column} &&
{column <= upper2} && {lower3 <= depth } && {depth <= upper3}
)
[ +? {Result = (valid_line line) && {valid_column column} && {valid_depth depth}}; ];
-
+
//
// Counting:
//
-
+
- count1:INTEGER <-
// Size of the first dimension.
(
@@ -185,10 +185,10 @@ Section Public
0
)
[ +? {Result = upper1 - lower1 + 1}; ];
-
+
- line_count:INTEGER <- count1;
// Equivalent of `count1'.
-
+
- count2:INTEGER <-
// Size of the second dimension.
(
@@ -196,10 +196,10 @@ Section Public
0
)
[ +? {Result = upper2 - lower2 + 1}; ];
-
+
- column_count:INTEGER <- count2;
// Equivalent of `count2'.
-
+
- count3:INTEGER <-
// Size of the third dimension.
(
@@ -207,10 +207,10 @@ Section Public
0
)
[ +? {Result = upper3 - lower3 + 1}; ];
-
+
- depth_count:INTEGER <- count3;
// Equivalent of `count3'.
-
+
- count:INTEGER <-
// Total number of elements.
(
@@ -226,7 +226,7 @@ Section Public
-? { valid_index (line1,column1,depth1)};
-? { valid_index (line2,column2,depth2)};
]
- (
+ (
deferred;
)
[
@@ -234,7 +234,7 @@ Section Public
+? {item(line2,column2,depth2) = Old item(line1,column1,depth1)};
+? {count = Old count};
];
-
+
- set_all_with v:V <-
// Set all item with value `v'.
(
@@ -244,23 +244,23 @@ Section Public
- clear_all <-
// Set all items to default values.
- ( + value:V;
-
+ ( + value:V;
+
set_all_with value;
)
- [
+ [
+? {count = Old count};
+? {all_default};
];
-
+
//
// Creating or initializing:
//
-
+
- from_collection3 model:COLLECTION3(V) <-
// Uses `model' to initialize self.
[ -? {model != NULL}; ]
- (
+ (
deferred;
)
[
@@ -268,13 +268,13 @@ Section Public
+? {count2 = model.count2};
+? {count3 = model.count3};
];
-
+
- from_model model:COLLECTION(COLLECTION(COLLECTION(V))) <-
// The `model' is used to fill line by line self.
// Assume all sub-collections have the same
// dimension.
[ -? { model != NULL }; ]
- (
+ (
deferred;
)
[
@@ -282,7 +282,7 @@ Section Public
+? {count2 > 0 ->> {count2 = model.first.count}};
+? {count3 > 0 ->> {count3 = model.first.first.count}};
];
-
+
//
// Looking and comparison:
//
@@ -292,7 +292,7 @@ Section Public
(
deferred;
);
-
+
- Self:SELF '==' other:COLLECTION3(V) :BOOLEAN <-
// Do both collections have the same `lower1', `lower2', `lower3', `upper1', `upper2' and
// `upper3', and items?
@@ -301,17 +301,17 @@ Section Public
// See also `is_equal_map'.
( + line, column, depth: INTEGER;
+ result:BOOLEAN;
-
+
(
- (lower1 = other.lower1) &&
- {upper1 = other.upper1} &&
- {lower2 = other.lower2} &&
+ (lower1 = other.lower1) &&
+ {upper1 = other.upper1} &&
+ {lower2 = other.lower2} &&
{upper2 = other.upper2} &&
- {lower3 = other.lower3} &&
+ {lower3 = other.lower3} &&
{upper3 = other.upper3}
- ).if {
+ ).if {
result := TRUE;
- line := upper1;
+ line := upper1;
{(! result) || {line < lower1}}.until_do {
column := upper2;
{(! result) || {column < lower2}}.until_do {
@@ -330,22 +330,22 @@ Section Public
- is_equal_map other: COLLECTION3(V) :BOOLEAN <-
// Do both collections have the same `lower1', `lower2', `lower3', `upper1', `upper2' and `upper3',
- // and items?
+ // and items?
//
// See also `=='.
( + line, column, depth:INTEGER;
+ result:BOOLEAN;
-
+
(
- (lower1 = other.lower1) &&
- {upper1 = other.upper1} &&
- {lower2 = other.lower2} &&
+ (lower1 = other.lower1) &&
+ {upper1 = other.upper1} &&
+ {lower2 = other.lower2} &&
{upper2 = other.upper2} &&
- {lower3 = other.lower3} &&
+ {lower3 = other.lower3} &&
{upper3 = other.upper3}
- ).if {
+ ).if {
result := TRUE;
- line := upper1;
+ line := upper1;
{(! result) || {line < lower1}}.until_do {
column := upper2;
{(! result) || {column < lower2}}.until_do {
@@ -361,7 +361,7 @@ Section Public
};
result
);
-
+
//
// Printing:
//
@@ -369,7 +369,7 @@ Section Public
- fill_tagged_out_memory <-
( + line:INTEGER;
+ v:V;
-
+
tagged_out_memory.append "lower1:";
lower1.append_in tagged_out_memory;
tagged_out_memory.append " upper1:";
@@ -383,18 +383,18 @@ Section Public
tagged_out_memory.append " upper3:";
upper3.append_in tagged_out_memory;
tagged_out_memory.append " [\n";
-
+
line := lower1;
{ (line > upper1) || { tagged_out_memory.count > 4096}}.until_do {
tagged_out_memory.append "line ";
line.append_in tagged_out_memory;
tagged_out_memory.append "\t:";
-
+
lower2.to upper2 do { column:INTEGER;
tagged_out_memory.append "column ";
column.append_in tagged_out_memory;
tagged_out_memory.append "\t:";
-
+
lower3.to upper3 do { depth:INTEGER;
tagged_out_memory.append "depth ";
depth.append_in tagged_out_memory;
@@ -407,23 +407,23 @@ Section Public
};
tagged_out_memory.extend ' ';
};
-
+
tagged_out_memory.extend '\n';
};
-
+
tagged_out_memory.extend '\n';
line := line + 1;
};
-
+
(valid_line line).if {
tagged_out_memory.append "......\n";
};
);
-
+
//
// Miscellaneous features:
//
-
+
- occurrences elt:V :INTEGER <-
// Number of occurrences using `equal'.
//
@@ -452,14 +452,14 @@ Section Public
deferred;
FALSE
);
-
+
- fast_has x:V :BOOLEAN <-
// Search if a element x is in the array using `='.
(
deferred;
FALSE
);
-
+
- replace_all old_value:V with new_value:V <-
// Replace all occurences of the element `old_value' by `new_value'
// using `equal' for comparison.
@@ -472,7 +472,7 @@ Section Public
+? {count = Old count};
+? {occurrences old_value = 0};
];
-
+
- fast_replace_all old_value:V with new_value:V <-
// Replace all occurences of the element `old_value' by `new_value'
// using operator `=' for comparison.
@@ -485,20 +485,20 @@ Section Public
+? {count = Old count};
+? {fast_occurrences old_value = 0};
];
-
- - sub_collection3 (line_min, column_min, depth_min:INTEGER)
+
+ - sub_collection3 (line_min, column_min, depth_min:INTEGER)
to (line_max, column_max, depth_max:INTEGER) :SELF <-
// Create a new object using selected area of `self'.
[
-? { valid_index (line_min,column_min,depth_min)};
-? { valid_index (line_max,column_max,depth_max)};
]
- (
+ (
deferred;
)
[ +? {Result != NULL}; ];
-
- - set_area (line_min, column_min, depth_min:INTEGER)
+
+ - set_area (line_min, column_min, depth_min:INTEGER)
to (line_max, column_max, depth_max:INTEGER) with element:V <-
// Set all the elements of the selected area rectangle with `element'.
[
@@ -515,4 +515,4 @@ Section Public
};
)
[ +? {count = Old count}; ];
-
+
diff --git a/lib/internal/portable/collection/dictionary.li b/lib/internal/portable/collection/dictionary.li
index a5ea380..ea8d097 100644
--- a/lib/internal/portable/collection/dictionary.li
+++ b/lib/internal/portable/collection/dictionary.li
@@ -23,27 +23,27 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Associative memory. Values of type `V' are stored using Keys of type `K'.";
-
- // To make a comparison with the well knowned ARRAY class, with a DICTIONARY,
- // index used are not only INTEGER, you can use for example a STRING to access
+
+ // To make a comparison with the well knowned ARRAY class, with a DICTIONARY,
+ // index used are not only INTEGER, you can use for example a STRING to access
// to your information.
//
// Well knowned implementations, see HASHED_DICTIONARY and AVL_DICTIONARY.
//
// See also BIJECTIVE_DICTIONARY class.
-
+
Section Inherit
-
+
+ parent_traversable:Expanded TRAVERSABLE(V);
-
+
Section Public
-
+
//
// Counting:
//
-
+
- count:INTEGER <-
// Actual `count' of stored elements.
(
@@ -53,17 +53,17 @@ Section Public
- is_empty:BOOLEAN <- count = 0;
// Is it empty?
-
+
//
// Basic access:
//
-
+
- has k:K :BOOLEAN <-
// Is there a value currently associated with key `k'?
//
// See also `fast_has', `at'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
]
(
deferred;
@@ -74,11 +74,11 @@ Section Public
// Return the value associated to key `k'.
//
// See also `fast_at', `reference_at', `has'.
- [ ...
- -? {has k};
+ [ ...
+ -? {has k};
]
( + result:V;
-
+
deferred;
result
);
@@ -91,16 +91,16 @@ Section Public
//
// See also `fast_reference_at', `at', `has'.
[ ...
- -? {k != NULL};
+ -? {k != NULL};
// "Values are expanded." -? {(Result != NULL) -> (! Result.is_expanded_type)};
]
( + result:V;
-
- deferred;
+
+ deferred;
result
)
[ ...
- +? {(has k) ->> {Result = at k}};
+ +? {(has k) ->> {Result = at k}};
];
- fast_has k:K :BOOLEAN <-
@@ -108,8 +108,8 @@ Section Public
// Using basic `=' for comparison.
//
// See also `has', `at', `fast_at'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
]
(
deferred;
@@ -121,10 +121,10 @@ Section Public
//
// See also `at', `reference_at', `fast_reference_at'.
[ ...
- -? {fast_has k};
+ -? {fast_has k};
]
( + result:V;
-
+
deferred;
result
);
@@ -133,55 +133,55 @@ Section Public
// Same work as `reference_at', but basic `=' is used for comparison.
//
// See also `reference_at', `at', `has'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
// BSBS: Il faut que tu init Result, sinon ca ne marche pas !!!
- //"Values are expanded." -? {(Result != NULL) ->> {! Result.is_expanded_type}};
+ //"Values are expanded." -? {(Result != NULL) ->> {! Result.is_expanded_type}};
]
- ( + result:V;
-
+ ( + result:V;
+
deferred;
result
)
[ ...
- +? {fast_has k ->> {Result = fast_at k}};
+ +? {fast_has k ->> {Result = fast_at k}};
];
-
+
//
// Modification.
//
-
+
- put v:V to k:K <-
- // 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
+ // 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'.
- // As the `put' procedure actually uses `is_equal', you may consider
+ // As the `put' procedure actually uses `is_equal', you may consider
// to use `fast_put' for expanded objects as well while trying to get
// the very best performances.
//
// See also `fast_put', `add'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
]
(
deferred;
)
[ ...
- +? {v = at k};
+ +? {v = at k};
];
- fast_put v:V to k:K <-
// Same job as `put', but uses basic `=' for comparison.
//
// See also `put', `add'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
]
(
deferred
)
[ ...
- +? {v = fast_at k};
+ +? {v = fast_at k};
];
- add v:V to k:K <-
@@ -189,8 +189,8 @@ Section Public
// Actually, this is equivalent to call `put', but it may run a little bit faster.
//
// See also `put', `fast_put'.
- [ ...
- -? {! has k};
+ [ ...
+ -? {! has k};
]
(
deferred
@@ -199,18 +199,18 @@ Section Public
+? {count = 1 + Old count};
+? {v = at k};
];
-
+
//
// Looking and searching some value:
//
-
+
- occurrences v:V :INTEGER <-
// Number of occurrences using `is_equal' for comparison.
//
// See also `fast_occurrences', `fast_has', `has'.
- ( + i,result:INTEGER;
+ ( + i,result:INTEGER;
+ safe_equal:SAFE_EQUAL(V);
-
+
i := 1;
{i > count}.until_do {
(safe_equal.test v with (item i)).if {
@@ -221,15 +221,15 @@ Section Public
result
)
[ ...
- +? {Result >= 0};
+ +? {Result >= 0};
];
-
+
- fast_occurrences v:V :INTEGER <-
// Number of occurrences using basic `=' for comparison.
//
// See also `occurrences', `fast_has', `has'.
( + result,i:INTEGER;
-
+
i := 1;
{i > count}.until_do {
(v = item i).if {
@@ -240,19 +240,19 @@ Section Public
result
)
[ ...
- +? {Result >= 0};
+ +? {Result >= 0};
];
-
+
- key_at v:V :K <-
// Retrieve the key used for value `v' using `is_equal' for comparison.
//
// See also `fast_key_at', `at'.
- [ ...
+ [ ...
-? {occurrences v = 1};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ safe_equal:SAFE_EQUAL(V);
-
+
i := 1;
{safe_equal.test v with (item i)}.until_do {
i := i + 1;
@@ -271,7 +271,7 @@ Section Public
-? {fast_occurrences v = 1};
]
( + i:INTEGER;
-
+
i := 1;
{v = item i}.until_do {
i := i + 1;
@@ -280,45 +280,45 @@ Section Public
)
[ ...
+? {at Result = v};
- ];
-
+ ];
+
//
// Removing:
//
-
+
- remove k:K <-
// Remove entry `k' (which may exist or not before this call).
- // As the `remove' procedure actually uses `is_equal', you may
- // consider to use `fast_remove' for expanded objects as well
+ // As the `remove' procedure actually uses `is_equal', you may
+ // consider to use `fast_remove' for expanded objects as well
// while trying to get the very best performances.
//
// See also `fast_remove', `clear_count'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
]
(
deferred
)
[ ...
- +? {! has k};
+ +? {! has k};
];
-
+
- fast_remove k:K <-
// Same job as `remove', but uses basic `=' for comparison.
//
// See also `remove', `clear_count'.
- [ ...
- -? {k != NULL};
+ [ ...
+ -? {k != NULL};
]
(
deferred
)
[ ...
- -? {! has k};
+ -? {! has k};
];
- clear_count <-
- // Discard all items (`is_empty' is True after that call).
+ // Discard all items (`is_empty' is True after that call).
// The internal `capacity' is not changed by this call.
//
// See also `clear_count_and_capacity', `remove'.
@@ -331,7 +331,7 @@ Section Public
];
- clear_count_and_capacity <-
- // Discard all items (`is_empty' is True after that call).
+ // Discard all items (`is_empty' is True after that call).
// The internal `capacity' may also be reduced after this call.
//
// See also `clear_count', `remove'.
@@ -341,24 +341,24 @@ Section Public
[ ...
"Is empty." +? {count = 0};
+? {capacity <= Old capacity};
- ];
+ ];
- capacity:INTEGER <-
- // Approximation of the actual internal storage `capacity'.
- // The `capacity' will grow automatically when needed
- // (i.e. `capacity' is not a limit for the number of values stored).
- // Also note that the `capacity' value may not be always accurate
- // depending of the implementation (anyway, this `capacity' value
+ // Approximation of the actual internal storage `capacity'.
+ // The `capacity' will grow automatically when needed
+ // (i.e. `capacity' is not a limit for the number of values stored).
+ // Also note that the `capacity' value may not be always accurate
+ // depending of the implementation (anyway, this `capacity' value
// is at least equals to `count').
(
deferred;
0
);
-
+
//
// To provide iterating facilities:
//
-
+
- lower:INTEGER := 1;
- upper:INTEGER <-
@@ -371,7 +371,7 @@ Section Public
- item i:INTEGER :V <-
( + result:V;
-
+
deferred;
result
)
@@ -380,7 +380,7 @@ Section Public
];
- first:V <- item lower;
-
+
- last:V <- item upper;
- key index:INTEGER :K <-
@@ -388,14 +388,14 @@ Section Public
-? {valid_index index};
]
( + result:K;
-
+
deferred;
result
)
[ ...
+? {(fast_at Result) = item index};
];
-
+
- key_map_in buffer:COLLECTION(K) <-
// Append in `buffer', all available keys (this may be useful to
// speed up the traversal).
@@ -405,7 +405,7 @@ Section Public
-? {buffer != NULL};
]
( + i:INTEGER;
-
+
i := count;
{i < lower}.until_do {
buffer.add_last (key i);
@@ -425,7 +425,7 @@ Section Public
-? {buffer != NULL};
]
( + i:INTEGER;
-
+
i := count;
{i < lower}.until_do {
buffer.add_last (item i);
@@ -435,11 +435,11 @@ Section Public
[
+? {buffer.count = count + Old buffer.count};
];
-
+
//
// Comparaison.
//
-
+
- Self:SELF '==' other:SELF :BOOLEAN <-
// Do both dictionaries have the same set of associations?
// Keys are compared with `is_equal' and values are comnpared
@@ -448,7 +448,7 @@ Section Public
// See also `is_equal_map'.
( + i:INTEGER;
+ result:BOOLEAN;
-
+
(Self = other).if {
result := TRUE;
}.elseif {count = other.count} then {
@@ -477,14 +477,14 @@ Section Public
// Both keys and values are compared with `is_equal'.
//
// See also `is_equal'.
- ( + i:INTEGER;
- + k:K;
+ ( + i:INTEGER;
+ + k:K;
+ safe_equal:SAFE_EQUAL(V);
+ result:BOOLEAN;
-
+
(Self = other).if {
result := TRUE;
- }.elseif {count = other.count} then {
+ }.elseif {count = other.count} then {
result := TRUE;
i := 1;
{(! result) || {i > count}}.until_do {
@@ -497,7 +497,7 @@ Section Public
};
} else {
result := FALSE;
- };
+ };
};
};
result
@@ -506,7 +506,7 @@ Section Public
- copy other:SELF <-
// Reinitialize by copying all associations of `other'.
( + i:INTEGER;
-
+
clear_count;
i := 1;
{i > other.count}.until_do {
@@ -518,15 +518,15 @@ Section Public
//
// Agents based features:
//
-
+
- do_all action:BLOCK <-
// Apply `action' to every (V, K) associations of `Current'.
//
// See also `for_all', `exist'.
- ( + i:INTEGER;
- + v:V;
+ ( + i:INTEGER;
+ + v:V;
+ k:K;
-
+
i := lower;
{i > upper}.until_do {
v := item i;
@@ -534,7 +534,7 @@ Section Public
action.value (v, k);
i := i + 1;
};
- );
+ );
- foreach_pair action:{(K,V);} <-
(
@@ -553,8 +553,8 @@ Section Public
- foreach_key action:{K; } until test:{K; BOOLEAN} <-
( + i:INTEGER;
+ k:K;
- i := lower;
- {(i > upper) || {test.value (k := key i)}}.until_do {
+ i := lower;
+ {(i > upper) || {test.value (k := key i)}}.until_do {
action.value k;
i := i + 1;
};
@@ -563,13 +563,13 @@ Section Public
- foreach_key action:{K; } while test:{K; BOOLEAN} <-
( + i:INTEGER;
+ k:K;
- i := lower;
- {(i <= upper) && {test.value (k := key i)}}.while_do {
+ i := lower;
+ {(i <= upper) && {test.value (k := key i)}}.while_do {
action.value k;
i := i + 1;
};
);
-
+
- foreach_value action:{V; } <-
(
lower.to upper do { i:INTEGER;
@@ -580,8 +580,8 @@ Section Public
- foreach_value action:{V; } until test:{V; BOOLEAN} <-
( + i:INTEGER;
+ v:V;
- i := lower;
- {(i > upper) || {test.value (v := item i)}}.until_do {
+ i := lower;
+ {(i > upper) || {test.value (v := item i)}}.until_do {
action.value v;
i := i + 1;
};
@@ -590,8 +590,8 @@ Section Public
- foreach_value action:{V; } while test:{V; BOOLEAN} <-
( + i:INTEGER;
+ v:V;
- i := lower;
- {(i <= upper) && {test.value (v := item i)}}.while_do {
+ i := lower;
+ {(i <= upper) && {test.value (v := item i)}}.while_do {
action.value v;
i := i + 1;
};
@@ -601,14 +601,14 @@ Section Public
// Do all (V, K) associations satisfy `test'?
//
// See also `do_all', `exist'.
- ( + i:INTEGER;
- + v:V;
+ ( + i:INTEGER;
+ + v:V;
+ k:K;
+ result:BOOLEAN;
-
+
result := TRUE;
i := lower;
- {(! result) || {i > upper}}.until_do {
+ {(! result) || {i > upper}}.until_do {
v := item i;
k := key i;
result := test.value (v, k);
@@ -621,25 +621,25 @@ Section Public
// Does at least one (V, K) association satisfy `test'?
//
// See also `for_all', `do_all'.
- ( + i:INTEGER;
- + v:V;
+ ( + i:INTEGER;
+ + v:V;
+ k:K;
+ result:BOOLEAN;
-
- i := lower;
+
+ i := lower;
{result || {i > upper}}.until_do {
v := item i;
k := key i;
- result := test.value (v, k);
+ result := test.value (v, k);
i := i + 1;
};
result
);
-
+
//
// Other features:
//
-
+
- internal_key k:K :K <-
// Retrieve the internal key object which correspond to the existing
// entry `k' (the one memorized into the `Current' dictionary).
@@ -649,7 +649,7 @@ Section Public
-? {has k};
]
( + result:K;
-
+
deferred;
result
)
@@ -660,15 +660,15 @@ Section Public
//
// Creation.
//
-
+
- create:SELF <-
( + result:SELF;
-
+
result := clone;
result.make;
result
);
-
+
- make <-
// Creates an empty dictionary.
(
@@ -681,7 +681,7 @@ Section Public
//
//
//
-
+
- key_safe_equal k1:K with k2:K :BOOLEAN <-
// Because keys are never NULL, we do not rely on the SAFE_EQUAL class.
[ ...
@@ -689,7 +689,7 @@ Section Public
-? {k2 != NULL};
]
( + result:BOOLEAN;
-
+
(k1 = k2).if {
result := TRUE;
}.elseif {k1.same_dynamic_type k2} then {
@@ -701,5 +701,5 @@ Section Public
//
// invariant
//
-
+
// [ -? {capacity >= count}; ]
diff --git a/lib/internal/portable/collection/hashed_dictionary_node.li b/lib/internal/portable/collection/hashed_dictionary_node.li
index 2ff137a..340baf9 100644
--- a/lib/internal/portable/collection/hashed_dictionary_node.li
+++ b/lib/internal/portable/collection/hashed_dictionary_node.li
@@ -19,27 +19,27 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := HASHED_DICTIONARY_NODE(V,K);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Auxilliary class to implement DICTIONARY(V,K).";
-
+
Section Inherit
-
+
- parent_any_hashed_dictionary_node:ANY_HASHED_DICTIONARY_NODE := ANY_HASHED_DICTIONARY_NODE;
-
+
Section Public
-
+
+ item:V;
-
+
+ key:K;
-
+
+ next:HASHED_DICTIONARY_NODE(V,K);
// The `next' one when some clash occurs.
-
+
- set_item i:V <-
(
item := i;
@@ -47,23 +47,23 @@ Section Public
[
+? {item = i};
];
-
+
- set_next n:HASHED_DICTIONARY_NODE(V,K) <-
(
next := n;
)
[
+? {next = n};
- ];
-
+ ];
+
- create i:V to k:K next n:HASHED_DICTIONARY_NODE(V,K) :SELF<-
( + result:SELF;
-
+
result := clone;
result.make i to k next n;
result
);
-
+
- make i:V to k:K next n:HASHED_DICTIONARY_NODE(V,K) <-
(
item := i;
diff --git a/lib/internal/portable/collection/hashed_set_node.li b/lib/internal/portable/collection/hashed_set_node.li
index d1bb53f..8c2e441 100644
--- a/lib/internal/portable/collection/hashed_set_node.li
+++ b/lib/internal/portable/collection/hashed_set_node.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := HASHED_SET_NODE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Auxilliary class to implement SET(V).";
-
+
Section Inherit
-
+
- parent_any_hashed_set_node:ANY_HASHED_SET_NODE := ANY_HASHED_SET_NODE;
-
+
Section Public
-
+
+ item:V;
-
+
+ next:HASHED_SET_NODE(V);
// The `next' one when some clash occurs.
-
+
- set_next n:HASHED_SET_NODE(V) <-
(
next := n;
@@ -45,17 +45,17 @@ Section Public
[
+? {next = n};
];
-
+
Section HASHED_SET
-
+
- create i:V next n:HASHED_SET_NODE(V) :SELF <-
( + result:SELF;
-
+
result := clone;
result.make i next n;
result
);
-
+
- make i:V next n:HASHED_SET_NODE(V) <-
(
item := i;
@@ -65,5 +65,5 @@ Section HASHED_SET
+? {item = i};
+? {next = n};
];
-
-
+
+
diff --git a/lib/internal/portable/collection/linked2_list_node.li b/lib/internal/portable/collection/linked2_list_node.li
index f039854..6190a20 100644
--- a/lib/internal/portable/collection/linked2_list_node.li
+++ b/lib/internal/portable/collection/linked2_list_node.li
@@ -19,36 +19,36 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED2_LIST_NODE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment := "To implement LINKED2_LIST(V).";
-
+
Section Inherit
-
+
- parent_any_two_way_linked_list_node:ANY_TWO_WAY_LINKED_LIST_NODE := ANY_TWO_WAY_LINKED_LIST_NODE;
-
+
Section Public
-
+
+ item:V;
-
+
+ previous:LINKED2_LIST_NODE(V);
-
+
+ next:LINKED2_LIST_NODE(V);
Section LINKED2_LIST
-
+
- create i:V previous p:SELF next n:SELF :SELF<-
( + result:SELF;
-
+
result := clone;
result.make i previous p next n;
result
);
-
+
- make i:V previous p:SELF next n:SELF <-
(
item := i;
@@ -62,7 +62,7 @@ Section LINKED2_LIST
];
Section LINKED2_LIST,LINKED2_LIST_NODE
-
+
- set_item i:V <-
(
item := i;
@@ -70,7 +70,7 @@ Section LINKED2_LIST,LINKED2_LIST_NODE
[
+? {item = i};
];
-
+
- set_next n:SELF <-
(
next := n;
@@ -78,17 +78,17 @@ Section LINKED2_LIST,LINKED2_LIST_NODE
[
+? {next = n};
];
-
+
- set_all_with v:V <-
( + lnk:SELF;
-
- lnk := Self;
+
+ lnk := Self;
{lnk = NULL}.until_do {
lnk.set_item v;
lnk := lnk.next;
};
);
-
+
- set_previous p:SELF <-
(
previous := p;
diff --git a/lib/internal/portable/collection/linked_collection.li b/lib/internal/portable/collection/linked_collection.li
index f737bc1..e312262 100644
--- a/lib/internal/portable/collection/linked_collection.li
+++ b/lib/internal/portable/collection/linked_collection.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED_COLLECTION(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Common root of LINKED_LIST and TWO_WAY_LINKED_LIST..";
-
+
Section Inherit
-
+
- parent_collection:COLLECTION(V) := COLLECTION(V);
-
+
Section Public
-
+
- lower:INTEGER := 1;
// Lower index bound is frozen.
+ upper:INTEGER;
// Memorized upper index bound.
-
+
- create:SELF <-
( + result:SELF;
-
+
result := clone;
result.make;
result
);
-
+
- make <-
// Make an empty list
(
@@ -55,7 +55,7 @@ Section Public
- remove_head n:INTEGER <-
( + i:INTEGER;
-
+
i := n;
{i = 0}.until_do {
remove_first;
@@ -65,9 +65,9 @@ Section Public
- remove_tail n:INTEGER <-
( + i:INTEGER;
-
- i := n;
- {i = 0}.until_do {
+
+ i := n;
+ {i = 0}.until_do {
remove_last;
i := i - 1;
};
@@ -77,16 +77,16 @@ Section Public
(
index_of element start lower
);
-
+
- fast_first_index_of element:V :INTEGER <-
(
fast_index_of element start lower
);
-
+
//
// Implement manifest generic creation.
//
-
+
- manifest_make needed_capacity:INTEGER <-
// Manifest creation of a list of items of type E.
(
diff --git a/lib/internal/portable/collection/linked_list_node.li b/lib/internal/portable/collection/linked_list_node.li
index 2a8da56..eae68af 100644
--- a/lib/internal/portable/collection/linked_list_node.li
+++ b/lib/internal/portable/collection/linked_list_node.li
@@ -19,36 +19,36 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED_LIST_NODE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "To implement LINKED_LIST(V). .";
-
+
Section Inherit
-
+
- parent_any_linked_list_node:ANY_LINKED_LIST_NODE := ANY_LINKED_LIST_NODE;
-
+
Section Public
-
+
+ item:V;
-
+
+ next:LINKED_LIST_NODE(V);
-
+
Section LINKED_LIST
-
+
- create i:V next n:LINKED_LIST_NODE(V) :SELF <-
( + result:SELF;
-
+
result := clone;
result.make i next n;
result
);
-
+
- make i:V next n:LINKED_LIST_NODE(V) <-
- (
+ (
item := i;
next := n;
)
@@ -56,10 +56,10 @@ Section LINKED_LIST
+? {item = i};
+? {next = n};
];
-
-
+
+
Section LINKED_LIST_NODE,LINKED_LIST
-
+
- set_item i:V <-
(
item := i;
@@ -67,7 +67,7 @@ Section LINKED_LIST_NODE,LINKED_LIST
[
+? {item = i};
];
-
+
- set_next n:LINKED_LIST_NODE(V) <-
(
next := n;
@@ -75,10 +75,10 @@ Section LINKED_LIST_NODE,LINKED_LIST
[
+? {next = n};
];
-
+
- set_all_with v:V <-
( + lnk:SELF;
-
+
lnk := Self;
{lnk = NULL}.until_do {
lnk.set_item v;
diff --git a/lib/internal/portable/collection/linked_xor_node.li b/lib/internal/portable/collection/linked_xor_node.li
index a204155..42f1857 100644
--- a/lib/internal/portable/collection/linked_xor_node.li
+++ b/lib/internal/portable/collection/linked_xor_node.li
@@ -19,37 +19,37 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED_XOR_NODE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment := "To implement LINKED_XOR_LIST(V).";
-
+
Section Inherit
-
+
- parent_any_two_way_linked_list_node:ANY_TWO_WAY_LINKED_LIST_NODE := ANY_TWO_WAY_LINKED_LIST_NODE;
-
+
Section Public
-
+
+ item:V;
-
+
+ link:POINTER;
Section LINKED_XOR_LIST
-
+
- create i:V previous p:SELF next n:SELF :SELF<-
( + result:SELF;
-
+
result := clone;
result.make i previous p next n;
result
);
-
+
- make i:V previous p:SELF next n:SELF <-
(
- item := i;
+ item := i;
link := p.to_pointer ^ n.to_pointer; // BSBS: il faut admettre NULL.to_pointer (perf!)
)
[
@@ -57,7 +57,7 @@ Section LINKED_XOR_LIST
];
Section LINKED_XOR_LIST,LINKED_XOR_NODE
-
+
- set_item i:V <-
(
item := i;
@@ -65,20 +65,19 @@ Section LINKED_XOR_LIST,LINKED_XOR_NODE
[
+? {item = i};
];
-
+
- next prev:LINKED_XOR_NODE :LINKED_XOR_NODE <-
- (
+ (
CONVERT(POINTER,LINKED_XOR_NODE).on (link ^ prev.to_pointer)
);
-
+
- previous nex:LINKED_XOR_NODE :LINKED_XOR_NODE <-
(
CONVERT(POINTER,LINKED_XOR_NODE).on (link ^ nex.to_pointer)
);
-
+
- set_link p:SELF and n:SELF <-
(
link := p.to_pointer ^ n.to_pointer;
);
-
-
\ No newline at end of file
+
diff --git a/lib/internal/portable/collection/native_array.li b/lib/internal/portable/collection/native_array.li
index 13c9946..6989b1c 100644
--- a/lib/internal/portable/collection/native_array.li
+++ b/lib/internal/portable/collection/native_array.li
@@ -19,31 +19,31 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Strict NATIVE_ARRAY(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Native array of collection library.";
-
+
// This class gives access to the lowest level for arrays. As any low level array, you can
// get high performances with NATIVE_ARRAYs, but you loose most valid bounds checks (as
// you can do in plain C code for example).
-
+
Section Inherit
-
+
- parent_safe_equal:SAFE_EQUAL(V) := SAFE_EQUAL(V);
-
-Section Public
-
+
+Section Public
+
//
// Basic features:
//
-
+
- object_size:INTEGER := 0; // For detect error.
-
- - element_sizeof:INTEGER <-
+
+ - element_sizeof:INTEGER <-
// The size in number of bytes for type `E'.
( + result:INTEGER;
(V.is_expanded_type).if {
@@ -53,7 +53,7 @@ Section Public
};
result
);
-
+
- calloc_intern nb_elements:INTEGER :NATIVE_ARRAY(V) <-
// Allocate a new array of 'nb_elements' of type `E'.
// The new array is initialized with default values.
@@ -63,9 +63,9 @@ Section Public
( + capacity:INTEGER;
+ p:POINTER;
+ result :NATIVE_ARRAY(V);
-
- capacity := nb_elements * element_sizeof;
- //p := `malloc(@capacity)`:POINTER;
+
+ capacity := nb_elements * element_sizeof;
+ //p := `malloc(@capacity)`:POINTER;
p := MEMORY.alloc_dynamic capacity;
result := CONVERT(POINTER,NATIVE_ARRAY(V)).on p;
result
@@ -73,7 +73,7 @@ Section Public
[ ...
+? {Result != NULL};
];
-
+
- create nb_elements:INTEGER :NATIVE_ARRAY(V) <-
// Allocate a new array of `nb_elements' of type `E'.
// The new array is initialized with default values.
@@ -81,15 +81,15 @@ Section Public
-? {nb_elements > 0};
]
( + result:NATIVE_ARRAY(V);
-
+
result:=calloc_intern nb_elements;
- result.clear_all (nb_elements-1);
+ result.clear_all (nb_elements-1);
result
)
[ ...
// +? {Result.all_default (nb_elements-1)};
];
-
+
- realloc old_nb_elts:INTEGER with new_nb_elts:INTEGER :NATIVE_ARRAY(V) <-
// Assume Current is a valid NATIVE_ARRAY in range
// [0 .. `old_nb_elts'-1]. Allocate a bigger new array in
@@ -104,11 +104,11 @@ Section Public
( + new:NATIVE_ARRAY(V);
+ old_ptr,new_ptr:POINTER;
+ new_cap:INTEGER;
-
- old_ptr := CONVERT(NATIVE_ARRAY(V),POINTER).on Self;
+
+ old_ptr := CONVERT(NATIVE_ARRAY(V),POINTER).on Self;
new_cap := new_nb_elts * element_sizeof;
//new_ptr := `realloc(@old_ptr, at new_cap)`:POINTER;
- new_ptr := MEMORY.realloc_dynamic old_ptr
+ new_ptr := MEMORY.realloc_dynamic old_ptr
old_size (old_nb_elts * element_sizeof) new_size new_cap;
new := CONVERT(POINTER,NATIVE_ARRAY(V)).on new_ptr;
new.clear old_nb_elts to (new_nb_elts - 1);
@@ -117,20 +117,20 @@ Section Public
[ ...
+? {Result != NULL};
];
-
+
- first:V <- item 0;
-
+
- item index:INTEGER :V <-
// To read an `item'.
- // Assume that `calloc' is already done and that `index' is
+ // Assume that `calloc' is already done and that `index' is
// the range [0 .. `nb_elements'-1].
[ ...
-? {index >= 0};
]
- (
- `10`
+ (
+ `10`
);
-
+
- put element:V to index:INTEGER <-
// To write an item.
// Assume that `calloc' is already done and that `index'
@@ -138,30 +138,30 @@ Section Public
[ ...
-? {index >= 0};
]
- (
- force_put element to index;
+ (
+ force_put element to index;
)
[ ...
-// +? {element = item index};
+// +? {element = item index};
];
-
+
//
// Displacement
//
-
- - Self:SELF '+' Left 80 other:INTEGER :NATIVE_ARRAY(V) <-
+
+ - Self:SELF '+' Left 80 other:INTEGER :NATIVE_ARRAY(V) <-
// other is in element index
( + ptr:POINTER;
-
+
ptr := to_pointer;
ptr := ptr + other * element_sizeof;
CONVERT(POINTER, NATIVE_ARRAY(V)).on ptr
);
-
+
//
// Comparison:
//
-
+
- memcmp other:NATIVE_ARRAY(V) until capacity:INTEGER :BOOLEAN <-
// True if all elements in range [0..capacity-1] are
// identical using `equal'. Assume Current and `other'
@@ -171,14 +171,14 @@ Section Public
-? {(capacity > 0) ->> {other.is_not_null}};
]
( + i:INTEGER;
-
+
i := capacity - 1;
{(i >= 0) && {safe_equal (item i,other.item i)}}.while_do {
i := i - 1;
};
i < 0
);
-
+
- slice_memcmp (at:INTEGER,other:NATIVE_ARRAY(V),other_lower,other_upper:INTEGER) :BOOLEAN <-
// True if all elements in range [0 .. `other_upper' - `other_lower'] are identical
// to the elements in range [`other_lower' .. `other_upper'] of `other' using
@@ -191,28 +191,28 @@ Section Public
-? {(other_upper >= other_lower) ->> {other.is_not_null}};
]
( + i:INTEGER;
-
+
i := other_upper - other_lower;
{(i >= 0) && {safe_equal (item (at + i),other.item (other_lower + i))}}.while_do {
i := i - 1;
};
i < 0
);
-
+
- fast_memcmp other:NATIVE_ARRAY(V) until capacity:INTEGER :BOOLEAN <-
// Same jobs as `memcmp' but uses infix `=' instead `equal'.
[ ...
-? {(capacity > 0) ->> {other.is_not_null}};
]
( + i:INTEGER;
-
+
i := capacity-1;
{(i >=0 ) && {item i = other.item i}}.while_do {
i := i - 1;
};
i < 0
);
-
+
- slice_fast_memcmp (at:INTEGER, other:NATIVE_ARRAY(V), other_lower,other_upper:INTEGER) :BOOLEAN <-
// Same jobs as `slice_memcmp' but uses infix "=" instead of `is_equal'.
[ ...
@@ -221,15 +221,15 @@ Section Public
-? {other_upper >= other_lower - 1};
-? {(other_upper >= other_lower) ->> {other.is_not_null}};
]
- ( + i:INTEGER;
-
+ ( + i:INTEGER;
+
i := other_upper - other_lower;
{(i < 0) || {item (at + i) != other.item (other_lower + i)}}.until_do {
i := i - 1;
};
i < 0
);
-
+
- deep_memcmp other:NATIVE_ARRAY(V) until capacity:INTEGER :BOOLEAN <-
// Same jobs as `memcmp' but uses `is_deep_equal' instead `equal'.
[ ...
@@ -238,7 +238,7 @@ Section Public
( + result:BOOLEAN; // BEN : A REVOIR, il y a + efficace...
+ e1,e2:V;
+ i:INTEGER;
-
+
result := TRUE;
i := capacity - 1;
{(result = FALSE) || {i < 0}}.until_do {
@@ -257,7 +257,7 @@ Section Public
};
result
);
-
+
- slice_deep_memcmp (at:INTEGER,other:NATIVE_ARRAY(V),other_lower,other_upper:INTEGER) :BOOLEAN <-
// Same jobs as `slice_memcmp' but uses `is_deep_equal' instead of `is_equal'.
[ ...
@@ -266,10 +266,10 @@ Section Public
-? {other_upper >= other_lower - 1};
-? {(other_upper >= other_lower) ->> {other.is_not_null}};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ e1,e2:V;
+ result:BOOLEAN;
-
+
i := other_upper - other_lower;
result := TRUE;
{(! result) || {i < 0}}.until_do {
@@ -289,11 +289,11 @@ Section Public
};
result
);
-
+
//
// Searching:
//
-
+
- first_index_of element:V until upper:INTEGER :INTEGER <-
// Give the index of the first occurrence of `element' using
// `==' for comparison.
@@ -303,15 +303,15 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
{(idx > upper) || {safe_equal (element,item idx)}}.until_do {
idx := idx + 1;
};
idx
);
-
+
- index_of (element:V,start_index:INTEGER) until upper:INTEGER :INTEGER <-
- // Using `is_equal' for comparison, gives the index of the first occurrence of `element'
+ // Using `is_equal' for comparison, gives the index of the first occurrence of `element'
// at or after `start_index'. Answer `upper + 1' when the search fail.
// See also `fast_index_of', `reverse_index_of'.
[ ...
@@ -319,7 +319,7 @@ Section Public
-? {start_index <= upper};
]
( + result:INTEGER;
-
+
result := start_index;
{(result > upper) || {safe_equal (element,item result)}}.until_do {
result := result + 1;
@@ -330,7 +330,7 @@ Section Public
+? {Result.in_range start_index to (upper + 1)};
+? {(Result <= upper) ->> {safe_equal (element,item Result)}};
];
-
+
- reverse_index_of element:V from upper:INTEGER :INTEGER <-
// Give the index of the first occurrence of `element' using
// `==' for comparison, from upper to lower.
@@ -339,7 +339,7 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
idx := upper;
{(idx < 0) || {safe_equal (element,item idx)}}.until_do {
idx := idx - 1;
@@ -350,9 +350,9 @@ Section Public
+? {Result.in_range (-1) to upper};
+? {(Result > 0) ->> {safe_equal (element, item Result)}};
];
-
+
- fast_index_of (element:V,start_index:INTEGER) until upper:INTEGER :INTEGER <-
- // Using basic `=' for comparison, gives the index of the first occurrence of
+ // Using basic `=' for comparison, gives the index of the first occurrence of
// `element' at or after `start_index'. Answer `upper + 1' when the search fail.
// See also `index_of', `reverse_index_of'.
[ ...
@@ -360,9 +360,9 @@ Section Public
-? {start_index <= upper};
]
( + result:INTEGER;
-
+
result := start_index;
- {(result > upper) || {element = item result}}.until_do {
+ {(result > upper) || {element = item result}}.until_do {
result := result + 1;
};
result
@@ -371,7 +371,7 @@ Section Public
+? {Result.in_range start_index to (upper + 1)};
+? {(Result <= upper) ->> {element = item Result}};
];
-
+
- fast_reverse_index_of element:V from upper:INTEGER :INTEGER <-
// Same as `reverse_index_of' but use basic `=' for comparison.
// Search is done in reverse direction, which means from `upper' down to the
@@ -381,7 +381,7 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
idx := upper;
{(idx < 0) || {element = item idx}}.until_do {
idx := idx - 1;
@@ -401,7 +401,7 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
{(idx > upper) || {element = item idx}}.until_do {
idx := idx + 1;
};
@@ -410,8 +410,8 @@ Section Public
[ ...
+? {Result.in_range 0 to (upper + 1)};
+? {(Result <= upper) ->> {element = item Result}};
- ];
-
+ ];
+
- has element:V until upper:INTEGER :BOOLEAN <-
// Look for `element' using `==' for comparison.
// Also consider `has' to choose the most appropriate.
@@ -419,8 +419,8 @@ Section Public
-? {upper >= -1};
]
( + result:BOOLEAN;
- + i:INTEGER;
-
+ + i:INTEGER;
+
i := upper;
{(result) || {i < 0}}.until_do {
result := safe_equal (element,item i);
@@ -428,7 +428,7 @@ Section Public
};
result
);
-
+
- fast_has element:V until upper:INTEGER :BOOLEAN <-
// Look for `element' using basic `=' for comparison.
// Also consider `has' to choose the most appropriate.
@@ -436,18 +436,18 @@ Section Public
-? {upper >= -1};
]
( + i:INTEGER;
-
+
i := upper;
{(i < 0) || {element = item i}}.until_do {
i := i - 1;
};
i >= 0
);
-
+
//
// Removing:
//
-
+
- remove_first upper:INTEGER <-
// Assume `upper' is a valid index.
// Move range [1 .. `upper'] by 1 position left.
@@ -455,13 +455,13 @@ Section Public
-? {upper >= 0};
]
( + i:INTEGER;
-
+
{i = upper}.until_do {
put (item (i + 1)) to i;
i := i + 1;
};
);
-
+
- remove index:INTEGER until upper:INTEGER <-
// Assume `upper' is a valid index.
// Move range [`index' + 1 .. `upper'] by 1 position left.
@@ -470,18 +470,18 @@ Section Public
-? {index <= upper};
]
( + i:INTEGER;
-
+
i := index;
{i = upper}.until_do {
put (item (i + 1)) to i;
i := i + 1;
};
);
-
+
//
// Replacing:
//
-
+
- replace_all old_value:V with new_value:V until upper:INTEGER <-
// Replace all occurences of the element `old_value' by `new_value'
// using `==' for comparison.
@@ -489,14 +489,14 @@ Section Public
[ ...
-? {upper >= -1};
]
- (
+ (
upper.downto 0 do { i:INTEGER;
(safe_equal (old_value,(item i))).if {
put new_value to i;
};
};
);
-
+
- fast_replace_all old_value:V with new_value:V until upper:INTEGER <-
// Replace all occurences of the element `old_value' by `new_value'
// using basic `=' for comparison.
@@ -504,18 +504,18 @@ Section Public
[ ...
-? {upper >= -1};
]
- (
+ (
upper.downto 0 do { i:INTEGER;
(old_value = item i).if {
put new_value to i;
};
};
);
-
+
//
// Adding:
//
-
+
- copy src:NATIVE_ARRAY(V) to dest:INTEGER until src_capacity:INTEGER <-
// Copy range [0 .. `src_capacity - 1'] of `src' to range
// [`dest' .. `dest + src_capacity - 1'] of `Self'.
@@ -525,7 +525,7 @@ Section Public
-? {src_capacity >= 0};
]
( + i1, i2:INTEGER;
-
+
i1 := dest;
{i2 = src_capacity}.until_do {
put (src.item i2) to i1;
@@ -533,7 +533,7 @@ Section Public
i1 := i1 + 1;
};
);
-
+
- slice_copy src:NATIVE_ARRAY(V) to dest:INTEGER from src_min:INTEGER to src_max:INTEGER <-
// Copy range [`src_min' .. `src_max'] of `src' to range
// [`at' .. `at + src_max - src_min - 1'] of `Current'.
@@ -543,8 +543,8 @@ Section Public
-? {src_min <= src_max + 1};
-? {(src != Self) | (dest != src_min)};
]
- ( + i1, i2:INTEGER;
-
+ ( + i1, i2:INTEGER;
+
i1 := dest;
i2 := src_min;
{i2 > src_max}.until_do {
@@ -553,11 +553,11 @@ Section Public
i1 := i1 + 1;
};
);
-
+
//
// Other:
//
-
+
- set_all_with v:V until upper:INTEGER <-
// Set all elements in range [0 .. upper] with
// value `v'.
@@ -569,7 +569,7 @@ Section Public
put v to i;
};
);
-
+
- set_slice_with v:V from lower:INTEGER until upper:INTEGER <-
// Set all elements in range [`lower' .. `upper'] with value `v'.
[ ...
@@ -577,14 +577,14 @@ Section Public
-? {upper >= lower - 1};
]
( + i:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
put v to i;
i := i + 1;
};
);
-
+
- clear_all upper:INTEGER <-
// Set all elements in range [0 .. `upper'] with
// the default value.
@@ -592,12 +592,12 @@ Section Public
-? {upper >= -1};
]
( + v:V;
-
- upper.downto 0 do { i:INTEGER;
+
+ upper.downto 0 do { i:INTEGER;
put v to i;
};
);
-
+
- clear lower:INTEGER to upper:INTEGER <-
// Set all elements in range [`lower' .. `upper'] with
// the default value
@@ -606,12 +606,12 @@ Section Public
-? {upper >= lower};
]
( + v:V;
-
+
lower.to upper do { i:INTEGER;
put v to i;
};
);
-
+
- copy_from model:NATIVE_ARRAY(V) until upper:INTEGER <-
// Assume `upper' is a valid index both in Current and `model'.
[ ...
@@ -622,7 +622,7 @@ Section Public
put (model.item i) to i;
};
);
-
+
- deep_twin_from capacity:INTEGER :NATIVE_ARRAY(V) <-
// To implement `deep_twin'. Allocate a new array of
// `capacity' initialized with `deep_twin'.
@@ -632,7 +632,7 @@ Section Public
]
( + element:V;
+ result:NATIVE_ARRAY(V);
-
+
(capacity > 0).if {
result := calloc capacity;
(capacity - 1).downto 0 do { i:INTEGER;
@@ -644,7 +644,7 @@ Section Public
};
};
);
-
+
- move lower:INTEGER to upper:INTEGER by offset:INTEGER <-
// Move range [`lower' .. `upper'] by `offset' positions.
// Freed positions are not initialized to default values.
@@ -653,7 +653,7 @@ Section Public
-? {upper >= lower};
-? {lower + offset >= 0};
]
- (
+ (
(offset != 0).if {
(offset < 0).if {
lower.to upper do { i:INTEGER;
@@ -666,7 +666,7 @@ Section Public
};
};
);
-
+
- occurrences element:V until upper:INTEGER :INTEGER <-
// Number of occurrences of `element' in range [0..upper]
// using `equal' for comparison.
@@ -675,7 +675,7 @@ Section Public
-? {upper >= -1};
]
( + count:INTEGER;
-
+
upper.downto 0 do { i:INTEGER;
(safe_equal (element,item i)).if {
count := count + 1;
@@ -683,9 +683,9 @@ Section Public
};
count
);
-
+
- slice_occurrences element:V from lower:INTEGER until upper:INTEGER :INTEGER <-
- // Number of occurrences of `element' in range [`lower' .. `upper'] using
+ // Number of occurrences of `element' in range [`lower' .. `upper'] using
// `is_equal' for comparison.
// See also `slice_fast_occurrences' to chose the apropriate one.
[ ...
@@ -693,7 +693,7 @@ Section Public
-? {upper >= lower - 1};
]
( + i,result:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
(safe_equal (element,item i)).if {
@@ -712,7 +712,7 @@ Section Public
-? {upper >= -1};
]
( + count:INTEGER;
-
+
upper.downto 0 do { i:INTEGER;
(element = item i).if {
count := count + 1;
@@ -720,7 +720,7 @@ Section Public
};
count
);
-
+
- slice_fast_occurrences element:V from lower:INTEGER until upper:INTEGER :INTEGER <-
// Number of occurrences of `element' in range [`lower' .. `upper']
// using basic "=" for comparison.
@@ -730,7 +730,7 @@ Section Public
-? {upper >= lower - 1};
]
( + i,result:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
(element = item i).if {
@@ -740,7 +740,7 @@ Section Public
};
result
);
-
+
- all_default upper:INTEGER :BOOLEAN <-
// Do all items in range [0 .. `upper'] have their type's
// default value?
@@ -758,7 +758,7 @@ Section Public
};
result
);
-
+
- slice_default lower:INTEGER to upper:INTEGER :BOOLEAN <-
// Do all items in range [`lower' .. `upper'] have their type's default value?
// Note: for non Void items, the test is performed with the `is_default' predicate.
@@ -766,10 +766,10 @@ Section Public
-? {lower >= 0};
-? {upper >= lower - 1};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ v:V;
+ result:BOOLEAN;
-
+
result := TRUE;
i := lower;
{(i > upper) || {! result}}.until_do {
@@ -781,30 +781,30 @@ Section Public
};
result
);
-
+
//
// Interfacing with C:
//
-
+
- to_external:POINTER <- to_pointer;
// Gives access to the C pointer on the area of storage.
-
+
- is_null:BOOLEAN <- to_pointer.is_null;
-
+
- is_not_null:BOOLEAN <- to_pointer.is_not_null;
-
+
//
// Guru Section
//
-
+
- println <- `puts(@Self)`;
-
+
- force_put element:V to index:INTEGER <-
// Used in Memory count: not to use directly without caution !
[ ...
-? {index>=0};
]
- (
- `9`;
+ (
+ `9`;
);
diff --git a/lib/internal/portable/collection/native_array_volatile.li b/lib/internal/portable/collection/native_array_volatile.li
index ea662a6..e5589c7 100644
--- a/lib/internal/portable/collection/native_array_volatile.li
+++ b/lib/internal/portable/collection/native_array_volatile.li
@@ -19,31 +19,31 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Strict NATIVE_ARRAY_VOLATILE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Native array of collection library.";
-
+
// This class gives access to the lowest level for arrays. As any low level array, you can
// get high performances with NATIVE_ARRAYs, but you loose most valid bounds checks (as
// you can do in plain C code for example).
-
+
Section Inherit
-
+
- parent_safe_equal:SAFE_EQUAL(V) := SAFE_EQUAL(V);
-
-Section Public
-
+
+Section Public
+
//
// Basic features:
//
-
+
- object_size:INTEGER := 0; // For detect error.
-
- - element_sizeof:INTEGER <-
+
+ - element_sizeof:INTEGER <-
// The size in number of bytes for type `E'.
( + result:INTEGER;
(V.is_expanded_type).if {
@@ -53,7 +53,7 @@ Section Public
};
result
);
-
+
- calloc_intern nb_elements:INTEGER :NATIVE_ARRAY_VOLATILE(V) <-
// Allocate a new array of 'nb_elements' of type `E'.
// The new array is initialized with default values.
@@ -63,9 +63,9 @@ Section Public
( + capacity:INTEGER;
+ p:POINTER;
+ result :NATIVE_ARRAY_VOLATILE(V);
-
- capacity := nb_elements * element_sizeof;
- //p := `malloc(@capacity)`:POINTER;
+
+ capacity := nb_elements * element_sizeof;
+ //p := `malloc(@capacity)`:POINTER;
p := MEMORY.alloc_dynamic (capacity.to_uinteger_32);
result := CONVERT(POINTER,NATIVE_ARRAY_VOLATILE(V)).on p;
result
@@ -73,7 +73,7 @@ Section Public
[ ...
+? {Result != NULL};
];
-
+
- create nb_elements:INTEGER :NATIVE_ARRAY_VOLATILE(V) <-
// Allocate a new array of `nb_elements' of type `E'.
// The new array is initialized with default values.
@@ -81,15 +81,15 @@ Section Public
-? {nb_elements > 0};
]
( + result:NATIVE_ARRAY_VOLATILE(V);
-
+
result:=calloc_intern nb_elements;
- result.clear_all (nb_elements-1);
+ result.clear_all (nb_elements-1);
result
)
[ ...
+? {Result.all_default (nb_elements-1)};
];
-
+
- realloc old_nb_elts:INTEGER with new_nb_elts:INTEGER :NATIVE_ARRAY_VOLATILE(V) <-
// Assume Current is a valid NATIVE_ARRAY_VOLATILE in range
// [0 .. `old_nb_elts'-1]. Allocate a bigger new array in
@@ -104,12 +104,12 @@ Section Public
( + new:NATIVE_ARRAY_VOLATILE(V);
+ old_ptr,new_ptr:POINTER;
+ new_cap:INTEGER;
-
- old_ptr := CONVERT(NATIVE_ARRAY_VOLATILE(V),POINTER).on Self;
+
+ old_ptr := CONVERT(NATIVE_ARRAY_VOLATILE(V),POINTER).on Self;
new_cap := new_nb_elts * element_sizeof;
//new_ptr := `realloc(@old_ptr, at new_cap)`:POINTER;
- new_ptr := MEMORY.realloc_dynamic old_ptr
- old_size ((old_nb_elts * element_sizeof).to_uinteger_32)
+ new_ptr := MEMORY.realloc_dynamic old_ptr
+ old_size ((old_nb_elts * element_sizeof).to_uinteger_32)
new_size (new_cap.to_uinteger_32);
new := CONVERT(POINTER,NATIVE_ARRAY_VOLATILE(V)).on new_ptr;
new.clear old_nb_elts to (new_nb_elts - 1);
@@ -118,20 +118,20 @@ Section Public
[ ...
+? {Result != NULL};
];
-
+
- first:V <- item 0;
-
+
- item index:INTEGER :V <-
// To read an `item'.
- // Assume that `calloc' is already done and that `index' is
+ // Assume that `calloc' is already done and that `index' is
// the range [0 .. `nb_elements'-1].
[ ...
-? {index >= 0};
]
- (
- `10`
+ (
+ `10`
);
-
+
- put element:V to index:INTEGER <-
// To write an item.
// Assume that `calloc' is already done and that `index'
@@ -139,30 +139,30 @@ Section Public
[ ...
-? {index >= 0};
]
- (
- force_put element to index;
+ (
+ force_put element to index;
)
[ ...
- +? {element = item index};
+ +? {element = item index};
];
-
+
//
// Displacement
//
-
- - Self:SELF '+' Left 80 other:INTEGER :NATIVE_ARRAY_VOLATILE(V) <-
+
+ - Self:SELF '+' Left 80 other:INTEGER :NATIVE_ARRAY_VOLATILE(V) <-
// other is in element index
( + ptr:POINTER;
-
+
ptr := to_pointer;
ptr := ptr + other * element_sizeof;
CONVERT(POINTER, NATIVE_ARRAY_VOLATILE(V)).on ptr
);
-
+
//
// Comparison:
//
-
+
- memcmp other:NATIVE_ARRAY_VOLATILE(V) until capacity:INTEGER :BOOLEAN <-
// True if all elements in range [0..capacity-1] are
// identical using `equal'. Assume Current and `other'
@@ -172,14 +172,14 @@ Section Public
-? {(capacity > 0) ->> {other.is_not_null}};
]
( + i:INTEGER;
-
+
i := capacity - 1;
{(i >= 0) && {safe_equal (item i,other.item i)}}.while_do {
i := i - 1;
};
i < 0
);
-
+
- slice_memcmp (at:INTEGER,other:NATIVE_ARRAY_VOLATILE(V),other_lower,other_upper:INTEGER) :BOOLEAN <-
// True if all elements in range [0 .. `other_upper' - `other_lower'] are identical
// to the elements in range [`other_lower' .. `other_upper'] of `other' using
@@ -192,28 +192,28 @@ Section Public
-? {(other_upper >= other_lower) ->> {other.is_not_null}};
]
( + i:INTEGER;
-
+
i := other_upper - other_lower;
{(i >= 0) && {safe_equal (item (at + i),other.item (other_lower + i))}}.while_do {
i := i - 1;
};
i < 0
);
-
+
- fast_memcmp other:NATIVE_ARRAY_VOLATILE(V) until capacity:INTEGER :BOOLEAN <-
// Same jobs as `memcmp' but uses infix `=' instead `equal'.
[ ...
-? {(capacity > 0) ->> {other.is_not_null}};
]
( + i:INTEGER;
-
+
i := capacity-1;
{(i >=0 ) && {item i = other.item i}}.while_do {
i := i - 1;
};
i < 0
);
-
+
- slice_fast_memcmp (at:INTEGER, other:NATIVE_ARRAY_VOLATILE(V), other_lower,other_upper:INTEGER) :BOOLEAN <-
// Same jobs as `slice_memcmp' but uses infix "=" instead of `is_equal'.
[ ...
@@ -222,15 +222,15 @@ Section Public
-? {other_upper >= other_lower - 1};
-? {(other_upper >= other_lower) ->> {other.is_not_null}};
]
- ( + i:INTEGER;
-
+ ( + i:INTEGER;
+
i := other_upper - other_lower;
{(i < 0) || {item (at + i) != other.item (other_lower + i)}}.until_do {
i := i - 1;
};
i < 0
);
-
+
- deep_memcmp other:NATIVE_ARRAY_VOLATILE(V) until capacity:INTEGER :BOOLEAN <-
// Same jobs as `memcmp' but uses `is_deep_equal' instead `equal'.
[ ...
@@ -239,7 +239,7 @@ Section Public
( + result:BOOLEAN; // BEN : A REVOIR, il y a + efficace...
+ e1,e2:V;
+ i:INTEGER;
-
+
result := TRUE;
i := capacity - 1;
{(result = FALSE) || {i < 0}}.until_do {
@@ -258,7 +258,7 @@ Section Public
};
result
);
-
+
- slice_deep_memcmp (at:INTEGER,other:NATIVE_ARRAY_VOLATILE(V),other_lower,other_upper:INTEGER) :BOOLEAN <-
// Same jobs as `slice_memcmp' but uses `is_deep_equal' instead of `is_equal'.
[ ...
@@ -267,10 +267,10 @@ Section Public
-? {other_upper >= other_lower - 1};
-? {(other_upper >= other_lower) ->> {other.is_not_null}};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ e1,e2:V;
+ result:BOOLEAN;
-
+
i := other_upper - other_lower;
result := TRUE;
{(! result) || {i < 0}}.until_do {
@@ -290,11 +290,11 @@ Section Public
};
result
);
-
+
//
// Searching:
//
-
+
- first_index_of element:V until upper:INTEGER :INTEGER <-
// Give the index of the first occurrence of `element' using
// `==' for comparison.
@@ -304,15 +304,15 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
{(idx > upper) || {safe_equal (element,item idx)}}.until_do {
idx := idx + 1;
};
idx
);
-
+
- index_of (element:V,start_index:INTEGER) until upper:INTEGER :INTEGER <-
- // Using `is_equal' for comparison, gives the index of the first occurrence of `element'
+ // Using `is_equal' for comparison, gives the index of the first occurrence of `element'
// at or after `start_index'. Answer `upper + 1' when the search fail.
// See also `fast_index_of', `reverse_index_of'.
[ ...
@@ -320,7 +320,7 @@ Section Public
-? {start_index <= upper};
]
( + result:INTEGER;
-
+
result := start_index;
{(result > upper) || {safe_equal (element,item result)}}.until_do {
result := result + 1;
@@ -331,7 +331,7 @@ Section Public
+? {Result.in_range start_index to (upper + 1)};
+? {(Result <= upper) ->> {safe_equal (element,item Result)}};
];
-
+
- reverse_index_of element:V from upper:INTEGER :INTEGER <-
// Give the index of the first occurrence of `element' using
// `==' for comparison, from upper to lower.
@@ -340,7 +340,7 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
idx := upper;
{(idx < 0) || {safe_equal (element,item idx)}}.until_do {
idx := idx - 1;
@@ -351,9 +351,9 @@ Section Public
+? {Result.in_range (-1) to upper};
+? {(Result > 0) ->> {safe_equal (element, item Result)}};
];
-
+
- fast_index_of (element:V,start_index:INTEGER) until upper:INTEGER :INTEGER <-
- // Using basic `=' for comparison, gives the index of the first occurrence of
+ // Using basic `=' for comparison, gives the index of the first occurrence of
// `element' at or after `start_index'. Answer `upper + 1' when the search fail.
// See also `index_of', `reverse_index_of'.
[ ...
@@ -361,9 +361,9 @@ Section Public
-? {start_index <= upper};
]
( + result:INTEGER;
-
+
result := start_index;
- {(result > upper) || {element = item result}}.until_do {
+ {(result > upper) || {element = item result}}.until_do {
result := result + 1;
};
result
@@ -372,7 +372,7 @@ Section Public
+? {Result.in_range start_index to (upper + 1)};
+? {(Result <= upper) ->> {element = item Result}};
];
-
+
- fast_reverse_index_of element:V from upper:INTEGER :INTEGER <-
// Same as `reverse_index_of' but use basic `=' for comparison.
// Search is done in reverse direction, which means from `upper' down to the
@@ -382,7 +382,7 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
idx := upper;
{(idx < 0) || {element = item idx}}.until_do {
idx := idx - 1;
@@ -402,7 +402,7 @@ Section Public
-? {upper >= -1};
]
( + idx:INTEGER;
-
+
{(idx > upper) || {element = item idx}}.until_do {
idx := idx + 1;
};
@@ -411,8 +411,8 @@ Section Public
[ ...
+? {Result.in_range 0 to (upper + 1)};
+? {(Result <= upper) ->> {element = item Result}};
- ];
-
+ ];
+
- has element:V until upper:INTEGER :BOOLEAN <-
// Look for `element' using `==' for comparison.
// Also consider `has' to choose the most appropriate.
@@ -420,8 +420,8 @@ Section Public
-? {upper >= -1};
]
( + result:BOOLEAN;
- + i:INTEGER;
-
+ + i:INTEGER;
+
i := upper;
{(result) || {i < 0}}.until_do {
result := safe_equal (element,item i);
@@ -429,7 +429,7 @@ Section Public
};
result
);
-
+
- fast_has element:V until upper:INTEGER :BOOLEAN <-
// Look for `element' using basic `=' for comparison.
// Also consider `has' to choose the most appropriate.
@@ -437,18 +437,18 @@ Section Public
-? {upper >= -1};
]
( + i:INTEGER;
-
+
i := upper;
{(i < 0) || {element = item i}}.until_do {
i := i - 1;
};
i >= 0
);
-
+
//
// Removing:
//
-
+
- remove_first upper:INTEGER <-
// Assume `upper' is a valid index.
// Move range [1 .. `upper'] by 1 position left.
@@ -456,13 +456,13 @@ Section Public
-? {upper >= 0};
]
( + i:INTEGER;
-
+
{i = upper}.until_do {
put (item (i + 1)) to i;
i := i + 1;
};
);
-
+
- remove index:INTEGER until upper:INTEGER <-
// Assume `upper' is a valid index.
// Move range [`index' + 1 .. `upper'] by 1 position left.
@@ -471,18 +471,18 @@ Section Public
-? {index <= upper};
]
( + i:INTEGER;
-
+
i := index;
{i = upper}.until_do {
put (item (i + 1)) to i;
i := i + 1;
};
);
-
+
//
// Replacing:
//
-
+
- replace_all old_value:V with new_value:V until upper:INTEGER <-
// Replace all occurences of the element `old_value' by `new_value'
// using `==' for comparison.
@@ -490,14 +490,14 @@ Section Public
[ ...
-? {upper >= -1};
]
- (
+ (
upper.downto 0 do { i:INTEGER;
(safe_equal (old_value,(item i))).if {
put new_value to i;
};
};
);
-
+
- fast_replace_all old_value:V with new_value:V until upper:INTEGER <-
// Replace all occurences of the element `old_value' by `new_value'
// using basic `=' for comparison.
@@ -505,18 +505,18 @@ Section Public
[ ...
-? {upper >= -1};
]
- (
+ (
upper.downto 0 do { i:INTEGER;
(old_value = item i).if {
put new_value to i;
};
};
);
-
+
//
// Adding:
//
-
+
- copy src:NATIVE_ARRAY_VOLATILE(V) to dest:INTEGER until src_capacity:INTEGER <-
// Copy range [0 .. `src_capacity - 1'] of `src' to range
// [`dest' .. `dest + src_capacity - 1'] of `Self'.
@@ -526,7 +526,7 @@ Section Public
-? {src_capacity >= 0};
]
( + i1, i2:INTEGER;
-
+
i1 := dest;
{i2 = src_capacity}.until_do {
put (src.item i2) to i1;
@@ -534,7 +534,7 @@ Section Public
i1 := i1 + 1;
};
);
-
+
- slice_copy src:NATIVE_ARRAY_VOLATILE(V) to dest:INTEGER from src_min:INTEGER to src_max:INTEGER <-
// Copy range [`src_min' .. `src_max'] of `src' to range
// [`at' .. `at + src_max - src_min - 1'] of `Current'.
@@ -544,8 +544,8 @@ Section Public
-? {src_min <= src_max + 1};
-? {(src != Self) | (dest != src_min)};
]
- ( + i1, i2:INTEGER;
-
+ ( + i1, i2:INTEGER;
+
i1 := dest;
i2 := src_min;
{i2 > src_max}.until_do {
@@ -554,11 +554,11 @@ Section Public
i1 := i1 + 1;
};
);
-
+
//
// Other:
//
-
+
- set_all_with v:V until upper:INTEGER <-
// Set all elements in range [0 .. upper] with
// value `v'.
@@ -570,7 +570,7 @@ Section Public
put v to i;
};
);
-
+
- set_slice_with v:V from lower:INTEGER until upper:INTEGER <-
// Set all elements in range [`lower' .. `upper'] with value `v'.
[ ...
@@ -578,14 +578,14 @@ Section Public
-? {upper >= lower - 1};
]
( + i:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
put v to i;
i := i + 1;
};
);
-
+
- clear_all upper:INTEGER <-
// Set all elements in range [0 .. `upper'] with
// the default value.
@@ -593,12 +593,12 @@ Section Public
-? {upper >= -1};
]
( + v:V;
-
- upper.downto 0 do { i:INTEGER;
+
+ upper.downto 0 do { i:INTEGER;
put v to i;
};
);
-
+
- clear lower:INTEGER to upper:INTEGER <-
// Set all elements in range [`lower' .. `upper'] with
// the default value
@@ -607,12 +607,12 @@ Section Public
-? {upper >= lower};
]
( + v:V;
-
+
lower.to upper do { i:INTEGER;
put v to i;
};
);
-
+
- copy_from model:NATIVE_ARRAY_VOLATILE(V) until upper:INTEGER <-
// Assume `upper' is a valid index both in Current and `model'.
[ ...
@@ -623,7 +623,7 @@ Section Public
put (model.item i) to i;
};
);
-
+
- deep_twin_from capacity:INTEGER :NATIVE_ARRAY_VOLATILE(V) <-
// To implement `deep_twin'. Allocate a new array of
// `capacity' initialized with `deep_twin'.
@@ -633,7 +633,7 @@ Section Public
]
( + element:V;
+ result:NATIVE_ARRAY_VOLATILE(V);
-
+
(capacity > 0).if {
result := calloc capacity;
(capacity - 1).downto 0 do { i:INTEGER;
@@ -645,7 +645,7 @@ Section Public
};
};
);
-
+
- move lower:INTEGER to upper:INTEGER by offset:INTEGER <-
// Move range [`lower' .. `upper'] by `offset' positions.
// Freed positions are not initialized to default values.
@@ -654,7 +654,7 @@ Section Public
-? {upper >= lower};
-? {lower + offset >= 0};
]
- (
+ (
(offset != 0).if {
(offset < 0).if {
lower.to upper do { i:INTEGER;
@@ -667,7 +667,7 @@ Section Public
};
};
);
-
+
- occurrences element:V until upper:INTEGER :INTEGER <-
// Number of occurrences of `element' in range [0..upper]
// using `equal' for comparison.
@@ -676,7 +676,7 @@ Section Public
-? {upper >= -1};
]
( + count:INTEGER;
-
+
upper.downto 0 do { i:INTEGER;
(safe_equal (element,item i)).if {
count := count + 1;
@@ -684,9 +684,9 @@ Section Public
};
count
);
-
+
- slice_occurrences element:V from lower:INTEGER until upper:INTEGER :INTEGER <-
- // Number of occurrences of `element' in range [`lower' .. `upper'] using
+ // Number of occurrences of `element' in range [`lower' .. `upper'] using
// `is_equal' for comparison.
// See also `slice_fast_occurrences' to chose the apropriate one.
[ ...
@@ -694,7 +694,7 @@ Section Public
-? {upper >= lower - 1};
]
( + i,result:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
(safe_equal (element,item i)).if {
@@ -713,7 +713,7 @@ Section Public
-? {upper >= -1};
]
( + count:INTEGER;
-
+
upper.downto 0 do { i:INTEGER;
(element = item i).if {
count := count + 1;
@@ -721,7 +721,7 @@ Section Public
};
count
);
-
+
- slice_fast_occurrences element:V from lower:INTEGER until upper:INTEGER :INTEGER <-
// Number of occurrences of `element' in range [`lower' .. `upper']
// using basic "=" for comparison.
@@ -731,7 +731,7 @@ Section Public
-? {upper >= lower - 1};
]
( + i,result:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
(element = item i).if {
@@ -741,7 +741,7 @@ Section Public
};
result
);
-
+
- all_default upper:INTEGER :BOOLEAN <-
// Do all items in range [0 .. `upper'] have their type's
// default value?
@@ -759,7 +759,7 @@ Section Public
};
result
);
-
+
- slice_default lower:INTEGER to upper:INTEGER :BOOLEAN <-
// Do all items in range [`lower' .. `upper'] have their type's default value?
// Note: for non Void items, the test is performed with the `is_default' predicate.
@@ -767,10 +767,10 @@ Section Public
-? {lower >= 0};
-? {upper >= lower - 1};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ v:V;
+ result:BOOLEAN;
-
+
result := TRUE;
i := lower;
{(i > upper) || {! result}}.until_do {
@@ -782,28 +782,28 @@ Section Public
};
result
);
-
+
//
// Interfacing with C:
//
-
+
- to_external:POINTER <- to_pointer;
// Gives access to the C pointer on the area of storage.
-
+
- is_null:BOOLEAN <- to_pointer.is_null;
-
+
- is_not_null:BOOLEAN <- to_pointer.is_not_null;
-
+
//
// Guru Section
//
-
+
- force_put element:V to index:INTEGER <-
// Used in Memory count: not to use directly without caution !
[ ...
-? {index>=0};
]
- (
- `9`;
+ (
+ `9`;
);
diff --git a/lib/internal/portable/collection/set.li b/lib/internal/portable/collection/set.li
index aa0f84f..9c3dda7 100644
--- a/lib/internal/portable/collection/set.li
+++ b/lib/internal/portable/collection/set.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SET(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Definition of a mathematical set of objects.";
// All common operations on mathematical sets are available.
// Well knowned implementations are HASHED_SET and AVL_SET.
-
+
Section Inherit
-
+
+ parent_traversable:TRAVERSABLE(V) := TRAVERSABLE(V);
-
+
+ parent_safe_equal:SAFE_EQUAL(V) := SAFE_EQUAL(V);
-
+
Section Public
//
// Counting:
//
-
+
- count:INTEGER <-
// Cardinality of the set (i.e. actual `count' of stored elements).
(
deferred;
0
);
-
+
- is_empty:BOOLEAN <- count = 0;
// Is the set empty?
-
+
//
// Adding and removing:
//
-
+
- add e:V <-
- // Add new item `e' to the set. The mathematical definition of adding
- // in a set is followed, i.e. the element `e' is added only and only
+ // Add new item `e' to the set. The mathematical definition of adding
+ // in a set is followed, i.e. the element `e' is added only and only
// if it is not yet present in the set.
- // As this `add' feature is actually using `is_equal', you may consider
- // to use `fast_add' for expanded objects as well while trying to get
+ // As this `add' feature is actually using `is_equal', you may consider
+ // to use `fast_add' for expanded objects as well while trying to get
// the very best performances.
[ ...
- -? {e != NULL};
+ -? {e != NULL};
]
(
deferred;
@@ -77,7 +77,7 @@ Section Public
- fast_add e:V <-
// Same job as `add', but uses basic `=' for comparison.
[ ...
- -? {e != NULL};
+ -? {e != NULL};
]
(
deferred;
@@ -92,7 +92,7 @@ Section Public
// Remove item `e' from the set: the mathematical definition of
// removing from a set is followed.
[ ...
- -? {e != NULL};
+ -? {e != NULL};
]
(
deferred;
@@ -106,7 +106,7 @@ Section Public
- fast_remove e:V <-
// Same job as `remove', but uses basic `=' for comparison.
[ ...
- -? {e != NULL};
+ -? {e != NULL};
]
(
deferred;
@@ -116,13 +116,13 @@ Section Public
"Not in not removed." +? {(! Old fast_has e) -> (count = Old count)};
"In then removed." +? {(Old fast_has e) -> (count = Old count - 1)};
];
-
+
- clear <- clear_count;
-
+
- clear_count <-
- // Empty the current set (`is_empty' is True after that call).
- // If possible, the actual implementation is supposed to keep
- // its internal storage area in order to refill `Current' in
+ // Empty the current set (`is_empty' is True after that call).
+ // If possible, the actual implementation is supposed to keep
+ // its internal storage area in order to refill `Current' in
// an efficient way.
//
// See also `clear_count_and_capacity' to select the most appropriate.
@@ -130,12 +130,12 @@ Section Public
deferred;
)
[ ...
- "Is empty." +? {count = 0};
+ "Is empty." +? {count = 0};
];
- clear_count_and_capacity <-
- // Empty the current set (`is_empty' is True after that call).
- // If possible, the actual implementation is supposed to release
+ // Empty the current set (`is_empty' is True after that call).
+ // If possible, the actual implementation is supposed to release
// its internal storage area for this memory to be used by other objects.
//
// See also `clear_count' to select the most appropriate.
@@ -143,36 +143,36 @@ Section Public
deferred;
)
[ ...
- "Is empty." +? {count = 0};
+ "Is empty." +? {count = 0};
];
-
+
//
// Looking and searching:
//
-
+
- has e:V :BOOLEAN <-
// Is element `e' in the set?
- // As this query is actually using `is_equal', you may consider to use
- // `fast_has' for expanded objects as well while trying to get the very
+ // As this query is actually using `is_equal', you may consider to use
+ // `fast_has' for expanded objects as well while trying to get the very
// best performances.
[ ...
- -? {e != NULL};
+ -? {e != NULL};
]
(
deferred;
FALSE
)
[ ...
- +? {Result -> ! is_empty};
+ +? {Result -> ! is_empty};
];
-
+
- fast_has e:V :BOOLEAN <-
// Is element `e' actually stored in the set?
- // Warning: this query is using basic `=' for comparison.
+ // Warning: this query is using basic `=' for comparison.
//
// See also `has' when dealing with reference types.
[ ...
- -? {e != NULL};
+ -? {e != NULL};
]
(
deferred;
@@ -182,7 +182,7 @@ Section Public
];
- reference_at e:V :V <-
- // Non Void when `e' is in the set. In such a situation, `Result' is the
+ // Non Void when `e' is in the set. In such a situation, `Result' is the
// object which is actually stored in the `Current' set (see ensure assertion).
[ ...
-? {e != NULL};
@@ -193,19 +193,19 @@ Section Public
NULL
)
[ ...
- +? {has e ->> {Result == e}};
+ +? {has e ->> {Result == e}};
];
-
+
//
// To provide iterating facilities:
//
-
+
- lower:INTEGER := 1;
- upper:INTEGER <-
( count )
[ ...
- +? {Result = count};
+ +? {Result = count};
];
- item i:INTEGER :V <-
@@ -213,25 +213,25 @@ Section Public
//
// See also `lower', `upper', `valid_index'.
//
- // SETs are intrinsically unordered, so there is no guarantee that
- // `item'(i) after performing an `add' or `remove' operation is related
+ // SETs are intrinsically unordered, so there is no guarantee that
+ // `item'(i) after performing an `add' or `remove' operation is related
// in any way to `item'(i) before that operation.
( + result:V;
-
+
deferred;
result
)
- [ ...
- +? {fast_has Result};
- ];
+ [ ...
+ +? {fast_has Result};
+ ];
- first:V <- item lower;
// The very `first' item.
//
// See also `last', `item'.
//
- // SETs are intrinsically unordered, so there is no guarantee that
- // `first' after performing an `add' or `remove' operation is related
+ // SETs are intrinsically unordered, so there is no guarantee that
+ // `first' after performing an `add' or `remove' operation is related
// in any way to `first' before that operation.
- last:V <- item upper;
@@ -239,22 +239,22 @@ Section Public
//
// See also `first', `item'.
//
- // SETs are intrinsically unordered, so there is no guarantee that
- // `last' after performing an `add' or `remove' operation is related
+ // SETs are intrinsically unordered, so there is no guarantee that
+ // `last' after performing an `add' or `remove' operation is related
// in any way to `last' before that operation.
-
+
//
// Mathematical operations:
//
-
+
- union other:SELF <-
// Make the union of the `Current' set with `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + i:INTEGER;
+ e:V;
-
+
i := 1;
{i > other.count}.until_do {
e := other.item i;
@@ -265,17 +265,17 @@ Section Public
};
)
[ ...
- +? {count <= Old count + other.count};
+ +? {count <= Old count + other.count};
];
-
+
- fast_union other:SELF <-
// Make the union of the `Current' set with `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + i:INTEGER;
+ e:V;
-
+
i := 1;
{i > other.count}.until_do {
e := other.item i;
@@ -286,16 +286,16 @@ Section Public
};
)
[ ...
- +? {count <= Old count + other.count};
+ +? {count <= Old count + other.count};
];
-
+
- Self:SELF '+' other:SELF :SELF <-
// Return the union of the `Current' set with `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + result:SELF;
-
+
result := twin;
result.union other;
result
@@ -308,11 +308,11 @@ Section Public
- intersection other:SELF <-
// Make the intersection of the `Current' set with `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ e:V;
-
+
i := upper;
{i < lower}.until_do {
e := item i;
@@ -323,17 +323,17 @@ Section Public
};
)
[ ...
- +? {count <= other.count.min (Old count)};
+ +? {count <= other.count.min (Old count)};
];
- fast_intersection other:SELF <-
// Make the intersection of the `Current' set with `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
- ( + i:INTEGER;
+ ( + i:INTEGER;
+ e:V;
-
+
i := upper;
{i < lower}.until_do {
e := item i;
@@ -344,16 +344,16 @@ Section Public
};
)
[ ...
- +? {count <= other.count.min (Old count)};
+ +? {count <= other.count.min (Old count)};
];
-
+
- Self:SELF '^' other:SELF :SELF <-
// Return the intersection of the `Current' set with `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + result:SELF;
-
+
result := twin;
result.intersection other;
result
@@ -366,10 +366,10 @@ Section Public
- minus other:SELF <-
// Make the set `Current' - `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + i:INTEGER;
-
+
(other = Self).if {
clear_count;
} else {
@@ -381,43 +381,43 @@ Section Public
};
)
[ ...
- +? {count <= Old count};
+ +? {count <= Old count};
];
- Self:SELF '-' other:SELF :SELF <-
// Return the set `Current' - `other'.
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + result:SELF;
-
+
result := twin;
result.minus other;
result
)
[ ...
+? {Result.count <= count};
- +? {Result.is_subset_of Self};
+ +? {Result.is_subset_of Self};
];
//
// Comparison:
//
-
+
- is_subset_of other:SELF :BOOLEAN <-
// Is the `Current' set a subset of `other'?
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + i:INTEGER;
+ result:BOOLEAN;
-
+
(Self = other).if {
result := TRUE;
}.elseif {count <= other.count} then {
result := TRUE;
i := 1;
- {(! result) || {i > count}}.until_do {
+ {(! result) || {i > count}}.until_do {
result := other.has (item i);
i := i + 1;
};
@@ -425,22 +425,22 @@ Section Public
result
)
[ ...
- +? {Result -> (count <= other.count)};
+ +? {Result -> (count <= other.count)};
];
- is_disjoint_from other:SELF :BOOLEAN <-
// Is the `Current' set disjoint from `other' ?
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + i:INTEGER;
+ result:BOOLEAN;
-
+
(Self != other).if {
result := TRUE;
i := 1;
(count <= other.count).if {
- {(! result) || {i > count}}.until_do {
+ {(! result) || {i > count}}.until_do {
result := ! other.has (item i);
i := i + 1;
};
@@ -454,22 +454,22 @@ Section Public
result
)
[ ...
- +? {Result = (Self ^ other).is_empty};
+ +? {Result = (Self ^ other).is_empty};
];
-
+
- fast_is_disjoint_from other:SELF :BOOLEAN <-
// Is the `Current' set disjoint from `other' ?
[ ...
- -? {other != NULL};
+ -? {other != NULL};
]
( + i:INTEGER;
+ result:BOOLEAN;
-
+
(Self != other).if {
result := TRUE;
i := 1;
(count <= other.count).if {
- {(! result) || {i > count}}.until_do {
+ {(! result) || {i > count}}.until_do {
result := ! other.fast_has (item i);
i := i + 1;
};
@@ -483,20 +483,20 @@ Section Public
result
)
[ ...
- // +? {Result = (Self ^ other).is_empty};
+ // +? {Result = (Self ^ other).is_empty};
];
-
+
- Self:SELF '==' other:SELF :BOOLEAN <-
// Is the `Current' set equal to `other'?
( + i:INTEGER;
+ result:BOOLEAN;
-
+
(Self = other).if {
result := TRUE;
}.elseif {count = other.count} then {
result := TRUE;
i := 1;
- {(! result) || {i > count}}.until_do {
+ {(! result) || {i > count}}.until_do {
result := other.has (item i);
i := i + 1;
};
@@ -510,17 +510,17 @@ Section Public
//
// Duplication.
//
-
+
- copy other:SELF <-
// Copy 'other' into the current set
( + i:INTEGER;
-
+
// Note: this naive implementation is OK because node
// recycling is implemented.
// BSBS: A revoir.
make;
i := 1;
- {i > other.count}.until_do {
+ {i > other.count}.until_do {
add (other.item i);
i := i + 1;
};
@@ -529,10 +529,10 @@ Section Public
- from_collection model:COLLECTION(V) <-
// Add all items of `model'.
[ ...
- -? {model != NULL};
+ -? {model != NULL};
]
( + i, up:INTEGER;
-
+
make
up := model.upper;
i := model.lower;
@@ -545,13 +545,13 @@ Section Public
//
// Agents based features:
//
-
+
- do_all action:BLOCK <-
// Apply `action' to every item of `Self'.
//
// See also `for_all', `exists'.
( + i:INTEGER;
-
+
i := lower;
{i > upper}.until_do {
action.value (item i);
@@ -565,7 +565,7 @@ Section Public
// See also `do_all', `exists'.
( + i:INTEGER;
+ result:BOOLEAN;
-
+
result := TRUE;
i := lower;
{(! result) || {i > upper}}.until_do {
@@ -581,7 +581,7 @@ Section Public
// See also `do_all', `for_all'.
( + i:INTEGER;
+ result:BOOLEAN;
-
+
i := lower;
{result || {i > upper}}.until_do {
result := predicate.value (item i);
@@ -593,21 +593,21 @@ Section Public
//
// Creation.
//
-
- - create:SELF <-
+
+ - create:SELF <-
( + result:SELF;
-
+
result := clone;
result.make;
result
);
-
+
- make <-
// Creation of an empty SET.
(
deferred;
)
[ ...
- +? {is_empty};
+ +? {is_empty};
];
diff --git a/lib/internal/portable/collection/simple_dictionary.li b/lib/internal/portable/collection/simple_dictionary.li
index b1304e0..22cd995 100644
--- a/lib/internal/portable/collection/simple_dictionary.li
+++ b/lib/internal/portable/collection/simple_dictionary.li
@@ -19,15 +19,15 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SIMPLE_DICTIONARY(V, K);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
// Basic dictionaries (assymmetry value / key)
// (class akin to DOUBLE_DICTIONARY)
Section Inherit
-
+
+ parent_dictionary:Expanded DICTIONARY(V,K);
diff --git a/lib/internal/portable/file_system/fs_min.li b/lib/internal/portable/file_system/fs_min.li
index d3b145b..5ee80e0 100644
--- a/lib/internal/portable/file_system/fs_min.li
+++ b/lib/internal/portable/file_system/fs_min.li
@@ -19,64 +19,64 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FS_MIN;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment := "File system minimum";
-
+
- external := `#include <unistd.h>`;
-
+
Section Inherit
-
+
- parent_object:OBJECT <- OBJECT;
-
-Section Private
-
+
+Section Private
+
- string_tmp:STRING := STRING.create 128;
-
+
Section Public
-
+
//
- // Independance File System
+ // Independance File System
//
-
- - open_read n:ABSTRACT_STRING :POINTER <-
+
+ - open_read n:ABSTRACT_STRING :POINTER <-
( + buf:NATIVE_ARRAY(CHARACTER);
string_tmp.copy n;
buf := string_tmp.to_external;
- `fopen((char*)@buf,"rb")`:(POINTER)
+ `fopen((char*)@buf,"rb")`:(POINTER)
);
- - open_write n:ABSTRACT_STRING :POINTER <-
+ - open_write n:ABSTRACT_STRING :POINTER <-
( + buf:NATIVE_ARRAY(CHARACTER);
string_tmp.copy n;
buf := string_tmp.to_external;
`fopen((char*)@buf,"wb")`:(POINTER)
);
-
- - read f:POINTER in buf:STRING size sz:INTEGER :INTEGER <-
+
+ - read f:POINTER in buf:STRING size sz:INTEGER :INTEGER <-
( + ptr:NATIVE_ARRAY(CHARACTER);
+ result:INTEGER;
- ptr := buf.to_external;
+ ptr := buf.to_external;
result := `fread((void *)(@ptr),(size_t)(1), (size_t)(@sz),(FILE*)(@f))`:(INTEGER);
ptr.put '\0' to sz;
buf.from_external ptr;
result
);
- - write f:POINTER with buf:STRING size sz:INTEGER :INTEGER <-
+ - write f:POINTER with buf:STRING size sz:INTEGER :INTEGER <-
( + ptr:NATIVE_ARRAY(CHARACTER);
+ result:INTEGER;
- ptr := buf.to_external;
+ ptr := buf.to_external;
result := `fwrite((void *)(@ptr),(size_t)(1), (size_t)(@sz),(FILE*)(@f))`:(INTEGER);
result
);
-
+
- close p:POINTER <- `fclose((FILE*)(@p))`;
-
+
- file_size p:POINTER :INTEGER <-
( + result:INTEGER;
`fseek((FILE*)(@p),0,SEEK_END)`;
@@ -89,13 +89,13 @@ Section Public
( + p:NATIVE_ARRAY(CHARACTER);
+ stream:POINTER;
+ result:BOOLEAN;
-
+
string_tmp.copy new_path;
- p := string_tmp.to_external;
+ p := string_tmp.to_external;
stream := `fopen((char*)@p,"w+b")`:POINTER;
(result := (stream != NULL)).if {
- close stream;
+ close stream;
};
result
);
-
+
diff --git a/lib/internal/portable/io/file_input_stream.li b/lib/internal/portable/io/file_input_stream.li
index 957941f..bcd396d 100644
--- a/lib/internal/portable/io/file_input_stream.li
+++ b/lib/internal/portable/io/file_input_stream.li
@@ -73,10 +73,10 @@ Section Public
- read_character <-
// Return last character from stream
( + result:INTEGER;
-
+
push_back_flag.if {
push_back_flag := FALSE;
- } else {
+ } else {
result := file.physical_read tmp size 1;
(result = 0).if {
// nothing was read
@@ -91,8 +91,8 @@ Section Public
};
);
- - unread_character <-
- (
+ - unread_character <-
+ (
push_back_flag := TRUE;
);
diff --git a/lib/internal/portable/io/file_output_stream.li b/lib/internal/portable/io/file_output_stream.li
index 5eaa52a..42ff121 100644
--- a/lib/internal/portable/io/file_output_stream.li
+++ b/lib/internal/portable/io/file_output_stream.li
@@ -50,21 +50,21 @@ Section Public
result.make std_file;
result
);
-
+
Section Public
- put_character c:CHARACTER <-
// Put `c' on stream
- (
+ (
tmp.put c to 0;
file.physical_write tmp size 1;
);
- flush <- (); //file.basic_fush;
-
+
Section Private
-
+
- tmp:NATIVE_ARRAY(UINTEGER_8) := NATIVE_ARRAY(UINTEGER_8).create 1;
-
+
// kate: hl Lisaac v0.2; indent-width 2; space-indent on; replace-tabs off;
// kate: tab-width 8; remove-trailing-space on;
diff --git a/lib/internal/portable/io/input_stream.li b/lib/internal/portable/io/input_stream.li
index cb57e9b..bc9271b 100644
--- a/lib/internal/portable/io/input_stream.li
+++ b/lib/internal/portable/io/input_stream.li
@@ -19,27 +19,27 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := INPUT_STREAM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "This abstract class is the superclass of all classes \
\representing an input stream of bytes.";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
- push_back_flag:BOOLEAN;
// True if one char is already pushed back.
-
+
- last_integer:INTEGER;
// Last integer read using `read_integer'.
-
+
- last_string:STRING :=
// Access to the unique common buffer to get for example the result
// computed by `read_line', `read_word', `newline', etc. This is a once
@@ -47,15 +47,15 @@ Section Public
(
STRING.create 1024
);
-
-
+
+
- is_connected:BOOLEAN <-
// True when the corresponding stream is connected
// to some physical input device.
(
deferred;
);
-
+
- end_of_input:BOOLEAN <-
// Has end-of-input been reached ?
// True when the last character has been read.
@@ -63,10 +63,10 @@ Section Public
? { is_connected };
deferred;
);
-
-
+
+
// To read one character at a time:
-
+
- read_character:CHARACTER <-
// Read a character and assign it to `last_character'.
( + result:CHARACTER;
@@ -75,15 +75,15 @@ Section Public
? {! push_back_flag};
result
);
-
-
+
+
- last_character:CHARACTER <-
// Last character read with `read_character'.
(
? { is_connected };
deferred;
);
-
+
- unread_character <-
// Un-read the last character read.
(
@@ -91,9 +91,9 @@ Section Public
deferred;
? { push_back_flag };
);
-
+
// Skipping separators:
-
+
- skip_separators <-
// Skip all separators (see `is_separator' of class CHARACTER) and
// make the first non-separator available in `last_character'. This
@@ -109,12 +109,12 @@ Section Public
unread_character;
};
);
-
+
- skip_separators_using separators:STRING <-
// Same job as `skip_separators' using the `separators' set.
(
? { separators != NULL };
-
+
{ end_of_input ||{!separators.has last_character}}.until_do {
read_character;
};
@@ -122,7 +122,7 @@ Section Public
unread_character;
};
);
-
+
- skip_remainder_of_line <-
// Skip all the remainder of the line including the end of
// line character itself.
@@ -142,9 +142,9 @@ Section Public
};
};
);
-
+
// To read one number at a time:
-
+
- read_integer <-
// Read an integer according to the Lisaac syntax.
// Make result available in `last_integer'.
@@ -159,9 +159,9 @@ Section Public
// state = 2 :in the number.
// state = 3 :end state.
// state = 4 :error state.
-
+
? { !end_of_input };
-
+
{ state > 2 }.until_do {
read_character;
(state = 0).if {
@@ -192,7 +192,7 @@ Section Public
state := 3;
};
};
-
+
end_of_input.if {
state.when 0 to 1 then {
state := 4;
@@ -201,7 +201,7 @@ Section Public
};
};
};
-
+
!end_of_input.if {
unread_character;
};
@@ -213,9 +213,9 @@ Section Public
last_integer := - last_integer;
};
);
-
-
- /*
+
+
+ /*
- read_real <-
// Read a REAL and make the result available in `last_real'
// and in `last_double'.
@@ -225,10 +225,10 @@ Section Public
read_double;
last_real := last_double.to_real;
);
-
+
- last_real:REAL;
// Last real read with `read_real'.
-
+
- read_double <-
// Read a DOUBLE and make the result available in `last_double'.
(
@@ -240,11 +240,11 @@ Section Public
// state = 3 :in the fractional part.
// state = 4 :end state.
// state = 5 :error state.
-
+
? { !end_of_input };
-
+
last_string.clear
-
+
{ state >= 4 }.until_do {
read_character;
( state = 0).if {
@@ -287,7 +287,7 @@ Section Public
state := 4;
};
};
-
+
end_of_input.if {
state.when 2 to 4 then {
state := 4;
@@ -296,16 +296,16 @@ Section Public
};
};
};
-
+
(! end_of_input).if {
unread_character;
};
-
+
( state = 5 ).if {
io.put_string "Error in INPUT_STREAM.read_double.\n";
crash;
};
-
+
( last_string.count > 0).if {
last_double := last_string.to_double;
} else {
@@ -315,15 +315,15 @@ Section Public
last_double := - last_double;
};
);
-
-
+
+
- last_double:DOUBLE;
// Last double read with `read_double'.
-
+
*/
-
+
// To read one line or one word at a time:
-
+
- read_line <-
// Read a complete line ended by '\n' or `end_of_input'. Make the
// result available in `last_string' common buffer. The end of line
@@ -333,8 +333,8 @@ Section Public
last_string.clear;
read_line_in last_string;
);
-
-
+
+
- read_word <-
// Read a word using `is_separator' of class CHARACTER. Result is
// available in the `last_string' common buffer. Heading separators are
@@ -343,28 +343,28 @@ Section Public
// encountered, Result can be the empty string.
(
? { !end_of_input };
-
+
skip_separators;
!end_of_input.if {
read_character;
};
-
+
last_string.clear;
{ end_of_input || { last_character.is_separator }}.until_do {
last_string.extend last_character;
read_character;
};
);
-
+
- newline <-
// Consume input until newline ('\n') is found. Corresponding
// STRING is stored in `last_string' common buffer.
(
+ stop:BOOLEAN;
-
+
last_string.clear;
stop := end_of_input;
-
+
{stop}.until_do {
read_character;
( end_of_input || { last_character = '\n' }).if {
@@ -374,7 +374,7 @@ Section Public
};
};
);
-
+
- reach_and_skip keyword:STRING <-
// Try to skip enough characters in order to reach the `keyword'
// which is skipped too. If the `keyword' is not in the remainder of
@@ -385,19 +385,19 @@ Section Public
+ stop:BOOLEAN;
+ i:INTEGER;
+ first:CHARACTER;
-
+
? { !keyword.is_empty };
-
+
last_string.clear;
first := keyword.first;
-
+
{ end_of_input || stop }.until_do {
// Reach the first character of the `keyword':
i := 2;
{ (i > last_string.count) || { last_string.item i = first }}.until_do {
i := i + 1;
};
-
+
( i <= last_string.count ).if {
last_string.remove_first (i - 1);
} else {
@@ -410,10 +410,10 @@ Section Public
};
last_string.extend last_character;
};
-
+
? { !end_of_input ->> {last_string.item 1 = first}};
? { last_string.count <= keyword.count };
-
+
// Now we need as many characters as in `keyword':
{ end_of_input || { last_string.count = keyword.count } }.until_do {
read_character;
@@ -421,17 +421,17 @@ Section Public
};
stop := last_string == keyword;
};
-
+
!end_of_input.if {
read_character;
unread_character;
};
-
+
? {!end_of_input ->> { last_string == keyword} };
);
-
+
// Other features:
-
+
- read_line_in buffer:STRING <-
// Same jobs as `read_line' but storage is directly done in `buffer'.
(
@@ -439,13 +439,13 @@ Section Public
? { buffer != NULL };
deferred;
);
-
+
- read_word_using separators:STRING <-
// Same jobs as `read_word' using `separators'.
(
? { !end_of_input };
? { separators != NULL };
-
+
skip_separators_using separators;
!end_of_input.if {
read_character;
@@ -456,24 +456,24 @@ Section Public
read_character;
};
);
-
+
- read_tail_in str:STRING <-
// Read all remaining character of the file in `str'.
(
? { str != NULL };
-
+
end_of_input.until_do {
read_character;
!end_of_input.if {
str.extend last_character;
};
};
-
+
? { end_of_input };
);
Section Private
-
+
- basic_io_getc :CHARACTER <- SYSTEM_IO.get_char;
-
+
- basic_io_eof :CHARACTER <- SYSTEM_IO.eof;
\ No newline at end of file
diff --git a/lib/internal/portable/io/std_input_output.li b/lib/internal/portable/io/std_input_output.li
index 99b10fe..c1e0766 100644
--- a/lib/internal/portable/io/std_input_output.li
+++ b/lib/internal/portable/io/std_input_output.li
@@ -19,20 +19,20 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=STD_INPUT_OUTPUT;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="To have the useful `io'";
-
+
Section Inherit
-
+
- inherit_input_stream:INPUT_STREAM := INPUT_STREAM;
- inherit_output_stream:OUTPUT_STREAM := OUTPUT_STREAM;
-
+
Section Public
- is_connected:BOOLEAN := TRUE;
@@ -70,7 +70,7 @@ Section Public
(
std_input.end_of_input
);
-
+
- read_line_in str:STRING <-
(
std_input.read_line_in str;
diff --git a/lib/internal/portable/memory/memory.li b/lib/internal/portable/memory/memory.li
index e6328a6..3f5924f 100644
--- a/lib/internal/portable/memory/memory.li
+++ b/lib/internal/portable/memory/memory.li
@@ -19,104 +19,104 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Strict MEMORY;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- comment := "Memory manager 32/64 bits.";
-
+
- external :=
`
#define MINIMUM_SIZE 256
void *table_size[MINIMUM_SIZE/sizeof(void *)];
void *last_block[64];
`;
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
//
// MACRO ALLOCATOR
//
-
+
Section Mapping
-
- + previous_linear:MEMORY;
+
+ + previous_linear:MEMORY;
+ size_and_id:UINTEGER_CPU;
-
- //---------------> Limit for Busy
-
+
+ //---------------> Limit for Busy
+
+ next_free :MEMORY;
+ previous_free:MEMORY;
-
+
//---------------> Limit for Free
-
-Section Private
-
+
+Section Private
+
//
// Product by compiler.
//
-
+
// For GC only.
/*
- get_object_size t:INTEGER :INTEGER <- `get_object_size(@t)`:INTEGER;
-
- - mark_static_object <- `mark_static_object()`;
-
+
+ - mark_static_object <- `mark_static_object()`;
+
- demark_static_object <- `demark_static_object()`;
-
+
- mark_object ptr:POINTER type t:INTEGER <- `mark_object(@ptr, at t)`;
-
+
- demark_object ptr:POINTER type t:INTEGER <- `demark_object(@ptr, at t)`;
- */
-
+ */
+
Section Public
-
- - object_size:INTEGER <- POINTER.object_size + UINTEGER_CPU.object_size;
-
-Section MEMORY
-
+
+ - object_size:INTEGER <- POINTER.object_size + UINTEGER_CPU.object_size;
+
+Section MEMORY
+
- is_debug_memory:BOOLEAN := FALSE;
-
+
- this:POINTER <- CONVERT(MEMORY,POINTER).on Self;
-
+
- begin:POINTER <- this + object_size;
-
+
- size:UINTEGER_CPU <- size_and_id & ~ 3.to_uinteger_cpu;
-
+
- next_linear:MEMORY <- CONVERT(POINTER,MEMORY).on (begin + size);
-
+
- id:UINTEGER_CPU <- size_and_id & 01b;
-
+
- id_end:UINTEGER_CPU <- 10b;
-
+
- is_end:BOOLEAN <- (size_and_id & id_end).to_boolean;
-
+
- set_previous_linear p:MEMORY <- ( previous_linear := p; );
-
+
- set_size_and_id s:UINTEGER_CPU <- ( size_and_id := s; );
-
+
- get_index p:POINTER :UINTEGER_CPU <- (p - begin_memory).to_uinteger_cpu >> 26;
-
+
- nb_page:UINTEGER_CPU;
-
- - put_last m:MEMORY to idx:UINTEGER_CPU <-
+
+ - put_last m:MEMORY to idx:UINTEGER_CPU <-
(
? {idx < nb_page};
`last_block[@idx] = @m`;
);
-
+
- get_last idx:UINTEGER_CPU :MEMORY <-
- (
+ (
? {idx < nb_page};
`last_block[@idx]`:MEMORY
);
-
+
- search_capacity <-
- (
+ (
capacity_max := SYSTEM.get_memory_capacity;
begin_memory := SYSTEM.get_begin_memory;
/*
@@ -130,7 +130,7 @@ Section MEMORY
- new_page:MEMORY <-
( + old_size,new_size:UINTEGER_CPU;
+ block:MEMORY;
-
+
(capacity_max = 0).if {
search_capacity;
};
@@ -142,32 +142,32 @@ Section MEMORY
die_with_code exit_failure_code;
};
/*
- "Begin_memory + old_size : ".print;
+ "Begin_memory + old_size : ".print;
(begin_memory + old_size).print_hex; '\n'.print;
"object_size ".print; object_size.print; '\n'.print;
*/
- block := CONVERT(POINTER,MEMORY).on (begin_memory + old_size);
- block.set_previous_linear NULL;
+ block := CONVERT(POINTER,MEMORY).on (begin_memory + old_size);
+ block.set_previous_linear NULL;
block.set_size_and_id (id_free | id_end | (64.mb - object_size));
- block.add_link_free;
+ block.add_link_free;
put_last block to (nb_page - 1);
block
);
-
+
//
// Busy / Free Block.
//
-
+
- id_free:UINTEGER_CPU <- 00b;
- id_busy:UINTEGER_CPU <- 01b;
-
+
- set_next_free n:MEMORY <- ( next_free := n; );
- set_previous_free p:MEMORY <- ( previous_free := p; );
-
+
- delete_link_free <-
( + prev,next:MEMORY;
-
+
prev := previous_free;
next := next_free;
(prev = NULL).if {
@@ -179,72 +179,72 @@ Section MEMORY
next.set_previous_free prev;
};
);
-
+
- add_link_free <-
- (
+ (
next_free := first_free;
previous_free := NULL;
- (first_free != NULL).if {
+ (first_free != NULL).if {
first_free.set_previous_free Self;
- };
- first_free := Self;
+ };
+ first_free := Self;
);
-
+
Section MEMORY
-
+
- first_free:MEMORY;
-
+
//
// Management.
//
-
+
- to_free idx:UINTEGER_CPU <-
( + new_free,next:MEMORY;
+ new_size:UINTEGER_CPU;
{id = id_busy} ? "Memory: Macro block not busy.";
- {idx.in_range 0 to 63} ? "Memory: Bound index.";
-
+ {idx.in_range 0 to 63} ? "Memory: Bound index.";
+
next := next_linear;
new_free := previous_linear;
new_size := size_and_id & ~ 1.to_uinteger_cpu;
((new_free = NULL) || {new_free.id != id_free}).if {
// `Self' => Free
- new_free := Self;
- add_link_free;
+ new_free := Self;
+ add_link_free;
} else {
// `previous_linear' => Free
- new_size := new_size + new_free.size_and_id + object_size;
+ new_size := new_size + new_free.size_and_id + object_size;
};
-
+
((! is_end) && {next.id = id_free}).if {
// Delete and concat `next_linear'
new_size := new_size + next.size_and_id + object_size;
- next.delete_link_free;
- };
+ next.delete_link_free;
+ };
new_free.set_size_and_id new_size;
-
+
(new_free.is_end).if {
- put_last new_free to idx;
+ put_last new_free to idx;
} else {
next := new_free.next_linear;
next.set_previous_linear new_free;
- };
+ };
);
-
+
- to_busy sz:POINTER index idx:UINTEGER_CPU <-
- ( + siz,new_size:UINTEGER_CPU;
+ ( + siz,new_size:UINTEGER_CPU;
+ new,next:MEMORY;
- {id = id_free} ? "Memory: Macro block not free.";
+ {id = id_free} ? "Memory: Macro block not free.";
{(sz & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
-
+
delete_link_free;
- //
+ //
siz := size_and_id;
- new_size := siz - sz;
+ new_size := siz - sz;
(new_size > (minimum_size+object_size+object_size)).if {
siz := sz;
new := CONVERT(POINTER,MEMORY).on (begin+sz);
- new.set_previous_linear Self;
+ new.set_previous_linear Self;
new.set_size_and_id (new_size - object_size);
new.add_link_free;
(new.is_end).if {
@@ -253,21 +253,21 @@ Section MEMORY
next := new.next_linear;
next.set_previous_linear new;
};
- };
+ };
size_and_id := siz | id_busy;
{id = id_busy} ? "Memory: Macro Block not busy.";
);
-
+
- resize new_size:UINTEGER_CPU index idx:UINTEGER_CPU :MEMORY <-
( + nxt,result:MEMORY;
- + old_size,sz:UINTEGER_CPU;
-
+ + old_size,sz:UINTEGER_CPU;
+
{(new_size & (POINTER.object_size -1)) = 0} ? "Memory: Alignment.";
{idx.in_range 0 to 63} ? "Memory: Bound index.";
-
+
old_size := size;
- (new_size > old_size).if {
- (! is_end).if {
+ (new_size > old_size).if {
+ (! is_end).if {
nxt := next_linear;
sz := new_size - old_size - object_size;
((nxt.id = id_free) && {nxt.size >= sz}).if {
@@ -280,33 +280,33 @@ Section MEMORY
nxt.set_previous_linear Self;
};
result := Self;
- };
+ };
};
- (result = NULL).if {
- // new allocation.
- result := search new_size;
- copy begin to (result.begin) size old_size;
- to_free idx;
+ (result = NULL).if {
+ // new allocation.
+ result := search new_size;
+ copy begin to (result.begin) size old_size;
+ to_free idx;
};
} else {
result := Self;
- };
+ };
result
);
-
+
//
// Searching.
//
-
+
- search new_size:UINTEGER_CPU :MEMORY <-
( + result:MEMORY;
+ idx:UINTEGER_CPU;
-
-
+
+
{new_size > minimum_size-POINTER.object_size} ? "Memory: Big block.";
{(new_size & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
-
- result := first_free;
+
+ result := first_free;
{(result != NULL) && {result.size < new_size}}.while_do {
result := result.next_free;
};
@@ -316,17 +316,17 @@ Section MEMORY
idx := get_index (result.this);
{idx.in_range 0 to 63} ? "Memory: Bound index.";
result.to_busy new_size index idx;
-
+
result
);
-
+
- new_lab t:UINTEGER_32 :POINTER <-
( + idx:UINTEGER_CPU;
+ blc,prev:MEMORY;
+ result:POINTER;
-
+
{
- (idx < nb_page) &&
+ (idx < nb_page) &&
{
blc := get_last idx;
(blc.size < 4096) || {blc.id = id_busy}
@@ -334,80 +334,80 @@ Section MEMORY
}.while_do {
idx := idx + 1;
};
-
- (idx >= nb_page).if {
+
+ (idx >= nb_page).if {
blc := new_page;
- };
+ };
blc.set_size_and_id (blc.size_and_id - 4096);
- result := blc.next_linear.this;
-
+ result := blc.next_linear.this;
+
(blc.size < minimum_size).if {
blc.delete_link_free;
prev := blc.previous_linear;
- (prev != NULL).if {
+ (prev != NULL).if {
prev.set_size_and_id (prev.size_and_id + blc.size_and_id + object_size);
put_last prev to idx;
};
};
- put_32 t to result;
-
+ put_32 t to result;
+
{((result - begin_memory) & 0FFFh) = 0} ? "Memory: Alignment LAB.";
result + UINTEGER_32.object_size
- );
-
+ );
+
Section Private
-
+
- minimum_size:UINTEGER_CPU <- `MINIMUM_SIZE`:UINTEGER_CPU;
-
- - table_type idx:UINTEGER_32 :POINTER <-
+
+ - table_type idx:UINTEGER_32 :POINTER <-
(
//{idx.in_range 0 to 17} ? "Memory: Bound table_type.";
`&(table_type[@idx])`:POINTER
);
-
- - table_size idx:UINTEGER_CPU :POINTER <-
+
+ - table_size idx:UINTEGER_CPU :POINTER <-
(
- {idx.in_range 1 to (minimum_size/POINTER.object_size)} ?
+ {idx.in_range 1 to (minimum_size/POINTER.object_size)} ?
"Memory: Bound table_size.";
`&(table_size[@idx-1])`:POINTER
);
-
+
- begin_memory:POINTER;
-
+
- capacity_max:UINTEGER_CPU;
-
+
- read_ptr p:POINTER :POINTER <-
( + mem:NATIVE_ARRAY(POINTER);
mem := CONVERT(POINTER, NATIVE_ARRAY(POINTER)).on p;
mem.item 0
);
-
+
- put_ptr v:POINTER to p:POINTER <-
( + mem:NATIVE_ARRAY(POINTER);
mem := CONVERT(POINTER, NATIVE_ARRAY(POINTER)).on p;
mem.put v to 0;
);
-
+
- put_32 v:UINTEGER_32 to p:POINTER <-
( + mem:NATIVE_ARRAY(UINTEGER_32);
mem := CONVERT(POINTER, NATIVE_ARRAY(UINTEGER_32)).on p;
mem.put v to 0;
);
-
+
- micro_alloc new_size:UINTEGER_CPU table ptr_table:POINTER lab lab_type:UINTEGER_32 :POINTER <-
( + result,next,next2:POINTER;
+ page:POINTER;
{(new_size & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
{new_size >= POINTER.object_size} ? "Memory: Size = 0.";
- result := read_ptr ptr_table;
- (result = NULL).if {
- // Allocation new LAB.
- result := new_lab lab_type;
- next := result + new_size;
+ result := read_ptr ptr_table;
+ (result = NULL).if {
+ // Allocation new LAB.
+ result := new_lab lab_type;
+ next := result + new_size;
put_ptr NULL to next;
- put_ptr next to ptr_table;
- } else {
+ put_ptr next to ptr_table;
+ } else {
// Next Linked list.
next := read_ptr result;
(next = NULL).if {
@@ -416,72 +416,72 @@ Section Private
((page + (new_size << 1)) <= 4096).if {
next := result + new_size;
} else {
- next := new_lab lab_type;
+ next := new_lab lab_type;
};
put_ptr NULL to next;
put_ptr next to ptr_table;
- } else {
- // Linked list allocation.
+ } else {
+ // Linked list allocation.
next2 := read_ptr next & ~ 11b.to_uinteger_cpu;
- put_ptr next2 to result;
- result := next;
- };
- };
+ put_ptr next2 to result;
+ result := next;
+ };
+ };
result
);
-
+
- micro_free p:POINTER table ptr_table:POINTER <-
( + next,last:POINTER;
{p != NULL} ? "Memory: Pointer NULL.";
-
+
last := read_ptr ptr_table;
{last != NULL} ? "Memory: Table NULL.";
next := read_ptr last;
put_ptr (next | 11b) to p;
put_ptr p to last;
);
-
+
Section Private
- copy src:POINTER to dst:POINTER size sz:UINTEGER_CPU <-
( + na_src,na_dst:NATIVE_ARRAY(POINTER);
+ siz:INTEGER;
-
+
siz := sz.to_integer;
{(siz & (POINTER.object_size -1)) = 0} ? "Memory: Copy alignment.";
siz := siz / POINTER.object_size;
na_src := CONVERT(POINTER, NATIVE_ARRAY(POINTER)).on src;
na_dst := CONVERT(POINTER, NATIVE_ARRAY(POINTER)).on dst;
- //
- (siz - 1).downto 0 do { j:INTEGER;
+ //
+ (siz - 1).downto 0 do { j:INTEGER;
na_dst.put (na_src.item j) to j;
- };
+ };
);
-
+
- fill_memory src:POINTER size sz:UINTEGER_CPU <-
// Just for debug.
( + na_src:NATIVE_ARRAY(POINTER);
+ siz:UINTEGER_CPU;
-
+
{(sz & (POINTER.object_size -1)) = 0} ? "Memory: Copy alignment.";
-
- siz := sz.align_power (POINTER.object_size) / POINTER.object_size;
- na_src := CONVERT(POINTER,NATIVE_ARRAY(POINTER)).on src;
+
+ siz := sz.align_power (POINTER.object_size) / POINTER.object_size;
+ na_src := CONVERT(POINTER,NATIVE_ARRAY(POINTER)).on src;
((siz-1).to_integer).downto 0 do { j:INTEGER;
na_src.put NULL to j;
- };
- );
+ };
+ );
/*
Section External
-
+
- calloc (nb,sz:UINTEGER) :POINTER <-
( + result:POINTER;
+ size:UINTEGER_32;
+ tab:NATIVE_ARRAY(UINTEGER_8);
-
+
size := nb*sz;
"calloc = ".print;
- size.print; '\n'.print;
+ size.print; '\n'.print;
result := malloc (size.to_uinteger);
tab := CONVERT(POINTER,NATIVE_ARRAY(UINTEGER_8)).on result;
0.to (size-1) do { i:INTEGER;
@@ -489,11 +489,11 @@ Section External
};
result
);
-
+
- malloc sz:UINTEGER :POINTER <-
( + result:POINTER;
"malloc = ".print;
- sz.print; '\n'.print;
+ sz.print; '\n'.print;
result := MEMORY.alloc_dynamic (sz.to_pointer);
(result = NULL).if {
"MEMORY : MERDE\n".print;
@@ -501,10 +501,10 @@ Section External
"MEMORY :sortie\n".print;
result
);
-
+
- free ptr:POINTER <-
( + mem:MEMORY;
-
+
"FREE\n".print;
(ptr != NULL).if {
mem := CONVERT(POINTER, MEMORY).on (ptr - object_size);
@@ -518,127 +518,127 @@ Section Public
//
// MICRO ALLOCATOR
//
-
+
- alloc_type t:UINTEGER_32 size sz:UINTEGER_CPU :POINTER <-
// Allocation for object without type. (LAB_TYPE)
- ( + ptr_table,result:POINTER;
+ ( + ptr_table,result:POINTER;
+ new_size:UINTEGER_CPU;
-
+
verify_memory "Begin alloc_type size";
-
+
{sz <= minimum_size} ? "Memory: Size bound.";
- new_size := sz.align_power (POINTER.object_size);
- {(new_size & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
+ new_size := sz.align_power (POINTER.object_size);
+ {(new_size & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
ptr_table := table_type t;
- result := micro_alloc new_size table ptr_table lab (t | 1b);
-
+ result := micro_alloc new_size table ptr_table lab (t | 1b);
+
verify_memory "End alloc_type size";
-
+
result
);
-
+
- free p:POINTER type t:UINTEGER_32 <-
( + ptr_table:POINTER;
{p != NULL} ? "Memory: Pointer NULL.";
-
+
verify_memory "Begin free type";
-
+
ptr_table := table_type t;
micro_free p table ptr_table;
-
+
verify_memory "End free type";
);
-
+
- alloc_size sz:UINTEGER_CPU :POINTER <-
// Allocation for object with type. (LAB_SIZE)
( + ptr_table,result:POINTER;
+ new_size:UINTEGER_CPU;
-
+
verify_memory "Begin alloc_size";
-
+
{sz <= minimum_size} ? "Memory: Size bound.";
-
- new_size := sz.align_power (POINTER.object_size);
-
+
+ new_size := sz.align_power (POINTER.object_size);
+
{(new_size & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
-
- ptr_table := table_size (new_size / POINTER.object_size);
+
+ ptr_table := table_size (new_size / POINTER.object_size);
result := micro_alloc new_size table ptr_table lab (new_size.to_uinteger_32);
-
+
verify_memory "End alloc_size";
result
);
-
+
- free p:POINTER size sz:UINTEGER_CPU <-
( + ptr_table:POINTER;
+ new_size:UINTEGER_CPU;
{p != NULL} ? "Memory: Pointer NULL.";
-
+
verify_memory "Begin free size";
-
- new_size := sz.align_power (POINTER.object_size);
-
+
+ new_size := sz.align_power (POINTER.object_size);
+
{(new_size & (POINTER.object_size - 1)) = 0} ? "Memory: Alignment.";
-
+
ptr_table := table_size (new_size / POINTER.object_size);
micro_free p table ptr_table;
-
+
verify_memory "End free size";
);
-
+
- alloc_dynamic sz:UINTEGER_CPU :POINTER <-
// Allocation NATIVE_ARRAY[E]. (LAB_SIZE or malloc)
( + new_size,new_size2:UINTEGER_CPU;
+ result:POINTER;
{sz != 0} ? "Memory: Size = 0";
-
+
verify_memory "Begin alloc_dynamic";
-
- new_size := sz.align_power (POINTER.object_size);
+
+ new_size := sz.align_power (POINTER.object_size);
new_size2 := new_size; // + UINTEGER_CPU.object_size;
(new_size2 <= minimum_size).if {
- result := alloc_size new_size2;
+ result := alloc_size new_size2;
//put_32 3 to result; // 3 : 2=NATIVE_ARRAY
result := result; // + UINTEGER_CPU.object_size;
- } else {
- result := search new_size .begin;
+ } else {
+ result := search new_size .begin;
};
-
+
verify_memory "End alloc_dynamic";
-
- result
+
+ result
);
-
+
- realloc_dynamic p:POINTER old_size old_sz:UINTEGER_CPU new_size new_sz:UINTEGER_CPU :POINTER <-
( + old_size,old_size2,new_size:UINTEGER_CPU;
+ mem:MEMORY;
- + result:POINTER;
+ + result:POINTER;
{old_size < new_sz} ? "Memory: New size < Old size.";
-
+
verify_memory "Begin realloc_dynamic";
-
- old_size := old_sz.align_power (POINTER.object_size);
- old_size2 := old_size; // + UINTEGER_CPU.object_size;
- new_size := new_sz.align_power (POINTER.object_size);
- (old_size2 <= minimum_size).if {
- result := alloc_dynamic new_size;
+
+ old_size := old_sz.align_power (POINTER.object_size);
+ old_size2 := old_size; // + UINTEGER_CPU.object_size;
+ new_size := new_sz.align_power (POINTER.object_size);
+ (old_size2 <= minimum_size).if {
+ result := alloc_dynamic new_size;
copy p to result size old_size;
- free (p /*- UINTEGER_CPU.object_size*/) size old_size2;
- } else {
+ free (p /*- UINTEGER_CPU.object_size*/) size old_size2;
+ } else {
mem := CONVERT(POINTER, MEMORY).on (p - object_size);
- result := mem.resize new_size index (get_index p).begin;
+ result := mem.resize new_size index (get_index p).begin;
};
-
+
verify_memory "End realloc_dynamic";
-
+
result
);
-
+
- free_dynamic p:POINTER size sz:UINTEGER_CPU <-
( + new_size,new_size2:UINTEGER_CPU;
+ mem:MEMORY;
-
+
new_size := sz.align_power (POINTER.object_size); // BSBS: Optim, alignment by compilo.
new_size2 := new_size; // + UINTEGER_CPU.object_size;
(new_size2 <= minimum_size).if {
@@ -648,19 +648,19 @@ Section Public
mem.to_free (get_index p);
};
);
-
+
//
// GARBAGE COLLECTOR
//
/*
- garbage_collector_pass <-
(
- mark;
+ mark;
sweep;
);
-
-Section Private
-
+
+Section Private
+
- mark <-
( + stack,lab:NATIVE_ARRAY(POINTER);
+ ptr,beg_mem,end_mem,ptr_lab,ptr_table,lim_lab:POINTER;
@@ -669,10 +669,10 @@ Section Private
+ mem:MEMORY;
+ type:UINTEGER_32;
+ type_object, size_object,step:UINTEGER_32;
-
+
// Mark Global + BSS.
- mark_static_object;
-
+ mark_static_object;
+
// Mark Stack object.
stack := `top_stack()`:NATIVE_ARRAY(POINTER);
size_stack := (`@stack - begin_stack`:UINTEGER_32) / POINTER.object_size.to_uinteger_32;
@@ -687,7 +687,7 @@ Section Private
mem := get_last (ptr_mem >> 26);
(ptr > mem.next_linear.this).if {
// `ptr' is in LAB.
- ptr_lab := begin_memory + (ptr_mem & 0FFFFF000h);
+ ptr_lab := begin_memory + (ptr_mem & 0FFFFF000h);
type := read ptr_lab .to_uinteger_32;
(type & 01b != 0).if {
// LAB Type.
@@ -713,15 +713,15 @@ Section Private
};
};
);
-
+
- sweep <-
( + last:MEMORY;
+ ptr_lab,ptr_end,ptr,ptr_table,end_lab,ptr_max:POINTER;
+ type,type_object,size_object:UINTEGER_32;
-
+
// Demark a Global + BSS.
demark_static_object;
-
+
// Demark a Store.
ptr_end := begin_memory + 64.mb;
(nb_page-1).downto 0 do { i:UINTEGER_32;
@@ -747,7 +747,7 @@ Section Private
ptr := ptr + size_object;
};
} else {
- // LAB Size.
+ // LAB Size.
size_object := type;
ptr_table := table_size (size_object / POINTER.object_size.to_uinteger_32);
end_lab := read ptr_table;
@@ -761,19 +761,19 @@ Section Private
demark_object ptr type type_object;
ptr := ptr + size_object;
};
- };
+ };
};
ptr_end := ptr_end + 64.mb;
};
);
*/
-
+
Section Private
-
+
- verify_memory msg:STRING_CONSTANT<-
( + m,next,prev:MEMORY;
+ msg_intern:STRING_CONSTANT;
-
+
(is_debug_memory).if {
(begin_memory != NULL).if {
next := CONVERT(POINTER, MEMORY).on begin_memory;
@@ -781,16 +781,16 @@ Section Private
m := next;
next := m.next_linear;
prev := m.previous_linear;
-
+
(prev = NULL).if {
(m != begin_memory).if {
msg_intern := "Begin list fail!\n";
};
- } else {
+ } else {
(prev.next_linear != m).if {
msg_intern := "Previous fail!\n";
};
- };
+ };
(m.id = id_busy).if {
// Busy
} else {
@@ -800,12 +800,12 @@ Section Private
};
};
(m.is_end).if {
-
+
} else {
(next.previous_linear != m).if {
msg_intern := "Next fail!\n";
};
- };
+ };
}.do_until {(m.is_end) || {msg_intern != NULL}};
(msg_intern != NULL).if {
"************* Crash memory *************\n".print;
@@ -817,28 +817,28 @@ Section Private
};
};
);
-
+
- print_memory <-
( + m,next:MEMORY;
-
+
"------------------------------------\n".print;
"first free : ".print;
- first_free.this.print_hex;
+ first_free.this.print_hex;
'\n'.print;
-
+
next := CONVERT(POINTER, MEMORY).on begin_memory;
{
m := next;
next := m.next_linear;
-
+
'['.print;
(m.previous_linear = NULL).if {
"NULL".print;
} else {
- (m.previous_linear.this).print_hex;
+ (m.previous_linear.this).print_hex;
};
"<-".print;
- m.this.print_hex;
+ m.this.print_hex;
(m.id = id_busy).if {
"(B)".print;
} else {
diff --git a/lib/internal/portable/number/fixed_real.li b/lib/internal/portable/number/fixed_real.li
index 9dba77c..e9152b3 100644
--- a/lib/internal/portable/number/fixed_real.li
+++ b/lib/internal/portable/number/fixed_real.li
@@ -19,55 +19,55 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FIXED_REAL;
-
+
- comment := "Real number of fixed decimal part.";
-
+
Section Insert
-
+
- parent_real:REAL := REAL;
-
+
Section SELF
- - shift_bits:INTEGER <-
+ - shift_bits:INTEGER <-
(
deferred;
0
);
-
+
Section Public
-
+
- floor:INTEGER <-
(
deferred;
);
-
- //
+
+ //
// Conversions with tests
//
-
+
//
// - To unsigned integers
//
- - to_uinteger_8:UINTEGER_8 <-
- (
+ - to_uinteger_8:UINTEGER_8 <-
+ (
floor.to_raw_uinteger_8
);
- - to_uinteger_16:UINTEGER_16 <-
- (
+ - to_uinteger_16:UINTEGER_16 <-
+ (
floor.to_raw_uinteger_16
);
- to_uinteger_32:UINTEGER_32 <-
- (
+ (
floor.to_raw_uinteger_32
);
- - to_uinteger_64:UINTEGER_64 <-
- (
+ - to_uinteger_64:UINTEGER_64 <-
+ (
floor.to_raw_uinteger_64
);
@@ -76,30 +76,30 @@ Section Public
//
- to_integer_8:INTEGER_8 <-
- (
+ (
floor.to_raw_integer_8
);
- to_integer_16:INTEGER_16 <-
- (
+ (
floor.to_raw_integer_16
);
- to_integer_32:INTEGER_32 <-
- (
+ (
floor.to_raw_integer_32
);
- to_integer_64:INTEGER_64 <-
- (
+ (
floor.to_raw_integer_64
);
-
+
- to_integer:INTEGER <-
(
floor
);
-
+
//
// - To unsigned fixed reals
//
@@ -131,13 +131,13 @@ Section Public
} else {
result := to_raw_uinteger_32 >> (shift_bits - 6);
};
- result.to_raw_ureal_26_6
+ result.to_raw_ureal_26_6
);
-
+
//
// - To signed fixed reals
//
-
+
- to_real_16_16:REAL_16_16 <-
( + result:UINTEGER_32;
(shift_bits < 16).if {
@@ -165,36 +165,36 @@ Section Public
} else {
result := to_raw_integer_32 >> (shift_bits - 6);
};
- result.to_raw_ureal_26_6
+ result.to_raw_ureal_26_6
);
-
+
//
// - To float reals
//
-
+
- to_real_32:REAL_32 <-
- (
+ (
to_raw_real_32 / (1 << shift_bits)
);
- to_real_64:REAL_64 <-
- (
+ (
to_raw_real_64 / (1 << shift_bits)
);
- to_real_80:REAL_80 <-
- (
+ (
to_raw_real_80 / (1 << shift_bits)
);
- atan:SELF <- not_yet_implemented;
- - sqrt:SELF <-
+ - sqrt:SELF <-
// The Heron approximation Algorithm.
[ -? {Self > 0}; ]
( + result:SELF;
result := Self;
- 0.to 7 do { j:INTEGER;
+ 0.to 7 do { j:INTEGER;
result := (result + Self / result) /# 2;
};
result
@@ -211,27 +211,27 @@ Section Public
//
// Comparaison.
//
-
+
- Self:SELF '~=' other:SELF :BOOLEAN <-
(
Self = other
);
-
+
- is_not_a_number:BOOLEAN <- FALSE;
-
+
- is_infinity:BOOLEAN <- FALSE;
-
+
//
// Print.
//
-
+
- append_in buffer:STRING decimal n:INTEGER <-
- (
+ (
not_yet_implemented;
);
-
- - scientific_append_in buffer:STRING <-
- (
+
+ - scientific_append_in buffer:STRING <-
+ (
not_yet_implemented;
);
-
+
diff --git a/lib/internal/portable/number/float_map.li b/lib/internal/portable/number/float_map.li
index f7c4132..606b56e 100644
--- a/lib/internal/portable/number/float_map.li
+++ b/lib/internal/portable/number/float_map.li
@@ -19,46 +19,46 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FLOAT_MAP;
-
+
- comment := "Mapping for REAL_xx.";
-
+
Section PRIVATE
-
+
- deferred <- crash_with_message "Slot deferred.";
-
+
Section REAL, REAL_32, REAL_64, REAL_80
-
+
- get_map f:SELF <-
(
deferred;
);
-
+
- sign:BOOLEAN <- deferred; // TRUE if positif, FALSE else.
-
+
- exponent:UINTEGER_32 <- deferred;
-
- - mantissa:UINTEGER_64 <- deferred;
-
+
+ - mantissa:UINTEGER_64 <- deferred;
+
//
// Consultation.
//
-
- - is_infinite:BOOLEAN <-
+
+ - is_infinite:BOOLEAN <-
(exponent = ((1 << exponent_bits) - 1)) && {(mantissa >> (mantissa_bits-1)) = 0};
-
+
- is_nan:BOOLEAN <-
(exponent = ((1 << exponent_bits) - 1)) && {(mantissa >> (mantissa_bits-1)) != 0};
-
+
- is_zero:BOOLEAN <- (exponent = 0) && {mantissa = 0};
-
+
Section Public
//
// Format.
//
-
+
- mantissa_bits:INTEGER_8 <- deferred;
- exponent_bits:INTEGER_8 <- deferred;
diff --git a/lib/internal/portable/number/float_map32.li b/lib/internal/portable/number/float_map32.li
index b657219..0cd0a51 100644
--- a/lib/internal/portable/number/float_map32.li
+++ b/lib/internal/portable/number/float_map32.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FLOAT_MAP32;
-
+
- comment := "Mapping for REAL_32.";
-
+
Section Inherit
-
+
- parent_float_map:FLOAT_MAP := FLOAT_MAP;
-
+
Section Mapping
-
+
+ map_32:UINTEGER_32;
Section REAL, REAL_32, REAL_64, REAL_80
-
+
- get_map f:SELF <-
( + tab:NATIVE_ARRAY(SELF);
tab := CONVERT(FLOAT_MAP32,NATIVE_ARRAY(SELF)).on FLOAT_MAP32;
tab.put f to 0;
);
-
+
- sign:BOOLEAN <- (map_32 >> 31) = 0; // TRUE if positif, FALSE else.
-
+
- exponent:UINTEGER_32 <- (map_32 >> mantissa_bits) & 0FFh;
-
+
- mantissa:UINTEGER_64 <- (map_32 & 7F_FFFFh);
-
+
Section Public
//
// Format.
//
-
+
- mantissa_bits:INTEGER_8 := 23;
- exponent_bits:INTEGER_8 := 8;
-
+
diff --git a/lib/internal/portable/number/float_map64.li b/lib/internal/portable/number/float_map64.li
index efe6575..e35b866 100644
--- a/lib/internal/portable/number/float_map64.li
+++ b/lib/internal/portable/number/float_map64.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FLOAT_MAP64;
-
+
- comment := "Mapping for REAL_64.";
-
+
Section Inherit
-
+
- parent_float_map:FLOAT_MAP := FLOAT_MAP;
-
+
Section Mapping
-
+
+ map_64:UINTEGER_64;
-
+
Section REAL, REAL_32, REAL_64, REAL_80
-
+
- get_map f:SELF <-
( + tab:NATIVE_ARRAY(SELF);
tab := CONVERT(FLOAT_MAP64,NATIVE_ARRAY(SELF)).on FLOAT_MAP64;
- tab.put f to 0;
+ tab.put f to 0;
);
-
+
- sign:BOOLEAN <- (map_64 >> 63) = 0; // TRUE if positif, FALSE else.
-
+
- exponent:UINTEGER_32 <- ((map_64 >> mantissa_bits) & 07_FFh).to_uinteger_32;
-
+
- mantissa:UINTEGER_64 <- map_64 & ((1 << mantissa_bits)-1);
-
+
Section Public
//
// Format.
//
-
+
- mantissa_bits:INTEGER_8 := 52;
- exponent_bits:INTEGER_8 := 11;
-
+
diff --git a/lib/internal/portable/number/float_map80.li b/lib/internal/portable/number/float_map80.li
index 94cbfd9..3b8ceec 100644
--- a/lib/internal/portable/number/float_map80.li
+++ b/lib/internal/portable/number/float_map80.li
@@ -19,41 +19,41 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FLOAT_MAP80;
-
+
- comment := "Mapping for REAL_80.";
-
+
Section Inherit
-
+
- parent_float_map:FLOAT_MAP := FLOAT_MAP;
-
+
Section Mapping
-
+
+ exp_16:UINTEGER_16;
+ man_64:UINTEGER_64;
-
+
Section REAL, REAL_32, REAL_64, REAL_80
-
+
- get_map f:SELF <-
( + tab:NATIVE_ARRAY(SELF);
tab := CONVERT(FLOAT_MAP80,NATIVE_ARRAY(SELF)).on FLOAT_MAP80;
- tab.put f to 0;
+ tab.put f to 0;
);
-
+
- sign:BOOLEAN <- (exp_16 >> 15) = 0; // TRUE if positif, FALSE else.
-
+
- exponent:UINTEGER_32 <- exp_16 & 07F_FFh;
-
+
- mantissa:UINTEGER_64 <- man_64;
-
+
Section Public
//
// Format.
//
-
+
- mantissa_bits:INTEGER_8 := 64;
- exponent_bits:INTEGER_8 := 15;
-
+
diff --git a/lib/internal/portable/number/float_real.li b/lib/internal/portable/number/float_real.li
index 0476467..8aac6aa 100644
--- a/lib/internal/portable/number/float_real.li
+++ b/lib/internal/portable/number/float_real.li
@@ -19,15 +19,15 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FLOAT_REAL;
-
+
- comment := "Real number of variable decimal part.";
-
- - external := `#include <math.h>`;
-
+
+ - external := `#include <math.h>`;
+
Section Insert
-
+
- parent_float_map:FLOAT_MAP := FLOAT_MAP;
-
+
- parent_real:REAL := REAL;
diff --git a/lib/internal/portable/number/numeric.li b/lib/internal/portable/number/numeric.li
index b61df09..98c9a7f 100644
--- a/lib/internal/portable/number/numeric.li
+++ b/lib/internal/portable/number/numeric.li
@@ -19,38 +19,38 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NUMERIC;
-
+
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Xavier Oswald";
-
+
- comment :="Generic number.";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
//
// Features
//
-
+
- one:SELF <- 1; // Neutral element for `*' and `/'.
-
+
- zero:SELF <- 0; // Neutral element for `+' and `-'.
//
// Functions
- //
-
- - in_range low:SELF to up:SELF :BOOLEAN <-
+ //
+
+ - in_range low:SELF to up:SELF :BOOLEAN <-
(low <= Self) && {up >= Self};
-
+
- sign:INTEGER <-
// Sign of Current (0 -1 or 1).
( + result:INTEGER;
-
+
(Self > 0).if {
result := 1;
}.elseif {Self < 0} then {
@@ -60,74 +60,74 @@ Section Public
)
[
+? {-1 <= result};
- +? {result <= 1};
+ +? {result <= 1};
];
//
// binary operator :
//
-
+
- Self:SELF '-' Left 80 other:SELF :SELF <- `3`;
-
+
- Self:SELF '*' Left 100 other:SELF :SELF <- `4`;
-
+
- Self:SELF '/' Left 100 other:SELF :SELF <- `5`; // ? {other/=0}
-
+
- Self:SELF '+' Left 80 other:SELF :SELF <- Self - -other;
-
+
//
// Unary operator
//
-
+
- '+' Self:SELF :SELF <- Self;
-
+
- '-' Self:SELF :SELF <- SELF.zero - Self;
//
// Compatibility Binary operator
//
-
+
- Self:SELF '-#' Left 80 other:INTEGER :SELF <- Self - other;
-
+
- Self:SELF '*#' Left 100 other:INTEGER :SELF <- Self * other;
-
+
- Self:SELF '/#' Left 100 other:INTEGER :SELF <- Self / other;
-
+
- Self:SELF '+#' Left 80 other:INTEGER :SELF <- Self + other;
-
+
- Self:SELF '>#' Right 60 other:INTEGER :BOOLEAN <- Self > other;
-
+
- Self:SELF '<#' Right 60 other:INTEGER :BOOLEAN <- ! (Self >=# other);
-
+
- Self:SELF '<=#' Right 60 other:INTEGER :BOOLEAN <- ! (Self ># other);
-
+
- Self:SELF '>=#' Right 60 other:INTEGER :BOOLEAN <- (Self ># other) | (Self ==# other);
-
+
- Self:SELF '==#' Right 60 other:INTEGER :BOOLEAN <- (Self = other);
//
// Test binary operator :
//
-
+
- Self:SELF '>' Right 60 other:SELF :BOOLEAN <- `2`;
-
+
- Self:SELF '<' Right 60 other:SELF :BOOLEAN <- ! (Self >= other);
-
+
- Self:SELF '<=' Right 60 other:SELF :BOOLEAN <- ! (Self > other);
-
+
- Self:SELF '>=' Right 60 other:SELF :BOOLEAN <- (Self > other) | (Self = other);
-
- - Self:SELF '==' Right 60 other:E :BOOLEAN <-
+
+ - Self:SELF '==' Right 60 other:E :BOOLEAN <-
( + my_other:SELF;
-
+
my_other := other;
Self = my_other
);
-
+
//
// Switch case :
//
-
+
- when value:SELF then block:{} :SELF <-
// when `value' equals `Self', execute `block'
// You can chain "when ... then ..." between them like : <br/>
@@ -136,22 +136,22 @@ Section Public
(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 <-
// Execute `block' when `Self' is in range of `first_value' to `last_value'
- (
+ (
? {first_value <= last_value};
((Self >= first_value) && {Self <= last_value}).if block;
Self
);
-
+
- else block:{} <-
(
block;
@@ -159,7 +159,7 @@ Section Public
//
// Looping.
//
-
+
- to limit_up:SELF do blc:{SELF;} <-
// Classical loop from `Self' to `limit_up'
(
@@ -168,7 +168,7 @@ Section Public
(Self + 1).to limit_up do blc;
};
);
-
+
- downto limit_down:SELF do blc:{SELF;} <-
// Classical backward loop from `Self' to `limit_up'
(
@@ -177,7 +177,7 @@ Section Public
(Self-1).downto limit_down do blc;
};
);
-
+
- to limit_up:SELF by step:SELF do blc:{SELF;} <-
// Classical loop from `Self' to `limit_up' stepping `step'
(
@@ -186,7 +186,7 @@ Section Public
(Self + step).to limit_up by step do blc;
};
);
-
+
- downto limit_down:SELF by step:SELF do blc:{SELF;} <-
// Classical backward loop from `Self' to `limit_up' stepping `step'
(
@@ -211,11 +211,11 @@ Section Public
//
// Function :
//
-
- - abs:SELF <-
+
+ - abs:SELF <-
// Absolute value of `Self'.
( + result:SELF;
-
+
(Self < 0).if {
result := - Self;
} else {
@@ -223,11 +223,11 @@ Section Public
};
result
);
-
+
- min other:SELF :SELF <-
// Minimum between value of `Self' and `other'
( + result:SELF;
-
+
(Self > other).if {
result := other;
} else {
@@ -235,11 +235,11 @@ Section Public
};
result
);
-
+
- max other:SELF :SELF <-
// Maximum between value of `Self' and `other'
( + result:SELF;
-
+
(Self > other).if {
result := Self;
} else {
@@ -247,31 +247,31 @@ Section Public
};
result
);
-
+
//
// Conversion for other type.
//
-
+
- 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.
// * See: `append_in' to save memory.
( + result:STRING;
-
+
result := STRING.create 11;
append_in result;
result
);
-
- - to_boolean:BOOLEAN <-
+
+ - 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
// creation during the process.
-
- - to_string_format s:SELF :STRING <-
+
+ - to_string_format s:SELF :STRING <-
// Same as `to_string' but the result is on `s' character and the
// number is right aligned.
// * Require: s size large enough for `Self'
@@ -281,21 +281,21 @@ Section Public
-? {to_string.count <= s};
]
( + result:STRING;
-
+
result := to_string;
result.precede_multiple ' ' by (s.to_integer - result.count);
-
+
result
)
[
+? {Result.count = s};
];
-
+
- append_in str:STRING format s:INTEGER <-
// 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.
- (
+ (
append_in str format s with ' ';
);
@@ -311,7 +311,7 @@ Section Public
-? {to_string.count <= s};
]
( + old_count:INTEGER;
-
+
old_count := str.count;
append_in str;
str.insert char to old_count on (s - (str.count - old_count));
@@ -319,11 +319,11 @@ Section Public
[
+? {str.count = (Old str.count + s)};
];
-
+
//
// Print
//
-
+
- print <-
// Print
(
@@ -331,15 +331,15 @@ Section Public
append_in string_tmp;
string_tmp.print;
);
-
+
- print_format s:SELF <-
- // Print with format size `s'
+ // Print with format size `s'
(
string_tmp.clear;
append_in string_tmp format s;
string_tmp.print;
);
-
+
- print_format s:SELF with c:CHARACTER <-
// Print with format size `s' replacing blank character by `c'
(
@@ -347,170 +347,170 @@ Section Public
append_in string_tmp format s with c;
string_tmp.print;
);
-
+
//
// Conversions with tests
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
deferred;
FALSE
);
-
+
//
// - To unsigned integers
//
- - to_uinteger_8:UINTEGER_8 <-
+ - to_uinteger_8:UINTEGER_8 <-
// [ -? {bound_test (UINTEGER_8.minimum) to (UINTEGER_8.maximum)}; ]
- (
+ (
to_raw_uinteger_8
);
- - to_uinteger_16:UINTEGER_16 <-
+ - to_uinteger_16:UINTEGER_16 <-
[ -? {bound_test (UINTEGER_16.minimum) to (UINTEGER_16.maximum)}; ]
- (
+ (
to_raw_uinteger_16
);
- to_uinteger_32:UINTEGER_32 <-
[ -? {bound_test (UINTEGER_32.minimum) to (UINTEGER_32.maximum)}; ]
- (
+ (
to_raw_uinteger_32
);
- - to_uinteger_64:UINTEGER_64 <-
+ - to_uinteger_64:UINTEGER_64 <-
[ -? {bound_test (UINTEGER_64.minimum) to (UINTEGER_64.maximum)}; ]
- (
+ (
to_raw_uinteger_64
);
- - to_uinteger_big:UINTEGER_BIG <-
- (
+ - to_uinteger_big:UINTEGER_BIG <-
+ (
UINTEGER_BIG.create Self
);
-
+
- to_uinteger:UINTEGER <-
[ -? {Self >= 0}; ]
(
to_raw_uinteger
);
-
+
- to_uinteger_cpu:UINTEGER_CPU <-
- [ -? {Self >= 0}; ]
+ [ -? {Self >= 0}; ]
(
to_raw_uinteger_cpu
);
-
+
//
// - To signed integers
//
-
- - to_integer:INTEGER <- to_raw_integer;
-
+
+ - to_integer:INTEGER <- to_raw_integer;
+
- to_integer_8:INTEGER_8 <-
[ -? {bound_test (INTEGER_8.minimum) to (INTEGER_8.maximum)}; ]
- (
+ (
to_raw_integer_8
);
- to_integer_16:INTEGER_16 <-
[ -? {bound_test (INTEGER_16.minimum) to (INTEGER_16.maximum)}; ]
- (
+ (
to_raw_integer_16
);
- to_integer_32:INTEGER_32 <-
[ -? {bound_test (INTEGER_32.minimum) to (INTEGER_32.maximum)}; ]
- (
+ (
to_raw_integer_32
);
- to_integer_64:INTEGER_64 <-
//[ -? {bound_test (INTEGER_64.minimum) to (INTEGER_64.maximum)}; ]
- (
+ (
to_raw_integer_64
);
- - to_integer_big:UINTEGER_BIG <-
- (
+ - to_integer_big:UINTEGER_BIG <-
+ (
deferred;
NULL
);
-
+
//
// - To unsigned fixed reals
//
- to_ureal_16_16:UREAL_16_16 <-
[ -? {bound_test (UREAL_16_16.minimum) to (UREAL_16_16.maximum)}; ]
- (
+ (
(Self *# 1_0000h).to_raw_ureal_16_16
);
- to_ureal_24_8:UREAL_24_8 <-
[ -? {bound_test (UREAL_24_8.minimum) to (UREAL_24_8.maximum)}; ]
- (
+ (
(Self *# 1_00h).to_raw_ureal_24_8
);
- to_ureal_26_6:UREAL_26_6 <-
[ -? {bound_test (UREAL_26_6.minimum) to (UREAL_26_6.maximum)}; ]
- (
+ (
(Self *# 100_0000b).to_raw_ureal_26_6
);
-
+
//
// - To signed fixed reals
//
-
+
- to_real_16_16:REAL_16_16 <-
[ -? {bound_test (REAL_16_16.minimum) to (REAL_16_16.maximum)}; ]
- (
+ (
(Self *# 1_0000h).to_raw_real_16_16
);
- to_real_24_8:REAL_24_8 <-
[ -? {bound_test (REAL_24_8.minimum) to (REAL_24_8.maximum)}; ]
- (
+ (
(Self *# 1_00h).to_raw_real_24_8
);
- to_real_26_6:REAL_26_6 <-
[ -? {bound_test (REAL_26_6.minimum) to (REAL_26_6.maximum)}; ]
- (
+ (
(Self *# 100_0000b).to_raw_real_26_6
);
-
+
//
// - To float reals
//
-
+
- to_real:REAL <- to_raw_real;
-
+
- to_real_32:REAL_32 <-
- (
+ (
to_raw_real_32
);
- to_real_64:REAL_64 <-
- (
+ (
to_raw_real_64
);
- to_real_80:REAL_80 <-
- (
+ (
to_raw_real_80
);
-
+
Section Public
-
+
//
// Convertion format without test.
//
-
+
- to_raw_integer:INTEGER <- CONVERT(SELF,INTEGER ).on Self;
- to_raw_uinteger:UINTEGER <- CONVERT(SELF,UINTEGER ).on Self;
@@ -522,9 +522,9 @@ Section Public
- to_raw_uinteger_32:UINTEGER_32 <- CONVERT(SELF,UINTEGER_32 ).on Self;
- to_raw_uinteger_64:UINTEGER_64 <- CONVERT(SELF,UINTEGER_64 ).on Self;
-
+
- to_raw_uinteger_cpu:UINTEGER_CPU<- CONVERT(SELF,UINTEGER_CPU).on Self;
-
+
- to_raw_integer_8:INTEGER_8 <- CONVERT(SELF,INTEGER_8 ).on Self;
- to_raw_integer_16:INTEGER_16 <- CONVERT(SELF,INTEGER_16 ).on Self;
@@ -532,29 +532,29 @@ Section Public
- to_raw_integer_32:INTEGER_32 <- CONVERT(SELF,INTEGER_32 ).on Self;
- to_raw_integer_64:INTEGER_64 <- CONVERT(SELF,INTEGER_64 ).on Self;
-
+
- to_raw_real:REAL <- CONVERT(SELF,REAL ).on Self;
-
+
- to_raw_ureal_16_16:UREAL_16_16 <- CONVERT(SELF,UREAL_16_16 ).on Self;
- to_raw_ureal_24_8:UREAL_24_8 <- CONVERT(SELF,UREAL_24_8 ).on Self;
- - to_raw_ureal_26_6:UREAL_26_6 <- CONVERT(SELF,UREAL_26_6 ).on Self;
+ - to_raw_ureal_26_6:UREAL_26_6 <- CONVERT(SELF,UREAL_26_6 ).on Self;
- to_raw_real_16_16:REAL_16_16 <- CONVERT(SELF,REAL_16_16 ).on Self;
- to_raw_real_24_8:REAL_24_8 <- CONVERT(SELF,REAL_24_8).on Self;
- - to_raw_real_26_6:REAL_26_6 <- CONVERT(SELF,REAL_26_6).on Self;
+ - to_raw_real_26_6:REAL_26_6 <- CONVERT(SELF,REAL_26_6).on Self;
- to_raw_real_32:REAL_32 <- CONVERT(SELF,REAL_32).on Self;
-
+
- to_raw_real_64:REAL_64 <- CONVERT(SELF,REAL_64).on Self;
- to_raw_real_80:REAL_80 <- CONVERT(SELF,REAL_80).on Self;
Section Private
-
+
- string_tmp:STRING := STRING.create 32;
-
+
diff --git a/lib/internal/portable/number/signed_fixed_real.li b/lib/internal/portable/number/signed_fixed_real.li
index bcd7238..6f22146 100644
--- a/lib/internal/portable/number/signed_fixed_real.li
+++ b/lib/internal/portable/number/signed_fixed_real.li
@@ -19,123 +19,123 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SIGNED_FIXED_REAL;
-
+
- comment := "Signed real number of fixed decimal part.";
-
+
Section Insert
-
+
- parent_fixed_real:FIXED_REAL := FIXED_REAL;
-
+
Section Public
-
+
//
// Bound test
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
(low < to_raw_integer_64) && {up > to_raw_uinteger_64}
);
-
+
//
// Around
//
-
+
- object_size:INTEGER := 4;
- floor:INTEGER <-
// Greatest integral value no greater than Current.
- (
- to_raw_integer_32 >> shift_bits
+ (
+ to_raw_integer_32 >> shift_bits
)
[
+? {Self >= Result};
+? {(Self - Result) < 1};
];
-
+
- ceiling:INTEGER <-
// Smallest integral value no smaller than Current.
- (
- (to_raw_integer_32 + ((1 << shift_bits) - 1)) >> shift_bits
+ (
+ (to_raw_integer_32 + ((1 << shift_bits) - 1)) >> shift_bits
)
[
+? {Self <= Result};
+? {(Self - Result) < 1};
];
-
+
- rounded:INTEGER <-
// Rounded integral value.
(
(to_raw_integer_32 + ((1 << shift_bits) / 2)) >> shift_bits
);
-
+
- truncated_to_integer:INTEGER <- floor;
// Integer part (largest absolute value no greater than Current).
-
+
//
// binary operator :
//
-
- - Self:SELF '-' Left 80 other:SELF :SELF <-
+
+ - Self:SELF '-' Left 80 other:SELF :SELF <-
(
CONVERT(INTEGER_32,SELF).on (to_raw_integer_32 - other.to_raw_integer_32)
);
- - Self:SELF '*#' Left 100 other:INTEGER :SELF <-
- (
+ - Self:SELF '*#' Left 100 other:INTEGER :SELF <-
+ (
CONVERT(INTEGER_32,SELF).on (to_raw_integer_32 * other)
);
-
- - Self:SELF '*' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '*' Left 100 other:SELF :SELF <-
(
CONVERT(INTEGER_64,SELF).on ((to_raw_integer_64 * other.to_raw_integer_64) >> shift_bits)
);
-
- - Self:SELF '/#' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '/#' Left 100 other:INTEGER :SELF <-
(
CONVERT(INTEGER_32,SELF).on (to_raw_integer_32 / other)
);
-
- - Self:SELF '/' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '/' Left 100 other:SELF :SELF <-
(
CONVERT(INTEGER_64,SELF).on ((to_raw_integer_64 << shift_bits) / other.to_raw_integer_64)
);
-
+
- Self:SELF '&' Left 100 other:SELF :SELF <-
(
CONVERT(INTEGER_32,SELF).on (to_raw_integer_32 & other.to_raw_integer_32)
);
-
- - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
(
CONVERT(INTEGER_32,SELF).on (to_raw_integer_32 >> other)
);
-
- - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
(
CONVERT(INTEGER_32,SELF).on (to_raw_integer_32 << other)
);
-
+
//
// Test binary operator :
//
-
- - Self:SELF '>' Right 60 other:SELF :BOOLEAN <-
+
+ - Self:SELF '>' Right 60 other:SELF :BOOLEAN <-
(
to_raw_integer_32 > other.to_raw_integer_32
);
-
+
//
// prefix : Unary operator
//
-
- - '~' Self:SELF :SELF <-
+
+ - '~' Self:SELF :SELF <-
(
CONVERT(INTEGER_32,SELF).on (~ to_raw_integer_32)
);
-
+
diff --git a/lib/internal/portable/number/signed_integer.li b/lib/internal/portable/number/signed_integer.li
index 4965740..fb33543 100644
--- a/lib/internal/portable/number/signed_integer.li
+++ b/lib/internal/portable/number/signed_integer.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SIGNED_INTEGER;
-
+
- comment := "Generic Signed Integer.";
-
+
Section Insert
-
+
- parent_integer:INTEGER := INTEGER;
-
+
Section Public
-
+
- append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,j:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
@@ -46,27 +46,27 @@ Section Public
val := - Self;
buffer.extend '-';
};
-
+
i := buffer.upper+1;
-
- {val = 0}.until_do {
+
+ {val = 0}.until_do {
buffer.extend ((val % 10).digit);
val := val / 10;
};
-
+
j := buffer.upper;
{i >= j}.until_do {
buffer.swap i with j;
j := j - 1;
i := i + 1;
- };
+ };
};
);
-
+
- to_octal:SELF <-
// Gives coresponding octal value.
( + result, unit, current:SELF;
-
+
(Self < 0).if {
result := -((-Self).to_octal);
} else {
@@ -80,33 +80,32 @@ Section Public
};
result
);
-
+
//
// Hashing:
//
-
+
- hash_code:INTEGER <-
( + result:INTEGER;
-
+
(Self < 0).if {
result := ~ Self;
} else {
result := Self;
};
-
+
result
)
[
+? {Result>=0};
];
-
+
//
// Bound test
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
(low < to_raw_integer_64) && {up > to_raw_uinteger_64}
);
-
\ No newline at end of file
diff --git a/lib/internal/portable/number/unsigned_fixed_real.li b/lib/internal/portable/number/unsigned_fixed_real.li
index df3dea7..264d78a 100644
--- a/lib/internal/portable/number/unsigned_fixed_real.li
+++ b/lib/internal/portable/number/unsigned_fixed_real.li
@@ -19,125 +19,125 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := UNSIGNED_FIXED_REAL;
-
+
- comment := "Unsigned real number of fixed decimal part.";
-
+
Section Inherit
-
+
- parent_fixed_real:FIXED_REAL := FIXED_REAL;
-
+
Section Public
-
+
//
// Bound test
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
(up > to_raw_uinteger_64)
);
-
+
//
// Around
//
-
+
- object_size:INTEGER := 4;
-
- - minimum:INTEGER_64 <- 0;
+
+ - minimum:INTEGER_64 <- 0;
- floor:INTEGER <-
// Greatest integral value no greater than Current.
- (
- to_raw_uinteger_32 >> shift_bits
+ (
+ to_raw_uinteger_32 >> shift_bits
)
[
+? {Self <= Result};
+? {(Self - Result) < 1};
];
-
+
- ceiling:INTEGER <-
// Smallest integral value no smaller than Current.
- (
- (to_raw_uinteger_32 + ((1 << shift_bits) - 1)) >> shift_bits
+ (
+ (to_raw_uinteger_32 + ((1 << shift_bits) - 1)) >> shift_bits
)
[
+? {Self >= Result};
+? {(Self - Result) < 1};
];
-
+
- rounded:INTEGER <-
// Rounded integral value.
(
(to_raw_uinteger_32 + ((1 << shift_bits) / 2)) >> shift_bits
);
-
+
- truncated_to_integer:INTEGER <- floor;
// Integer part (largest absolute value no greater than Current).
-
+
//
// binary operator :
//
-
- - Self:SELF '-' Left 80 other:SELF :SELF <-
+
+ - Self:SELF '-' Left 80 other:SELF :SELF <-
(
CONVERT(UINTEGER_32,SELF).on (to_raw_uinteger_32 - other.to_raw_uinteger_32)
);
- - Self:SELF '*#' Left 100 other:INTEGER :SELF <-
- (
+ - Self:SELF '*#' Left 100 other:INTEGER :SELF <-
+ (
CONVERT(UINTEGER_32,SELF).on (to_raw_uinteger_32 * other)
);
-
- - Self:SELF '*' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '*' Left 100 other:SELF :SELF <-
(
CONVERT(UINTEGER_64,SELF).on ((to_raw_uinteger_64 * other.to_raw_uinteger_64) >> shift_bits)
);
-
- - Self:SELF '/#' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '/#' Left 100 other:INTEGER :SELF <-
(
CONVERT(UINTEGER_32,SELF).on (to_raw_uinteger_32 / other)
);
-
- - Self:SELF '/' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '/' Left 100 other:SELF :SELF <-
(
CONVERT(UINTEGER_64,SELF).on ((to_raw_uinteger_64 << shift_bits) / other.to_raw_uinteger_64)
);
-
+
- Self:SELF '&' Left 100 other:SELF :SELF <-
(
CONVERT(UINTEGER_32,SELF).on (to_raw_uinteger_32 & other.to_raw_uinteger_32)
);
-
- - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
(
CONVERT(UINTEGER_32,SELF).on (to_raw_uinteger_32 >> other)
);
-
- - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
(
CONVERT(UINTEGER_32,SELF).on (to_raw_uinteger_32 << other)
);
-
+
//
// Test binary operator :
//
-
- - Self:SELF '>' Right 60 other:SELF :BOOLEAN <-
+
+ - Self:SELF '>' Right 60 other:SELF :BOOLEAN <-
(
to_raw_uinteger_32 > other.to_raw_uinteger_32
);
-
+
//
// prefix : Unary operator
//
-
- - '~' Self:SELF :SELF <-
+
+ - '~' Self:SELF :SELF <-
(
CONVERT(UINTEGER_32,SELF).on (~ to_raw_uinteger_32)
);
-
+
diff --git a/lib/internal/portable/number/unsigned_integer.li b/lib/internal/portable/number/unsigned_integer.li
index 63fdc08..23836cf 100644
--- a/lib/internal/portable/number/unsigned_integer.li
+++ b/lib/internal/portable/number/unsigned_integer.li
@@ -19,59 +19,59 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := UNSIGNED_INTEGER;
-
+
- comment := "Generic Unsigned Integer.";
-
+
Section Insert
-
+
- parent_integer:INTEGER := INTEGER;
-
+
Section Public
-
+
//
// Range
//
-
+
- minimum:INTEGER_64 := 0.to_raw_integer_64;
-
+
//
// Function :
//
-
+
- sign:INTEGER <-
// Sign of Current (0 -1 or 1).
- (
- (Self != 0).to_integer;
+ (
+ (Self != 0).to_integer;
);
-
+
- abs:SELF <- Self; // Absolute value of `self'.
-
+
//
// Convertion
//
-
+
- append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:SELF;
+ i,j:INTEGER;
? {buffer!=NULL};
-
+
(Self = 0).if {
buffer.extend '0';
} else {
-
+
i := buffer.upper+1;
-
+
val := Self;
{val = 0}.until_do {
buffer.extend ((val % 10).digit);
val := val / 10;
};
j := buffer.upper;
-
+
{i >= j}.until_do {
buffer.swap i with j;
j := j - 1;
@@ -80,16 +80,16 @@ Section Public
};
);
-
+
- print <-
- (
+ (
print_positif;
);
-
+
- to_octal:SELF <-
// Gives coresponding octal value.
( + result, unit, current:SELF;
-
+
current := Self;
unit := 1;
{current!=0}.while_do {
@@ -99,31 +99,31 @@ Section Public
};
result
);
-
+
//
// Hashing:
//
-
+
- hash_code:INTEGER <- to_integer;
-
+
//
// Looping
//
-
+
- downto limit_down:SELF do blc:{SELF; } <-
(
- (Self+1).downto_unsigned limit_down do blc;
+ (Self+1).downto_unsigned limit_down do blc;
);
-
+
//
// Bound test
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
(up > to_raw_uinteger_64)
);
-
+
Section Private
- downto_unsigned limit_down:SELF do blc:{SELF; } <-
@@ -134,4 +134,3 @@ Section Private
};
);
-
\ No newline at end of file
diff --git a/lib/internal/portable/string/character_ref.li b/lib/internal/portable/string/character_ref.li
index b973d00..1c93cec 100644
--- a/lib/internal/portable/string/character_ref.li
+++ b/lib/internal/portable/string/character_ref.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CHARACTER_REF;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :=" .";
-
+
Section Inherit
-
+
- parent_hashable:HASHABLE <- HASHABLE;
-
+
- parent_comparable:COMPARABLE <- COMPARABLE;
-
+
Section Public
-
+
- item:CHARACTER;
-
+
- set_item value:CHARACTER <-
(
item := value;
@@ -46,7 +46,7 @@ Section Public
(
item < other.item
);
-
+
- code:INTEGER_8 <-
// ASCII code of Current
(
@@ -67,14 +67,14 @@ Section Public
// Object Printing:
- out_in_tagged_out_memory <- fill_tagged_out_memory;
-
+
- fill_tagged_out_memory <-
(
item.fill_tagged_out_memory;
);
-
+
// Hashing:
-
+
- hash_code:INTEGER <-
(
item.hash_code
diff --git a/lib/internal/portable/string/string_buffer.li b/lib/internal/portable/string/string_buffer.li
index 6008935..fac1a0b 100644
--- a/lib/internal/portable/string/string_buffer.li
+++ b/lib/internal/portable/string/string_buffer.li
@@ -56,7 +56,7 @@ Section Public
- from_string s:STRING :SELF <- create_from s;
- to_string :STRING <- parent_string;
-
+
- to_abstract_string:ABSTRACT_STRING <- parent_string;
- Self:SELF '+' other:ABSTRACT_STRING :STRING_BUFFER <-
diff --git a/lib/internal/portable/system/system_detect.li b/lib/internal/portable/system/system_detect.li
index 02759ef..00bb24f 100644
--- a/lib/internal/portable/system/system_detect.li
+++ b/lib/internal/portable/system/system_detect.li
@@ -26,7 +26,7 @@ Section Header
- copyright := "2008 Mildred Ki'Lya";
- bibliography := "";
- comment := "Detect charecteristics of the system/C compiler";
-
+
// Don't hesitate to add others slots to detect your platform.
Section Inherit
diff --git a/lib/standard/boolean/boolean.li b/lib/standard/boolean/boolean.li
index 968d70d..0a6263a 100644
--- a/lib/standard/boolean/boolean.li
+++ b/lib/standard/boolean/boolean.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded BOOLEAN;
@@ -29,111 +29,111 @@ Section Header
- type := `char`;
- default := FALSE;
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
-Section Private
-
+
+Section Private
+
- deferred_boolean:BOOLEAN <-
( + result:BOOLEAN;
-
+
deferred;
result
);
-
+
Section Public
//
// Conditional :
//
-
+
- if_true block:{} <- deferred;
-
+
- if_false block:{} <- deferred;
-
+
- if true_block:{} else false_block:{} <- `ERROR`; //deferred;
-
+
- if_true true_block:{} else false_block:{} <- deferred;
-
+
- if_false true_block:{} else false_block:{} <- deferred;
-
+
- if true_block:{} :BOOLEAN <- deferred_boolean;
-
+
- elseif cond:{BOOLEAN} then block:{} :BOOLEAN <- deferred_boolean;
-
+
- elseif cond:{BOOLEAN} then block:{} else block_else:{} <- deferred;
-
- - else_if cond:{BOOLEAN} then block:{} :BOOLEAN <-
+
+ - else_if cond:{BOOLEAN} then block:{} :BOOLEAN <-
// Alias.
elseif cond then block;
-
- - else_if cond:{BOOLEAN} then block:{} else block_else:{} <-
+
+ - else_if cond:{BOOLEAN} then block:{} else block_else:{} <-
// Alias.
elseif cond then block else block_else;
-
+
//
// Binary operator :
//
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <- Self = other;
-
+
- Self:SELF '!==' Right 60 other:SELF :BOOLEAN <- Self != other;
-
+
- Self:SELF '||' Left 10 other:{BOOLEAN} :BOOLEAN <- deferred_boolean;
-
- - Self:SELF '&&' Left 20 other:{BOOLEAN} :BOOLEAN <- deferred_boolean;
-
+
+ - Self:SELF '&&' Left 20 other:{BOOLEAN} :BOOLEAN <- deferred_boolean;
+
- Self:SELF '|' Left 10 other:BOOLEAN :BOOLEAN <- deferred_boolean;
-
+
- Self:SELF '&' Left 20 other:BOOLEAN :BOOLEAN <- deferred_boolean;
-
+
- Self:SELF '^' Left 10 other:BOOLEAN :BOOLEAN <- deferred_boolean;
-
+
- Self:SELF '->' Right 25 other:BOOLEAN :BOOLEAN <- deferred_boolean;
- Self:SELF '->>' Right 25 other:{BOOLEAN} :BOOLEAN <- deferred_boolean;
-
+
- Self:SELF '=>' s:ABSTRACT_STRING <- deferred;
-
+
//
// Prefix operator
//
-
+
- '!' Self:SELF :BOOLEAN <- deferred;
-
+
//
// Convertion
//
-
- - to_string:STRING <-
+
+ - to_string:STRING <-
( + result:STRING;
-
+
deferred;
result
);
-
- - to_integer:INTEGER <-
+
+ - to_integer:INTEGER <-
( + result:INTEGER;
-
+
deferred;
result
);
-
- - to_character:CHARACTER <-
+
+ - to_character:CHARACTER <-
( + result:CHARACTER;
-
+
deferred;
result
);
-
+
- append_in str:STRING <- str.append to_string;
//
// Output.
//
-
+
- print <-
(
deferred;
diff --git a/lib/standard/boolean/false.li b/lib/standard/boolean/false.li
index 078c39e..5c88a40 100644
--- a/lib/standard/boolean/false.li
+++ b/lib/standard/boolean/false.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded FALSE;
@@ -29,24 +29,24 @@ Section Header
- type := `char`;
- default := FALSE;
-
+
Section Inherit
-
+
- inherit_boolean:BOOLEAN := BOOLEAN;
-
+
Section Public
-
+
//
// Conditional :
//
-
+
- if_true block:{};
-
+
- if_false block:{} <-
( //? {block!=NULL};
block.value;
);
-
+
- if true_block:{} else false_block:{} <-
(
false_block.value;
@@ -56,24 +56,24 @@ Section Public
(
false_block.value;
);
-
- - if_false true_block:{} else false_block:{} <-
+
+ - if_false true_block:{} else false_block:{} <-
(
true_block.value;
);
-
+
- if true_block:{} :BOOLEAN <- FALSE;
-
+
- elseif cond:{BOOLEAN} then block:{} :BOOLEAN <-
( + result:BOOLEAN;
-
+
result := cond.value;
result.if {
block.value;
};
result
);
-
+
- elseif cond:{BOOLEAN} then block:{} else block_else:{} <-
(
(cond.value).if {
@@ -82,49 +82,49 @@ Section Public
block_else.value;
};
);
-
+
//
// Binary operator :
//
-
+
- Self:SELF '||' Left 10 other:{BOOLEAN} :BOOLEAN <- other.value;
-
+
- Self:SELF '&&' Left 20 other:{BOOLEAN} :BOOLEAN <- FALSE;
-
+
- Self:SELF '|' Left 10 other:BOOLEAN :BOOLEAN <- other;
-
+
- Self:SELF '&' Left 20 other:BOOLEAN :BOOLEAN <- FALSE;
-
+
- Self:SELF '^' Left 10 other:BOOLEAN :BOOLEAN <- other;
-
+
- Self:SELF '->' Right 25 other:BOOLEAN :BOOLEAN <- TRUE;
-
+
- Self:SELF '->>' Right 25 other:{BOOLEAN} :BOOLEAN <- TRUE;
-
+
- Self:SELF '=>' s:ABSTRACT_STRING <-
(
);
-
+
//
// Prefix operator
//
-
+
- '!' Self:SELF :BOOLEAN <- TRUE;
-
+
//
// Convertion
//
-
+
- to_string:STRING <- "0".to_string;
-
+
- to_integer:INTEGER <- 0;
-
+
- to_character:CHARACTER <- '0';
-
+
//
// Output.
//
-
+
- print <-
(
"FALSE".print;
diff --git a/lib/standard/boolean/true.li b/lib/standard/boolean/true.li
index 592bce9..3e60d8b 100644
--- a/lib/standard/boolean/true.li
+++ b/lib/standard/boolean/true.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded TRUE;
@@ -29,87 +29,87 @@ Section Header
- type := `char`;
- default := TRUE;
-
+
Section Inherit
-
+
- inherit_boolean:BOOLEAN := BOOLEAN;
-
+
Section Public
-
+
//
// Conditional :
//
-
+
- if_true block:{} <-
(
block.value;
);
-
+
- if_false block:{};
-
+
- if true_block:{} else false_block:{} <-
(
true_block.value;
);
-
+
- if_true true_block:{} else false_block:{} <-
(
true_block.value;
);
-
- - if_false true_block:{} else false_block:{} <-
+
+ - if_false true_block:{} else false_block:{} <-
(
false_block.value;
);
-
+
- if true_block:{} :BOOLEAN <-
(
true_block.value;
TRUE
);
-
+
- elseif cond:{BOOLEAN} then block:{} :BOOLEAN <- TRUE;
-
+
- elseif cond:{BOOLEAN} then block:{} else block_else:{};
-
+
//
// Binary operator :
//
-
+
- Self:SELF '||' Left 10 other:{BOOLEAN} :BOOLEAN <- TRUE; // or else
-
+
- Self:SELF '&&' Left 20 other:{BOOLEAN} :BOOLEAN <- other.value; // and then
-
+
- Self:SELF '|' Left 10 other:BOOLEAN :BOOLEAN <- TRUE; // or
-
+
- Self:SELF '&' Left 20 other:BOOLEAN :BOOLEAN <- other; // and
-
+
- Self:SELF '^' Left 10 other:BOOLEAN :BOOLEAN <- ! other;
-
+
- Self:SELF '->' Right 25 other:BOOLEAN :BOOLEAN <- other;
- Self:SELF '->>' Right 25 other:{BOOLEAN} :BOOLEAN <- other.value;
-
+
- Self:SELF '=>' s:ABSTRACT_STRING <-
(
s.print;
`while (1)`;
);
-
+
//
// Prefix operator
//
-
+
- '!' Self:SELF :BOOLEAN <- FALSE;
-
+
//
// Conversion
//
-
+
- to_string:STRING <- "1".to_string; // BSBS: A revoir ...
-
+
- to_integer:INTEGER <- 1;
-
+
- to_character:CHARACTER <- '1';
//
diff --git a/lib/standard/collection/array.li b/lib/standard/collection/array.li
index eaa5955..f68abd6 100644
--- a/lib/standard/collection/array.li
+++ b/lib/standard/collection/array.li
@@ -19,48 +19,48 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ARRAY(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment :=" General purpose resizable ARRAYs .";
-
+
// General purpose resizable ARRAYs as they are define in the Eiffel language definition.
// The `lower' bound can be any arbitrary value, even a negative one.<br/> <br/>
//
- // This implementation uses only one chunk of memory, the `storage' area which is a
- // NATIVE_ARRAY. One must keep in mind that this internal `storage' area is always kept
+ // This implementation uses only one chunk of memory, the `storage' area which is a
+ // NATIVE_ARRAY. One must keep in mind that this internal `storage' area is always kept
// left align. Thus, you can expect good performances while using an ARRAY to modelize a
// stack behavior with `add_last' / `last' / `remove_last'.<br/>
- // Conversely `add_first' and `remove_first' are likely to slow down your program if
- // they are too often used. If the fact that `lower' is always stuck to 0 is not a
+ // Conversely `add_first' and `remove_first' are likely to slow down your program if
+ // they are too often used. If the fact that `lower' is always stuck to 0 is not a
// problem for you, also consider FAST_ARRAY to get better performances.<br/>
-
+
Section Inherit
-
+
+ parent_arrayed_collection:Expanded ARRAYED_COLLECTION(V);
-
+
Section Public
-
+
+ lower:INTEGER; // Lower index bound.
-
+
//
// Creation and Modification:
//
-
+
- create min_index:INTEGER to max_index:INTEGER :SELF <-
// Prepare the array to hold values for indexes in range
// [`min_index' .. `max_index']. Set all values to default.
// When `max_index' = `min_index' - 1, the array `is_empty'.
( + result:SELF;
-
+
result := SELF.clone;
result.make min_index to max_index;
result
);
-
+
- make min_index:INTEGER to max_index:INTEGER <-
// Prepare the array to hold values for indexes in range
// [`min_index' .. `max_index']. Set all values to default.
@@ -72,25 +72,25 @@ Section Public
[ ...
{min_index <= max_index + 1} -? "Valid bounds.";
]
- (
+ (
ensure_capacity (max_index - min_index + 1) and_bounds min_index to max_index;
)
[ ...
"Lower set." +? { lower = min_index };
"Upper set." +? { upper = max_index };
- "Items set." +? { all_default };
+ "Items set." +? { all_default };
];
-
+
- create_with_capacity needed_capacity:INTEGER lower low:INTEGER :SELF <-
// Create an empty array with `capacity' initialized
// at least to `needed_capacity' and `lower' set to `low'.
( + result:SELF;
-
+
result := clone;
result.with_capacity needed_capacity lower low;
result
);
-
+
- with_capacity needed_capacity:INTEGER lower low:INTEGER <-
// Create an empty array with `capacity' initialized
// at least to `needed_capacity' and `lower' set to `low'.
@@ -105,9 +105,9 @@ Section Public
+? { needed_capacity <= capacity };
+? { lower = low };
];
-
+
Section Public
-
+
- ensure_capacity needed_capacity:INTEGER and_bounds low:INTEGER to up:INTEGER <-
// Extend needed capacity and bouds if necessary
// * Require: `up' superior or equal to `low' - 1
@@ -129,11 +129,11 @@ Section Public
+? { upper = up };
+? {all_default};
];
-
+
//
// Modification:
//
-
+
- resize min_index:INTEGER to max_index:INTEGER <-
// Resize to bounds `min_index' and `max_index'. Do not lose any
// item whose index is in both [`lower' .. `upper'] and
@@ -146,7 +146,7 @@ Section Public
-? { min_index <= max_index + 1 };
]
( + needed, offset, intersize:INTEGER;
-
+
needed := max_index - min_index + 1;
( needed > 0 ).if {
( needed > capacity ).if {
@@ -188,15 +188,15 @@ Section Public
+? { lower = min_index };
+? { upper = max_index };
];
-
-
+
+
- reindex new_lower:INTEGER <-
// Change indexing to take in account the expected `new_lower'
// index. The `upper' index is translated accordingly.
// * Ensure: `lower' is equal to `new_lower'
// * Ensure: `count' is equal to `count' before
( + i:INTEGER;
-
+
i := new_lower - lower;
lower := lower + i;
upper := upper + i;
@@ -205,15 +205,15 @@ Section Public
+? { lower = new_lower };
+? { count = Old count };
];
-
+
//
// Implementation of deferred:
//
-
+
- subarray min:INTEGER to max:INTEGER :SELF <-
// Return the subarray between `min' to `max'
// * Ensure: `Result.lower' is equal to `min' before
- ( + result:SELF;
+ ( + result:SELF;
result := slice min to max;
result.reindex min;
@@ -222,34 +222,34 @@ Section Public
[ ...
+? { Result.lower = min };
];
-
+
- is_empty:BOOLEAN <-
// Is Self empty ?
( upper < lower );
-
- - count:INTEGER <-
- //Size of current
+
+ - count:INTEGER <-
+ //Size of current
( upper - lower + 1 );
-
+
- item i:INTEGER :V <-
// Item at the corresponding index `i'.
// * Description en Francais : Item à l'index `i'
// * See: `lower', `upper', `valid_index', `put', `swap'
- (
+ (
storage.item (i - lower)
);
-
+
- put element:V to i:INTEGER <-
// Make `element' the item at index `i'.
// * See: `lower', `upper', `valid_index', `item', `swap', `force'.
- (
- storage.put element to (i - lower);
+ (
+ storage.put element to (i - lower);
);
-
+
- force element:V to index:INTEGER <-
// Make `element' the item at index `i', reindexing array if necessary.
// * See: `lower', `upper', `valid_index', `item', `swap', `force'.
- (
+ (
(upper < index).if {
(index = upper + 1).if {
add_last element;
@@ -265,13 +265,13 @@ Section Public
};
)
[ ...
- +? { lower = index.min (Old lower) };
+ +? { lower = index.min (Old lower) };
];
-
+
- copy other:SELF <-
// Copy `other' into Self
( + needed_capacity:INTEGER;
-
+
lower := other.lower;
upper := other.upper;
needed_capacity := upper - lower + 1;
@@ -283,24 +283,24 @@ Section Public
storage.copy_from (other.storage) until (needed_capacity - 1);
};
);
-
+
- set_all_with v:V <-
- // Set all element with `v'
- (
- storage.set_all_with v until (upper - lower);
+ // Set all element with `v'
+ (
+ storage.set_all_with v until (upper - lower);
);
-
+
- remove_first <-
// Remove the first `element'
// * Ensure: `upper' has same value before and after
- (
+ (
storage.remove_first (upper - lower);
lower := lower + 1;
)
[ ...
+? {upper = Old upper};
];
-
+
- remove_head n:INTEGER <-
// Remove the n firsts `element'
// * Ensure: `upper' has same value before and after
@@ -311,31 +311,31 @@ Section Public
[ ...
+? {upper = Old upper};
];
-
+
- remove index:INTEGER <-
// Remove the nth `element'
- (
+ (
storage.remove (index - lower) until (upper - lower);
- upper := upper - 1;
+ upper := upper - 1;
);
-
+
- clear <-
// Clear the array
// * Ensure: `capacity' has same value before and after
(
- upper := lower - 1;
+ upper := lower - 1;
)
[ ...
- +? {capacity = Old capacity};
+ +? {capacity = Old capacity};
];
-
+
- add_first element:V <-
// Add a new item in first position : `count' is increased by
// one and all other items are shifted right.
//
// * See: `add_last', `first', `last', `add'.
- (
+ (
(upper < lower).if {
add_last element;
} else {
@@ -344,13 +344,13 @@ Section Public
put (element,lower);
};
);
-
+
- add_last element:V <-
// Add a new item at the end : `count' is increased by one.
//
// * See: `add_first', `last', `first', `add'.
( + new_capacity:INTEGER;
-
+
( capacity < count + 1 ).if {
( capacity = 0 ).if {
new_capacity := 16;
@@ -363,14 +363,14 @@ Section Public
};
};
upper := upper + 1;
- put element to upper;
+ put element to upper;
);
-
+
- from_collection model:COLLECTION(V) <-
// Initialize the current object with the contents of `model'
(
- with_capacity ((model.count),(model.lower));
- upper := modele.upper;
+ with_capacity ((model.count),(model.lower));
+ upper := modele.upper;
(model.lower).to (model.upper) do { i:INTEGER;
put ((model.item i),i);
};
@@ -379,56 +379,56 @@ Section Public
+? { lower = model.lower };
+? { upper = model.upper };
];
-
+
- all_default:BOOLEAN <-
(
storage.all_default (upper - lower)
);
-
+
- occurrences element:V :INTEGER <-
- (
+ (
storage.occurrences element until (upper - lower)
);
-
+
- fast_occurrences element:V :INTEGER <-
- (
+ (
storage.fast_occurrences element until (upper - lower)
);
-
+
- first_index_of element:V :INTEGER <-
( + result:INTEGER;
-
+
(upper >= lower).if {
result := lower + storage.first_index_of element until (upper - lower);
} else {
result := lower;
};
);
-
+
- index_of element:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
-
+
(upper >= lower).if {
result := lower + storage.index_of (element,start_index - lower) until (upper - lower);
} else {
result := lower;
};
- result
+ result
);
-
+
- reverse_index_of element:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
-
+
(upper >= lower).if {
result := lower + storage.reverse_index_of element from (start_index - lower);
} else {
result := lower;
};
);
-
+
- fast_index_of element:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
-
+
(upper >= lower).if {
result := lower + storage.fast_index_of (element,start_index - lower) until (upper - lower);
} else {
@@ -436,10 +436,10 @@ Section Public
};
result
);
-
+
- fast_reverse_index_of element:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
-
+
(upper >= lower).if {
result := lower + storage.fast_reverse_index_of element from (start_index - lower);
} else {
@@ -447,36 +447,36 @@ Section Public
};
result
);
-
+
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <-
- ( + result:BOOLEAN;
-
+ ( + result:BOOLEAN;
+
(Self = other).if {
result := true;
}.elseif {(lower = other.lower) && {upper = other.upper}} then {
result := storage.fast_memcmp (other.storage) until count;
- };
+ };
result
);
-
+
- is_equal_map other:SELF :BOOLEAN <-
( + result:BOOLEAN;
-
+
( Self = other ).if {
result := true;
}.elseif {(lower = other.lower) && {upper = other.upper}} then {
result := storage.memcmp (other.storage) until count;
- };
+ };
result
);
-
+
- slice min:INTEGER to max:INTEGER :SELF <-
( + result:SELF;
-
+
result := SELF.create lower to (lower + max - min);
(max >= min).if {
// Slice not empty
result.storage.slice_copy storage to 0 from (min - lower) to (max - lower);
- };
+ };
);
-
+
diff --git a/lib/standard/collection/array2.li b/lib/standard/collection/array2.li
index ed833d9..fb5cf90 100644
--- a/lib/standard/collection/array2.li
+++ b/lib/standard/collection/array2.li
@@ -19,46 +19,46 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ARRAY2(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :=" General prurpose, resizable, two dimensional array.";
-
+
Section Inherit
+ parent_collection2:Expanded COLLECTION2(V);
-
+
Section Public
-
+
+ lower1:INTEGER;
+ lower2:INTEGER;
-
+
+ upper1:INTEGER;
+ upper2:INTEGER;
-
+
Section ARRAY2
-
+
+ storage:NATIVE_ARRAY(V);
// To store elements line by line.
+ capacity:INTEGER;
// Number of elements in `storage'.
-
+
Section Public
-
+
//
// Creation / modification:
//
-
+
- create (line_min, column_min:INTEGER) to (line_max, column_max:INTEGER) :SELF <-
// Reset all bounds `line_minimum' / `line_maximum' / `column_minimum' and
// `column_maximum' using arguments as new values.
// All elements are set to the default value of type E.
( + result:SELF;
-
+
result:= clone;
result.make (line_min, column_min) to (line_max, column_max);
result
@@ -83,7 +83,7 @@ Section Public
} else {
capacity := count;
storage := NATIVE_ARRAY(V).create count;
- };
+ };
)
[ ...
+? {line_minimum = line_min};
@@ -94,13 +94,13 @@ Section Public
- from_collection2 model:COLLECTION2(V) <-
(
- make (model.line_minimum,model.column_minimum)
+ make (model.line_minimum,model.column_minimum)
to (model.line_maximum,model.column_maximum);
-
+
line_minimum.to line_maximum do { i:INTEGER;
column_minimum.to column_maximum do { j:INTEGER;
put (model.item (i,j)) to (i,j);
- };
+ };
};
)
[ ...
@@ -108,7 +108,7 @@ Section Public
+? { lower2 = model.lower2 };
];
- - from_collection contents:COLLECTION(V)
+ - from_collection contents:COLLECTION(V)
size (line_min,column_min:INTEGER) to (line_max,column_max:INTEGER) <-
// Reset all bounds using `line_min', `line_max', `column_min',
// and `column_max' .
@@ -118,11 +118,11 @@ Section Public
-? { column_min <= column_max };
-? { contents.count = (line_max - line_min + 1) * (column_max - column_min +1) };
]
- (
- make (line_min,column_min) to (line_max,column_max);
+ (
+ make (line_min,column_min) to (line_max,column_max);
0.to (count - 1) do { i:INTEGER;
storage.put (contents.item (contents.lower + i)) to i;
- };
+ };
)
[ ...
+? { line_minimum = line_min };
@@ -131,7 +131,7 @@ Section Public
+? { column_maximum = column_max };
+? { count = contents.count };
];
-
+
- from_model model:COLLECTION(COLLECTION(V)) <-
// The `model' is used to fill line by line the COLLECTION2.
// Assume all sub-collections of `model' have the same indexing.
@@ -141,7 +141,7 @@ Section Public
(model.lower).to (modele.upper) do { line:INTEGER;
(model.first.lower).to (model.first.upper) do { column:INTEGER;
put (model.item line.item column) to (line,column);
- };
+ };
};
)
[ ...
@@ -150,11 +150,11 @@ Section Public
-? { column_minimum = model.first.lower};
-? { column_maximum = model.first.upper};
];
-
+
//
// Resizing:
//
-
+
- resize (line_min, column_min:INTEGER) to (line_max, column_max:INTEGER) <-
// Resize bounds of the Current array
[ ...
@@ -162,17 +162,17 @@ Section Public
-? { column_max >= column_min };
]
( + tmp:SELF;
-
- tmp := SELF.create (line_min,column_min) to (line_max, column_max);
+
+ tmp := SELF.create (line_min,column_min) to (line_max, column_max);
// BSBS: It may be possible to avoid this ceation when :
// BSBS: new `capacity' <= old `capacity'
lower1.to line_maximum do { l:INTEGER;
lower2.to column_maximum do { c:INTEGER;
(tmp.valid_index (l,c)).if {
tmp.put (item (l,c)) to (l,c);
- };
- };
- };
+ };
+ };
+ };
standard_copy tmp;
)
[ ...
@@ -181,72 +181,72 @@ Section Public
+? { column_minimum = column_min };
+? { column_maximum = column_max };
];
-
+
//
// Implementation of others feature from COLLECTION2:
//
-
+
- item (line,column:INTEGER) :V <-
(
storage.item ((line - lower1) * count2 + column - lower2)
);
-
+
- put element:V to (line,column:INTEGER) <-
(
storage.put element to ((line - lower1) * count2 + column - lower2);
);
-
+
- count1:INTEGER <-
(
upper1 - lower1 + 1
);
-
+
- count2:INTEGER <-
(
upper2 - lower2 + 1
);
-
+
- count:INTEGER <-
(
count1 * count2
);
-
+
- force x:V to (line, column:INTEGER) <-
(
(! valid_index (line,column)).if {
- resize (line.min lower1,column.min lower2) to
+ resize (line.min lower1,column.min lower2) to
(line.max upper1,column.max upper2);
};
put x to (line,column);
);
-
+
- set_all_with element:V <-
(
storage.set_all_with element until (count - 1);
);
-
+
- replace_all old_value:V with new_value:V <-
(
storage.replace_all old_value with new_value until (count - 1);
);
-
+
- fast_replace_all old_value:V with new_value:V <-
(
storage.fast_replace_all old_value with new_value until (count - 1);
);
-
- - sub_collection2 (line_min, column_min:INTEGER) to (line_max, column_max:INTEGER) :SELF <-
+
+ - sub_collection2 (line_min, column_min:INTEGER) to (line_max, column_max:INTEGER) :SELF <-
( + k:INTEGER;
+ result:SELF;
-
- result := SELF.create (line_min,column_min) to (line_max,column_max);
+
+ result := SELF.create (line_min,column_min) to (line_max,column_max);
k := 0;
- line_min.to line_max do { i:INTEGER;
+ line_min.to line_max do { i:INTEGER;
column_min.to column_max do { j:INTEGER;
result.storage.put (item (i,j)) to k;
k := k + 1;
- };
- };
+ };
+ };
result
)
[ ...
@@ -255,51 +255,51 @@ Section Public
+? { result.upper1 = line_max };
+? { result.upper2 = column_max };
];
-
+
//
// Looking and comparison:
//
-
+
- occurrences elt:V :INTEGER <-
(
- storage.occurrences elt until (count - 1)
+ storage.occurrences elt until (count - 1)
);
-
+
- fast_occurrences elt:V :INTEGER <-
(
- storage.fast_occurrences elt until (count - 1)
+ storage.fast_occurrences elt until (count - 1)
);
-
+
- has x:V :BOOLEAN <-
// Search if a element x is in the array using `equal'.
// See also `fast_has' to chose the apropriate one.
( + result:BOOLEAN;
-
+
(count > 0).if {
result := storage.first_index_of x until (count - 1) <= count - 1;
};
result
);
-
+
- fast_has x:V :BOOLEAN <-
// Search if a element x is in the array using `='.
( + result:BOOLEAN;
-
+
(count > 0).if {
result := storage.fast_first_index_of x until (count - 1) <= count - 1;
};
result
);
-
+
- all_default:BOOLEAN <-
(
storage.all_default (count - 1)
);
-
+
- swap (line1, column1:INTEGER) with (line2, column2:INTEGER) <-
( + tmp:V;
- + c2, index1, index2:INTEGER;
-
+ + c2, index1, index2:INTEGER;
+
c2 := count2;
index1 := (line1 - lower1) * c2 + column1 - lower2;
index2 := (line2 - lower1) * c2 + column2 - lower2;
@@ -307,7 +307,7 @@ Section Public
storage.put (storage.item index2) to index1;
storage.put tmp to index2;
);
-
+
- copy other:SELF <-
(
lower1 := other.lower1;
@@ -320,7 +320,7 @@ Section Public
};
storage.copy_from (other.storage) until (count - 1);
);
-
+
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <-
(
+ result:BOOLEAN;
@@ -334,32 +334,32 @@ Section Public
} else {
result := storage.memcmp (other.storage) until count;
};
-
+
result
);
-
+
//
// Other features:
//
-
+
- transpose <-
// Transpose the Current array
( + oldu1,oldu2 :INTEGER;
+ oldl1,oldl2 :INTEGER;
+ tmp1,tmp2:INTEGER;
-
+
oldu1 := line_maximum;
oldu2 := column_maximum;
oldl1 := lower1;
oldl2 := lower2;
tmp1 := lower1.min lower2;
tmp2 := line_maximum.max column_maximum;
- resize (tmp1,tmp1) to (tmp2,tmp2);
- lower1.to line_maximum do { i:INTEGER;
+ resize (tmp1,tmp1) to (tmp2,tmp2);
+ lower1.to line_maximum do { i:INTEGER;
(i + 1).to column_maximum do { j:INTEGER;
swap (i,j) with (j,i);
};
- };
+ };
resize (oldl2,oldl1) to (oldu2,oldu1);
)
[ ...
@@ -369,19 +369,19 @@ Section Public
+? { column_maximum = Old line_maximum };
+? { count = Old count };
];
-
+
- to_external:POINTER <-
// Gives C access to the internal `storage' (may be dangerous).
(
storage.to_external
);
-
+
//
// Invariant.
//
-
+
// [ ...
// -? { count2 = upper2 - lower2 + 1 };
// -? { capacity >= count }
-// ];
-
+// ];
+
diff --git a/lib/standard/collection/array3.li b/lib/standard/collection/array3.li
index 362c849..273d681 100644
--- a/lib/standard/collection/array3.li
+++ b/lib/standard/collection/array3.li
@@ -19,60 +19,60 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ARRAY3(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment :=" General prurpose, resizable, three dimensional array..";
-
+
Section Inherit
-
+
+ parent_collection3:Expanded COLLECTION3(V);
-
+
Section Public
-
+
+ lower1:INTEGER;
+ lower2:INTEGER;
+ lower3:INTEGER;
-
+
+ upper1:INTEGER;
+ upper2:INTEGER;
+ upper3:INTEGER;
-
+
+ count1:INTEGER;
+ count2:INTEGER;
+ count3:INTEGER;
-
+
+ count:INTEGER;
-
+
Section ARRAY3
-
+
+ storage:NATIVE_ARRAY(V);
// To store elements line by line.
-
+
+ capacity:INTEGER;
// Number of elements in `storage'.
-
+
Section Public
-
+
//
// Creation / modification:
- //
-
- - create (line_min, column_min, depth_min:INTEGER)
+ //
+
+ - create (line_min, column_min, depth_min:INTEGER)
to (line_max, column_max, depth_max:INTEGER) :SELF <-
// Reset all bounds `line_minimum' / `line_maximum' / `column_minimum'
// `column_maximum' / `depth_min' and `depth_max' using arguments as
// new values. All elements are set to the default value of type E.
( + result:SELF;
-
+
result := clone;
result.make (line_min, column_min, depth_min) to (line_max, column_max, depth_max);
result
- );
-
+ );
+
- make (line_min, column_min, depth_min:INTEGER) to (line_max, column_max, depth_max:INTEGER) <-
// Reset all bounds `line_minimum' / `line_maximum' / `column_minimum'
// `column_maximum' / `depth_min' and `depth_max' using arguments as
@@ -82,7 +82,7 @@ Section Public
-? { column_min <= column_max };
-? { depth_min <= depth_max };
]
- (
+ (
lower1 := line_min;
upper1 := line_max;
lower2 := column_min;
@@ -108,28 +108,28 @@ Section Public
+? { depth_minimum = depth_min };
+? { depth_maximum = depth_max };
];
-
+
- from_collection3 model:COLLECTION3(V) <-
(
- make (model.line_minimum, model.column_minimum, model.depth_minimum)
+ make (model.line_minimum, model.column_minimum, model.depth_minimum)
to (model.line_maximum, model.column_maximum, model.depth_maximum);
-
- line_minimum.to line_maximum do { i:INTEGER;
- column_minimum.to column_maximum do { j:INTEGER;
+
+ line_minimum.to line_maximum do { i:INTEGER;
+ column_minimum.to column_maximum do { j:INTEGER;
depth_minimum.to depth_maximum do { k:INTEGER;
put (model.item (i,j,k)) to (i,j,k);
- };
- };
- };
+ };
+ };
+ };
)
[ ...
+? { lower1 = model.lower1 };
+? { lower2 = model.lower2 };
+? { lower3 = model.lower3 };
];
-
- - from_collection contents:COLLECTION(V)
- size (line_min,column_min,depth_min:INTEGER)
+
+ - from_collection contents:COLLECTION(V)
+ size (line_min,column_min,depth_min:INTEGER)
to (line_max,column_max,depth_max:INTEGER) <-
// Reset all bounds using `line_min', `line_max', `column_min',
// `column_max', `depth_min', and `depth_max'.
@@ -138,18 +138,18 @@ Section Public
-? { line_min <= line_max };
-? { column_min <= column_max };
-? { depth_min <= depth_max };
- -? {
- contents.count = (line_max - line_min + 1) *
- (column_max - column_min + 1) *
- (depth_max - depth_min + 1)
+ -? {
+ contents.count = (line_max - line_min + 1) *
+ (column_max - column_min + 1) *
+ (depth_max - depth_min + 1)
};
]
- (
+ (
make (line_min,column_min,depth_min) to (line_max,column_max,depth_max);
-
+
0.to (count - 1) do { i:INTEGER;
storage.put (contents.item (contents.lower + i)) to i;
- };
+ };
)
[ ...
+? { line_minimum = line_min };
@@ -160,19 +160,19 @@ Section Public
+? { depth_maximum = depth_max };
+? { count = contents.count };
];
-
+
- from_model model:COLLECTION(COLLECTION(COLLECTION(V))) <-
//The `model' is used to fill line by line the COLLECTION3.
//Assume all sub-collections of have the same indexing.
(
- make (model.lower,model.first.lower,model.first.first.lower)
+ make (model.lower,model.first.lower,model.first.first.lower)
to (model.upper,model.first.upper,model.first.first.upper);
-
+
(model.lower).to (model.upper) do { line:INTEGER;
(model.first.lower).to (model.first.upper) do { column:INTEGER;
(model.first.first.lower).to (model.first.first.upper) do { depth:INTEGER;
put (model.item line.item column.item depth) to (line,column,depth);
- };
+ };
};
};
)
@@ -184,11 +184,11 @@ Section Public
-? { depth_minimum = model.first.first.lower };
-? { depth_maximum = model.first.first.upper };
];
-
+
//
// Resizing:
//
-
+
- resize (line_min, column_min, depth_min:INTEGER) to (line_max, column_max, depth_max:INTEGER) <-
// Resize bounds of the Current array
[ ...
@@ -197,22 +197,22 @@ Section Public
-? { depth_max >= depth_min };
]
( + tmp:SELF;
-
+
tmp := SELF.clone;
tmp.make (line_min, column_min, depth_min) to (line_max, column_max, depth_max);
//BSBS: It may be possible to avoid this creation when :
//BSBS: new `capacity' <= old `capacity'
-
+
lower1.to line_maximum do { l:INTEGER;
lower2.to column_maximum do { c:INTEGER;
lower3.to depth_maximum do { d:INTEGER;
(tmp.valid_index (l,c,d)).if {
tmp.put (item (l,c,d)) to (l,c,d);
- };
- };
- };
- };
-
+ };
+ };
+ };
+ };
+
standard_copy tmp;
)
[ ...
@@ -223,128 +223,128 @@ Section Public
+? { depth_minimum = depth_min };
+? { depth_maximum = depth_max };
];
-
+
//
// Implementation of others feature from COLLECTION3:
//
-
+
- item (line, column, depth:INTEGER) :V <-
(
storage.item (
- (line - lower1) * count2 * count3 +
+ (line - lower1) * count2 * count3 +
(column - lower2) * count3 + depth - lower3
)
);
-
+
- put element:V to (line, column, depth:INTEGER) <-
(
storage.put element to (
- (line - lower1) * count2 * count3 +
+ (line - lower1) * count2 * count3 +
(column - lower2) * count3 + depth - lower3
);
);
-
+
- force x:V to (line, column, depth:INTEGER) <-
(
(! valid_index (line,column,depth)).if {
- resize (line.min lower1,column.min lower2,depth.min lower3)
+ resize (line.min lower1,column.min lower2,depth.min lower3)
to (line.max upper1,column.max upper2,depth.max upper3);
};
put x to (line,column,depth);
);
-
+
- set_all_with element:V <-
(
storage.set_all_with element with (count - 1);
);
-
+
- replace_all old_value:V with new_value:V <-
(
storage.replace_all old_value with new_value until (count - 1);
);
-
+
- fast_replace_all old_value:V with new_value:V <-
(
storage.fast_replace_all old_value with new_value until (count - 1);
);
-
- - sub_collection3 (line_min, column_min, depth_min:INTEGER)
+
+ - sub_collection3 (line_min, column_min, depth_min:INTEGER)
to (line_max, column_max, depth_max:INTEGER) :SELF <-
( + n:INTEGER;
+ result:SELF;
-
+
result := create (line_min,column_min,depth_min) to (line_max,column_max,depth_max);
-
+
line_min.to line_max do { i:INTEGER;
column_min.to column_max do { j:INTEGER;
depth_min.to depth_max do { k:INTEGER;
result.storage.put (item (i,j,k)) to n;
n := n + 1;
- };
+ };
};
};
result
)
- [ ...
+ [ ...
+? { result.lower1 = line_min };
+? { result.lower2 = column_min };
+? { result.lower3 = depth_min };
+? { result.upper1 = line_max };
+? { result.upper2 = column_max };
- +? { result.upper3 = depth_max };
+ +? { result.upper3 = depth_max };
];
-
+
//
// Looking and comparison:
//
-
+
- occurrences elt:V :INTEGER <-
(
storage.occurrences elt until (count - 1)
);
-
+
- fast_occurrences elt:V :INTEGER <-
(
storage.fast_occurrences elt until (count - 1)
);
-
+
- has x:V :BOOLEAN <-
//Search if a element x is in the array using `equal'.
//See also `fast_has' to choose the apropriate one.
( + result:BOOLEAN;
-
+
(count > 0).if {
result := storage.index_of x until (count - 1) <= count - 1;
};
result
);
-
+
- fast_has x:V :BOOLEAN <-
// Search if a element x is in the array using `='.
( + result:BOOLEAN;
-
+
(count > 0).if {
result := storage.fast_index_of x until (count - 1) <= count -1;
};
result
);
-
+
- all_default:BOOLEAN <-
(
storage.all_default (count - 1)
);
-
+
- swap (line1, column1, depth1:INTEGER) with (line2, column2, depth2:INTEGER) <-
( + tmp:V;
+ index1, index2:INTEGER;
-
+
index1 := (line1 - lower1) * count2 * count3 + (column1 - lower2) * count3 + depth1 - lower3;
index2 := (line2 - lower1) * count2 * count3 + (column2 - lower2) * count3 + depth2 - lower3;
tmp := storage.item index1;
storage.put(storage.item index2) to index1;
storage.put tmp to index2;
);
-
+
- copy other:SELF <-
(
lower1 := other.lower1;
@@ -363,25 +363,25 @@ Section Public
};
storage.copy_from (other.storage) until (count - 1);
);
-
+
//
// Invariant.
//
-
+
// [ ...
// -? { count1 = upper1 - lower1 + 1 };
// -? { count2 = upper2 - lower2 + 1 };
// -? { count3 = upper3 - lower3 + 1 };
// -? { capacity >= count };
// ];
-
-
-/*
+
+
+/*
- '==' Right 60 other:SELF :BOOLEAN <-
(
+ result:BOOLEAN;
result := FALSE;
-
+
( other = Self ).if {
result := true;
}.elseif { lower1 != other.lower1 } then {
@@ -393,7 +393,7 @@ Section Public
} else {
result := storage.memcmp (other.storage) until count;
};
-
+
result
);
*/
\ No newline at end of file
diff --git a/lib/standard/collection/avl_dictionary.li b/lib/standard/collection/avl_dictionary.li
index 94a7ede..a69fcf1 100644
--- a/lib/standard/collection/avl_dictionary.li
+++ b/lib/standard/collection/avl_dictionary.li
@@ -19,42 +19,42 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := AVL_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 an AVL balanced tree.
- // AVL stands for the names of G. M. Adel'son-Velskii and E. M. Landis,
- // two Russian mathematicians who first came up with this method of keeping
+
+ // Efficient implementation of DICTIONARY using an AVL balanced tree.
+ // AVL stands for the names of G. M. Adel'son-Velskii and E. M. Landis,
+ // two Russian mathematicians who first came up with this method of keeping
// the tree balanced.
Section Insert
-
+
+ parent_avl_tree:Expanded AVL_TREE(K);
Section Inherit
-
+
+ parent_simple_dictionary:Expanded SIMPLE_DICTIONARY(V, K);
-
+
Section Private
-
+
- key_memory:K <- item_memory;
-
+
Section Public
-
+
- capacity:INTEGER <- count;
- - at k:K :V <-
+ - at k:K :V <-
( + dic:AVL_DICTIONARY_NODE(V,K);
dic ?= root.at k;
dic.value
);
- - fast_at k:K :V <-
+ - fast_at k:K :V <-
( + dic:AVL_DICTIONARY_NODE(V,K);
dic ?= root.fast_at k;
dic.value
@@ -63,7 +63,7 @@ Section Public
- reference_at k:K :V <-
( + result:V;
+ n:AVL_DICTIONARY_NODE(V, K);
-
+
(root != NULL).if {
n := root.at k;
(n != NULL).if {
@@ -76,7 +76,7 @@ Section Public
- fast_reference_at k:K :V <-
( + result:V;
+ n:AVL_DICTIONARY_NODE(V, K);
-
+
(root != NULL).if {
n := root.fast_at k;
(n != NULL).if {
@@ -85,9 +85,9 @@ Section Public
};
result
);
-
+
- put v:V to k:K <- add v to k;
-
+
- add v:V to k:K <-
(
value_memory := v;
@@ -104,7 +104,7 @@ Section Public
- occurrences v:V :INTEGER <-
( + result:INTEGER;
-
+
(root != NULL).if {
result := root.occurrences v;
};
@@ -113,7 +113,7 @@ Section Public
- fast_occurrences v:V :INTEGER <-
( + result:INTEGER;
-
+
(root != NULL).if {
result := root.fast_occurrences v;
};
@@ -121,7 +121,7 @@ Section Public
);
- key_at v:V :K <- root.key_at v;
-
+
- fast_key_at v:V :K <- root.fast_key_at v;
- clear_count <- clear_count_and_capacity;
@@ -154,7 +154,7 @@ Section Public
);
- internal_key k:K :K <- root.at(k).key;
-
+
- make <-
(
map := FAST_ARRAY(AVL_TREE_NODE(K)).create 0;
@@ -166,19 +166,19 @@ Section Public
);
Section Private
-
+
+ value_memory:V;
- set_value_and_key n:AVL_TREE_NODE(K) <-
( + dic:AVL_DICTIONARY_NODE(V,K);
-
+
dic ?= n;
dic.make (value_memory, key_memory);
);
- set_value n:AVL_TREE_NODE(K) <-
( + dic:AVL_DICTIONARY_NODE(V,K);
-
+
dic ?= n;
dic.set_value value_memory;
);
@@ -195,7 +195,7 @@ Section Private
- discard_node n:AVL_DICTIONARY_NODE(V, K) <-
( + v:V;
+ k:K;
-
+
n.make (v, k);
);
@@ -203,12 +203,12 @@ Section Private
(
AVL_DICTIONARY_NODE(V, K).clone
);
-
-
- //
+
+
+ //
//invariant
//
-
+
//[ ...
// -? {lost_nodes != NULL};
// -? {lost_nodes = common_lost_nodes.at generating_type};
diff --git a/lib/standard/collection/avl_set.li b/lib/standard/collection/avl_set.li
index 873aab8..be21856 100644
--- a/lib/standard/collection/avl_set.li
+++ b/lib/standard/collection/avl_set.li
@@ -19,20 +19,20 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := AVL_SET(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
Section Inherit
-
+
+ parent_set:Expanded SET(V);
-
+
+ parent_avl_tree:Expanded AVL_TREE(V);
-
-Section Public
-
+
+Section Public
+
- add e:V <-
(
item_memory := e;
@@ -58,7 +58,7 @@ Section Public
- reference_at e:V :V <-
( + n:AVL_SET_NODE(V);
+ result:V;
-
+
(root != NULL).if {
n := root.at e;
(n != NULL).if {
@@ -70,18 +70,18 @@ Section Public
- item index:INTEGER :V <-
( + result:V;
-
+
(map_dirty).if {
build_map;
};
map.item (index - 1).item
);
-
+
Section Private
-
+
- set_item n:AVL_SET_NODE(V) <-
(
- n.make item_memory;
+ n.make item_memory;
);
- set_value n:AVL_SET_NODE(V);
@@ -97,7 +97,7 @@ Section Private
- discard_node n:AVL_SET_NODE(V) <-
( //+ i:V;
-
+
//n.make i;
//n.set_left (lost_nodes.item);
//lost_nodes.set_item n;
@@ -108,16 +108,16 @@ Section Private
AVL_SET_NODE(V).create
);
-Section Public
-
+Section Public
+
- create:SELF <-
( + result:SELF;
-
+
result := clone;
result.make;
result
);
-
+
- make <-
(
//(lost_nodes != NULL).if {
@@ -131,11 +131,11 @@ Section Public
// };
// };
);
-
+
//
// Invariant.
//
-
+
// [
// -? {lost_nodes != NULL};
// -? {lost_nodes = common_lost_nodes.at generating_type};
diff --git a/lib/standard/collection/fast_array.li b/lib/standard/collection/fast_array.li
index ed7ac33..028f759 100644
--- a/lib/standard/collection/fast_array.li
+++ b/lib/standard/collection/fast_array.li
@@ -19,80 +19,80 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FAST_ARRAY(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- author :="Boutet Jerome (boutet at loria.fr)";
-
+
- comment :="Resizable, fixed lower bound array.\
\Unlike ARRAY, the `lower' bound of a FAST_ARRAY is frozen \
\to 0. Thus, some memory is saved and looping toward `lower' \
\bound (which is 0) run a little bit faster.";
-
- // General purpose resizable FAST_ARRAYs. The only difference with ARRAY is the
+
+ // General purpose resizable FAST_ARRAYs. The only difference with ARRAY is the
// fact that the `lower' bound is actually frozen to 0. The `item' access is likely
- // to be more efficient as well as loop going from `upper' to `lower' just because
+ // to be more efficient as well as loop going from `upper' to `lower' just because
// `lower' is 0. Keep in mind that even if the `lower' is frozen to 0
- // it is really better to use the `lower' attribute, and not 0 directly, just because
+ // it is really better to use the `lower' attribute, and not 0 directly, just because
// you may decide in the future to use another COLLECTION implementation.
//
- // Like ARRAY, the FAST_ARRAY implementation uses only one chunk of memory, the
- // `storage' area which is a NATIVE_ARRAY. One must keep in mind that this internal
- // `storage' area is always kept left align. Thus, you can expect good performances
- // while using a FAST_ARRAY to modelize a stack behavior with
- // `add_last' / `last' / `remove_last'. Conversely `add_first' and `remove_first' are
- // likely to slow down your program if they are too often used. If the fact that
+ // Like ARRAY, the FAST_ARRAY implementation uses only one chunk of memory, the
+ // `storage' area which is a NATIVE_ARRAY. One must keep in mind that this internal
+ // `storage' area is always kept left align. Thus, you can expect good performances
+ // while using a FAST_ARRAY to modelize a stack behavior with
+ // `add_last' / `last' / `remove_last'. Conversely `add_first' and `remove_first' are
+ // likely to slow down your program if they are too often used. If the fact that
// `lower' is stuck to 0 do matter, also consider ARRAY.
-
+
Section Inherit
-
+
+ parent_arrayed_collection:Expanded ARRAYED_COLLECTION(V);
-
+
Section Public
-
+
- lower:INTEGER := 0; // Frozen lower bound.
-
+
//
// Creation and modification:
//
-
+
- create new_count:INTEGER :SELF <-
// Make array with range [0 .. `new_count' - 1].
// When `new_count' = 0 the array is empty.
( + result:SELF;
-
- result := clone;
+
+ result := clone;
result.make new_count;
result
);
-
+
- create_with_capacity new_count:INTEGER :SELF <-
// Create an empty array with at least `needed_capacity'.
( + result:SELF;
-
- result := clone;
+
+ result := clone;
result.with_capacity new_count;
result
);
-
+
- create_with_native_array_byte na:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :SELF <-
( + result:SELF;
-
+
result := clone;
result.make_with_native_array_byte na size s;
result
);
-
+
- make_with_map_object obj:OBJECT <-
// BSBS: A revoir.
[ ...
//-? {obj.object_size!=0};
-? {element_sizeof = 1};
]
- (
+ (
storage := CONVERT(OBJECT,NATIVE_ARRAY(V)).on obj;
capacity := obj.object_size;
upper := -1;
@@ -100,13 +100,13 @@ Section Public
[ ...
+? {storage != NULL};
];
-
+
- make_with_native_array_byte na:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER <-
[ ...
-? {s > 0};
-? {na != NULL};
]
- (
+ (
storage := na;
capacity := s;
upper := -1;
@@ -114,36 +114,36 @@ Section Public
[ ...
+? {storage != NULL};
];
-
+
- make new_count:INTEGER <-
// Make array with range [0 .. `new_count' - 1].
// When `new_count' = 0 the array is empty.
[ ...
-? { new_count >= 0};
]
- (
+ (
( new_count.to_integer > capacity).if {
// The new one is bigger:
- storage := NATIVE_ARRAY(V).create new_count;
+ storage := NATIVE_ARRAY(V).create new_count;
capacity := new_count;
- }.elseif { (capacity > 0) && { upper >= 0}} then {
+ }.elseif { (capacity > 0) && { upper >= 0}} then {
// The new one is smaller and just need to be cleared:
storage.clear 0 to upper;
- };
+ };
upper := new_count - 1;
)
[ ...
+? { count = new_count };
+? { capacity >= Old capacity };
- +? { (upper >= 0) ->> {all_default} };
- ];
-
+ +? { (upper >= 0) ->> {all_default} };
+ ];
+
- with_capacity needed_capacity:INTEGER <-
// Create an empty array with at least `needed_capacity'.
[ ...
-? { needed_capacity >= 0 };
]
- (
+ (
(capacity < needed_capacity).if {
storage := NATIVE_ARRAY(V).create needed_capacity;
capacity := needed_capacity;
@@ -154,16 +154,16 @@ Section Public
)
[ ...
+? { capacity >= needed_capacity };
- +? { is_empty };
- ];
-
+ +? { is_empty };
+ ];
+
//
// Hashable.
//
-
+
- hash_code:INTEGER <-
( + result:INTEGER;
-
+
(! is_empty).if {
(last != NULL).if {
result := last.hash_code;
@@ -173,7 +173,7 @@ Section Public
};
result
);
-
+
//
// Modification:
//
@@ -183,28 +183,28 @@ Section Public
[
-? {new_capacity >= 0};
]
- (
+ (
(new_capacity > capacity).if {
(capacity = 0).if {
storage := NATIVE_ARRAY(V).create new_capacity;
} else {
- storage := storage.realloc capacity with new_capacity;
- };
- capacity := new_capacity;
- };
+ storage := storage.realloc capacity with new_capacity;
+ };
+ capacity := new_capacity;
+ };
)
[
- +? { capacity >= Old capacity };
+ +? { capacity >= Old capacity };
];
-
+
- fast_resize new_count:INTEGER <-
[
- ? {new_count <= capacity};
+ ? {new_count <= capacity};
]
(
upper := new_count - 1;
);
-
+
- resize new_count:INTEGER <-
// Resize the array. When `new_count' is greater than
// `count', new positions are initialized with appropriate
@@ -213,7 +213,7 @@ Section Public
-? {new_count >= 0};
]
( + new_capacity:INTEGER;
-
+
( new_count > count).if {
(capacity = 0).if {
storage := NATIVE_ARRAY(V).create new_count;
@@ -222,37 +222,37 @@ Section Public
new_capacity := capacity * 2;
{ new_capacity >= new_count }.until_do {
new_capacity := new_capacity * 2;
- };
+ };
storage := storage.realloc capacity with new_capacity;
- capacity := new_capacity;
- };
+ capacity := new_capacity;
+ };
}.elseif { new_count != count } then {
storage.clear new_count to (count - 1);
- };
-
+ };
+
upper := new_count - 1;
- )
+ )
[ ...
+? { count = new_count };
- +? { capacity >= Old capacity };
- ];
-
+ +? { capacity >= Old capacity };
+ ];
+
//
// Implementation of deferred:
//
-
+
- is_empty:BOOLEAN <- ( upper < 0 ); // end is_empty
-
- - item i:INTEGER :V <-
- (
+
+ - item i:INTEGER :V <-
+ (
storage.item i
- );
-
+ );
+
- put element:V to i:INTEGER <-
- (
- storage.put element to i;
- );
-
+ (
+ storage.put element to i;
+ );
+
- add element:V first n:INTEGER <-
[ -? {n > 0}; ]
( + new_capacity,new_count:INTEGER;
@@ -272,9 +272,9 @@ Section Public
storage.move 0 to upper by n;
storage.set_slice_with element from lower until (n-1);
);
-
+
- add_first element:V <-
- (
+ (
add_last element;
(upper = 0).if {
}.elseif {upper = 1} then {
@@ -282,12 +282,12 @@ Section Public
} else {
move 0 to (upper - 1) by 1;
storage.put element to 0;
- };
- );
-
+ };
+ );
+
- add_last element:V <-
( + new_capacity:INTEGER;
-
+
(upper + 1 <= capacity - 1 ).if {
upper := upper + 1;
}.elseif {capacity = 0} then {
@@ -299,93 +299,93 @@ Section Public
storage := storage.realloc capacity with new_capacity;
capacity := new_capacity;
upper := upper + 1;
- };
+ };
storage.put element to upper;
- );
-
+ );
+
- count:INTEGER <- ( upper + 1 ); // end count
-
+
- clear <-
- (
+ (
upper := -1;
)
[ ...
- +? { capacity = Old capacity };
- ];
-
+ +? { capacity = Old capacity };
+ ];
+
- copy other:SELF <-
// Copy `other' onto Current.
( + other_upper, new_capacity:INTEGER;
-
- other_upper := other.upper;
+
+ other_upper := other.upper;
(other_upper >= 0).if {
new_capacity := other_upper + 1;
-
+
( capacity < new_capacity ).if {
storage := NATIVE_ARRAY(V).create new_capacity;
capacity := new_capacity;
//}.elseif { capacity > 0 } then {
// storage.clear_all (capacity - 1);
- };
+ };
storage.copy_from (other.storage) until other_upper;
//}.elseif { capacity > 0 } then {
// storage.clear_all (capacity - 1);
- };
+ };
upper := other_upper;
- );
-
+ );
+
- set_all_with v:V <-
- (
- storage.set_all_with v until upper;
- ) ;
-
+ (
+ storage.set_all_with v until upper;
+ ) ;
+
//
// Sort (BSBS: to put in ARRAYED_COLLECTION)
//
-
+
- bubble_sort <-
- // Bubble sort
- (
+ // Bubble sort
+ (
bubble_sort_with { (a,b:V); a > b};
);
-
+
- bubble_sort_with cmp:{ (V,V); BOOLEAN} <-
- // Bubble sort
+ // Bubble sort
( + low,up,idx,max:INTEGER;
+ sw:BOOLEAN;
-
+
max := upper-1;
-
+
low := 0;
up := max;
{
sw:=FALSE;
- low.to up do { i:INTEGER;
+ low.to up do { i:INTEGER;
(cmp.value (item i,item (i+1))).if {
swap i with (i+1);
sw := TRUE;
};
-
+
idx := max - i;
(cmp.value (item idx,item (idx+1))).if {
swap idx with (idx+1);
sw := TRUE;
- };
+ };
};
up := up - 1;
low := low + 1;
}.do_while {sw};
);
-
- - quick_sort_from low:INTEGER to up:INTEGER <-
+
+ - quick_sort_from low:INTEGER to up:INTEGER <-
quick_sort_from low to up with { (a,b:V); a > b};
-
+
- quick_sort_from low:INTEGER to up:INTEGER with cmp:{ (V,V); BOOLEAN} <-
// Quick sort algorithm (naive implementation)
( + i, p:INTEGER;
+ pivot, tmp:INTEGER;
- (up > low).if {
+ (up > low).if {
pivot := (low + up) >> 1;
swap pivot with low;
p := low;
@@ -400,130 +400,130 @@ Section Public
quick_sort_from (p + 1) to up;
};
);
-
+
- quick_sort <- quick_sort_from lower to upper;
-
+
- quick_sort_with cmp:{ (V,V); BOOLEAN} <- quick_sort_from lower to upper with cmp;
-
+
//
// Other.
//
-
+
- from_collection model:COLLECTION(V) <-
( + i1:INTEGER;
-
+
with_capacity model.count;
upper := model.count - 1;
- i1 := 0;
+ i1 := 0;
(model.lower).to (model.upper) do { i2:INTEGER;
storage.put (model.item i2) to i1;
i1 := i1 + 1;
- };
- );
-
+ };
+ );
+
- Self:SELF '==' Right 60 other:E :BOOLEAN <-
( + result:BOOLEAN;
+ same:SELF;
-
+
( Self = other).if {
result := TRUE;
- } else {
+ } else {
same ?= other;
((same != NULL) && { upper = same.upper }).if {
result := storage.fast_memcmp (same.storage) until (upper + 1) ;
};
};
-
+
result
- );
-
- - is_equal_map other:SELF :BOOLEAN <-
+ );
+
+ - is_equal_map other:SELF :BOOLEAN <-
( + result:BOOLEAN;
-
+
( Self = other).if {
result := TRUE;
}.elseif {upper = other.upper} then {
result := storage.memcmp (other.storage) until (upper + 1);
- };
-
+ };
+
result
- );
-
- - all_default:BOOLEAN <-
+ );
+
+ - all_default:BOOLEAN <-
[
-? {storage != NULL};
]
- (
+ (
storage.all_default upper
- );
-
- - occurrences element:V :INTEGER <-
- (
- storage.occurrences element until upper
- );
-
- - fast_occurrences element:V :INTEGER <-
- (
- storage.fast_occurrences element until upper
- );
-
- - first_index_of element:V :INTEGER <-
+ );
+
+ - occurrences element:V :INTEGER <-
+ (
+ storage.occurrences element until upper
+ );
+
+ - fast_occurrences element:V :INTEGER <-
+ (
+ storage.fast_occurrences element until upper
+ );
+
+ - first_index_of element:V :INTEGER <-
( + result:INTEGER;
-
+
(upper >= 0).if {
result := storage.first_index_of element until upper;
};
result
- );
+ );
- - index_of element:V start start_index:INTEGER :INTEGER <-
+ - index_of element:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
-
+
(upper >= 0).if {
result := storage.index_of (element,start_index) until upper;
- };
- result
- );
-
+ };
+ result
+ );
+
- reverse_index_of element:V start start_index:INTEGER :INTEGER <-
(
storage.reverse_index_of (element, start_index)
);
-
- - fast_first_index_of element:V :INTEGER <-
- ( + result:INTEGER;
-
+
+ - fast_first_index_of element:V :INTEGER <-
+ ( + result:INTEGER;
+
(upper >= 0).if {
result := storage.fast_first_index_of element until upper;
- };
+ };
result
- );
+ );
+
+ - fast_index_of element:V start start_index:INTEGER :INTEGER <-
+ ( + result:INTEGER;
- - fast_index_of element:V start start_index:INTEGER :INTEGER <-
- ( + result:INTEGER;
-
(upper >= 0).if {
result := storage.fast_index_of (element,start_index) until upper;
- };
+ };
result
- );
-
+ );
+
- fast_reverse_index_of element:V start start_index:INTEGER :INTEGER <-
(
storage.fast_reverse_index_of (element, start_index)
);
-
+
- subarray min:INTEGER to max:INTEGER :SELF <- // slice
( + result:SELF;
-
+
result := SELF.create (max - min + 1);
result.storage.slice_copy storage to 0 from min to max;
-
+
result
- );
-
- - force element:V to index:INTEGER <-
- (
+ );
+
+ - force element:V to index:INTEGER <-
+ (
( index <= upper ).if {
storage.put element to index;
}.elseif { index = (upper + 1) } then {
@@ -531,12 +531,12 @@ Section Public
} else {
resize (index + 1);
storage.put element to index;
- };
- );
-
- - remove_first <-
+ };
+ );
+
+ - remove_first <-
( + void_storage:NATIVE_ARRAY(V);
-
+
( upper = 0).if {
storage := void_storage;
capacity := 0;
@@ -544,30 +544,30 @@ Section Public
} else {
storage.remove_first upper;
upper := upper - 1;
- };
+ };
)
[ ...
+? {lower = Old lower};
- ];
-
+ ];
+
- remove_head n:INTEGER <-
(
storage.move n to upper by (-n);
upper := upper - n;
);
-
- - remove index:INTEGER <-
- (
+
+ - remove index:INTEGER <-
+ (
storage.remove index until upper;
upper := upper - 1;
- );
-
+ );
+
- remove beg:INTEGER to end:INTEGER <-
[ ...
-? {beg <= end};
]
( + s:INTEGER;
-
+
(beg = end).if {
remove beg;
} else {
@@ -581,16 +581,16 @@ Section Public
[
-? {beg >= 0};
]
- (
- (beg <= upper).if {
- upper := beg - 1;
+ (
+ (beg <= upper).if {
+ upper := beg - 1;
};
);
-
+
//
// Guru Section.
//
-
+
- set_upper new_up:INTEGER <-
(
upper := new_up;
diff --git a/lib/standard/collection/fast_array2.li b/lib/standard/collection/fast_array2.li
index 9744008..b4274ad 100644
--- a/lib/standard/collection/fast_array2.li
+++ b/lib/standard/collection/fast_array2.li
@@ -129,7 +129,7 @@ Section Public
// The `model' is used to fill line by line the COLLECTION2.
// Assume all sub-collections of `model' have the number of items.
( + l,c:INTEGER;
-
+
make(model.count, model.first.count);
l := model.lower;
lower1.to upper1 do { line:INTEGER;
@@ -145,13 +145,13 @@ Section Public
- sub_collection2 (line_min,column_min:INTEGER) to (line_max,column_max:INTEGER) :SELF <-
( + l,c:INTEGER;
+ result:SELF;
-
+
result := create (line_max - line_min + 1, column_max - column_min + 1);
l := line_min;
(result.lower1).to (result.upper1) do { line:INTEGER;
c := column_min;
(result.lower2).to (result.upper2) do { column:INTEGER;
- result.put (item (l, c)) to (line, column);
+ result.put (item (l, c)) to (line, column);
c := c + 1;
};
l := l + 1;
diff --git a/lib/standard/collection/fast_array3.li b/lib/standard/collection/fast_array3.li
index 632d337..d2760df 100644
--- a/lib/standard/collection/fast_array3.li
+++ b/lib/standard/collection/fast_array3.li
@@ -19,63 +19,63 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FAST_ARRAY3(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Resizable three dimensional array.\
\Unlike ARRAY3, the `lower1', `lower2' and `lower3' bounds \
\are frozen to 0. Thus, one can expect better performances. .";
-
+
Section Inherit
-
+
+ parent_collection3:Expanded COLLECTION3(V);
-
+
Section Public
-
+
+ upper1:INTEGER;
+ count1:INTEGER;
-
+
+ upper2:INTEGER;
+ count2:INTEGER;
-
+
+ upper3:INTEGER;
+ count3:INTEGER;
-
+
+ count:INTEGER;
-
+
Section Private
-
+
+ count2x3:INTEGER;
// To speed up access, this value is always equal to
// `count2' * `count3'
-
+
Section FAST_ARRAY3
-
+
+ storage:NATIVE_ARRAY(V);
-
+
+ capacity:INTEGER; // of `storage'.
-
+
Section Public
-
+
- lower1:INTEGER := 0;
-
+
- lower2:INTEGER := 0;
-
+
- lower3:INTEGER := 0;
-
+
- create (new_count1, new_count2, new_count3:INTEGER) :SELF<-
// Create or reset `Current' with new dimensions.
// All elements are set to the default value of type E.
( + result:SELF;
-
+
result := clone;
result.make (new_count1, new_count2, new_count3);
result
);
-
+
- make (new_count1, new_count2, new_count3 :INTEGER) <-
// Create or reset `self' with new dimensions.
// All elements are set to the default value of type E.
@@ -84,7 +84,7 @@ Section Public
-? { new_count2 > 0 };
-? { new_count3 > 0 };
]
- (
+ (
count1 := new_count1;
upper1 := new_count1 - 1;
count2 := new_count2;
@@ -106,7 +106,7 @@ Section Public
+? { count3 = new_count3 };
+? { all_default };
];
-
+
- from_collection3 model:COLLECTION3(V) <-
// Uses the `model' to update self.
(
@@ -119,7 +119,7 @@ Section Public
};
};
);
-
+
- from_collection contents:COLLECTION(V) size (new_count1, new_count2, new_count3:INTEGER) <-
// Reset all bounds using `new_count#i'.
// Copy all elements of `contents', line by line into self.
@@ -129,7 +129,7 @@ Section Public
-? { new_count3 >= 0 };
-? { contents.count = new_count1 * new_count2 * new_count3 };
]
- (
+ (
make (new_count1, new_count2, new_count3);
lower1.to (count - 1) do { i:INTEGER;
storage.put (contents.item (contents.lower + i)) to i;
@@ -141,19 +141,19 @@ Section Public
+? { depth_maximum = new_count3 - 1 };
+? { count = contents.count };
];
-
-
+
+
- from_model model:COLLECTION(COLLECTION(COLLECTION(V))) <-
// The `model' is used to fill line by line the COLLECTION3.
// Assume all sub-collections of have the same indexing.
( + n:INTEGER;
-
+
make (
- model.upper - model.lower + 1,
- model.first.upper - model.first.lower + 1,
+ model.upper - model.lower + 1,
+ model.first.upper - model.first.lower + 1,
model.first.first.upper - model.first.first.lower + 1
);
-
+
(model.lower).to (model.upper) do { line:INTEGER;
(model.first.lower).to (model.first.upper) do { column:INTEGER;
(model.first.first.lower).to (model.first.first.upper) do { depth:INTEGER;
@@ -168,22 +168,22 @@ Section Public
+? { column_maximum = model.first.upper - model.first.lower };
+? { depth_maximum = model.first.first.upper - model.first.first.lower };
];
-
+
//
// Implementation of others feature from COLLECTION3:
//
-
+
- item (line, column, depth:INTEGER) :V <-
(
storage.item (line * count2x3 + column * count3 + depth)
);
-
+
- put element:V to (line, column, depth:INTEGER) <-
(
storage.put element to (line * count2x3 + column * count3 + depth);
);
-
-
+
+
- force element:V to (line, column, depth :INTEGER) <-
(
(! valid_index (line, column, depth)).if {
@@ -191,8 +191,8 @@ Section Public
};
put element to (line,column,depth);
);
-
-
+
+
- copy other:SELF <-
(
count1 := other.count1;
@@ -209,18 +209,18 @@ Section Public
};
storage.copy_from (other.storage) until (count - 1);
);
-
- - sub_collection3 (line_min,column_min,depth_min:INTEGER)
+
+ - sub_collection3 (line_min,column_min,depth_min:INTEGER)
to (line_max,column_max,depth_max:INTEGER) :SELF <-
( + n:INTEGER;
+ result:SELF;
-
+
result := SELF.create (
- line_max - line_min + 1,
- column_max - column_min + 1,
+ line_max - line_min + 1,
+ column_max - column_min + 1,
depth_max - depth_min + 1
);
-
+
line_min.to line_max do { i:INTEGER;
column_min.to column_max do { j:INTEGER;
depth_min.to depth_max do { k:INTEGER;
@@ -234,30 +234,30 @@ Section Public
[ ...
+? { result.upper1 = line_max - line_min };
+? { result.upper2 = column_max - column_min };
- +? { result.upper3 = depth_max - depth_min };
+ +? { result.upper3 = depth_max - depth_min };
];
-
+
//
// Writing:
//
-
+
- set_all_with x:V <-
// All element are set with the value x.
(
storage.set_all_with x until (count - 1);
);
-
+
- all_default:BOOLEAN <-
(
storage.all_default (count - 1)
);
-
+
- slice (l1,up1:INTEGER) to (l2,up2:INTEGER) to (l3,up3:INTEGER) :SELF <-
// Create a new collection initialized with elements of
// range `low'..`up'. result has the same dynamic type
// as self collection.
( + result:SELF;
-
+
result := SELF.create (up1 - l1 + 1, up2 - l2 + 1, up3 - l3 + 1);
l1.to up1 do { line:INTEGER;
l2.to up2 do { column:INTEGER;
@@ -266,8 +266,8 @@ Section Public
};
};
};
- );
-
+ );
+
- set_slice (l1,up1:INTEGER) to (l2,up2:INTEGER) to (l3,up3:INTEGER) with element:V <-
// Set all the elements in the
// range [(l1,up1),(l2,up2),(l3,up3)] of
@@ -280,8 +280,8 @@ Section Public
};
};
};
- );
-
+ );
+
- swap (line1, column1, depth1:INTEGER) with (line2, column2, depth2:INTEGER) <-
( + tmp:V;
+ c3, c2x3, index1, index2:INTEGER;
@@ -293,25 +293,25 @@ Section Public
storage.put (storage.item index2) to index1;
storage.put tmp to index2;
);
-
+
//
// Looking and comparison:
//
-
+
- occurrences elt:V :INTEGER <-
(
storage.occurrences elt until (count - 1)
);
-
+
- fast_occurrences elt:V :INTEGER <-
(
storage.fast_occurrences elt until (count - 1)
);
-
+
//
// Resizing:
//
-
+
- resize (new_count1,new_count2,new_count3:INTEGER) <-
[ ...
-? { new_count1 > 0};
@@ -319,11 +319,11 @@ Section Public
-? { new_count3 > 0};
]
( + tmp:SELF;
-
+
tmp := SELF.create (new_count1, new_count2, new_count3);
// BSBS: It may be possible to avoid this creation when :
// BSBS: new `capacity' <= old `capacity'
-
+
line_maximum.downto 0 do { l:INTEGER;
column_maximum.downto 0 do { c:INTEGER;
depth_maximum.downto 0 do { d:INTEGER;
@@ -344,65 +344,65 @@ Section Public
+? { count3 = new_count3 };
+? { count = new_count1 * new_count2 * new_count3 };
];
-
+
//
// Looking and Searching:
//
-
+
- has x:V :BOOLEAN <-
// Look for `x' using `equal' for comparison.
( + result:BOOLEAN;
-
+
(count > 0).if {
result := storage.index_of x until (count-1) <= (count-1);
};
result
- );
-
+ );
+
- fast_has x:V :BOOLEAN <-
// Same as `has' but use `=' for comparison
( + result:BOOLEAN;
-
+
(count > 0).if {
result := storage.fast_index_of x until (count - 1) <= (count - 1);
};
result
- );
-
+ );
+
//
// Other features:
//
-
+
- replace_all old_value:V with new_value:V <-
(
storage.replace_all old_value with new_value until (count - 1);
);
-
-
+
+
- fast_replace_all old_value:V with new_value:V <-
(
storage.fast_replace_all old_value with new_value until (count - 1);
);
-
+
//
// Invariant.
//
-
+
// [ ...
// -? {count1 = upper1 + 1};
-// -? {count2 = upper2 + 1};
+// -? {count2 = upper2 + 1};
// -? {count3 = upper3 + 1};
// -? {count = count1 * count2 * count3};
// -? {count2x3 = count2 * count3};
// -? {capacity >= count};
// ];
-
+
/*
- '==' Right 60 other:SELF :BOOLEAN <-
(
+ result:BOOLEAN;
result := FALSE;
-
+
(other = Self).if {
result := TRUE;
}.elseif { upper1 != other.upper1} then {
@@ -411,7 +411,7 @@ Section Public
} else {
result := storage.memcmp (other.storage) until count;
};
-
+
result
);
*/
\ No newline at end of file
diff --git a/lib/standard/collection/hashed_dictionary.li b/lib/standard/collection/hashed_dictionary.li
index a20916d..c7a0ee9 100644
--- a/lib/standard/collection/hashed_dictionary.li
+++ b/lib/standard/collection/hashed_dictionary.li
@@ -29,7 +29,7 @@ Section Header
\Values of type `V' are stored using Keys of type `K'.";
// Efficient implementation of DICTIONARY using `hash_code' on keys.
-
+
Section Inherit
- parent_simple_dictionary:Expanded SIMPLE_DICTIONARY(V,K);
@@ -310,7 +310,7 @@ Section Public
- fast_remove k:K <-
( + h, idx:INTEGER;
+ node, previous_node:HASHED_DICTIONARY_NODE(V,K);
-
+
cache_user := -1;
h := k.hash_code;
idx := h % capacity;
@@ -320,10 +320,10 @@ Section Public
count := count - 1;
node := dispose_node node;
buckets.put node to idx;
- } else {
+ } else {
previous_node := node;
- node := node.next;
- {(node = NULL) || {node.key = k}}.until_do {
+ node := node.next;
+ {(node = NULL) || {node.key = k}}.until_do {
previous_node := node;
node := node.next;
};
@@ -369,7 +369,7 @@ 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};
@@ -582,7 +582,7 @@ Section Public
+? { is_empty };
+? { capacity >= medium_size };
];
-
+
//
// Invariant
//
diff --git a/lib/standard/collection/hashed_set.li b/lib/standard/collection/hashed_set.li
index 58bc7f4..58b7fdf 100644
--- a/lib/standard/collection/hashed_set.li
+++ b/lib/standard/collection/hashed_set.li
@@ -19,53 +19,53 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := HASHED_SET(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Definition of a mathematical set of hashable objects.";
-
+
// All common operations on mathematical sets are available.
-
+
Section Inherit
-
+
+ parent_set:Expanded SET(V);
-
+
Section Public
-
+
- default_size:INTEGER := 53;
// Minimum size for storage in number of items.
-
+
Section SET
-
+
+ buckets:NATIVE_ARRAY(HASHED_SET_NODE(V));
// The `buckets' storage area is the primary hash table of `capacity'
// elements. To search some element, 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).
-
+
//
// Internal cache handling:
//
-
+
+ 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
// -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_SET_NODE(V);
// Meaningful only when `cache_user' is not -1.
-
+
+ cache_buckets:INTEGER;
// Meaningful only when `cache_user' is not -1.
-
+
Section Public
-
+
- create:SELF <-
// Create an empty set. Internal storage `capacity' of the set is
// initialized using the `Default_size' value. Then, tuning of needed
@@ -77,15 +77,15 @@ Section Public
result.make;
result
);
-
- - make <-
- (
+
+ - make <-
+ (
with_capacity default_size;
)
[ ...
+? { capacity = default_size };
];
-
+
- create_with_capacity sz:INTEGER :SELF <-
// Create an empty set using `medium_size' as an appropriate value
// to help initialization of `capacity'. Thus, this feature may be used
@@ -96,18 +96,18 @@ Section Public
// `capacity'. Keep in mind that the `capacity' tuning is done
// automatically according to usage.
( + result:SELF;
-
+
result := clone;
- result.with_capacity sz;
+ result.with_capacity sz;
result
);
-
+
- with_capacity medium_size:INTEGER <-
[ ...
-? {medium_size > 0};
]
( + new_capacity:INTEGER;
-
+
new_capacity := HASH_TABLE_SIZE.prime_number_ceiling medium_size;
buckets := NATIVE_ARRAY(HASHED_SET_NODE(V)).create new_capacity;
capacity := new_capacity;
@@ -118,29 +118,29 @@ Section Public
+? { is_empty };
+? { capacity >= medium_size };
];
-
+
//
// Counting:
//
-
+
+ capacity:INTEGER; // Of the `buckets' storage area.
-
+
+ count:INTEGER;
-
+
//
// Adding and removing:
//
-
+
- add e:V <-
// Add a new item to the set:the mathematical definition of
// adding in a set is followed.
( + h, idx:INTEGER;
+ node:HASHED_SET_NODE(V);
-
+
cache_user := -1;
h := e.hash_code;
idx := h % capacity;
- node := buckets.item idx;
+ node := buckets.item idx;
{(node = NULL) || {node.item == e}}.until_do {
node := node.next;
};
@@ -160,11 +160,11 @@ Section Public
// adding in a set is followed.
( + h, idx:INTEGER;
+ node:HASHED_SET_NODE(V);
-
+
cache_user := -1;
h := e.hash_code;
idx := h % capacity;
- node := buckets.item idx;
+ node := buckets.item idx;
{(node = NULL) || {node.item = e}}.until_do {
node := node.next;
};
@@ -176,15 +176,15 @@ Section Public
node := HASHED_SET_NODE(V).create e next (buckets.item idx);
buckets.put node to idx;
count := count + 1;
- };
- );
-
+ };
+ );
+
- remove e:V <-
// Remove item `e' from the set:the mathematical definition of
// removing from a set is followed.
( + h, idx:INTEGER;
+ node, previous_node:HASHED_SET_NODE(V);
-
+
cache_user := -1;
h := e.hash_code;
idx := h % capacity;
@@ -206,15 +206,15 @@ Section Public
previous_node.set_next (node.next);
};
};
- };
+ };
);
-
+
- fast_remove e:V <-
// Remove item `e' from the set:the mathematical definition of
// removing from a set is followed.
( + h, idx:INTEGER;
+ node, previous_node:HASHED_SET_NODE(V);
-
+
cache_user := -1;
h := e.hash_code;
idx := h % capacity;
@@ -236,9 +236,9 @@ Section Public
previous_node.set_next (node.next);
};
};
- };
+ };
);
-
+
- clear <-
// Empty the current set.
(
@@ -249,29 +249,29 @@ Section Public
[ ...
+? {capacity = Old capacity};
];
-
+
//
// Looking and searching:
//
-
+
- has e:V :BOOLEAN <-
// Is element `e' in the set?
( + idx:INTEGER;
+ node:HASHED_SET_NODE(V);
-
+
idx := e.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) || {node.item == e}}.until_do {
node := node.next;
};
- node != NULL
+ node != NULL
);
-
+
- fast_has e:V :BOOLEAN <-
// Is element `e' in the set?
( + idx:INTEGER;
+ node:HASHED_SET_NODE(V);
-
+
idx := e.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) || {node.item = e}}.until_do {
@@ -279,12 +279,12 @@ Section Public
};
node != NULL
);
-
+
- reference_at e:V :V <-
- ( + idx:INTEGER;
+ ( + idx:INTEGER;
+ node:HASHED_SET_NODE(V);
+ result:V;
-
+
idx := e.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) || {node.item == e}}.until_do {
@@ -297,10 +297,10 @@ Section Public
);
- reference_at e:V with cmp:{(V,V); BOOLEAN} :V <-
- ( + idx:INTEGER;
+ ( + idx:INTEGER;
+ node:HASHED_SET_NODE(V);
+ result:V;
-
+
idx := e.hash_code % capacity;
node := buckets.item idx;
{(node = NULL) || {cmp.value (node.item,e)}}.until_do {
@@ -311,27 +311,27 @@ Section Public
};
result
);
-
+
//
// To provide iterating facilities:
//
-
+
- item i:INTEGER :V <-
// Return the item indexed by `index'.
- (
+ (
set_cache_user i;
cache_node.item
- );
-
+ );
+
//
// Mathematical operations:
//
-
+
- intersection other:SELF <-
// Make the intersection of the `self' set with `other'.
( + i,c:INTEGER;
+ node1, node2:HASHED_SET_NODE(V);
-
+
cache_user := -1;
i := capacity - 1;
c := count;
@@ -350,17 +350,17 @@ Section Public
(! other.has (node2.item)).if {
node1.set_next (node2.next);
count := count - 1;
- } else {
+ } else {
node1 := node2;
- };
+ };
node2 := node2.next;
c := c - 1;
};
};
i := i - 1;
- };
+ };
);
-
+
- copy other:SELF <-
// Copy 'other' into the current set
(
@@ -371,15 +371,15 @@ Section Public
} else {
clear;
};
-
+
lower.to (other.count) do { i:INTEGER;
add (other.item i);
};
);
-
+
- from_collection model:COLLECTION(V) <-
( + i, up:INTEGER;
-
+
with_capacity (model.count.max 1);
up := model.upper;
i := model.lower;
@@ -388,15 +388,15 @@ Section Public
i := i + 1;
};
);
-
-Section Private
-
+
+Section Private
+
- increase_capacity <-
// There is no more free slots:the set must grow.
( + i,idx, new_capacity:INTEGER;
+ old_buckets:NATIVE_ARRAY(HASHED_SET_NODE(V));
+ node1, node2:HASHED_SET_NODE(V);
-
+
new_capacity := HASH_TABLE_SIZE.prime_number_ceiling (capacity + 1);
old_buckets := buckets;
buckets := buckets.create new_capacity;
@@ -413,11 +413,11 @@ Section Private
};
i := i - 1;
};
- cache_user := -1;
+ cache_user := -1;
);
-
+
- set_cache_user index:INTEGER <-
- (
+ (
(index = cache_user + 1).if {
cache_user := index;
cache_node := cache_node.next;
@@ -440,16 +440,16 @@ Section Private
set_cache_user (cache_user + 1);
};
};
-
+
? { cache_user = index};
? { cache_buckets.in_range 0 to (capacity - 1)};
? { cache_node != NULL};
);
-
+
//
// Invariant.
//
-
+
// [
// -? {capacity > 0};
// -? {capacity >= count};
@@ -457,21 +457,21 @@ Section Private
// -? {(cache_user > 0) ->> {cache_node != NULL}};
// -? {(cache_user > 0) ->> {cache_buckets.in_range 0 to (capacity - 1)}}
// ];
-
- // -----------------OLD-----------------
-
+
+ // -----------------OLD-----------------
+
/*
-
-
-
+
+
+
- union other:SELF <-
// Make the union of the `self' set with `other'.
( + e:V;
+ old_count:INTEGER;
-
- ? {old_count := count;
+
+ ? {old_count := count;
other != NULL};
-
+
lower.to (other.count) do { i:INTEGER;
e := other.item i;
add e;
@@ -483,39 +483,39 @@ Section Private
// Make the union of the `self' set with `other'.
( + old_count:INTEGER;
+ e:V;
- ? {old_count := count;
+ ? {old_count := count;
other != NULL};
-
+
lower.to (other.count) do { i:INTEGER;
e := other.item i;
fast_add e;
};
? { count <= (old_count + other.count)};
);
-
-
+
+
- '+' Left 1 other:SELF :SELF <-
// Return the union of the `self' set with `other'.
(
+ result:SELF;
-
+
? { other != NULL};
-
+
result := twin ;
result.union other ;
-
+
? { result.count <= count + other.count};
? { (Self.is_subset_of result) && (other.is_subset_of result)};
-
+
result
);
-
-
-
+
+
+
- is_disjoint other:SELF :BOOLEAN <-
( + j:INTEGER;
+ result:BOOLEAN;
-
+
(other.count<count).if {
result := other.is_disjoint Self;
} else {
@@ -526,12 +526,12 @@ Section Private
result := (j=0);
};
result
- );
+ );
- fast_is_disjoint other:SELF :BOOLEAN <-
( + j:INTEGER;
+ result:BOOLEAN;
-
+
(other.count<count).if {
result := other.fast_is_disjoint Self;
} else {
@@ -543,63 +543,63 @@ Section Private
};
result
);
-
+
- '^' other:SELF :SELF <-
// Return the intersection of the `self' set with `other'.
(
+ result:SELF;
? {other != NULL};
-
+
result := twin;
result.intersection(other) ;
-
+
? { result.count <= other.count.min count};
? { (result.is_subset_of Self) && { result.is_subset_of other}};
);
-
+
- minus other:SELF <-
// Make the set `self' - `other'.
(
+ old_count:INTEGER;
-
+
? { other != NULL};
-
+
old_count:=count;
-
+
lower.to (other.count) do { i:INTEGER;
remove (other.item i);
};
-
+
? { count <= old count};
);
-
-
+
+
- '-' other:SELF :SELF <-
// Return the set `self' - `other'.
(
+ result:SELF;
-
+
? { other != NULL};
-
+
result := twin ;
result.minus other;
-
+
? { result.count <= count};
? { result.is_subset_of(Self)};
-
+
result
);
-
+
// Comparison:
-
+
- is_subset_of other:SELF :BOOLEAN <-
// Is the `self' set a subset of `other'?
(
+ i:INTEGER;
+ result:BOOLEAN;
-
+
? { other != NULL};
-
+
result := FALSE;
(Self = other).if {
result := TRUE;
@@ -612,21 +612,21 @@ Section Private
};
};
? { result ->> {count <= other.count}};
-
+
result
);
-
-
+
+
- is_disjoint_from other:SELF :BOOLEAN <-
// Is the `self' set disjoint from `other' ?
(
+ result:BOOLEAN;
+ i:INTEGER;
-
+
? { other != NULL};
-
+
result := FALSE;
-
+
( Self != other).if {
result := TRUE;
i := 1;
@@ -643,17 +643,17 @@ Section Private
};
};
? { result = (Self ^ other).is_empty };
-
+
result
);
-
-
+
+
- '==' Right 60 other:SELF :BOOLEAN <-
// Is the `self' set equal to `other'?
(
+ i:INTEGER;
+ result:BOOLEAN;
-
+
result := FALSE;
( Self = other ).if {
result := TRUE;
@@ -667,11 +667,11 @@ Section Private
};
//ensure then
//? { result = ((is_subset_of other) & (other.is_subset_of self))};
-
+
result
);
-
-
+
+
- fast_copy other:SELF <-
// Copy 'other' into the current set
@@ -683,17 +683,17 @@ Section Private
} else {
clear;
};
-
+
lower.to (other.count) do { i:INTEGER;
fast_add (other.item i);
};
);
-
-
+
+
// NONE
-
-
- - force e:V <-
+
+
+ - force e:V <-
// Add a new item to the set: the mathematical definition of
// adding in a set is followed.
( + h, idx: INTEGER;
@@ -710,7 +710,7 @@ Section Private
count := count + 1;
? {fast_has e};
);
-
+
- search e:V :V <-
// Is element `e' in the set?
( + idx:INTEGER;
@@ -727,7 +727,7 @@ Section Private
};
result
);
-
+
- get_if cmp:BLOCK with_hash h:INTEGER :V <-
// Is element `e' in the set?
( + idx:INTEGER;
@@ -761,10 +761,10 @@ Section Private
};
result
);
-
+
- fast_index_of elt:V :INTEGER <-
( + result:INTEGER;
-
+
result := upper;
{(result<lower) || {item result = elt}}.until_do {
result := result - 1;
diff --git a/lib/standard/collection/iterator.li b/lib/standard/collection/iterator.li
index f85c5cf..9bbd279 100644
--- a/lib/standard/collection/iterator.li
+++ b/lib/standard/collection/iterator.li
@@ -81,8 +81,8 @@ Section Public
- make t:TRAVERSABLE(V) increment inc:INTEGER :SELF <-
make t index (t.lower) increment inc;
- - make t:TRAVERSABLE(V) index i:INTEGER increment inc:INTEGER :SELF <-
- [
+ - make t:TRAVERSABLE(V) index i:INTEGER increment inc:INTEGER :SELF <-
+ [
-? {inc != 0};
-? {t != NULL};
-? {t.valid_index i};
@@ -91,7 +91,7 @@ Section Public
increment := inc;
traversable := t;
index := i;
- Self
+ Self
);
- make t:TRAVERSABLE(V) index i:INTEGER :SELF <-
diff --git a/lib/standard/collection/linked2_list.li b/lib/standard/collection/linked2_list.li
index 9307f4c..0e99725 100644
--- a/lib/standard/collection/linked2_list.li
+++ b/lib/standard/collection/linked2_list.li
@@ -19,48 +19,48 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED2_LIST(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Two way linked list with internal automatic memorization \
\of the last access .";
-
+
Section Inherit
-
+
+ parent_linked_collection:Expanded LINKED_COLLECTION(V);
-
+
Section LINKED2_LIST
-
+
+ first_link:LINK2(V);
// NULL when empty or gives access to the first element.
-
+
+ last_link:LINK2(V);
// NULL when empty or gives access to the last element.
-
- + mem_idx:INTEGER;
-
+
+ + mem_idx:INTEGER;
+
+ mem_lnk:LINK2(V);
// To speed up accessing, `mem_idx' and `mem_lnk' is the
// memory of the last access done. For example, after
// item(1), `mem_idx' is 1 and `mem_lnk' is `first_link'.
// When list is empty, `first_link' is NULL as well as
// `mem_lnk' and `mem_idx' is 0;
-
+
Section Public
-
+
- create:SELF <-
// Make an empty list;
- (
+ (
SELF.clone
);
-
+
- is_empty:BOOLEAN <- first_link = NULL;
-
+
- add_first element:V <-
- (
+ (
(first_link = NULL).if {
first_link := LINK2(V).create element previous NULL next NULL;
last_link := first_link;
@@ -77,9 +77,9 @@ Section Public
[ ...
+? { upper = 1 + Old upper };
];
-
+
- add_last element:V <-
- (
+ (
(first_link = NULL).if {
first_link := LINK2(V).create element previous NULL next NULL;
last_link := first_link;
@@ -92,10 +92,10 @@ Section Public
upper := upper + 1;
};
);
-
+
- add element:V to index:INTEGER <-
( + link:LINK2(V);
-
+
(index = 1).if {
add_first element;
}.elseif {index = upper + 1} then {
@@ -108,18 +108,18 @@ Section Public
link.next.set_previous link;
mem_lnk.set_next link;
upper := upper + 1;
- };
+ };
);
-
+
- remove_first <-
- (
+ (
(upper = 1).if {
- first_link := NULL;
+ first_link := NULL;
last_link := NULL;
mem_lnk := NULL;
mem_idx := 0;
upper := 0;
- } else {
+ } else {
first_link := first_link.next;
first_link.set_previous NULL;
upper := upper - 1;
@@ -128,13 +128,13 @@ Section Public
} else {
mem_lnk := first_link;
mem_idx := 1;
- };
+ };
};
);
-
+
- remove index:INTEGER <-
( + link:LINK2(V);
-
+
(index = 1).if {
remove_first;
}.elseif { index = upper} then {
@@ -149,11 +149,11 @@ Section Public
upper := upper - 1;
};
);
-
+
- first:V <- first_link.item;
-
+
- last:V <- last_link.item;
-
+
- item index:INTEGER :V <-
(
(index != mem_idx).if {
@@ -161,33 +161,33 @@ Section Public
};
mem_lnk.item
);
-
+
- put element:V to index:INTEGER <-
- (
+ (
(index != mem_idx).if {
go_item index;
};
- mem_lnk.set_item element;
+ mem_lnk.set_item element;
);
-
+
- count:INTEGER <- upper;
-
+
- set_all_with v:V <-
- (
+ (
(first_link != NULL).if {
first_link.set_all_with v;
- };
+ };
);
-
+
- copy other:SELF <-
(
from_collection other;
);
-
+
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <-
( + result:BOOLEAN;
+ lnk1, lnk2:LINK2(V);
-
+
(Self = other).if {
result := TRUE;
}.elseif {upper = other.upper} then {
@@ -199,15 +199,15 @@ Section Public
lnk1 := lnk1.next;
lnk2 := lnk2.next;
};
- };
+ };
result
);
-
+
- is_equal_map other:SELF :BOOLEAN <-
( + result:BOOLEAN;
+ lnk1, lnk2:LINK2(V);
+ safe_equal:SAFE_EQUAL(V);
-
+
( Self = other ).if {
result := TRUE;
}.elseif {upper = other.upper} then {
@@ -219,27 +219,27 @@ Section Public
lnk1 := lnk1.next;
lnk2 := lnk2.next;
};
- };
+ };
result
);
-
+
- index_of x:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
+ safe_equal:SAFE_EQUAL(V);
-
+
result := start_index;
{(result > upper) || {safe_equal.test x with (item result)}}.until_do {
result := result + 1;
- };
+ };
result
);
-
+
- reverse_index_of element:V start start_index:INTEGER :INTEGER <-
- ( + safe_equal:SAFE_EQUAL(V);
+ ( + safe_equal:SAFE_EQUAL(V);
+ temporary_idx:INTEGER;
+ temporary_lnk:LINK2(V);
+ result:INTEGER;
-
+
(start_index != mem_idx).if {
go_item start_index;
};
@@ -260,25 +260,25 @@ Section Public
- fast_index_of x:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
+ u:INTEGER;
-
+
result := lower;
u := upper;
{(result > u) || {x = item result}}.until_do {
result := result + 1;
};
result
- );
+ );
- fast_reverse_index_of element:V start start_index:INTEGER :INTEGER <-
( + temporary_idx:INTEGER;
+ temporary_lnk:LINK2(V);
+ result:INTEGER;
-
+
(start_index != mem_idx).if {
go_item start_index;
};
temporary_idx := mem_idx;
- temporary_lnk := mem_lnk;
+ temporary_lnk := mem_lnk;
{(temporary_idx < lower) || {element = temporary_lnk.item}}.until_do {
temporary_idx := temporary_idx - 1;
temporary_lnk := temporary_lnk.previous;
@@ -289,7 +289,7 @@ Section Public
mem_lnk := temporary_lnk;
};
);
-
+
- clear <-
(
(first_link != NULL).if {
@@ -303,10 +303,10 @@ Section Public
[ ...
+? {upper = 0};
];
-
+
- from_collection model:COLLECTION(V) <-
( + lnk:LINK2(V);
-
+
(first_link = NULL).if {
(model.lower).to (model.upper) do { i:INTEGER;
add_last (model.item i);
@@ -335,14 +335,14 @@ Section Public
upper := i;
last_link := mem_lnk;
};
- };
+ };
);
-
+
- slice low:INTEGER to up:INTEGER :SELF <-
( + lnk:LINK2(V);
+ result:SELF;
- result := SELF.create;
+ result := SELF.create;
(mem_idx != low).if {
go_item low;
};
@@ -353,26 +353,26 @@ Section Public
};
result
);
-
+
- occurrences element:V :INTEGER <-
( + lnk:LINK2(V);
+ safe_equal:SAFE_EQUAL(V);
+ result:INTEGER;
-
+
lnk := first_link;
{lnk = NULL}.until_do {
(safe_equal.test element with (lnk.item)).if {
result := result + 1;
};
lnk := lnk.next;
- };
+ };
result
);
-
+
- fast_occurrences element:V :INTEGER <-
( + lnk:LINK2(V);
+ result:INTEGER;
-
+
lnk := first_link;
{lnk = NULL}.until_do {
(element = lnk.item).if {
@@ -382,21 +382,21 @@ Section Public
};
result
);
-
+
- force element:V to index:INTEGER <-
( + v:V;
-
+
{index <= upper}.until_do {
add_last v;
};
put element to index;
);
-
+
- all_default:BOOLEAN <-
( + l:LINK2(V);
+ d:V;
+ result:BOOLEAN;
-
+
result := TRUE;
l := first_link;
{(! result) || {l = NULL}}.until_do {
@@ -405,12 +405,12 @@ Section Public
result := d.is_default;
};
l := l.next;
- };
+ };
result
);
-
+
- remove_last <-
- (
+ (
(upper = 1).if {
first_link := NULL;
last_link := NULL;
@@ -426,37 +426,37 @@ Section Public
mem_lnk := first_link;
};
upper := upper - 1;
- };
+ };
);
-
+
- replace_all old_value:V with new_value:V <-
( + safe_equal:SAFE_EQUAL(V);
-
+
lower.to upper do { i:INTEGER;
(safe_equal.test (item i) with old_value).if {
put new_value to i;
};
- };
+ };
);
-
+
- fast_replace_all old_value:V with new_value:V <-
- (
+ (
lower.to upper do { i:INTEGER;
(item i = old_value).if {
put new_value to i;
};
- };
+ };
);
-
+
- reverse <-
- ( + temp:V;
- + low:LINK2(V);
+ ( + temp:V;
+ + low:LINK2(V);
+ high:LINK2(V);
+ i:INTEGER;
-
+
low := first_link;
high := last_link;
-
+
i := count / 2;
? {(i > 0) -> ((low != NULL) & (high != NULL))};
? {(i > 0) -> ((low != high) & (low.previous != high))};
@@ -467,11 +467,11 @@ Section Public
low := low.next;
high := high.previous;
i := i - 1;
- };
+ };
);
-
+
Section Private
-
+
- go_item index:INTEGER <-
[ ...
-? { valid_index index };
@@ -512,15 +512,15 @@ Section Private
+? { mem_idx = index };
+? { mem_lnk != NULL };
];
-
+
//
// Invariant.
//
-
+
// [ ...
// "Empty status." -? {(first_link = NULL) ->
// ((last_link = NULL) & (upper = 0) & (mem_idx = 0) & (mem_lnk = NULL))};
-
+
// "Not empty status." -? {(first_link != NULL) ->
// ((last_link != NULL) & (upper > 0) & (mem_idx > 0) & (mem_lnk != NULL))};
// ];
diff --git a/lib/standard/collection/linked_list.li b/lib/standard/collection/linked_list.li
index be74681..677fd77 100644
--- a/lib/standard/collection/linked_list.li
+++ b/lib/standard/collection/linked_list.li
@@ -19,59 +19,59 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED_LIST(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="One way linked list with internal automatic memorization of the last access.";
-
- // One way linked list implementation with internal automatic cached memorization
- // of the last access. Because of the last access memory cache, the traversal of a
- // LINKED_LIST from the `lower' index to the `upper' index using `item' is quite
+
+ // One way linked list implementation with internal automatic cached memorization
+ // of the last access. Because of the last access memory cache, the traversal of a
+ // LINKED_LIST from the `lower' index to the `upper' index using `item' is quite
// efficient. As one can expect, adding element using `add_first' or
- // `add_last' is really efficient too, actually, the total number of elements
- // (i.e. `count') as well as a reference to the last cell is also cached automatically.
- // Keep in mind that LINKED_LIST uses a one way linked storage from `lower' to `upper',
- // so traversing a LINKED_LIST from `upper' to `lower' will be extremely time consumming
+ // `add_last' is really efficient too, actually, the total number of elements
+ // (i.e. `count') as well as a reference to the last cell is also cached automatically.
+ // Keep in mind that LINKED_LIST uses a one way linked storage from `lower' to `upper',
+ // so traversing a LINKED_LIST from `upper' to `lower' will be extremely time consumming
// (also consider LINKED2_LIST).
-
+
Section Inherit
-
+
+ parent_linked_collection:Expanded LINKED_COLLECTION(V);
-
+
Section LINKED_LIST
-
+
+ first_link:LINKED_LIST_NODE(V);
// NULL when empty or gives access to the first element.
-
+
+ last_link:LINKED_LIST_NODE(V);
// NULL when empty or gives access to the last element.
-
- + mem_idx:INTEGER;
+
+ + mem_idx:INTEGER;
+ mem_lnk:LINKED_LIST_NODE(V);
// To speed up accessing, `mem_idx' and `mem_lnk' is the
// memory of the last access done. For example, after
// item(1), `mem_idx' is 1 and `mem_lnk' is `first_link'.
// When list is empty, `first_link' is NULL as well as
// `mem_lnk' and `mem_idx' is 0;
-
+
Section Public
-
+
- create:SELF <-
// Make an empty list;
- (
- SELF.clone
+ (
+ SELF.clone
)
[ ...
+? {count = 0};
];
-
+
- is_empty:BOOLEAN <- first_link = NULL;
-
+
- add_first element:V <-
- (
+ (
(first_link = NULL).if {
first_link := LINKED_LIST_NODE(V).create element next NULL;
upper := 1;
@@ -82,12 +82,12 @@ Section Public
first_link := LINKED_LIST_NODE(V).create element next first_link;
upper := upper + 1;
mem_idx := mem_idx + 1;
- };
+ };
);
-
+
- add_last element:V <-
( + lnk:LINKED_LIST_NODE(V);
-
+
(first_link = NULL).if {
first_link := LINKED_LIST_NODE(V).create element next NULL;
upper := 1;
@@ -101,7 +101,7 @@ Section Public
last_link := lnk;
};
);
-
+
- add element:V to index:INTEGER <-
( + link:LINKED_LIST_NODE(V);
@@ -118,11 +118,11 @@ Section Public
upper := upper + 1;
};
);
-
+
- remove_first <-
- (
+ (
(upper = 1).if {
- first_link := NULL;
+ first_link := NULL;
last_link := NULL;
mem_lnk := NULL;
mem_idx := 0;
@@ -135,12 +135,12 @@ Section Public
mem_idx := mem_idx - 1;
};
upper := upper - 1;
- };
+ };
);
-
+
- remove index:INTEGER <-
- ( + link:LINKED_LIST_NODE(V);
-
+ ( + link:LINKED_LIST_NODE(V);
+
(index = 1).if {
remove_first;
}.elseif {index = upper} then {
@@ -152,13 +152,13 @@ Section Public
link := mem_lnk.next;
mem_lnk.set_next (link.next);
upper := upper - 1;
- };
+ };
);
-
+
- first:V <- first_link.item;
-
+
- last:V <- last_link.item;
-
+
- item i:INTEGER :V <-
(
(i != mem_idx).if {
@@ -166,33 +166,33 @@ Section Public
};
mem_lnk.item
);
-
+
- put element:V to i:INTEGER <-
- (
+ (
(i != mem_idx).if {
go_item i;
};
mem_lnk.set_item element;
);
-
+
- count:INTEGER <- upper;
-
+
- set_all_with v:V <-
- (
+ (
(first_link != NULL).if {
first_link.set_all_with v;
- };
+ };
);
-
+
- copy other:SELF <-
(
from_collection other;
);
-
+
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <-
( + result:BOOLEAN;
+ lnk1, lnk2:LINKED_LIST_NODE(V);
-
+
(Self = other).if {
result := TRUE;
}.elseif {upper = other.upper} then {
@@ -204,15 +204,15 @@ Section Public
lnk1 := lnk1.next;
lnk2 := lnk2.next;
};
- };
+ };
result
);
-
+
- is_equal_map other:SELF :BOOLEAN <-
( + result:BOOLEAN;
- + lnk1, lnk2:LINKED_LIST_NODE(V);
+ + lnk1, lnk2:LINKED_LIST_NODE(V);
+ safe_equal:SAFE_EQUAL(V);
-
+
( Self = other).if {
result := TRUE;
}.elseif {upper = other.upper} then {
@@ -224,24 +224,24 @@ Section Public
lnk1 := lnk1.next;
lnk2 := lnk2.next;
};
- };
+ };
result
);
-
+
- index_of element:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
//+ safe_equal:SAFE_EQUAL(V);
-
+
result := start_index;
//{(result > upper) || {safe_equal.test x with (item result)}}.until_do {
{(result > upper) || {element == item result}}.until_do {
result := result + 1;
- };
+ };
result
);
- reverse_index_of element:V start start_index:INTEGER :INTEGER <-
- ( + safe_equal: SAFE_EQUAL(V);
+ ( + safe_equal: SAFE_EQUAL(V);
+ temporary_idx, new_mem_idx:INTEGER;
+ temporary_lnk, new_mem_lnk:LINKED_LIST_NODE(V);
+ result:INTEGER;
@@ -265,11 +265,11 @@ Section Public
};
result
);
-
+
- fast_index_of element:V start start_index:INTEGER :INTEGER <-
( + u:INTEGER;
+ result:INTEGER;
-
+
result := start_index;
u := upper;
{(result > u) || {element = item result}}.until_do {
@@ -277,9 +277,9 @@ Section Public
};
result
);
-
+
- fast_reverse_index_of element:V start start_index:INTEGER :INTEGER <-
- ( + safe_equal: SAFE_EQUAL(V);
+ ( + safe_equal: SAFE_EQUAL(V);
+ temporary_idx, new_mem_idx:INTEGER;
+ temporary_lnk, new_mem_lnk:LINKED_LIST_NODE(V);
+ result:INTEGER;
@@ -303,7 +303,7 @@ Section Public
};
result
);
-
+
- clear <-
(
(first_link != NULL).if {
@@ -315,12 +315,12 @@ Section Public
};
)
[ ...
- +? {upper = 0};
+ +? {upper = 0};
];
-
+
- from_collection model:COLLECTION(V) <-
( + lnk:LINKED_LIST_NODE(V);
-
+
(first_link = NULL).if {
(model.lower).to (model.upper) do { i:INTEGER;
add_last (model.item i);
@@ -336,7 +336,7 @@ Section Public
};
};
(lnk = first_link).if {
- ? { model.count = 0 };
+ ? { model.count = 0 };
clear;
}.elseif { lnk != NULL } then {
+ i:INTEGER;
@@ -344,19 +344,19 @@ Section Public
(mem_idx != i).if {
go_item i;
};
- ? { lnk = mem_lnk.next };
+ ? { lnk = mem_lnk.next };
mem_lnk.set_next NULL;
upper := i;
last_link := mem_lnk;
};
- };
+ };
);
-
+
- slice low:INTEGER to up:INTEGER :SELF <-
( + result:SELF;
+ lnk:LINKED_LIST_NODE(V);
-
- result := SELF.create;
+
+ result := SELF.create;
(mem_idx != low).if {
go_item low;
};
@@ -365,29 +365,29 @@ Section Public
result.add_last (lnk.item);
lnk := lnk.next;
};
-
+
result
);
-
+
- occurrences element:V :INTEGER <-
( + lnk:LINKED_LIST_NODE(V);
+ result:INTEGER;
+ safe_equal:SAFE_EQUAL(V);
-
+
lnk := first_link;
{lnk = NULL}.until_do {
(safe_equal.test element with (lnk.item)).if {
result := result + 1;
};
lnk := lnk.next;
- };
+ };
result
);
-
+
- fast_occurrences element:V :INTEGER <-
( + lnk:LINKED_LIST_NODE(V);
+ result:INTEGER;
-
+
lnk := first_link;
{lnk = NULL}.until_do {
(element = lnk.item).if {
@@ -397,21 +397,21 @@ Section Public
};
result
);
-
+
- force element:V to index:INTEGER <-
( + v:V;
-
+
{index <= upper}.until_do {
add_last v;
};
put element to index;
);
-
+
- all_default:BOOLEAN <-
( + result:BOOLEAN;
+ l:LINKED_LIST_NODE(V);
+ d:V;
-
+
result := TRUE;
l := first_link;
{(! result) || {l = NULL}}.until_do {
@@ -421,12 +421,12 @@ Section Public
};
l := l.next;
};
-
+
result
);
-
+
- remove_last <-
- (
+ (
(upper = 1).if {
first_link := NULL;
last_link := NULL;
@@ -440,21 +440,21 @@ Section Public
upper := upper - 1;
last_link := mem_lnk;
last_link.set_next NULL;
- };
+ };
);
-
+
- replace_all old_value:V with new_value:V <-
( + safe_equal:SAFE_EQUAL(V);
-
+
lower.to upper do { i:INTEGER;
(safe_equal.test (item i) with old_value).if {
put new_value to i;
};
- };
+ };
);
-
+
- fast_replace_all old_value:V with new_value:V <-
- (
+ (
lower.to upper do { i:INTEGER;
(item i = old_value).if {
put new_value to i;
@@ -464,8 +464,8 @@ Section Public
- reverse <-
( + prev, lnk, next:LINKED_LIST_NODE(V);
-
- lnk := first_link;
+
+ lnk := first_link;
{lnk = NULL}.until_do {
next := lnk.next;
lnk.set_next prev;
@@ -478,17 +478,17 @@ Section Public
mem_idx := count - mem_idx + 1;
};
);
-
+
Section Private
-
+
- go_item i:INTEGER <-
- [
+ [
-? { valid_index i};
-? { mem_idx != i};
-? { mem_idx > 0};
-? { mem_lnk != NULL};
- ]
- (
+ ]
+ (
(mem_idx > i).if {
mem_idx := 1;
mem_lnk := first_link;
@@ -502,15 +502,15 @@ Section Private
+? {mem_idx = i};
+? {mem_lnk != NULL};
];
-
+
//
// Invariant
//
-
+
// [ ...
-// "Empty status." -? {(first_link = NULL) ->>
+// "Empty status." -? {(first_link = NULL) ->>
// {(last_link = NULL) & (upper = 0) & (mem_idx = 0) & (mem_lnk = NULL)}};
-// "Not empty status." -? {(first_link != NULL) ->>
-// {(last_link != NULL) & (upper > 0) & (mem_idx > 0) & (mem_lnk != NULL)}};
+// "Not empty status." -? {(first_link != NULL) ->>
+// {(last_link != NULL) & (upper > 0) & (mem_idx > 0) & (mem_lnk != NULL)}};
// ];
diff --git a/lib/standard/collection/linked_xor_list.li b/lib/standard/collection/linked_xor_list.li
index 6651a5c..204151c 100644
--- a/lib/standard/collection/linked_xor_list.li
+++ b/lib/standard/collection/linked_xor_list.li
@@ -19,55 +19,55 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LINKED_XOR_LIST(V);
- copyright := "2003-2007 Benoit Sonntag";
-
+
- comment := "One Xor way linked list with internal automatic memorization \
\of the last access .";
-
+
Section Inherit
-
+
+ parent_linked_collection:Expanded LINKED_COLLECTION(V);
-
+
Section LINKED2_LIST
-
+
+ first_link:LINKED_XOR_NODE(V);
// NULL when empty or gives access to the first element.
-
+
+ last_link:LINKED_XOR_NODE(V);
// NULL when empty or gives access to the last element.
-
- + mem_idx:INTEGER;
-
+
+ + mem_idx:INTEGER;
+
+ mem_lnk:LINKED_XOR_NODE(V);
+ mem_lnk_prev:LINKED_XOR_NODE(V);
- + mem_lnk_next:LINKED_XOR_NODE(V);
+ + mem_lnk_next:LINKED_XOR_NODE(V);
// To speed up accessing, `mem_idx' and `mem_lnk' is the
// memory of the last access done. For example, after
// item(1), `mem_idx' is 1 and `mem_lnk' is `first_link'.
// When list is empty, `first_link' is NULL as well as
// `mem_lnk' and `mem_idx' is 0;
-
+
Section Public
-
+
- create:SELF <-
// Make an empty list;
- (
+ (
SELF.clone
);
-
+
- is_empty:BOOLEAN <- first_link = NULL;
-
+
- add_first element:V <-
( + new:LINKED_XOR_NODE(V);
(first_link = NULL).if {
first_link := LINKED_XOR_NODE(V).create element previous NULL next NULL;
last_link := first_link;
upper := mem_idx := 1;
- mem_lnk := first_link;
+ mem_lnk := first_link;
} else {
new := LINKED_XOR_NODE(V).create element previous NULL next first_link;
first_link.set_link new and (first_link.next NULL);
@@ -82,7 +82,7 @@ Section Public
[ ...
+? { upper = 1 + Old upper };
];
-
+
- add_last element:V <-
( + new:LINKED_XOR_NODE(V);
(first_link = NULL).if {
@@ -101,10 +101,10 @@ Section Public
upper := upper + 1;
};
);
-
+
- add element:V to index:INTEGER <-
( + link:LINKED_XOR_NODE(V);
-
+
(index = 1).if {
add_first element;
}.elseif {index = upper + 1} then {
@@ -118,18 +118,18 @@ Section Public
mem_lnk.set_link mem_lnk_prev and link;
mem_lnk_next := link;
upper := upper + 1;
- };
+ };
);
-
+
- remove_first <-
( + next,next_next:LINKED_XOR_NODE;
(upper = 1).if {
- first_link := NULL;
+ first_link := NULL;
last_link := NULL;
mem_lnk := mem_lnk_prev := mem_lnk_next := NULL;
mem_idx := 0;
upper := 0;
- } else {
+ } else {
next := first_link.next NULL;
next_next := next.next first_link;
next.set_link NULL and next_next;
@@ -144,13 +144,13 @@ Section Public
mem_lnk := first_link;
mem_lnk_next := next_next;
mem_idx := 1;
- };
+ };
};
);
-
+
- remove index:INTEGER <-
( + next_next:LINKED_XOR_NODE(V);
-
+
(index = 1).if {
remove_first;
}.elseif { index = upper} then {
@@ -167,11 +167,11 @@ Section Public
upper := upper - 1;
};
);
-
+
- first:V <- first_link.item;
-
+
- last:V <- last_link.item;
-
+
- item index:INTEGER :V <-
(
(index != mem_idx).if {
@@ -179,39 +179,39 @@ Section Public
};
mem_lnk.item
);
-
+
- put element:V to index:INTEGER <-
- (
+ (
(index != mem_idx).if {
go_item index;
};
- mem_lnk.set_item element;
+ mem_lnk.set_item element;
);
-
+
- count:INTEGER <- upper;
-
+
- set_all_with v:V <-
- (
+ (
not_yet_implemented;
-
+
(first_link != NULL).if {
first_link.set_all_with v;
- };
+ };
);
-
+
- copy other:SELF <-
(
not_yet_implemented;
-
+
from_collection other;
);
-
+
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <-
( + result:BOOLEAN;
+ lnk1, lnk2:LINKED_XOR_NODE(V);
-
+
not_yet_implemented;
-
+
(Self = other).if {
result := TRUE;
}.elseif {upper = other.upper} then {
@@ -223,17 +223,17 @@ Section Public
lnk1 := lnk1.next;
lnk2 := lnk2.next;
};
- };
+ };
result
);
-
+
- is_equal_map other:SELF :BOOLEAN <-
( + result:BOOLEAN;
+ lnk1, lnk2:LINKED_XOR_NODE(V);
+ safe_equal:SAFE_EQUAL(V);
-
+
not_yet_implemented;
-
+
( Self = other ).if {
result := TRUE;
}.elseif {upper = other.upper} then {
@@ -245,31 +245,31 @@ Section Public
lnk1 := lnk1.next;
lnk2 := lnk2.next;
};
- };
+ };
result
);
-
+
- index_of x:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
+ safe_equal:SAFE_EQUAL(V);
-
+
not_yet_implemented;
-
+
result := start_index;
{(result > upper) || {safe_equal.test x with (item result)}}.until_do {
result := result + 1;
- };
+ };
result
);
-
+
- reverse_index_of element:V start start_index:INTEGER :INTEGER <-
- ( + safe_equal:SAFE_EQUAL(V);
+ ( + safe_equal:SAFE_EQUAL(V);
+ temporary_idx:INTEGER;
+ temporary_lnk:LINKED_XOR_NODE(V);
+ result:INTEGER;
-
+
not_yet_implemented;
-
+
(start_index != mem_idx).if {
go_item start_index;
};
@@ -290,29 +290,29 @@ Section Public
- fast_index_of x:V start start_index:INTEGER :INTEGER <-
( + result:INTEGER;
+ u:INTEGER;
-
+
not_yet_implemented;
-
+
result := lower;
u := upper;
{(result > u) || {x = item result}}.until_do {
result := result + 1;
};
result
- );
+ );
- fast_reverse_index_of element:V start start_index:INTEGER :INTEGER <-
( + temporary_idx:INTEGER;
+ temporary_lnk:LINKED_XOR_NODE(V);
+ result:INTEGER;
-
+
not_yet_implemented;
-
+
(start_index != mem_idx).if {
go_item start_index;
};
temporary_idx := mem_idx;
- temporary_lnk := mem_lnk;
+ temporary_lnk := mem_lnk;
{(temporary_idx < lower) || {element = temporary_lnk.item}}.until_do {
temporary_idx := temporary_idx - 1;
temporary_lnk := temporary_lnk.previous;
@@ -323,12 +323,12 @@ Section Public
mem_lnk := temporary_lnk;
};
);
-
+
- clear <-
(
-
+
not_yet_implemented;
-
+
(first_link != NULL).if {
first_link := NULL;
mem_idx := 0;
@@ -340,12 +340,12 @@ Section Public
[ ...
+? {upper = 0};
];
-
+
- from_collection model:COLLECTION(V) <-
( + lnk:LINKED_XOR_NODE(V);
-
+
not_yet_implemented;
-
+
(first_link = NULL).if {
(model.lower).to (model.upper) do { i:INTEGER;
add_last (model.item i);
@@ -374,16 +374,16 @@ Section Public
upper := i;
last_link := mem_lnk;
};
- };
+ };
);
-
+
- slice low:INTEGER to up:INTEGER :SELF <-
( + lnk:LINKED_XOR_NODE(V);
+ result:SELF;
-
+
not_yet_implemented;
-
- result := SELF.create;
+
+ result := SELF.create;
(mem_idx != low).if {
go_item low;
};
@@ -394,30 +394,30 @@ Section Public
};
result
);
-
+
- occurrences element:V :INTEGER <-
( + lnk:LINKED_XOR_NODE(V);
+ safe_equal:SAFE_EQUAL(V);
+ result:INTEGER;
-
+
not_yet_implemented;
-
+
lnk := first_link;
{lnk = NULL}.until_do {
(safe_equal.test element with (lnk.item)).if {
result := result + 1;
};
lnk := lnk.next;
- };
+ };
result
);
-
+
- fast_occurrences element:V :INTEGER <-
( + lnk:LINKED_XOR_NODE(V);
+ result:INTEGER;
-
+
not_yet_implemented;
-
+
lnk := first_link;
{lnk = NULL}.until_do {
(element = lnk.item).if {
@@ -427,25 +427,25 @@ Section Public
};
result
);
-
+
- force element:V to index:INTEGER <-
( + v:V;
-
+
not_yet_implemented;
-
+
{index <= upper}.until_do {
add_last v;
};
put element to index;
);
-
+
- all_default:BOOLEAN <-
( + l:LINKED_XOR_NODE(V);
+ d:V;
+ result:BOOLEAN;
-
+
not_yet_implemented;
-
+
result := TRUE;
l := first_link;
{(! result) || {l = NULL}}.until_do {
@@ -454,12 +454,12 @@ Section Public
result := d.is_default;
};
l := l.next;
- };
+ };
result
);
-
+
- remove_last <-
- (
+ (
(upper = 1).if {
first_link := NULL;
last_link := NULL;
@@ -469,7 +469,7 @@ Section Public
} else {
link := last_link.previous NULL;
link.set_link (link.previous last_link) and NULL;
- last_link := link;
+ last_link := link;
(mem_idx = upper).if {
mem_idx := 1;
mem_lnk := first_link;
@@ -477,44 +477,44 @@ Section Public
mem_lnk_next := mem_lnk.next NULL;
};
upper := upper - 1;
- };
+ };
);
-
+
- replace_all old_value:V with new_value:V <-
( + safe_equal:SAFE_EQUAL(V);
-
+
not_yet_implemented;
-
+
lower.to upper do { i:INTEGER;
(safe_equal.test (item i) with old_value).if {
put new_value to i;
};
- };
+ };
);
-
+
- fast_replace_all old_value:V with new_value:V <-
- (
-
+ (
+
not_yet_implemented;
-
+
lower.to upper do { i:INTEGER;
(item i = old_value).if {
put new_value to i;
};
- };
+ };
);
-
+
- reverse <-
- ( + temp:V;
- + low:LINKED_XOR_NODE(V);
+ ( + temp:V;
+ + low:LINKED_XOR_NODE(V);
+ high:LINKED_XOR_NODE(V);
+ i:INTEGER;
-
+
not_yet_implemented;
-
+
low := first_link;
high := last_link;
-
+
i := count / 2;
? {(i > 0) -> ((low != NULL) & (high != NULL))};
? {(i > 0) -> ((low != high) & (low.previous != high))};
@@ -525,11 +525,11 @@ Section Public
low := low.next;
high := high.previous;
i := i - 1;
- };
+ };
);
-
+
Section Private
-
+
- go_item index:INTEGER <-
[ ...
-? { valid_index index };
@@ -562,7 +562,7 @@ Section Private
{index = mem_idx}.until_do {
mem_lnk_next := mem_lnk;
mem_lnk := mem_lnk_prev;
- mem_lnk_prev := mem_lnk.previous mem_lnk_next;
+ mem_lnk_prev := mem_lnk.previous mem_lnk_next;
mem_idx := mem_idx - 1;
};
} else {
@@ -573,7 +573,7 @@ Section Private
{index = mem_idx}.until_do {
mem_lnk_prev := mem_lnk;
mem_lnk := mem_lnk_next;
- mem_lnk_next := mem_lnk.next mem_lnk_prev;
+ mem_lnk_next := mem_lnk.next mem_lnk_prev;
mem_idx := mem_idx + 1;
};
};
@@ -582,15 +582,15 @@ Section Private
+? { mem_idx = index };
+? { mem_lnk != NULL };
];
-
+
//
// Invariant.
//
-
+
// [ ...
// "Empty status." -? {(first_link = NULL) ->
// ((last_link = NULL) & (upper = 0) & (mem_idx = 0) & (mem_lnk = NULL))};
-
+
// "Not empty status." -? {(first_link != NULL) ->
// ((last_link != NULL) & (upper > 0) & (mem_idx > 0) & (mem_lnk != NULL))};
// ];
diff --git a/lib/standard/file_system/directory.li b/lib/standard/file_system/directory.li
index e715a6b..fbf80fa 100644
--- a/lib/standard/file_system/directory.li
+++ b/lib/standard/file_system/directory.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DIRECTORY;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Basic Directory management";
-
+
Section Inherit
-
+
- parent_entry:ENTRY := ENTRY;
-
+
Section DIRECTORY
-
+
+ list:LINKED_LIST(ENTRY);
- - alias:HASHED_DICTIONARY(ENTRY,ABSTRACT_STRING) :=
+ - alias:HASHED_DICTIONARY(ENTRY,ABSTRACT_STRING) :=
HASHED_DICTIONARY(ENTRY,ABSTRACT_STRING).create;
-
+
Section Public
-
+
//
// Manager.
//
-
+
- remove_me <- remove_path ".";
-
+
- remove p:ABSTRACT_STRING :BOOLEAN <-
// Remove file or directory (WARNING: delete recursive)
( + dir:DIRECTORY;
+ i:INTEGER;
+ result:BOOLEAN;
+ e:ENTRY;
-
+
e := get_entry p;
(e != NULL).if {
(e.is_directory).if {
dir ?= e;
result := dir.open;
(result).if {
- i := dir.lower;
+ i := dir.lower;
{(i > dir.upper) || {! result}}.until_do {
result := remove (dir.item i.path);
i := i + 1;
- };
+ };
result.if {
result := physical_remove (e.path);
};
@@ -73,25 +73,25 @@ Section Public
};
(result).if {
// Remove Alias.
- alias.remove (e.path);
+ alias.remove (e.path);
};
};
result
);
-
+
- move old_path:ABSTRACT_STRING to new_path:ABSTRACT_STRING :BOOLEAN <-
( + result:BOOLEAN;
+ e:ENTRY;
-
+
"WARNING : Et les alias des sous répertoires, fichiers, ...\n".print;
-
+
string_tmp.copy path;
string_tmp.add_last '/';
- string_tmp.append old_path;
+ string_tmp.append old_path;
reduce_path string_tmp;
string_tmp2.copy path;
string_tmp2.add_last '/';
- string_tmp2.append new_path;
+ string_tmp2.append new_path;
reduce_path string_tmp2;
e := alias.reference_at string_tmp;
((result := physical_move string_tmp to string_tmp2) && {e != NULL}).if {
@@ -101,41 +101,41 @@ Section Public
};
result
);
-
- - get_entry p:ABSTRACT_STRING :ENTRY <-
+
+ - get_entry p:ABSTRACT_STRING :ENTRY <-
( + result:ENTRY;
+ idx:INTEGER;
string_tmp2.copy path;
string_tmp2.add_last '/';
string_tmp2.append p;
reduce_path string_tmp2;
- string_tmp3.copy string_tmp2;
+ string_tmp3.copy string_tmp2;
{
result := alias.reference_at string_tmp2; // with { (e1,e2:ABSTRACT_STRING); e1 ~= e2 };
(result = NULL).if {
- idx := string_tmp2.fast_last_index_of '/';
+ idx := string_tmp2.fast_last_index_of '/';
(idx > 0).if {
string_tmp2.keep_head (idx-1);
} else {
string_tmp2.clear;
};
};
- }.do_while {(result = NULL) && {! string_tmp2.is_empty}};
+ }.do_while {(result = NULL) && {! string_tmp2.is_empty}};
(result = NULL).if {
result := FILE_SYSTEM.physical_get_entry string_tmp3;
}.elseif {string_tmp3.count != string_tmp2.count} then {
+ dir:DIRECTORY;
- dir ?= result;
- result := dir.physical_get_entry string_tmp3;
+ dir ?= result;
+ result := dir.physical_get_entry string_tmp3;
};
result
- );
-
+ );
+
//
// Indexing.
//
-
+
- open:BOOLEAN <-
(
deferred;
@@ -143,105 +143,105 @@ Section Public
[
+? {list != NULL};
];
-
+
- is_open:BOOLEAN <- list != NULL;
-
+
- lower:INTEGER := 1;
// Minimum index.
-
- - upper:INTEGER <-
+
+ - upper:INTEGER <-
[
{is_open} -? "Directory not open.";
]
(
list.upper
- );
-
+ );
+
// Maximum index.
-
- - valid_index index:INTEGER :BOOLEAN <-
+
+ - valid_index index:INTEGER :BOOLEAN <-
// True when `index' is valid (ie. inside actual
// bounds of the collection).
[
{is_open} -? "Directory not open.";
]
- (
- index.in_range lower to upper
+ (
+ index.in_range lower to upper
)
[
+? {Result = index.in_range lower to upper};
+? {list.count = Old list.count};
];
-
+
//
// Counting.
//
-
+
- count:INTEGER <- (upper - lower + 1);
// Number of available indices.
-
+
- is_empty:BOOLEAN <- count = 0;
// Is collection empty ?
-
+
//
// Accessing.
//
-
+
- item i:INTEGER :ENTRY <-
- // Item at the corresponding index `i'.
+ // Item at the corresponding index `i'.
[
-? {valid_index i};
{is_open} -? "Directory not open.";
]
- (
+ (
list.item i
- );
-
- - first:ENTRY <-
- // The very `first' item.
+ );
+
+ - first:ENTRY <-
+ // The very `first' item.
[
{is_open} -? "Directory not open.";
-? {! is_empty};
]
- (
+ (
item lower
);
-
-
+
+
- last:ENTRY <-
// The `last' item.
[
{is_open} -? "Directory not open.";
-? {! is_empty};
]
- (
+ (
item upper
);
-
+
- parent:ENTRY <-
(
get_entry ".."
);
-
+
//
// Writing:
//
-
+
- make_directory p:ABSTRACT_STRING :DIRECTORY <-
- ( + result:DIRECTORY;
+ ( + result:DIRECTORY;
string_tmp.copy path;
string_tmp.add_last '/';
- string_tmp.append p;
- reduce_path string_tmp;
+ string_tmp.append p;
+ reduce_path string_tmp;
(physical_make_directory string_tmp).if {
- result ?= get_entry string_tmp;
+ result ?= get_entry string_tmp;
? {result != NULL};
};
result
);
-
+
- make_file p:ABSTRACT_STRING :FILE <-
- ( + result:FILE;
+ ( + result:FILE;
string_tmp.copy path;
string_tmp.add_last '/';
string_tmp.append p;
@@ -252,20 +252,20 @@ Section Public
};
result
);
-
+
- create_file p:ABSTRACT_STRING :FILE <-
(
make_file p
);
-
+
//
// Display.
//
-
+
- print <-
- (
- lower.to upper do { j:INTEGER;
- string_tmp.copy (item j.path);
+ (
+ lower.to upper do { j:INTEGER;
+ string_tmp.copy (item j.path);
(item j.is_directory).if {
string_tmp.append " D ";
} else {
@@ -275,49 +275,49 @@ Section Public
string_tmp.add_last ' ';
};
string_tmp.print;
- };
+ };
'\n'.print;
);
-
+
Section DIRECTORY
-
+
//
// Physical implementation.
//
- physical_get_entry new_path:ABSTRACT_STRING :ENTRY <-
( + result:ENTRY;
-
- ((! is_open) && {open}).if {
+
+ ((! is_open) && {open}).if {
result := get_entry new_path;
};
result
);
-
+
- physical_make_directory new_path:ABSTRACT_STRING :BOOLEAN <-
- (
+ (
deferred;
FALSE
);
- physical_make_file new_path:ABSTRACT_STRING :BOOLEAN <-
- (
+ (
deferred;
FALSE
);
- physical_remove p:ABSTRACT_STRING :BOOLEAN <-
- (
+ (
deferred;
FALSE
);
-
+
- physical_move old_path:ABSTRACT_STRING to new_path:ABSTRACT_STRING :BOOLEAN <-
- (
+ (
deferred;
FALSE
);
-
+
Section Private
-
+
- string_tmp3:STRING := STRING.create 255;
diff --git a/lib/standard/file_system/entry.li b/lib/standard/file_system/entry.li
index 51020f3..e1049f4 100644
--- a/lib/standard/file_system/entry.li
+++ b/lib/standard/file_system/entry.li
@@ -19,102 +19,102 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ENTRY;
- copyright := "2003-2007 Benoit Sonntag, Jerome Hilbert";
-
+
- comment := "Abstract Entry.";
-
-Section Inherit
-
+
+Section Inherit
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
//
// Path.
//
-
+
+ path:STRING_CONSTANT;
-
- + name:STRING_CONSTANT;
-
+
+ + name:STRING_CONSTANT;
+
- dirname:STRING <-
( + result:STRING;
-
+
result := STRING.create (path.count);
get_parent_path path in result;
result
);
-
+
//
// Date / Time.
//
-
+
- access:UINTEGER_16 <- ( deferred; 0);
-
+
- access_time:TIME <- ( deferred; TIME);
- access_date:DATE <- ( deferred; DATE);
-
+
- update_time:TIME <- ( deferred; TIME);
- update_date:DATE <- ( deferred; DATE);
-
+
- create_time:TIME <- ( deferred; TIME);
- create_date:DATE <- ( deferred; DATE);
-
+
//
// type.
//
-
+
- is_directory:BOOLEAN <-
( + dir:DIRECTORY;
+ e:ENTRY;
-
+
e := Self; // Bug Compilo
dir ?= e;
dir != NULL
);
-
+
- is_file:BOOLEAN <- ! is_directory;
-
+
//
// Open / Close
//
-
+
- open:BOOLEAN <-
// Return FILE or DIRECTORY, NULL:error.
- (
+ (
deferred;
- );
-
- - is_open:BOOLEAN <-
+ );
+
+ - is_open:BOOLEAN <-
(
deferred;
FALSE
);
-
+
Section ENTRY
-
+
- string_tmp:STRING := STRING.create 255;
-
+
- string_tmp2:STRING := STRING.create 255;
-
+
- set_path n:ABSTRACT_STRING <-
( + idx:INTEGER;
path := STRING_CONSTANT.create_copy n;
- idx := path.last_index_of '/';
+ idx := path.last_index_of '/';
(name = NULL).if {
name := STRING_CONSTANT.clone;
};
- name.set_storage (path.storage + idx) count (path.count - idx);
+ name.set_storage (path.storage + idx) count (path.count - idx);
);
-
+
- reduce_path st:STRING <-
( + i:INTEGER;
+ stat:INTEGER;
+ car:CHARACTER;
-
+
st.replace_all '\\' with '/';
i := st.lower;
@@ -138,7 +138,7 @@ Section ENTRY
i := i - 2;
stat := 1;
}.when 3 then {
- // toto/foo/../bar => toto/bar
+ // toto/foo/../bar => toto/bar
// ^ ^
+ idx:INTEGER;
idx := st.last_index_of '/' since (i-4);
@@ -167,18 +167,18 @@ Section ENTRY
// foo/...bar => foo/...bar
stat := 0;
};
- }.elseif {(car = ':') && {i > 2} &&
+ }.elseif {(car = ':') && {i > 2} &&
{st.item (i-1).is_letter} && {st.item (i-2) = '/'}
} then {
st.remove_first (i-2);
- i := st.lower;
+ i := st.lower;
} else {
// Other character.
stat := 0;
};
i := i + 1;
};
-
+
stat.when 0 then {
// foo/bar => foo/bar
// ^ ^
@@ -189,9 +189,9 @@ Section ENTRY
}.when 2 then {
// foo/. => foo
// ^ ^
- st.remove_last 2;
+ st.remove_last 2;
}.when 3 then {
- // toto/foo/.. => toto
+ // toto/foo/.. => toto
// ^ ^
+ idx:INTEGER;
idx := st.last_index_of '/' since (i-4);
@@ -201,7 +201,7 @@ Section ENTRY
st.remove_between idx to (i-1);
};
};
-
+
(st.is_empty).if {
st.add_last '/';
};
@@ -210,13 +210,13 @@ Section ENTRY
//
// Alias Entry.
//
-
+
- get_parent_path p:ABSTRACT_STRING in tmp:STRING <-
- [
+ [
-? {p.last != '/'};
]
( + i:INTEGER;
-
+
(tmp != p).if {
tmp.copy p;
};
@@ -225,7 +225,7 @@ Section ENTRY
tmp.copy "../";
} else {
tmp.keep_head (i-1);
- (tmp.is_empty).if {
+ (tmp.is_empty).if {
tmp.add_last '/';
};
};
diff --git a/lib/standard/file_system/file.li b/lib/standard/file_system/file.li
index 50feea1..fff6398 100644
--- a/lib/standard/file_system/file.li
+++ b/lib/standard/file_system/file.li
@@ -19,55 +19,55 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FILE;
- copyright := "2003-2007 Benoit Sonntag, Jerome Hilbert";
-
+
- comment := "Abstract File Management";
-
+
Section Inherit
-
- - parent_entry:ENTRY := ENTRY;
-
+
+ - parent_entry:ENTRY := ENTRY;
+
Section Public
-
+
- cursor:UINTEGER_32 <-
[
-? {is_open};
]
- (
+ (
deferred;
0
);
-
+
- size:UINTEGER_32 <-
- (
+ (
deferred;
0
);
-
+
- set_cursor n:UINTEGER_32 <-
[
-? {is_open};
-? {n <= size};
]
(
- deferred;
+ deferred;
);
-
+
//
// Update.
//
-
+
- is_empty:BOOLEAN <- size = 0;
// Is collection empty ?
-
+
//
// Read.
//
-
- - read dest:OBJECT :INTEGER <-
+
+ - read dest:OBJECT :INTEGER <-
// WARNING: It's good for Mapping objects, else serializable is necessary.
[
-? {is_open};
@@ -75,8 +75,8 @@ Section Public
( + buf:NATIVE_ARRAY(UINTEGER_8);
buf := CONVERT(OBJECT,NATIVE_ARRAY(UINTEGER_8)).on dest;
physical_read buf size (dest.object_size)
- );
-
+ );
+
- read dest:ARRAYED size nb_elt:INTEGER :INTEGER <-
[
-? {is_open};
@@ -85,22 +85,22 @@ Section Public
+ index,s:INTEGER;
+ result:INTEGER;
+ new_count:INTEGER;
-
+
new_count := dest.count + nb_elt;
dest.set_capacity new_count;
buf := dest.to_native_array_uinteger_8;
index := dest.count * dest.element_sizeof;
- s := nb_elt * dest.element_sizeof;
+ s := nb_elt * dest.element_sizeof;
result := physical_read (buf+index) size s;
dest.set_count new_count;
? {result % dest.element_sizeof = 0};
result / dest.element_sizeof
);
-
+
//
// Write.
//
-
+
- write src:ARRAYED from start:INTEGER size nb_elt:INTEGER :INTEGER <-
[
-? {is_open};
@@ -108,7 +108,7 @@ Section Public
( + buf:NATIVE_ARRAY(UINTEGER_8);
+ index,s:INTEGER;
+ result:INTEGER;
-
+
buf := src.to_native_array_uinteger_8;
index := (start-src.lower) * src.element_sizeof;
s := nb_elt * src.element_sizeof;
@@ -116,36 +116,36 @@ Section Public
? {result % src.element_sizeof = 0};
result / src.element_sizeof
);
-
+
- write src:ARRAYED size nb_elt:INTEGER :INTEGER <-
(
write src from (src.lower) size nb_elt
);
-
+
- write src:ARRAYED :INTEGER <-
(
write src size (src.count)
);
-
+
//
// Close.
//
-
+
- close <-
- (
+ (
deferred;
)
[
+? {! is_open};
];
-
+
- open_read_only:BOOLEAN <-
(
deferred;
);
-
+
Section FILE
-
+
- physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
[
-? {is_open};
@@ -157,19 +157,19 @@ Section FILE
[
+? {cursor = Old cursor + s};
];
-
+
- physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
[
-? {is_open};
]
- (
+ (
deferred;
0
)
[
+? {cursor = Old cursor + s};
];
-
-
-
-
+
+
+
+
diff --git a/lib/standard/http/http_server.li b/lib/standard/http/http_server.li
index a095ba0..a9db798 100644
--- a/lib/standard/http/http_server.li
+++ b/lib/standard/http/http_server.li
@@ -19,16 +19,16 @@
// 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>
@@ -36,49 +36,49 @@ Section Header
#include <netinet/in.h>
#include <netdb.h>
-#include <sys/socket.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;
+
+ 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!";
@@ -88,114 +88,114 @@ Section Public
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)`;
-
+ `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;
+ `address.sin_addr.s_addr`:INTEGER.print;
"\nsin_port = ".print;
`ntohs(address.sin_port)`:INTEGER.print;
- '\n'.print;
+ '\n'.print;
"\nMaking a listen queue of ".print;
queue_size.print;
" elements".print;
*/
-
- // establish listen queue
+
+ // 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
+ // 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;
+ 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
+ // close socket
( + loc_h_socket:INTEGER;
- log.append "Closing the socket\n";
+ 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_end := buf.index_of '\n' since idx_start;
idx := buf.index_of sep since idx_start;
(idx < idx_end).if {
- sep := ':';
+ sep := ':';
key := buf.substring idx_start to (idx-1);
- {buf.item (idx + 1) = ' '}.while_do {
- idx := idx + 1;
+ {buf.item (idx + 1) = ' '}.while_do {
+ idx := idx + 1;
+ };
+ {buf.item (idx_end - 1) <= ' '}.while_do {
+ idx_end := idx_end - 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
+ buffer.copy
"HTTP/1.1 200 OK\n\
\Date: ";
SYSTEM.get_current_date.append_in buffer;
@@ -206,7 +206,7 @@ Section Public
\Content-Length: ";
buf.count.append_in buffer;
buffer.append "\n\
- \Connection: close\n\
+ \Connection: close\n\
\Content-type: ";
buffer.append type;
buffer.append "\n\n";
diff --git a/lib/standard/io/io.li b/lib/standard/io/io.li
index 181235d..431658a 100644
--- a/lib/standard/io/io.li
+++ b/lib/standard/io/io.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := IO;
@@ -28,7 +28,7 @@ Section Header
- comment := "Standard Input Output.";
Section Inherit
-
+
- inherit_std_input:STD_INPUT := STD_INPUT;
-
+
- inherit_std_output:STD_OUTPUT := STD_OUTPUT;
diff --git a/lib/standard/io/std_error.li b/lib/standard/io/std_error.li
index 3fde7a2..dfacdda 100644
--- a/lib/standard/io/std_error.li
+++ b/lib/standard/io/std_error.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := STD_ERROR;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
- - comment := " To write on the standard error output. As for UNIX, the default\
+
+ - comment := " To write on the standard error output. As for UNIX, the default\
\ standard error file is the screen. \
\Note: only one instance of this class should be necessary (have a look\
\in the root classes to search for the good name to use).";
-
+
Section Inherit
-
+
- inherit_output_stream:OUTPUT_STREAM := OUTPUT_STREAM;
-
+
Section Public
- is_connected:BOOLEAN := TRUE;
-
+
- make <-
(
);
diff --git a/lib/standard/io/std_input.li b/lib/standard/io/std_input.li
index 3fa5cfc..597814b 100644
--- a/lib/standard/io/std_input.li
+++ b/lib/standard/io/std_input.li
@@ -19,27 +19,27 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := STD_INPUT;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :=" To use the standard input file. As for UNIX, the default standard input is the keyboard.";
-
+
Section Inherit
-
+
- inherit_input_stream:INPUT_STREAM := INPUT_STREAM;
-
+
Section Private
- memory:CHARACTER;
// Memory of the last available user's value.
Section Public
-
+
- is_connected:BOOLEAN := TRUE;
-
+
- read_character:CHARACTER<-
// Read character from stdin
(
@@ -50,21 +50,21 @@ Section Public
};
last_character
);
-
-
+
+
- unread_character <-
(
push_back_flag := TRUE;
);
-
-
+
+
- last_character:CHARACTER <-
// Return last character from stdin
(
memory
);
-
-
+
+
- end_of_input:BOOLEAN <-
// Return TRUE if end of input
(
@@ -74,7 +74,7 @@ Section Public
};
result
);
-
+
- read_line_in buffer:STRING <-
// Real all character until \n (so read a line)
(
@@ -83,7 +83,7 @@ Section Public
( (last_character != '\n') && { memory != basic_io_eof } ).if {
buffer.extend memory;
mem := basic_io_getc;
-
+
{ (mem = basic_io_eof) || {mem = '\n'} }.until_do {
buffer.extend mem;
mem := basic_io_getc;
@@ -91,6 +91,6 @@ Section Public
memory := mem;
};
);
-
+
diff --git a/lib/standard/io/std_output.li b/lib/standard/io/std_output.li
index fa0c5b5..85af284 100644
--- a/lib/standard/io/std_output.li
+++ b/lib/standard/io/std_output.li
@@ -19,27 +19,27 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=STD_OUTPUT;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="Standard Output (UNIX Operating System).";
-
+
Section Inherit
-
+
- inherit_output_stream:OUTPUT_STREAM := OUTPUT_STREAM;
-
+
Section Public
-
+
- is_connected:BOOLEAN := TRUE;
-
+
- put_character c:CHARACTER <- basic_io_putc c;
// Put `c' on stdout
-
+
diff --git a/lib/standard/kernel/convert.li b/lib/standard/kernel/convert.li
index 4bf64f1..deb361b 100644
--- a/lib/standard/kernel/convert.li
+++ b/lib/standard/kernel/convert.li
@@ -19,16 +19,15 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CONVERT(S,D);
- copyright := "2003-2007 Benoit Sonntag";
-
+
- comment := "Don't use this prototype !";
Section Public
-
+
- on src:S :D <- `13`;
-
-
\ No newline at end of file
+
diff --git a/lib/standard/kernel/i_dont_know_prototyping.li b/lib/standard/kernel/i_dont_know_prototyping.li
index d95a0f6..350d1d5 100644
--- a/lib/standard/kernel/i_dont_know_prototyping.li
+++ b/lib/standard/kernel/i_dont_know_prototyping.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := I_DONT_KNOW_PROTOTYPING;
@@ -28,11 +28,11 @@ Section Header
- comment := "Facility, but it's not in prototype spirit.";
Section Public
-
+
//
// Conditional.
//
-
+
- if cond:BOOLEAN then true_block:{} :BOOLEAN <-
(
cond.if true_block
@@ -42,32 +42,32 @@ Section Public
(
cond.if true_block else false_block;
);
-
+
//
// Loop.
//
-
+
- while cond:{} do body:{} <-
(
cond.while_do body;
);
-
+
- do body:{} while cond:{} <-
(
body.do_while cond;
);
-
+
- repeat body:{} until cond:{} <-
(
body.do_until cond;
);
-
+
//
// Print.
//
-
+
- printf str:ABSTRACT_STRING <-
(
str.print;
);
-
+
diff --git a/lib/standard/kernel/object.li b/lib/standard/kernel/object.li
index 94733c7..4ca1ae1 100644
--- a/lib/standard/kernel/object.li
+++ b/lib/standard/kernel/object.li
@@ -19,198 +19,198 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := OBJECT;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- comment := "Root object.";
-
+
Section Insert
-
+
- im_an_idiot:Expanded I_DONT_KNOW_PROTOTYPING;
-
+
Section Public
-
+
//
// Compiler consideration.
//
-
+
- object_size:INTEGER <- `12`;
-
+
//- pointer_size:INTEGER <- POINTER.pointer_size;
- is_debug_mode:BOOLEAN <- debug_level != 0;
-
+
- debug_level:INTEGER <- `11`;
- compiler_inlining_level:INTEGER <- `18`;
- - compiler_optimization:BOOLEAN <- `19`;
+ - compiler_optimization:BOOLEAN <- `19`;
- compiler_built_on:STRING_CONSTANT <- `20`;
-
+
- is_ansi:BOOLEAN := SYSTEM.is_ansi;
-
+
//
// Control Error.
//
-
+
- top_runtime_stack:POINTER <- `14`;
-
- - print_runtime_stack_on ptr:POINTER <-
+
+ - print_runtime_stack_on ptr:POINTER <-
(
(debug_level != 0).if {
`lisaac_stack_print((_____CONTEXT *)@ptr)`;
};
);
-
+
- wait_all_the_time <- `pthread_join(c_thread, NULL)`;
-
+
- print_runtime_stack <- print_runtime_stack_on top_runtime_stack;
-
+
- crash_on ptr:POINTER with_message msg:ABSTRACT_STRING <-
(
print_runtime_stack_on ptr;
msg.print;
'\n'.print;
- die_with_code exit_failure_code;
+ die_with_code exit_failure_code;
);
-
+
- crash_with_message msg:ABSTRACT_STRING <-
- (
+ (
crash_on top_runtime_stack with_message msg;
);
- die_with_code code:INTEGER <- SYSTEM.exit code;
// Terminate execution with exit status code `code'.
-
+
- exit_success_code:INTEGER := 0;
-
+
- exit_failure_code:INTEGER := 1;
-
+
- deferred <-
( + ptr:POINTER;
ptr := top_runtime_stack;
crash_on ptr with_message "Slot deferred.";
);
-
+
- crash <-
( + ptr:POINTER;
ptr := top_runtime_stack;
crash_on ptr with_message "Crash system.";
);
-
+
- not_yet_implemented <-
( + ptr:POINTER;
ptr := top_runtime_stack;
crash_on ptr with_message "Sorry, Some Feature is Not Yet Implemented.";
);
-
+
//
// Common Function.
//
-
+
- Self:SELF '==' Right 60 other:E :BOOLEAN <- ( deferred; FALSE);
-
+
- Self:SELF '!==' Right 60 other:OBJECT :BOOLEAN <- (! (Self == other));
-
-
+
+
- clone_allocation_size:UINTEGER_CPU;
-
- - clone:SELF <-
+
+ - clone:SELF <-
( + result:SELF;
+ ptr:POINTER;
+ sz:UINTEGER_CPU;
+ typ_id:INTEGER;
-
- sz := object_size;
- (sz = 0).if {
+
+ sz := object_size;
+ (sz = 0).if {
result := Self;
- } else {
- typ_id := type_id_intern;
- //ptr := `malloc(((unsigned long)(@sz + 3)) & 0xFFFFFFFC)`:POINTER;
- clone_allocation_size := clone_allocation_size + sz;
+ } else {
+ typ_id := type_id_intern;
+ //ptr := `malloc(((unsigned long)(@sz + 3)) & 0xFFFFFFFC)`:POINTER;
+ clone_allocation_size := clone_allocation_size + sz;
(typ_id = -1).if {
ptr := MEMORY.alloc_size sz;
- } else {
+ } else {
ptr := MEMORY.alloc_type (typ_id.to_uinteger_32) size sz;
- };
- result := CONVERT(POINTER,SELF).on ptr;
+ };
+ result := CONVERT(POINTER,SELF).on ptr;
//MEMORY.copy to_pointer to ptr size (CONVERT(POINTER,UINTEGER_32).on sz);
- copy_intern_in result;
- (is_cop_type).if {
+ copy_intern_in result;
+ (is_cop_type).if {
`((lith_object *)@result)->first = NULL`;
`((lith_object *)@result)->last = NULL`;
};
};
result
);
-
- - free_allocation_memory <-
+
+ - free_allocation_memory <-
// Static free, don't use with GC.
( + ptr:POINTER;
+ sz:UINTEGER_CPU;
+ typ_id:INTEGER;
-
- sz := object_size;
- (sz != 0).if {
- typ_id := type_id_intern;
- //ptr := `free(@Self)`;
- clone_allocation_size := clone_allocation_size - sz;
+
+ sz := object_size;
+ (sz != 0).if {
+ typ_id := type_id_intern;
+ //ptr := `free(@Self)`;
+ clone_allocation_size := clone_allocation_size - sz;
ptr := to_pointer;
(typ_id = -1).if {
MEMORY.free ptr size sz;
} else {
MEMORY.free ptr type (typ_id.to_uinteger_32);
- };
+ };
};
);
-
+
- to_pointer:POINTER <- CONVERT(SELF,POINTER).on Self;
- to_string :STRING <- to_pointer.to_string;
- print <- to_string.print;
- - println <-
- (
- to_string.println;
+ - println <-
+ (
+ to_string.println;
);
-
+
- dynamic_type:SELF <- SELF;
-
+
- same_dynamic_type other:OBJECT :BOOLEAN <-
( + convert:SELF;
convert ?= other;
- convert != NULL
+ convert != NULL
);
-
+
- to_self_on obj:OBJECT :SELF <-
[
-? {obj != NULL};
- ]
+ ]
( + result:SELF;
-
+
result ?= obj;
result
)
[
+? {Result != NULL};
- ];
-
+ ];
+
//
// Reflexivity.
//
-
+
- forall_data action:{ E; } <- `21`;
-
+
//
// The Guru section (Don't touch, don't use !)
//
-
+
- is_expanded_type:BOOLEAN <- `0`;
-
+
- type_id_intern:INTEGER <- `1`;
-
+
- is_cop_type:BOOLEAN <- `15`;
-
+
- copy_intern_in other:SELF <- `*@other = *@Self`;
diff --git a/lib/standard/kernel/pointer.li b/lib/standard/kernel/pointer.li
index 3522db2..1bbe25a 100644
--- a/lib/standard/kernel/pointer.li
+++ b/lib/standard/kernel/pointer.li
@@ -19,59 +19,59 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded POINTER;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "References to objects (POINTER is mapped as C type 'void *')";
-
+
- export := UINTEGER_CPU;
-
+
- type := `void *`;
-
+
- default := `NULL`:POINTER;
-
+
Section Insert
-
+
- parent_unsigned_integer:UNSIGNED_INTEGER := UNSIGNED_INTEGER;
-
+
Section Public
-
+
- in_range low:SELF to up:SELF :BOOLEAN <- TRUE; // BSBS: A revoir.
-
+
- object_size:INTEGER <- `sizeof(void *)`:INTEGER;
-
+
- is_null:BOOLEAN <- (Self = NULL);
// Is the external POINTER a NULL pointer ?
-
+
- is_not_null:BOOLEAN <- ! is_null;
// Is the external POINTER a non-NULL pointer ?
-
+
- to_native_array:NATIVE_ARRAY(UINTEGER_8) <- NATIVE_ARRAY(UINTEGER_8).force_conversion Self;
// Convert `pointer' into 'native_array' type.
-
+
// - to_uinteger_32:UINTEGER_32 <- `(unsigned int)@Self`:UINTEGER_32;
// convert `pointer' into uinteger type (adress of the pointer)
-
+
// - from_uinteger p:UINTEGER_32 :POINTER <- CONVERT(UINTEGER_32,POINTER).on p;
// create POINTER from an adress
-
+
// - to_integer:INTEGER <- to_raw_integer;
- to_string :STRING <- to_uinteger_cpu.to_hexadecimal;
-
+
//
// Convertion format without test.
//
-
+
- to_raw_uinteger_cpu:UINTEGER_CPU <- CONVERT(SELF,UINTEGER_CPU).on Self;
-
+
- to_raw_integer:INTEGER <- CONVERT(UINTEGER_CPU,INTEGER).on to_raw_uinteger_cpu;
-
+
- to_raw_uinteger:UINTEGER <- CONVERT(UINTEGER_CPU,UINTEGER).on to_raw_uinteger_cpu;
-
+
- to_raw_uinteger_8:UINTEGER_8 <- CONVERT(UINTEGER_CPU,UINTEGER_8 ).on to_raw_uinteger_cpu;
- to_raw_uinteger_16:UINTEGER_16 <- CONVERT(UINTEGER_CPU,UINTEGER_16).on to_raw_uinteger_cpu;
@@ -79,7 +79,7 @@ Section Public
- to_raw_uinteger_32:UINTEGER_32 <- CONVERT(UINTEGER_CPU,UINTEGER_32).on to_raw_uinteger_cpu;
- to_raw_uinteger_64:UINTEGER_64 <- CONVERT(UINTEGER_CPU,UINTEGER_64).on to_raw_uinteger_cpu;
-
+
- to_raw_integer_8:INTEGER_8 <- CONVERT(UINTEGER_CPU,INTEGER_8 ).on to_raw_uinteger_cpu;
- to_raw_integer_16:INTEGER_16 <- CONVERT(UINTEGER_CPU,INTEGER_16).on to_raw_uinteger_cpu;
@@ -87,4 +87,3 @@ Section Public
- to_raw_integer_32:INTEGER_32 <- CONVERT(UINTEGER_CPU,INTEGER_32).on to_raw_uinteger_cpu;
- to_raw_integer_64:INTEGER_64 <- CONVERT(UINTEGER_CPU,INTEGER_64).on to_raw_uinteger_cpu;
-
\ No newline at end of file
diff --git a/lib/standard/kernel/reference.li b/lib/standard/kernel/reference.li
index 869182a..ac1ca52 100644
--- a/lib/standard/kernel/reference.li
+++ b/lib/standard/kernel/reference.li
@@ -19,12 +19,12 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := REFERENCE(E);
-
+
- import := E;
- export := E,POINTER;
-
+
- copyright := "2003-2008 Sonntag Benoit";
- author := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
@@ -35,9 +35,9 @@ Section Inherit
- parent_object:OBJECT := OBJECT;
Section Public
-
+
+ value:E;
-
+
//
// Creation.
//
@@ -50,14 +50,14 @@ Section Public
);
- make v:E <-
- (
+ (
value := v;
);
-
+
//
// Cast.
//
-
+
- to_e:E <- value;
-
+
- from_e v:E :SELF <- create v;
diff --git a/lib/standard/number/fixed_real/real_16_16.li b/lib/standard/number/fixed_real/real_16_16.li
index c06ed41..1c132ea 100644
--- a/lib/standard/number/fixed_real/real_16_16.li
+++ b/lib/standard/number/fixed_real/real_16_16.li
@@ -19,55 +19,55 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL_16_16;
- export := REAL_32, REAL_64;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "signed 16.16 fixed float.";
-
+
- type := `signed long`;
- default := (0.to_raw_real_16_16);
-
+
Section Insert
-
+
- parent_signed_fixed_real:SIGNED_FIXED_REAL := SIGNED_FIXED_REAL;
-
+
Section SELF
- shift_bits:INTEGER <- 16;
Section Public
-
+
//
// Range.
//
-
- - minimum:INTEGER_64 <- INTEGER_16.minimum;
- - maximum:UINTEGER_64 <- INTEGER_16.maximum;
-
+ - minimum:INTEGER_64 <- INTEGER_16.minimum;
+
+ - maximum:UINTEGER_64 <- INTEGER_16.maximum;
+
//
// Convertion format with test.
//
-
+
- to_real_16_16:REAL_16_16 <- Self;
-
+
//
// Convertion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:INTEGER;
+ old_count,new_count:INTEGER;
? {buffer!=NULL};
-
+
val := to_raw_integer;
-
+
(val < 0).if {
val := - val;
buffer.extend '-';
@@ -83,12 +83,12 @@ Section Public
buffer.insert '0' to old_count;
};
);
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/lib/standard/number/fixed_real/real_24_8.li b/lib/standard/number/fixed_real/real_24_8.li
index a804856..79ef0f7 100644
--- a/lib/standard/number/fixed_real/real_24_8.li
+++ b/lib/standard/number/fixed_real/real_24_8.li
@@ -19,53 +19,53 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL_24_8;
- export := REAL_32, REAL_64;
-
+
- comment := "signed 24.8 fixed float.";
-
+
- type := `signed long`;
- default := (0.to_raw_real_24_8);
-
+
Section Insert
-
+
- parent_signed_fixed_real:SIGNED_FIXED_REAL := SIGNED_FIXED_REAL;
-
+
Section SELF
- shift_bits:INTEGER <- 8;
Section Public
-
+
//
// Range.
//
-
- - minimum:INTEGER_64 <- - 7F_FFFFh.to_raw_integer_64;
- - maximum:UINTEGER_64 <- 7F_FFFFh.to_raw_uinteger_64;
-
+ - minimum:INTEGER_64 <- - 7F_FFFFh.to_raw_integer_64;
+
+ - maximum:UINTEGER_64 <- 7F_FFFFh.to_raw_uinteger_64;
+
//
// Convertion format with test.
//
-
+
- to_real_24_8:REAL_24_8 <- Self;
-
+
//
// Convertion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:INTEGER;
+ old_count,new_count:INTEGER;
? {buffer!=NULL};
-
+
val := to_raw_integer;
-
+
(val < 0).if {
val := - val;
buffer.extend '-';
@@ -82,13 +82,13 @@ Section Public
};
);
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/standard/number/fixed_real/real_26_6.li b/lib/standard/number/fixed_real/real_26_6.li
index b7ea699..174bbcd 100644
--- a/lib/standard/number/fixed_real/real_26_6.li
+++ b/lib/standard/number/fixed_real/real_26_6.li
@@ -19,62 +19,62 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL_26_6;
- export := REAL_32, REAL_64;
-
+
- comment := "signed 26.6 fixed float.";
- type := `unsigned long`;
- default := (0.to_raw_real_26_6);
-
+
Section Insert
-
+
- parent_signed_fixed_real:SIGNED_FIXED_REAL := SIGNED_FIXED_REAL;
Section SELF
- shift_bits:INTEGER <- 6;
-
+
Section Public
-
+
//
// Range.
//
-
+
- minimum:INTEGER_64 <- - 1FF_FFFFh.to_raw_integer_64;
-
+
- maximum:UINTEGER_64 <- 1FF_FFFFh.to_raw_uinteger_64;
-
+
//
// Convertion format with test.
//
-
+
- to_real_26_6:REAL_26_6 <- Self;
-
+
//
// Convertion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:INTEGER_32;
+ old_count,new_count:INTEGER;
? {buffer!=NULL};
-
+
val := to_raw_integer;
-
+
(val < 0).if {
val := - val;
buffer.extend '-';
};
(val >> 6).append_in buffer;
buffer.extend '.';
-
+
old_count:=buffer.count;
- // 1/64 = 0.015625 => 6 digit.
+ // 1/64 = 0.015625 => 6 digit.
(((val & 63) * 1000000)>>6).append_in buffer;
new_count:=old_count+6;
{buffer.count!=new_count}.while_do {
@@ -82,13 +82,13 @@ Section Public
};
);
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/standard/number/fixed_real/ureal_16_16.li b/lib/standard/number/fixed_real/ureal_16_16.li
index 49e1b06..263e403 100644
--- a/lib/standard/number/fixed_real/ureal_16_16.li
+++ b/lib/standard/number/fixed_real/ureal_16_16.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UREAL_16_16;
- export := REAL_32, REAL_64;
-
+
- comment := "unsigned 16.16 fixed float.";
-
+
- type := `signed long`;
- default := (0.to_raw_ureal_16_16);
-
+
Section Insert
-
+
- parent_unsigned_fixed_real:UNSIGNED_FIXED_REAL := UNSIGNED_FIXED_REAL;
Section SELF
- shift_bits:INTEGER <- 16;
-
+
Section Public
-
+
//
// Range.
//
-
- - maximum:UINTEGER_64 <- UINTEGER_16.maximum;
-
+
+ - maximum:UINTEGER_64 <- UINTEGER_16.maximum;
+
//
// Convertion format with test.
//
-
+
- to_real_16_16:REAL_16_16 <- Self;
-
+
//
// Convertion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:INTEGER;
+ old_count,new_count:INTEGER;
? {buffer!=NULL};
-
+
val := to_raw_integer;
-
+
(val < 0).if {
val := - val;
buffer.extend '-';
@@ -79,12 +79,12 @@ Section Public
buffer.insert '0' to old_count;
};
);
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/lib/standard/number/fixed_real/ureal_24_8.li b/lib/standard/number/fixed_real/ureal_24_8.li
index eb5322d..4b53639 100644
--- a/lib/standard/number/fixed_real/ureal_24_8.li
+++ b/lib/standard/number/fixed_real/ureal_24_8.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UREAL_24_8;
- export := REAL_32, REAL_64;
-
+
- comment := "signed 24.8 fixed float.";
-
+
- type := `signed long`;
- default := (0.to_raw_ureal_24_8);
-
+
Section Insert
-
+
- parent_unsigned_fixed_real:UNSIGNED_FIXED_REAL := UNSIGNED_FIXED_REAL;
-
+
Section SELF
- - shift_bits:INTEGER <- 8;
-
+ - shift_bits:INTEGER <- 8;
+
Section Public
-
+
//
// Range.
//
-
- - maximum:UINTEGER_64 <- 0FF_FFFFh.to_raw_uinteger_64;
-
+
+ - maximum:UINTEGER_64 <- 0FF_FFFFh.to_raw_uinteger_64;
+
//
// Convertion format with test.
//
-
+
- to_real_24_8:REAL_24_8 <- Self;
-
+
//
// Convertion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:INTEGER;
+ old_count,new_count:INTEGER;
? {buffer!=NULL};
-
+
val := to_raw_integer;
-
+
(val < 0).if {
val := - val;
buffer.extend '-';
@@ -80,13 +80,13 @@ Section Public
};
);
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/standard/number/fixed_real/ureal_26_6.li b/lib/standard/number/fixed_real/ureal_26_6.li
index 2a34844..2757838 100644
--- a/lib/standard/number/fixed_real/ureal_26_6.li
+++ b/lib/standard/number/fixed_real/ureal_26_6.li
@@ -19,56 +19,56 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UREAL_26_6;
- export := REAL_32, REAL_64;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "unsigned 26.6 fixed float.";
-
+
- type := `unsigned long`;
- default := (0.to_raw_ureal_26_6);
-
+
Section Insert
-
+
- parent_unsigned_fixed_real:UNSIGNED_FIXED_REAL := UNSIGNED_FIXED_REAL;
Section SELF
- shift_bits:INTEGER <- 6;
-
+
Section Public
-
+
//
// Range.
//
-
+
- maximum:UINTEGER_64 <- 3FF_FFFFh.to_raw_uinteger_64;
-
+
//
// Convertion format with test.
//
-
+
- to_ureal_26_6:UREAL_26_6 <- Self;
-
+
//
// Convertion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
( + val:UINTEGER_32;
+ old_count,new_count:INTEGER;
? {buffer!=NULL};
-
+
val := to_raw_uinteger_32;
(val >> 6).append_in buffer;
buffer.extend '.';
old_count:=buffer.count;
- // 1/64 = 0.015625 => 6 digit.
+ // 1/64 = 0.015625 => 6 digit.
(((val & 63) * 1000000)>>6).append_in buffer;
new_count:=old_count+6;
{buffer.count!=new_count}.while_do {
@@ -76,13 +76,13 @@ Section Public
};
);
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/standard/number/integer/integer.li b/lib/standard/number/integer/integer.li
index 8972d13..bbe5f0c 100644
--- a/lib/standard/number/integer/integer.li
+++ b/lib/standard/number/integer/integer.li
@@ -19,61 +19,61 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded INTEGER;
-
- - export :=
- // Integer:
+
+ - export :=
+ // Integer:
UINTEGER_8, UINTEGER_16, UINTEGER_32 , UINTEGER_64,
INTEGER_8 , INTEGER_16 , INTEGER_32 , INTEGER_64 ,
UINTEGER_BIG,UINTEGER , UINTEGER_CPU,//INTEGER_BIG,
// Fixed real:
- UREAL_16_16, UREAL_24_8 , UREAL_26_6 ,
- REAL_16_16 , REAL_24_8 , REAL_26_6 ,
+ UREAL_16_16, UREAL_24_8 , UREAL_26_6 ,
+ REAL_16_16 , REAL_24_8 , REAL_26_6 ,
// Float Real:
REAL, REAL_32, REAL_64, REAL_80,
// Other:
POINTER;
-
+
- comment := "Generic Integer.";
-
+
- type := `signed int`;
- default := 0;
Section Insert
-
+
- inherit_numeric:NUMERIC := NUMERIC;
-
+
Section Public
-
+
//
// Range.
//
-
- - maximum:UINTEGER_64 <-
- // Maximum of integer
- 07FFFFFFFh.to_raw_uinteger_64;
- - minimum:INTEGER_64 <-
+ - maximum:UINTEGER_64 <-
+ // Maximum of integer
+ 07FFFFFFFh.to_raw_uinteger_64;
+
+ - minimum:INTEGER_64 <-
// Minimum of integer
- (- 07FFFFFFFh).to_raw_integer_64;
+ (- 07FFFFFFFh).to_raw_integer_64;
//
// Binary Operator.
//
-
- - Self:SELF '%' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '%' Left 100 other:SELF :SELF <-
// Modulo
Self - ((Self / other) * other);
-
- - Self:SELF '%#' Left 100 other:INTEGER :SELF <-
+
+ - Self:SELF '%#' Left 100 other:INTEGER :SELF <-
// Modulo
Self % other;
-
+
- Self:SELF '**' Right 120 exp:SELF :SELF <-
// Power
( + result:SELF;
-
+
(exp = 0).if {
result := 1;
} else {
@@ -94,28 +94,28 @@ Section Public
//
// Conversion format with test.
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
TRUE
);
-
+
// - to_integer:INTEGER <- Self;
-
+
- to_pointer:POINTER <-
(
to_raw_pointer
);
-
+
//
- // BCD Format.
+ // BCD Format.
//
-
+
- to_binary:SELF <-
// Self is BCD formatted, convert to binary value
( + result:SELF;
+ val,mul:SELF;
-
+
val := Self;
mul := 1;
{val!=0}.while_do {
@@ -123,112 +123,112 @@ Section Public
mul := mul * 10;
val := val >> 4;
};
-
+
result
);
-
+
- to_bcd:SELF <-
// Self is binary formatted, convert to bcd value
( + result:SELF;
+ val,mul:SELF;
-
+
val := Self;
{val != 0}.while_do {
result := result | ((val % 10) << mul);
mul := mul + 4;
val := val / 10;
};
-
- result
+
+ result
);
-
+
//
// Facility typing.
//
-
- - kb:SELF <-
+
+ - kb:SELF <-
// Self in Kilobyte (ie. 1kb = 1024 bytes)
Self << 10;
-
- - mb:SELF <-
+
+ - mb:SELF <-
// Self in megabytes
Self << 20;
- - gb:SELF <-
+ - gb:SELF <-
// Self in gigabytes
Self << 30;
- - tb:SELF <-
+ - tb:SELF <-
// Self in terabytes
Self << 40;
//
// Logic Operator
//
-
- - Self:SELF '&' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '&' Left 100 other:SELF :SELF <-
// AND operator
`6`;
- - Self:SELF '|' Left 80 other:SELF :SELF <-
+ - Self:SELF '|' Left 80 other:SELF :SELF <-
// OR operator
~(~Self & ~other);
- - Self:SELF '^' Left 80 other:SELF :SELF <-
+ - Self:SELF '^' Left 80 other:SELF :SELF <-
// XOR operator
(~Self & other) | (Self & ~other);
- - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
+ - Self:SELF '>>' Left 100 other:INTEGER :SELF <-
// Shift right
`7`;
- - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
+ - Self:SELF '<<' Left 100 other:INTEGER :SELF <-
// Shift left
`8`;
-
+
//
// Unary operator
//
-
- - '~' Self:SELF :SELF <- - Self - SELF.one;
-
+
+ - '~' Self:SELF :SELF <- - Self - SELF.one;
+
//
- // Test.
+ // Test.
//
-
+
- align_power step:SELF :SELF <-
- [
+ [
-? {step.is_power_2};
]
( + a:SELF;
-
+
a := step - 1;
(Self + a) & (~ a)
);
-
+
- is_power_2:BOOLEAN <-
// TRUE is Self is power of 2
( + val:SELF;
+ result:BOOLEAN;
-
- (Self != 0).if {
+
+ (Self != 0).if {
val := Self;
{val.is_even}.while_do {
val := val >> 1;
- };
- result := val = 1;
+ };
+ result := val = 1;
};
result
);
-
+
//
// Function :
//
-
+
- sqrt:SELF <-
// Square root
( + r,x:SELF;
-
+
x:=(Self + 1) >> 1;
{x > r}.while_do {
x:=x-r;
@@ -236,11 +236,11 @@ Section Public
};
r
);
-
- - Self:SELF '!' :SELF <-
+
+ - Self:SELF '!' :SELF <-
// Factorial. Use it like "45!" or "bar!.print;"
factorial;
-
+
- factorial:SELF <-
// Factorial
// * Require: Self >= 0
@@ -248,7 +248,7 @@ Section Public
-? {Self >= 0};
]
( + result,value:SELF;
-
+
result := 1;
value := Self;
{value <= 1}.until_do {
@@ -257,7 +257,7 @@ Section Public
};
result
);
-
+
- fibonacci:SELF <-
// Fibonacci
// * Require: Self >= 0
@@ -265,7 +265,7 @@ Section Public
-? {Self >= 0};
]
( + result:SELF;
-
+
(Self <= 1).if {
result := 1;
} else {
@@ -273,32 +273,32 @@ Section Public
};
result
);
-
- - is_odd:BOOLEAN <-
+
+ - is_odd:BOOLEAN <-
// Is odd ?
- (Self & 1) = 1;
+ (Self & 1) = 1;
- - is_even:BOOLEAN <-
+ - is_even:BOOLEAN <-
// Is even ?
- ! is_odd;
+ ! is_odd;
- gcd other:SELF :SELF <-
// Great Common Divisor of `self' and `other'.
// * Require: Self >= 0
// * Require: `other' >= 0
- // * Ensure:
+ // * Ensure:
[
-? {Self >= 0};
-? {other >= 0};
]
( + result:SELF;
-
+
(other = 0).if {
result := Self;
} else {
result := other.gcd (Self % other);
};
-
+
result
)
[
@@ -341,8 +341,8 @@ Section Public
- random_upper:SELF <-
// Random number between 0 to `Self'.
- [
- -? {Self > 0};
+ [
+ -? {Self > 0};
]
(
random % (Self+1)
@@ -356,28 +356,28 @@ Section Public
[
-? {lower < upper};
]
- (
- lower + (upper-lower).random_upper
+ (
+ lower + (upper-lower).random_upper
)
[
+? {Result.in_range lower to upper};
];
-
+
//
// Looping.
//
-
+
- times action:{} <-
(
1.to Self do { i:INTEGER;
action.value;
};
);
-
+
//
// Convertion
//
-
+
// *French, Slot, Description : Renvoi une chaîne représentant le nombre en base 10
// *English, Slot, Description : String of the number in base 10
@@ -391,88 +391,88 @@ Section Public
- append_in buffer:STRING <- to_integer_32.append_in buffer;
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
-
+
- decimal_digit:CHARACTER <-
// Gives the corresponding CHARACTER for range 0..9.
[
-? {in_range 0 to 9};
]
- (
+ (
(Self.to_integer_8 + '0'.code).to_character
)
[
+? {"0123456789".has Result};
+? {Result.decimal_value = Self};
];
-
+
- digit:CHARACTER <- decimal_digit;
-
+
- hexadecimal_digit:CHARACTER <-
// Gives the corresponding CHARACTER for range 0..15.
[
-? {in_range 0 to 15};
]
( + result:CHARACTER;
-
+
(Self <= 9).if {
result := digit;
} else {
result := ('A'.code + (Self - 10).to_integer_8).to_character;
- };
+ };
result
)
[
+? {"0123456789ABCDEF".has Result};
];
-
+
- to_character:CHARACTER <- to_integer_8.to_character;
// Return the coresponding ASCII character.
-
+
- to_octal:SELF <-
// Gives coresponding octal value.
( + result:SELF;
-
+
deferred;
result
);
-
+
- to_hexadecimal:STRING <-
// 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.
// * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
-
+
result := STRING.create 8;
to_hexadecimal_in result;
result
);
-
+
- to_hexadecimal_format s:INTEGER :STRING <-
// 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.
// * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
-
+
result := STRING.create 8;
to_hexadecimal_in result format s;
result
- );
-
+ );
+
- to_hexadecimal_in buffer:STRING <-
// Append in `buffer' the equivalent of `to_hexadecimal'. No new STRING
// creation during the process.
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
i := buffer.count + 1;
val := Self;
- {val != 0}.while_do { //JBJB
+ {val != 0}.while_do { //JBJB
buffer.extend ((val & 15).hexadecimal_digit);
val := val >> 4;
};
@@ -484,20 +484,20 @@ Section Public
};
};
);
-
+
- to_hexadecimal_in buffer:STRING format s:INTEGER <-
// Append in `buffer' the equivalent of `to_hexadecimal'. No new STRING
// creation during the process.
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
i := buffer.count + 1;
val := Self;
- {val != 0}.while_do { //JBJB
+ {val != 0}.while_do { //JBJB
buffer.extend ((val & 15).hexadecimal_digit);
val := val >> 4;
};
@@ -509,7 +509,7 @@ Section Public
};
};
buffer.precede_multiple '0' by (s.to_integer - buffer.count);
- );
+ );
- to_binary_in buffer:STRING format s:INTEGER <-
// Append in `buffer' the equivalent of `to_binary_string'. No new STRING
@@ -518,13 +518,13 @@ Section Public
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
i := buffer.count + 1;
val := Self;
- {val != 0}.while_do {
+ {val != 0}.while_do {
buffer.extend ('0' +# (val & 1));
val := val >> 1;
};
@@ -536,20 +536,20 @@ Section Public
};
};
buffer.precede_multiple '0' by ((s.to_integer) - buffer.count);
- );
-
+ );
+
//
// Hashing:
//
-
+
- hash_code:INTEGER <-
// Hash code
to_integer_32.hash_code; // BSBS: Il faut revoir => Depending processor
-
+
//
// Print
//
-
+
- print <-
// Print
(
@@ -562,14 +562,14 @@ Section Public
print_positif;
};
);
-
+
- print_positif <-
// Display this number without memory.
// * Require: Self >= 0
[ -? {Self >=# 0}; ]
( + char:CHARACTER;
- + val:SELF;
-
+ + val:SELF;
+
char := (Self % 10).decimal_digit;
val := Self / 10;
(val != 0).if {
@@ -582,23 +582,23 @@ Section Public
// Display this number without memory.
( + char:CHARACTER;
+ val:SELF;
-
- char := (Self & 0Fh).hexadecimal_digit;
- val := Self / 16;
+
+ char := (Self & 0Fh).hexadecimal_digit;
+ val := Self / 16;
(val != 0).if {
val.print_hex;
};
char.print;
);
-
+
//
// Debug manager facility.
//
-
+
- Self:SELF '?' blc:{BOOLEAN} <- blc ?# Self;
-
-Section INTEGER
-
+
+Section INTEGER
+
- to_raw_pointer:POINTER <- CONVERT(UINTEGER_CPU,POINTER).on to_uinteger_cpu;
diff --git a/lib/standard/number/integer/integer_16.li b/lib/standard/number/integer/integer_16.li
index 7f46d8a..6775db9 100644
--- a/lib/standard/number/integer/integer_16.li
+++ b/lib/standard/number/integer/integer_16.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded INTEGER_16;
- export := INTEGER, INTEGER_64, INTEGER_32;
-
+
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Xavier Oswald";
-
+
- comment := "Signed 16 bits integer.";
- type := `signed short`;
- default := (0.to_raw_integer_16);
-
+
Section Insert
-
+
- parent_signed_integer:SIGNED_INTEGER := SIGNED_INTEGER;
-
+
Section Public
-
+
- object_size:INTEGER := 2;
//
// Range
//
-
+
- maximum:UINTEGER_64 <- 32767.to_raw_uinteger_64;
-
+
- minimum:INTEGER_64 <- - 32767.to_raw_integer_64;
-
+
//
// Conversion with test.
//
diff --git a/lib/standard/number/integer/integer_32.li b/lib/standard/number/integer/integer_32.li
index 056c2e4..52b5f8c 100644
--- a/lib/standard/number/integer/integer_32.li
+++ b/lib/standard/number/integer/integer_32.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded INTEGER_32;
-
+
- export := INTEGER, INTEGER_64, POINTER;
-
+
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Xavier Oswald";
- comment :="Signed 32 bits integer.";
- type := `signed int`;
- default := (0.to_raw_integer_32);
-
+
Section Insert
-
+
- parent_signed_integer:SIGNED_INTEGER := SIGNED_INTEGER;
-
+
Section Public
-
+
- object_size:INTEGER := 4;
//
// Range
//
-
- - maximum:UINTEGER_64 <- 07FFF_FFFFh.to_raw_uinteger_64;
-
+
+ - maximum:UINTEGER_64 <- 07FFF_FFFFh.to_raw_uinteger_64;
+
- minimum:INTEGER_64 <- - 07FFF_FFFFh.to_raw_integer_64;
-
+
//
// Conversion with test.
//
-
- - to_integer_32:INTEGER_32 <- Self;
+
+ - to_integer_32:INTEGER_32 <- Self;
diff --git a/lib/standard/number/integer/integer_64.li b/lib/standard/number/integer/integer_64.li
index 26fe87f..6d8d0ef 100644
--- a/lib/standard/number/integer/integer_64.li
+++ b/lib/standard/number/integer/integer_64.li
@@ -19,41 +19,41 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded INTEGER_64;
- export := INTEGER;
-
+
- comment := "Signed 64 bits integer.";
- type := `signed long long `;
- default := (0.to_raw_integer_64);
-
+
Section Insert
-
+
- parent_signed_integer:SIGNED_INTEGER := SIGNED_INTEGER;
-
+
Section Public
- object_size:INTEGER := 8;
-
-
+
+
- '-' Self:SELF :SELF <- zero - Self;
-
+
//
// Range
//
-
+
- maximum:UINTEGER_64 <- `0x7FFFFFFFFFFFFFFFLLU`:UINTEGER_64;
-
+
- minimum:INTEGER_64 <- `-0x8000000000000000LL`:INTEGER_64;
-
+
//
// Conversion with test.
//
-
+
- to_integer_64:INTEGER_64 <- Self;
-
+
diff --git a/lib/standard/number/integer/integer_8.li b/lib/standard/number/integer/integer_8.li
index fafaa16..45fe223 100644
--- a/lib/standard/number/integer/integer_8.li
+++ b/lib/standard/number/integer/integer_8.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name :=Expanded INTEGER_8;
- export := INTEGER, INTEGER_64, INTEGER_32, INTEGER_16;
- - copyright :=
+ - copyright :=
"2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Xavier Oswald";
- comment :="Signed 8 bits integer.";
- type := `signed char`;
- default := (`(0)`:INTEGER_8); //CONVERT[INTEGER,INTEGER_8].on 0); //0.to_raw_integer_8);
-
+
Section Insert
-
+
- parent_signed_integer:SIGNED_INTEGER := SIGNED_INTEGER;
-
+
Section Public
- object_size:INTEGER := 1;
-
+
//
// Range
//
-
+
- maximum:UINTEGER_64 <- 127.to_raw_uinteger_64;
-
+
- minimum:INTEGER_64 <- - 127.to_raw_integer_64;
-
+
//
// Conversion.
//
-
- - to_integer_8:INTEGER_8 <-
+
+ - to_integer_8:INTEGER_8 <-
[ ]
(
Self
@@ -60,11 +60,11 @@ Section Public
[ ];
- to_character:CHARACTER <- `@Self`:CHARACTER; // `13`;
-
-
+
+
diff --git a/lib/standard/number/integer/uinteger.li b/lib/standard/number/integer/uinteger.li
index 7607a83..116653d 100644
--- a/lib/standard/number/integer/uinteger.li
+++ b/lib/standard/number/integer/uinteger.li
@@ -19,56 +19,56 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
//
// BSBS : Tout a REVOIR !!!!!!!!!!!
//
-
+
+ name := Expanded UINTEGER;
-
+
- export := // BSBS : A revoir!
- // Integer:
+ // Integer:
UINTEGER_8, UINTEGER_16, UINTEGER_32, UINTEGER_64,
INTEGER_8 , INTEGER_16 , INTEGER_32 , INTEGER_64 ,
UINTEGER_BIG,//INTEGER_BIG,
// Fixed real:
- UREAL_16_16, UREAL_24_8 , UREAL_26_6 ,
- REAL_16_16 , REAL_24_8 , REAL_26_6 ,
+ UREAL_16_16, UREAL_24_8 , UREAL_26_6 ,
+ REAL_16_16 , REAL_24_8 , REAL_26_6 ,
// Float Real:
REAL, REAL_32, REAL_64, REAL_80,
// Other:
POINTER;
-
+
- comment := "Generic Integer.";
-
+
- type := `unsigned int`;
- default := 0;
Section Insert
-
+
- parent_numeric:NUMERIC := NUMERIC;
-
+
Section Public
-
+
//
// Range.
//
-
- - maximum:UINTEGER_64 <- 07FFFFFFFh.to_raw_uinteger_64;
-
- - minimum:INTEGER_64 <- (0).to_raw_integer_64;
-
+
+ - maximum:UINTEGER_64 <- 07FFFFFFFh.to_raw_uinteger_64;
+
+ - minimum:INTEGER_64 <- (0).to_raw_integer_64;
+
//
// Binary Operator.
//
-
+
- Self:SELF '%' Left 100 other:SELF :SELF <- Self - ((Self / other) * other);
-
+
- Self:SELF '%#' Left 100 other:INTEGER :SELF <- Self % other;
-
+
- Self:SELF '**' Right 120 exp:SELF :SELF <-
( + result:SELF;
-
+
(exp = 0).if {
result := 1;
} else {
@@ -89,28 +89,28 @@ Section Public
//
// Conversion format with test.
//
-
+
- bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
TRUE
);
-
+
// - to_integer:INTEGER <- Self;
-
+
- to_pointer:POINTER <-
(
to_raw_pointer
);
-
+
//
- // BCD Format.
+ // BCD Format.
//
-
+
- to_binary:SELF <-
// Self is BCD formatted, convert to binary value
( + result:SELF;
+ val,mul:SELF;
-
+
val := Self;
mul := 1;
{val!=0}.while_do {
@@ -118,29 +118,29 @@ Section Public
mul := mul * 10;
val := val >> 4;
};
-
+
result
);
-
+
- to_bcd:SELF <-
// Self is binary formatted, convert to bcd value
( + result:SELF;
+ val,mul:SELF;
-
+
val := Self;
{val != 0}.while_do {
result := result | ((val % 10) << mul);
mul := mul + 4;
val := val / 10;
};
-
- result
+
+ result
);
-
+
//
// Facility typing.
//
-
+
- kb:SELF <- Self << 10;
// Self in Kilobyte (ie. 1kb = 1024 bytes)
@@ -156,7 +156,7 @@ Section Public
//
// Logic Operator
//
-
+
- Self:SELF '&' Left 100 other:SELF :SELF <- `6`;
// AND operator
@@ -175,46 +175,46 @@ Section Public
//
// Unary operator
//
-
+
- '~' Self:SELF :SELF <- -Self - SELF.one; //(-SELF.one) - Self;
-
+
//
- // Test.
+ // Test.
//
-
+
- align_power step:SELF :SELF <-
- [
+ [
-? {step.is_power_2};
]
( + a:SELF;
-
+
a := step - 1;
(Self + a) & (~ a)
);
-
+
- is_power_2:BOOLEAN <-
// TRUE is Self is power of 2
( + val:SELF;
+ result:BOOLEAN;
-
- (Self != 0).if {
+
+ (Self != 0).if {
val := Self;
{val.is_even}.while_do {
val := val >> 1;
- };
- result := val = 1;
+ };
+ result := val = 1;
};
result
);
-
+
//
// Function :
//
-
+
- sqrt:SELF <-
// Square root
( + r,x:SELF;
-
+
x:=(Self + 1) >> 1;
{x > r}.while_do {
x:=x-r;
@@ -222,18 +222,18 @@ Section Public
};
r
);
-
+
- Self:SELF '!' :SELF <- factorial;
// Factorial. Use it like "45!;" or "bar!.print;"
-
+
- factorial:SELF <-
- // Factorial.
+ // Factorial.
// * Require: Self >= 0
[
-? {Self >= 0};
]
( + result,value:SELF;
-
+
result := 1;
value := Self;
{value <= 1}.until_do {
@@ -242,7 +242,7 @@ Section Public
};
result
);
-
+
- fibonacci:SELF <-
// Fibonacci
// * Require: Self >= 0
@@ -250,7 +250,7 @@ Section Public
-? {Self >= 0};
]
( + result:SELF;
-
+
(Self <= 1).if {
result := 1;
} else {
@@ -258,11 +258,11 @@ Section Public
};
result
);
-
+
- is_odd:BOOLEAN <- (Self & 1) = 1; // Is odd ?
-
+
- is_even:BOOLEAN <- ! is_odd; // Is even ?
-
+
- gcd other:SELF :SELF <-
// Great Common Divisor of `self' and `other'.
[
@@ -270,19 +270,19 @@ Section Public
-? {other >= 0};
]
( + result:SELF;
-
+
(other = 0).if {
result := Self;
} else {
result := other.gcd (Self % other);
};
-
+
result
)
[
+? {result == other.gcd self};
];
-
+
//
// Random
//
@@ -299,8 +299,8 @@ Section Public
- random_upper upper:SELF :SELF <-
// Random number between 0 to `upper'.
- [
- -? {upper > 0};
+ [
+ -? {upper > 0};
]
(
random % (upper+1)
@@ -314,28 +314,28 @@ Section Public
[
-? {lower < upper};
]
- (
+ (
lower + random_upper (upper-lower)
)
[
+? {Result.in_range lower to upper};
];
-
+
//
// Looping.
//
-
+
- times action:BLOCK <-
(
1.to Self do { i:INTEGER;
action.value;
};
);
-
+
//
// Convertion
//
-
+
// *French, Slot, Description : Renvoi une chaîne représentant le nombre en base 10
// *English, Slot, Description : String of the number in base 10
@@ -349,88 +349,88 @@ Section Public
- append_in buffer:STRING <- to_integer_32.append_in buffer;
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
-
+
- decimal_digit:CHARACTER <-
// Gives the corresponding CHARACTER for range 0..9.
[
-? {in_range 0 to 9};
]
- (
+ (
(Self.to_integer_8 + '0'.code).to_character
)
[
+? {"0123456789".has Result};
+? {Result.decimal_value = Self};
];
-
+
- digit:CHARACTER <- decimal_digit;
-
+
- hexadecimal_digit:CHARACTER <-
// Gives the corresponding CHARACTER for range 0..15.
[
-? {in_range 0 to 15};
]
( + result:CHARACTER;
-
+
(Self <= 9).if {
result := digit;
} else {
result := ('A'.code + (Self - 10).to_integer_8).to_character;
- };
+ };
result
)
[
+? {"0123456789ABCDEF".has Result};
];
-
+
- to_character:CHARACTER <- to_integer_8.to_character;
// Return the coresponding ASCII character.
-
+
- to_octal:SELF <-
// Gives coresponding octal value.
( + result:SELF;
-
+
deferred;
result
);
-
+
- to_hexadecimal:STRING <-
// 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.
// * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
-
+
result := STRING.create 8;
to_hexadecimal_in result;
result
);
-
+
- to_hexadecimal_format s:INTEGER :STRING <-
// 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.
// * See: `to_hexadecimal_in' to save memory.
( + result:STRING;
-
+
result := STRING.create 8;
to_hexadecimal_in result format s;
result
- );
-
+ );
+
- to_hexadecimal_in buffer:STRING <-
// Append in `buffer' the equivalent of `to_hexadecimal'. No new STRING
// creation during the process.
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
i := buffer.count + 1;
val := Self;
- {val != 0}.while_do { //JBJB
+ {val != 0}.while_do { //JBJB
buffer.extend ((val & 15).hexadecimal_digit);
val := val >> 4;
};
@@ -442,20 +442,20 @@ Section Public
};
};
);
-
+
- to_hexadecimal_in buffer:STRING format s:INTEGER <-
// Append in `buffer' the equivalent of `to_hexadecimal'. No new STRING
// creation during the process.
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
i := buffer.count + 1;
val := Self;
- {val != 0}.while_do { //JBJB
+ {val != 0}.while_do { //JBJB
buffer.extend ((val & 15).hexadecimal_digit);
val := val >> 4;
};
@@ -467,7 +467,7 @@ Section Public
};
};
buffer.precede_multiple '0' by (s.to_integer - buffer.count);
- );
+ );
- to_binary_in buffer:STRING format s:INTEGER <-
// Append in `buffer' the equivalent of `to_binary_string'. No new STRING
@@ -475,13 +475,13 @@ Section Public
[ -? {buffer!=NULL}; ]
( + val:SELF;
+ i,old_count:INTEGER;
-
+
(Self = 0).if {
buffer.extend '0';
} else {
i := buffer.count + 1;
val := Self;
- {val != 0}.while_do {
+ {val != 0}.while_do {
buffer.extend ('0' +# (val & 1));
val := val >> 1;
};
@@ -493,18 +493,18 @@ Section Public
};
};
buffer.precede_multiple '0' by ((s.to_integer) - buffer.count);
- );
-
+ );
+
//
// Hashing:
//
-
+
- hash_code:INTEGER <- to_integer_32.hash_code; // BSBS: Il faut revoir => Depending processor
-
+
//
// Print
//
-
+
- print <-
(
(Self = 0).if {
@@ -516,13 +516,13 @@ Section Public
print_positif;
};
);
-
+
- print_positif <-
// Display this number without memory.
[ -? {Self >=# 0}; ]
( + char:CHARACTER;
- + val:SELF;
-
+ + val:SELF;
+
char := (Self % 10).decimal_digit;
val := Self / 10;
(val != 0).if {
@@ -535,23 +535,23 @@ Section Public
// Display this number without memory.
( + char:CHARACTER;
+ val:SELF;
-
- char := (Self & 0Fh).hexadecimal_digit;
- val := Self / 16;
+
+ char := (Self & 0Fh).hexadecimal_digit;
+ val := Self / 16;
(val != 0).if {
val.print_hex;
};
char.print;
);
-
+
//
// Debug manager facility.
//
-
+
- Self:SELF '?' blc:BLOCK <- blc ?# Self;
-
-Section INTEGER
-
+
+Section INTEGER
+
- to_raw_pointer:POINTER <- CONVERT(SELF,POINTER).on Self;
diff --git a/lib/standard/number/integer/uinteger_16.li b/lib/standard/number/integer/uinteger_16.li
index 8acee90..a65d23b 100644
--- a/lib/standard/number/integer/uinteger_16.li
+++ b/lib/standard/number/integer/uinteger_16.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UINTEGER_16;
- export :=
- UINTEGER_64, UINTEGER_32,
+ UINTEGER_64, UINTEGER_32,
INTEGER_64 , INTEGER_32 ,
INTEGER;
-
+
- comment :="Unsigned 16 bits integer.";
- type := `unsigned short`;
- default := (0.to_raw_uinteger_16);
-
+
Section Insert
-
+
- parent_unsigned_integer:UNSIGNED_INTEGER := UNSIGNED_INTEGER;
-
+
Section Public
- - object_size:INTEGER := 2;
+ - object_size:INTEGER := 2;
//
// Range.
//
-
- - maximum:UINTEGER_64 := 65535.to_raw_uinteger_64;
-
+
+ - maximum:UINTEGER_64 := 65535.to_raw_uinteger_64;
+
//
// Conversion with test.
//
-
+
- to_uinteger_16:UINTEGER_16 <- Self;
-
+
//- to_char_unicode:CHAR_UNICODE <- CHAR_UNICODE.force_conversion Self;
diff --git a/lib/standard/number/integer/uinteger_32.li b/lib/standard/number/integer/uinteger_32.li
index 8d60296..28de9bb 100644
--- a/lib/standard/number/integer/uinteger_32.li
+++ b/lib/standard/number/integer/uinteger_32.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UINTEGER_32;
- export := INTEGER, UINTEGER_64, INTEGER_64;
-
+
- comment := "Unsigned 32 bits integer.";
-
+
- type := `unsigned int`;
- default := (0.to_raw_uinteger_32);
Section Insert
-
+
- parent_unsigned_integer:UNSIGNED_INTEGER := UNSIGNED_INTEGER;
-
+
Section Public
-
+
- object_size:INTEGER := 4;
//
// Range.
//
-
+
- maximum:UINTEGER_64 := ~ 0.to_raw_uinteger_32;
-
+
//
// Conversion with test.
//
-
+
- to_uinteger_32:UINTEGER_32 <- Self;
- to_uinteger_64:UINTEGER_64 <- to_raw_uinteger_64;
diff --git a/lib/standard/number/integer/uinteger_64.li b/lib/standard/number/integer/uinteger_64.li
index 769be07..4584258 100644
--- a/lib/standard/number/integer/uinteger_64.li
+++ b/lib/standard/number/integer/uinteger_64.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UINTEGER_64;
- export := INTEGER;
@@ -28,24 +28,23 @@ Section Header
- type := `unsigned long long`;
- default := (0.to_raw_uinteger_64);
-
+
Section Insert
-
+
- parent_unsigned_integer:UNSIGNED_INTEGER := UNSIGNED_INTEGER;
-
+
Section Public
-
+
- object_size:INTEGER := 8;
//
// Range.
//
-
- - maximum:UINTEGER_64 := `0xFFFFFFFFFFFFFFFFLLU`:UINTEGER_64; //BSBS pb C 0FFFFFFFFFFFFFFFFh;
-
+
+ - maximum:UINTEGER_64 := `0xFFFFFFFFFFFFFFFFLLU`:UINTEGER_64; //BSBS pb C 0FFFFFFFFFFFFFFFFh;
+
//
// Conversion with test.
//
-
+
- to_uinteger_64:UINTEGER_64 <- Self;
-
\ No newline at end of file
diff --git a/lib/standard/number/integer/uinteger_8.li b/lib/standard/number/integer/uinteger_8.li
index 18dfcc9..d8b9274 100644
--- a/lib/standard/number/integer/uinteger_8.li
+++ b/lib/standard/number/integer/uinteger_8.li
@@ -19,11 +19,11 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UINTEGER_8;
-
- - export :=
- UINTEGER_64, UINTEGER_32, UINTEGER_16,
+
+ - export :=
+ UINTEGER_64, UINTEGER_32, UINTEGER_16,
INTEGER_64 , INTEGER_32 , INTEGER_16 ,
INTEGER;
@@ -31,30 +31,30 @@ Section Header
- type := `unsigned char`;
- default := (0.to_raw_uinteger_8);
-
+
Section Insert
-
+
- parent_unsigned_integer:UNSIGNED_INTEGER := UNSIGNED_INTEGER;
-
+
Section Public
-
+
- object_size:INTEGER := 1;
//
// Range.
//
-
+
- maximum:UINTEGER_64 := 255.to_raw_uinteger_64;
-
+
//
// Conversion with test.
//
-
+
- to_uinteger_8:UINTEGER_8 <- Self;
-
- - to_character:CHARACTER <-
+
+ - to_character:CHARACTER <-
[ -? {in_range (CHARACTER.minimum) to (CHARACTER.maximum)}; ]
- (
+ (
CONVERT(UINTEGER_8, CHARACTER).on Self
);
diff --git a/lib/standard/number/integer/uinteger_big.li b/lib/standard/number/integer/uinteger_big.li
index eefe675..d69b3ae 100644
--- a/lib/standard/number/integer/uinteger_big.li
+++ b/lib/standard/number/integer/uinteger_big.li
@@ -22,7 +22,7 @@ Section Header
+ name := UINTEGER_BIG; // Aucun Auto-Cast pour l'instant...(peut etre
// INTEGER_BIG ...)
-
+
- comment := "Integer without bits limit! (Just for fun!)";
Section Inherit
@@ -30,11 +30,11 @@ Section Inherit
- parent_object:OBJECT := OBJECT;
Section UINTEGER_BIG
-
+
+ storage:FAST_ARRAY(UINTEGER_32);
-
+
- last_modulo:UINTEGER_32;
-
+
- count:INTEGER <- storage.count;
- lower:INTEGER <- storage.lower;
@@ -46,40 +46,40 @@ Section UINTEGER_BIG
- copy other:UINTEGER_BIG <- storage.copy (other.storage);
- force elt:UINTEGER_32 to idx:INTEGER <- storage.force elt to idx;
-
+
- put elt:UINTEGER_32 to idx:INTEGER <- storage.put elt to idx;
-
+
- add_last elt:UINTEGER_32 <- storage.add_last elt;
-
+
- resize new_size:INTEGER <-
(
- ? { new_size > 0};
+ ? { new_size > 0};
storage.resize new_size;
);
-
+
- last:UINTEGER_32 <- storage.last;
-
+
- normalize <-
(
{(storage.count != 1) && {storage.last == 0}}.while_do {
storage.remove_last;
- };
+ };
);
-Section Public
+Section Public
- - create init:UINTEGER_32 :UINTEGER_BIG <-
+ - create init:UINTEGER_32 :UINTEGER_BIG <-
( + result:SELF;
-
+
result := clone;
result.make init;
result
);
-
+
- make init:UINTEGER_32 :SELF <-
- (
+ (
(storage = NULL).if {
- storage := FAST_ARRAY(UINTEGER_32).create_with_capacity 4;
+ storage := FAST_ARRAY(UINTEGER_32).create_with_capacity 4;
} else {
storage.clear;
};
@@ -89,72 +89,72 @@ Section Public
//
// Conversion format with test.
//
-
- - to_uinteger_64:UINTEGER_64 <-
+
+ - to_uinteger_64:UINTEGER_64 <-
[ -? {count <= 2}; ] // Bound limit control.
( + result:UINTEGER_64;
-
+
result := storage.first;
(count > 1).if {
result := result | (storage.item 1.to_uinteger_64 << 32);
};
result
);
-
- - to_uinteger_32:UINTEGER_32 <-
+
+ - to_uinteger_32:UINTEGER_32 <-
[ -? {count = 1}; ]
- (
+ (
storage.first
);
-
- - to_uinteger_16:UINTEGER_16 <-
+
+ - to_uinteger_16:UINTEGER_16 <-
[ -? {count = 1}; ]
- (
+ (
storage.first.to_uinteger_16
);
-
- - to_uinteger_8:UINTEGER_8 <-
+
+ - to_uinteger_8:UINTEGER_8 <-
[ -? {count = 1}; ]
- (
+ (
storage.first.to_uinteger_8
);
-
- - to_integer_64:INTEGER_64 <-
+
+ - to_integer_64:INTEGER_64 <-
[ -? {(to_uinteger_64 >> 63) = 0}; ]
- (
+ (
to_uinteger_64.to_integer_64
);
-
- - to_integer:INTEGER <-
+
+ - to_integer:INTEGER <-
[ -? {(to_uinteger_64 >> 31) = 0}; ]
- (
+ (
storage.first.to_integer
);
-
- - to_integer_16:INTEGER_16 <-
+
+ - to_integer_16:INTEGER_16 <-
[ -? {(to_uinteger_16 >> 15) = 0}; ]
- (
+ (
storage.first.to_uinteger_16
);
-
- - to_integer_8:INTEGER_8 <-
+
+ - to_integer_8:INTEGER_8 <-
[ -? {(to_uinteger_8 >> 7) = 0}; ]
- (
+ (
storage.first.to_integer_8
);
-
+
//
// binary operator :
//
-
- - substract other:SELF :SELF <-
+
+ - substract other:SELF :SELF <-
[ ? {Self >= other}; ]
( + over,substr,part1,part2:UINTEGER_64;
+ idx:INTEGER;
(Self == other).if {
set_with_zero;
- } else {
+ } else {
idx := lower;
{idx > other.upper}.until_do {
part1 := item idx;
@@ -170,11 +170,11 @@ Section Public
over := substr >> 32;
put ((substr & 0FFFF_FFFFh).to_uinteger_32) to idx;
idx := idx + 1;
- };
+ };
normalize;
- };
+ };
);
-
+
- substract_integer other:INTEGER :SELF <-
[ ? {Self >=# other}; ]
( + part1,over,substr:UINTEGER_64;
@@ -182,7 +182,7 @@ Section Public
(Self ==# other).if {
set_with_zero;
- } else {
+ } else {
part1 := item 0;
substr := part1 - other;
over := substr >> 32;
@@ -194,16 +194,16 @@ Section Public
over := substr >> 32;
put ((substr & 0FFFF_FFFFh).to_uinteger_32) to idx;
idx := idx + 1;
- };
+ };
normalize;
- };
+ };
);
-
- - addition other:SELF :SELF <-
+
+ - addition other:SELF :SELF <-
[ -? {Self >= other}; ]
( + part1,part2,sum,over:UINTEGER_64;
+ idx:INTEGER;
-
+
idx := lower;
{idx > other.upper}.until_do {
part1 := item idx;
@@ -221,13 +221,13 @@ Section Public
};
(over != 0).if {
add_last (over.to_uinteger_32);
- };
- );
-
+ };
+ );
+
- addition_integer other:INTEGER :SELF <-
( + part1,sum,over:UINTEGER_64;
+ idx:INTEGER;
-
+
part1 := item 0;
sum := part1 + other;
put ((sum & 0FFFF_FFFFh).to_uinteger_32) to 0;
@@ -237,28 +237,28 @@ Section Public
part1 := item idx;
sum := part1 + over;
put ((sum & 0FFFF_FFFFh).to_uinteger_32) to idx;
- idx := idx + 1;
+ idx := idx + 1;
over := sum >> 32;
- };
+ };
(over != 0).if {
add_last (over.to_uinteger_32);
- };
+ };
);
-
- - multiply other:SELF :SELF <-
+
+ - multiply other:SELF :SELF <-
( + part1,part2,product:UINTEGER_64;
+ index_result:INTEGER;
-
+
lower.to upper do { idx:INTEGER;
+ result_current:UINTEGER_BIG;
-
+
result_current := 0;
result_current.resize count;
part1 := item idx;
index_result := idx;
(other.lower).to (other.upper) do { idx_other:INTEGER;
part2 := other.item idx_other;
- product := part1 * part2;
+ product := part1 * part2;
(product < (UINTEGER_32.maximum.to_uinteger_64)).if {
result_current.put (product.to_uinteger_32) to index_result;
} else {
@@ -268,24 +268,24 @@ Section Public
index_result := index_result + 1;
};
};
-
+
result := result + result_current;
-
+
};
result.clean;
result
);
-
+
- Self:SELF '*#' Left 100 other:INTEGER :SELF <-
(
+ result:UINTEGER_BIG;
+ part1,product,over:UINTEGER_64;
-
+
result := 0;
result.resize count;
- lower.to upper do { idx:INTEGER;
- part1 := item idx;
- product := part1 * other + over;
+ lower.to upper do { idx:INTEGER;
+ part1 := item idx;
+ product := part1 * other + over;
(product < (UINTEGER_32.maximum.to_uinteger_64)).if {
result.put (product.to_uinteger_32) to idx;
over := 0;
@@ -294,30 +294,30 @@ Section Public
over := product >> 32;
};
};
-
+
(over!==0).if {
result.add_last (over.to_uinteger_32);
- };
-
+ };
+
result.clean;
result
);
-
- - Self:SELF '/' Left 100 other:SELF :SELF <-
+
+ - Self:SELF '/' Left 100 other:SELF :SELF <-
( + result:UINTEGER_BIG;
-
-
+
+
);
-
-
+
+
- Self:SELF '/#' Left 100 other:INTEGER :SELF <-
( + result:SELF;
+ last_mod,div:UINTEGER_64;
+ idx:INTEGER;
-
+
result.resize count;
idx := upper;
- last_mod := item idx;
+ last_mod := item idx;
{idx < lower}.until_do {
div := 0;
(last_mod < other).if {
@@ -329,8 +329,8 @@ Section Public
};
} else {
div := last_mod / (other.to_uinteger_64);
- last_mod := last_mod % (other.to_uinteger_64);
- };
+ last_mod := last_mod % (other.to_uinteger_64);
+ };
(div !== 0).if {
result.put ((div & (UINTEGER_32.maximum.to_uinteger_64)).to_uinteger_32) to idx;
};
@@ -339,9 +339,9 @@ Section Public
result.clean;
result
);
-
+
- and_binary other:SELF :SELF <-
- (
+ (
(other.upper < upper).if {
storage.remove_tail (upper - other.upper);
};
@@ -350,22 +350,22 @@ Section Public
};
normalize;
);
-
+
- or_binary other:SELF :SELF <-
- (
+ (
lower.to (upper.min (other.upper)) do { i:INTEGER;
put (item i | other.item i) to i;
};
upper.to (other.upper) do { i:INTEGER;
add_last (other.item i);
- };
+ };
);
//
// Test binary operator :
//
-
- - Self:SELF '>' Right 60 other:SELF :BOOLEAN <-
+
+ - Self:SELF '>' Right 60 other:SELF :BOOLEAN <-
(
+ result:BOOLEAN;
(count > (other.count)).if {
@@ -386,14 +386,14 @@ Section Public
find := TRUE;
};
- i := i + 1;
+ i := i + 1;
};
};
-
+
result
);
-
-
+
+
- Self:SELF '>#' Right 60 other:INTEGER :BOOLEAN <-
(
+ result:BOOLEAN;
@@ -404,7 +404,7 @@ Section Public
};
result
);
-
+
- Self:SELF '==' Right 60 other:SELF :BOOLEAN <-
(
+ result:BOOLEAN;
@@ -418,61 +418,61 @@ Section Public
result := TRUE;
};
};
-
+
result
);
-
+
//
// Function.
//
- factorial_integer n:INTEGER <-
[ -? {n >= 0}; ]
- (
+ (
(n = 0).if {
set_with_zero;
put 1 to 0;
} else {
2.to n do { i:INTEGER;
- multiply_integer i;
+ multiply_integer i;
};
};
);
-
+
//
// conversion
//
-
- - append_in buffer:STRING <-
+
+ - append_in buffer:STRING <-
// Append in the `buffer' the equivalent of `to_string'. No new STRING
// creation during the process.
- ( + value:UINTEGER_BIG;
+ ( + value:UINTEGER_BIG;
+ mod:UINTEGER_32;
+ counter:INTEGER;
+ old_upper,new_upper:INTEGER;
-
+
old_upper:=buffer.upper + 1;
-
- (upper = 0).if {
+
+ (upper = 0).if {
item 0.append_in buffer;
} else {
value:=Self;
{
value:=value /# 1000000000;
- mod:=last_modulo;
+ mod:=last_modulo;
{counter==0}.until_do {
buffer.extend '0';
counter:=counter-1;
};
counter := 9;
- {
+ {
buffer.extend ((mod % 10).digit);
mod := mod / 10;
counter := counter-1;
}.do_while {mod!==0};
}.do_while {value!==0};
-
- new_upper := buffer.upper;
+
+ new_upper := buffer.upper;
// Swap.
{old_upper >= new_upper}.until_do {
@@ -482,30 +482,30 @@ Section Public
};
};
);
-
+
- print_positif <-
(
string_tmp.clear;
append_in string_tmp;
string_tmp.print;
);
-/*
+/*
- append_in buffer:STRING <-
( + val:SELF;
- + i,j:INTEGER;
+ + i,j:INTEGER;
? {buffer!=NULL};
-
+
(self == 0).if {
buffer.extend '0';
- } else {
- i := buffer.upper + 1;
+ } else {
+ i := buffer.upper + 1;
val.copy Self;
{val == 0}.until_do {
buffer.extend ((val %# 10).digit);
val := val /# 10;
};
j := buffer.upper;
-
+
{i >= j}.until_do {
buffer.swap i with j;
j := j - 1;
@@ -515,15 +515,15 @@ Section Public
);
*/
Section Public
-
+
- set_with_zero <-
(
storage.clear;
storage.add_last 0;
);
-
+
- is_zero:BOOLEAN <- ((storage.count = 1) && {storage.first = 0});
-
+
- compare other:SELF :INTEGER <-
// -1 if Self < other
// 0 if Self = other
@@ -531,7 +531,7 @@ Section Public
( + result,up_s,up_o:INTEGER;
+ v_s,v_o:INTEGER_32;
+ i:INTEGER;
-
+
up_s := upper;
up_o := other.upper;
(up_s = up_o).if {
@@ -551,13 +551,13 @@ Section Public
} else {
(up_s < up_o).if {
result := -1;
- } else {
+ } else {
result := 1;
};
};
result
);
-
+
- divide_one_word divisor:UINTEGER_32 :UINTEGER_32 <-
// This method is used by `divide'. The one word divisor is
// specified by `divisor' is saw as unsigned.
@@ -568,7 +568,7 @@ Section Public
( + i, remainder_word1, remainder_word0:INTEGER;
+ result:UINTEGER_32;
+ x:UINTEGER_64;
-
+
(count = 1).if {
result := first;
(result < divisor).if {
@@ -584,7 +584,7 @@ Section Public
remainder_word0 := item i;
x := (remainder_word1.to_uinteger_64 << 32) | remainder_word0;
remainder_word1 := x % divisor;
- put (x / divisor) to i;
+ put (x / divisor) to i;
i := i - 1;
};
(item upper = 0).if {
@@ -592,17 +592,17 @@ Section Public
? {item upper != 0};
};
result := remainder_word1;
- };
+ };
result
);
-
+
- normalize_shift:INTEGER_8 <-
// Shift left until the most significant bit is on.
// Result give the number of left shift.
[ -? {! is_zero}; ]
( + head:UINTEGER_32;
+ result:INTEGER_8;
-
+
head := item upper;
{(head & 8000_0000h) != 0}.until_do {
head := head << 1;
@@ -614,7 +614,7 @@ Section Public
result
)
[ +? {item upper < 0}; ];
-
+
- shift_left n:INTEGER <-
// Shift bits of magnitude by `n' position left. (Note that no bit can
// be lost because the `storage' area is automatically extended when
@@ -623,11 +623,11 @@ Section Public
( + left,right: INTEGER_8;
+ word_shift:INTEGER;
+ new_value:UINTEGER_32;
-
+
(last != 0).if {
word_shift := n >> 5;
- left := (n & 1Fh).to_integer_8; // Optimistic prediction
- right := 32 - left;
+ left := (n & 1Fh).to_integer_8; // Optimistic prediction
+ right := 32 - left;
((last >> right) = 0).if {
storage.add 0 first (word_shift+1);
word_shift.to (upper-1) do { i:INTEGER;
@@ -644,20 +644,20 @@ Section Public
new_value := item word_shift << left;
storage.put new_value to word_shift;
};
- };
+ };
);
-
+
- shift_right n:INTEGER <-
- // Shift bits of magnitude by `n' position right.
+ // Shift bits of magnitude by `n' position right.
[ -? {n > 0}; ]
( + left,right: INTEGER_8;
+ word_right:INTEGER;
+ new_value:UINTEGER_32;
-
+
(last != 0).if {
word_right := n >> 5;
- right := (n & 1Fh).to_integer_8; // Optimistic prediction
- left := 32 - right;
+ right := (n & 1Fh).to_integer_8; // Optimistic prediction
+ left := 32 - right;
word_shift.to (upper-1) do { i:INTEGER;
new_value := (item (i+1) << left) | (item i >> right);
storage.put new_value to (i - word_shift);
@@ -668,28 +668,28 @@ Section Public
} else {
storage.put new_value to (upper - word_shift);
storage.remove_tail word_shift;
- };
- };
+ };
+ };
);
-
- - multiply_and_subtract (u1, qhat: INTEGER, d_storage: FAST_ARRAY(UINTEGER_32),
+
+ - multiply_and_subtract (u1, qhat: INTEGER, d_storage: FAST_ARRAY(UINTEGER_32),
d_offset:INTEGER, r_storage:FAST_ARRAY(UINTEGER_32),r_offset, length: INTEGER):BOOLEAN <-
// Only used by `divide'.
[ -? {qhat != 0}; ]
- ( + i, j, jmax, m1, m2: INTEGER;
+ ( + i, j, jmax, m1, m2: INTEGER;
+ dec,result:BOOLEAN;
-
+
(qhat = 1).if {
i := d_offset;
j := r_offset;
- jmax := r_offset + length;
+ jmax := r_offset + length;
{j = jmax}.until_do {
(dec).if {
- x_32 := r_storage.item j - d_storage.item i - 1;
+ x_32 := r_storage.item j - d_storage.item i - 1;
dec := x_32 >= r_storage.item j;
r_storage.put x_32 to j;
} else {
- x_32 := r_storage.item j - d_storage.item i;
+ x_32 := r_storage.item j - d_storage.item i;
dec := x_32 > r_storage.item j;
r_storage.put x_32 to j;
};
@@ -700,11 +700,11 @@ Section Public
(u1 = 0).if {
result := TRUE;
} else {
- x_32 := r_storage.item j - 1;
+ x_32 := r_storage.item j - 1;
result := r_storage.item j = 0;
r_storage.put x_32 to j;
- ? {! result};
- };
+ ? {! result};
+ };
};
} else {
i := d_offset;
@@ -715,11 +715,11 @@ Section Public
m2 := (x & 0FFFF_FFFFh).to_uinteger_32;
m1 := (x >> 32).to_uinteger_32;
(dec).if {
- x_32 := r_storage.item j - m2 - 1;
+ x_32 := r_storage.item j - m2 - 1;
dec := x_32 >= r_storage.item j;
r_storage.put x_32 to j;
} else {
- x_32 := r_storage.item j - m2;
+ x_32 := r_storage.item j - m2;
dec := x_32 > r_storage.item j;
r_storage.put x_32 to j;
};
@@ -730,7 +730,7 @@ Section Public
(u1 = 0).if {
result := TRUE;
} else {
- x_32 := r_storage.item j - m1 - 1;
+ x_32 := r_storage.item j - m1 - 1;
result := x_32 >= r_storage.item j;
r_storage.put x_32 to j;
};
@@ -739,7 +739,7 @@ Section Public
}.elseif {u1 = 0} then {
result := TRUE;
} else {
- x_32 := r_storage.item j - m1;
+ x_32 := r_storage.item j - m1;
result := x_32 > r_storage.item j;
r_storage.put x_32 to j;
};
@@ -751,15 +751,15 @@ Section Public
r_storage:FAST_ARRAY(UINTEGER_32),r_offset, length:INTEGER):BOOLEAN <-
// Only used by `divide'.
// `old_u1' is the value of `u1' before `multiply_and_subtract'.
- ( + i, j, jmax:INTEGER;
+ ( + i, j, jmax:INTEGER;
+ inc,result:BOOLEAN;
-
+
i := d_offset;
j := r_offset;
jmax := r_offset + length;
- {j = jmax}.until_do {
+ {j = jmax}.until_do {
(inc).if {
- x_32 := r_storage.item j + d_storage.item i + 1;
+ x_32 := r_storage.item j + d_storage.item i + 1;
inc := x_32 <= r_storage.item j;
r_storage.put x_32 to j;
} else {
@@ -786,19 +786,19 @@ Section Public
-? {other != NULL};
-? {quotient != NULL};
-? {remainder != NULL};
- ]
- ( + v:SELF;
+ ]
+ ( + v:SELF;
v := other.twin;
v.multiply quotient;
v.add remainder;
Self == v
);
-
+
- divide_to (other, quotient, remainder:SELF) <-
// Euclidian division.
// Calculates the `quotient' and `remainder' of `Current'
// divided by `other'. (The contents of `Current' and `other' are
- // not changed.)
+ // not changed.)
// Note: Uses Algorithm D in Knuth
[ -? {! other.is_zero};
-? {quotient != NULL};
@@ -809,43 +809,43 @@ Section Public
-? {remainder != Self};
]
( + cmp, shift, nlen, dlen, qlen, j, k, v1, v2, u1, u2, rem: INTEGER;
- + qhat, rhat, v2qhat_1, v2qhat_2, d_offset: INTEGER;
+ + qhat, rhat, v2qhat_1, v2qhat_2, d_offset: INTEGER;
+ q_storage, r_storage, d_storage:FAST_ARRAY(UINTEGER_32);
+ q_capacity, r_capacity:INTEGER;
+ borrow:BOOLEAN;
-
+
(is_zero).if {
// Dividend is zero:
quotient.set_with_zero;
remainder.set_with_zero;
} else {
cmp := compare other;
- (cmp < 0).if {
+ (cmp < 0).if {
// Dividend less than divisor:
quotient.set_with_zero;
- remainder.copy Self;
+ remainder.copy Self;
}.elseif {cmp = 0} then {
- // Dividend equal to divisor:
+ // Dividend equal to divisor:
quotient.from_integer 1;
remainder.set_with_zero;
}.elseif {other.count = 1} then {
// Special case one word divisor:
- quotient.copy Self;
+ quotient.copy Self;
remainder.storage.clear;
- rem := quotient.divide_one_word (other.first);
- remainder.add_last rem;
+ rem := quotient.divide_one_word (other.first);
+ remainder.add_last rem;
} else {
// Copy divisor storage to protect divisor:
register1.copy other;
remainder.copy Self;
// D1 normalize the divisor:
- shift := register1.normalize_shift;
+ shift := register1.normalize_shift;
(shift != 0).if {
remainder.shift_left shift;
};
- // D2 Initialize j:
+ // D2 Initialize j:
r_storage := remainder.storage;
- r_capacity := remainder.capacity;
+ r_capacity := remainder.capacity;
nlen := remainder.count; // To avoid invariant class violation
remainder.set_with_zero;
d_storage := register1.storage;
@@ -877,11 +877,11 @@ Section Public
};
// To avoid invariant violation on quotient
quotient.set_with_zero;
- {k < 0}.until_do {
+ {k < 0}.until_do {
j := j - 1; // D3 Calculate qhat - estimate qhat
(u1 = v1).if {
qhat := ~0;
- } else {
+ } else {
x := (u1.to_uinteger_64 << 32) | u2;
rhat := (x % v1).to_uinteger_32;
qhat := (x / v1).to_uinteger_32; // Correct qhat
@@ -928,10 +928,10 @@ Section Public
(borrow).if {
// D6 Add back
borrow := add_back(u1, d_storage, d_offset, r_storage, j - dlen + 2, dlen);
- ? {borrow};
+ ? {borrow};
q_storage.put (qhat - 1) to k;
} else {
- q_storage.put qhat to k;
+ q_storage.put qhat to k;
};
};
// D7 loop on j
@@ -946,24 +946,24 @@ Section Public
};
quotient.set_all(q_storage, q_capacity, qlen, 0, FALSE);
// Remove leading zero of remainder
- j := dlen - 1;
+ j := dlen - 1;
{(j < 0) || {r_storage.item j != 0}}.until_do {
j := j - 1;
};
j := j + 1;
? {j >= 0};
(j = 0).if {
- ? {remainder.is_zero};
+ ? {remainder.is_zero};
} else {
remainder.set_all(r_storage, r_capacity, j, 0, FALSE);
};
// D8 Unnormalize:
(shift > 0).if {
remainder.shift_right shift;
- };
+ };
};
};
)
- [
- ? {is_a_good_divide(other, quotient, remainder)};
+ [
+ ? {is_a_good_divide(other, quotient, remainder)};
];
diff --git a/lib/standard/number/integer/uinteger_cpu.li b/lib/standard/number/integer/uinteger_cpu.li
index 5382811..87d040b 100644
--- a/lib/standard/number/integer/uinteger_cpu.li
+++ b/lib/standard/number/integer/uinteger_cpu.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded UINTEGER_CPU;
- export := UINTEGER_64, POINTER;
-
+
- comment := "Unsigned integer (variable size according to CPU word).";
-
+
- type := `unsigned long`;
- default := (0.to_raw_uinteger_cpu);
Section Insert
-
+
- parent_unsigned_integer:UNSIGNED_INTEGER := UNSIGNED_INTEGER;
-
+
Section Public
-
+
- object_size:INTEGER <- `sizeof(unsigned long)`:INTEGER;
//
// Range.
//
-
+
- maximum:UINTEGER_64 := (~ 0.to_uinteger_cpu).to_raw_uinteger_64;
-
+
//
// Conversion with test.
//
-
+
- to_uinteger_64:UINTEGER_64 <- to_raw_uinteger_64;
-
+
- to_pointer:POINTER <- to_raw_pointer;
\ No newline at end of file
diff --git a/lib/standard/number/real/real.li b/lib/standard/number/real/real.li
index 25cddfe..a0d6f60 100644
--- a/lib/standard/number/real/real.li
+++ b/lib/standard/number/real/real.li
@@ -19,9 +19,9 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL;
-
+
- export :=
REAL_32, REAL_64, REAL_80,
REAL_16_16, REAL_24_8, REAL_26_6,
@@ -29,28 +29,28 @@ Section Header
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Xavier Oswald";
- comment := "Generic real number.";
-
+
- type := `float`;
- default := 0.0;
-
+
- lip <-
(
add_lib "-lm";
);
Section Insert
-
+
- inherit_numeric:NUMERIC := NUMERIC;
-
+
Section Public
-
+
- Self:SELF '+' Left 80 other:SELF :SELF <- `@Self + @other`:SELF;
- - bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
+ - bound_test low:INTEGER_64 to up:UINTEGER_64 :BOOLEAN <-
(
TRUE
);
-
+
- pi :SELF <- 3.14159265358979323846;
// Pi number
@@ -78,7 +78,7 @@ Section Public
Self.pow exp
);
- - Self:SELF '^' Right 120 exp:SELF :SELF <-
+ - Self:SELF '^' Right 120 exp:SELF :SELF <-
// Power
(
Self.pow exp
@@ -87,46 +87,46 @@ Section Public
//
// Convertion format with test.
//
-
+
- floor:INTEGER <-
// Greatest integral value no greater than Current.
- (
+ (
to_raw_integer
);
-
+
- ceiling:INTEGER <-
// Smallest integral value no smaller than Current.
- (
+ (
(Self + 0.9999).floor
);
-
+
- rounded:INTEGER <-
// Rounded integral value.
(
(Self + 0.5).floor
);
-
+
- truncated_to_integer:INTEGER <- floor;
// Integer part (largest absolute value no greater than Current).
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' other:SELF :BOOLEAN <-
// Equal, close to 0.001
(
(Self - other).abs < 0.001
);
-
+
- is_not_a_number:BOOLEAN <- deferred;
-
+
- is_infinity:BOOLEAN <- deferred;
-
+
//
// Print.
//
-
+
- append_in buffer:STRING <-
// Append `Self' decimal representation in `buffer' with 4 decimal
(
@@ -141,31 +141,31 @@ Section Public
append_in result;
result
);
-
+
- append_in buffer:STRING format n:INTEGER decimal d:INTEGER <-
(
append_in buffer format n with ' ' decimal d;
);
-
+
- append_in buffer:STRING format n:INTEGER with c:CHARACTER decimal d:INTEGER <-
- // String of the number in base 10 with `c' replacing blanck
- [
+ // String of the number in base 10 with `c' replacing blanck
+ [
-? {n >= 3};
]
( + old_count:INTEGER;
-
+
old_count := buffer.count;
append_in buffer decimal d;
buffer.insert c to old_count on (n - (buffer.count - old_count));
);
-
+
- append_in buffer:STRING decimal n:INTEGER <-
// String of the number in base 10 with 4 decimal
( + val:SELF;
- + val_10:INTEGER;
+ + val_10:INTEGER;
+ char:CHARACTER;
+ i:INTEGER;
-
+
get_map Self;
// Sign.
(sign).if {
@@ -173,9 +173,9 @@ Section Public
} else {
buffer.add_last '-';
val := - Self;
- };
+ };
(is_zero).if {
- // Zero case.
+ // Zero case.
buffer.add_last '0';
}.elseif {is_infinite} then {
// Infinite case.
@@ -183,38 +183,38 @@ Section Public
}.elseif {is_nan} then {
// Nan case.
buffer.append "Nan";
- } else {
+ } else {
// Value case = 1.mantisse x 2^(exp-127)
(val > INTEGER.maximum.to_real_32).if {
scientific_append_in buffer;
} else {
- val_10 := val.to_integer;
- val_10.append_in buffer;
- val := val - val_10;
+ val_10 := val.to_integer;
+ val_10.append_in buffer;
+ val := val - val_10;
(n != 0).if {
buffer.add_last '.';
i := n;
- {(val != 0) && {i > 0}}.while_do {
+ {(val != 0) && {i > 0}}.while_do {
val := val * 10;
val_10 := val.to_integer;
char := val_10.decimal_digit;
buffer.add_last char;
val := val - val_10;
i := i - 1;
- };
+ };
buffer.extend_multiple '0' by i;
};
};
- };
+ };
);
-
- - scientific_append_in buffer:STRING <-
+
+ - scientific_append_in buffer:STRING <-
// Scientific number representation
( + val:SELF;
+ val_10:INTEGER;
+ exp_10:INTEGER;
+ char:CHARACTER;
-
+
get_map Self;
// Sign.
(sign).if {
@@ -222,7 +222,7 @@ Section Public
} else {
buffer.add_last '-';
val := - Self;
- };
+ };
(is_zero).if {
// Zero case.
buffer.add_last '0';
@@ -247,7 +247,7 @@ Section Public
buffer.add_last char;
buffer.add_last '.';
val := val - val_10;
- {val != 0}.while_do {
+ {val != 0}.while_do {
val := val * 10;
val_10 := val.to_integer;
char := val_10.decimal_digit;
@@ -258,19 +258,19 @@ Section Public
exp_10.append_in buffer;
};
);
-
+
- append_in buffer:STRING format_c fmt:ABSTRACT_STRING <-
- ( + nc_buf,nc_fmt:NATIVE_ARRAY(CHARACTER);
+ ( + nc_buf,nc_fmt:NATIVE_ARRAY(CHARACTER);
+ old_count,cap:INTEGER;
-
+
old_count := buffer.count;
cap := buffer.capacity - old_count;
nc_buf := buffer.to_external + old_count;
nc_fmt := fmt.to_external;
`snprintf(@nc_buf, at cap, at nc_fmt, at Self)`;
buffer.restore_after_external;
- );
-
+ );
+
- print_decimal s:INTEGER <-
// print with `s' decimal
(
@@ -278,17 +278,17 @@ Section Public
append_in string_tmp decimal s;
string_tmp.print;
);
-
+
- print_int i:INTEGER decimal d:INTEGER <-
(
print_format (i+d+1) decimal d;
);
-
+
- print_format s:INTEGER decimal d:INTEGER <-
[
-? {s > d};
]
- (
+ (
print_format s with ' ' decimal d;
);
@@ -296,16 +296,16 @@ Section Public
[
-? {s > d};
]
- (
+ (
string_tmp.clear;
append_in string_tmp format s with c decimal d;
string_tmp.print;
);
-
+
- print_format_c fmt:ABSTRACT_STRING <-
(
string_tmp.clear;
append_in string_tmp format_c fmt;
string_tmp.print;
);
-
+
diff --git a/lib/standard/number/real/real_32.li b/lib/standard/number/real/real_32.li
index 83020d4..7c2c3ce 100644
--- a/lib/standard/number/real/real_32.li
+++ b/lib/standard/number/real/real_32.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL_32;
- export := REAL, REAL_64, REAL_80;
-
+
- comment := "Float (C `float' mapping).";
-
+
- type := `float`;
- default := (0.to_raw_real_32);
-
+
Section Insert
-
+
- parent_float_map32:FLOAT_MAP32 := FLOAT_MAP32;
- parent_float_real:FLOAT_REAL := FLOAT_REAL;
-
+
diff --git a/lib/standard/number/real/real_64.li b/lib/standard/number/real/real_64.li
index 44d9ec0..28eb47f 100644
--- a/lib/standard/number/real/real_64.li
+++ b/lib/standard/number/real/real_64.li
@@ -19,23 +19,23 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL_64;
- export := REAL, REAL_80;
-
+
- comment := "Float (C `double' mapping).";
-
+
- type := `double`;
- default := (0.to_raw_real_64);
-
+
Section Insert
-
+
- parent_float_map64:FLOAT_MAP64 := FLOAT_MAP64;
-
+
- parent_float_real:FLOAT_REAL := FLOAT_REAL;
-
-
-
-
+
+
+
+
diff --git a/lib/standard/number/real/real_80.li b/lib/standard/number/real/real_80.li
index 010d493..ed47fa0 100644
--- a/lib/standard/number/real/real_80.li
+++ b/lib/standard/number/real/real_80.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded REAL_80;
- export := REAL;
-
+
- comment := "Float 80 bits (C `long double' mapping).";
-
+
- type := `long double`;
- default := (0.to_raw_real_80);
-
+
Section Insert
-
+
- parent_float_map80:FLOAT_MAP80 := FLOAT_MAP80;
- parent_float_real:FLOAT_REAL := FLOAT_REAL;
-
+
diff --git a/lib/standard/property/comparable.li b/lib/standard/property/comparable.li
index d4df7bc..787a70b 100644
--- a/lib/standard/property/comparable.li
+++ b/lib/standard/property/comparable.li
@@ -19,22 +19,22 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COMPARABLE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := " All classes handling COMPARABLE objects with a total order\
\relation should inherit from this class.";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
- - Self:SELF '==' Right 60 other:E :BOOLEAN <-
+
+ - Self:SELF '==' Right 60 other:E :BOOLEAN <-
( + result:BOOLEAN;
+ same:SELF;
same ?= other;
@@ -53,11 +53,11 @@ Section Public
// Is `self' less than or equal `other'?
(
+ result:BOOLEAN;
-
+
? { other != NULL };
result := ! (other < Self);
? { result = ((Self < other) | == other)};
-
+
result
);
@@ -74,7 +74,7 @@ Section Public
?{ other != NULL };
! (Self < other)
);
-
+
- in_range lower:SELF to upper:SELF :BOOLEAN <-
// Return true if `self' is in range [`lower'..`upper']
(
@@ -94,7 +94,7 @@ Section Public
} else {
result := 0;
};
-
+
? { (result = 0) = ( == other)};
? { (result = -1) = (Self < other)};
? { (result = 1) = (Self > other)};
@@ -106,27 +106,27 @@ Section Public
// Minimum of `self' and `other'.
(
+ result:SELF;
-
+
?{ other != NULL };
( Self <= other ).if {
result := Self;
} else {
result := other;
};
-
+
? { (result <= Self) && { result <= other}};
? { (compare result = 0) || { other.compare result = 0 }};
-
+
result
);
-
-
+
+
- max other:SELF :SELF <-
// Maximum of `self' and `other'.
(
+ result:SELF;
?{ other != NULL };
-
+
( Self >= other ).if {
result := Self;
} else {
diff --git a/lib/standard/property/hashable.li b/lib/standard/property/hashable.li
index 7e136e6..7db6847 100644
--- a/lib/standard/property/hashable.li
+++ b/lib/standard/property/hashable.li
@@ -19,20 +19,20 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := HASHABLE;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :=" .";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
- hash_code:INTEGER <-
// The hash-code value of `Current'.
(
diff --git a/lib/standard/property/safe_equal.li b/lib/standard/property/safe_equal.li
index 6b851b0..d3e215d 100644
--- a/lib/standard/property/safe_equal.li
+++ b/lib/standard/property/safe_equal.li
@@ -19,23 +19,23 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SAFE_EQUAL(E);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment :="The goal of this class is to share the definition of \
\feature `safe_equal'. Feature `safe_equal' compares \
\two arguments of type E, by calling `==' only \
\and only if both arguments have the `same_type'..";
-
+
Section Inherit
-
+
- parent:OBJECT := OBJECT;
-
+
Section Public
-
+
- safe_equal (e1, e2:E) :BOOLEAN <-
// In order to avoid run-time type errors, feature `safe_equal' call
// `==' only when `e1' and `e2' have exactly the same `generating_type'.
@@ -44,7 +44,7 @@ Section Public
// allocation of some reference type during the comparison).
( /*
+ result:BOOLEAN;
-
+
( e1.is_basic_expanded_type).if { then
result := (e1 = e2);
}.elseif {e1.is_expanded_type} then {
@@ -55,10 +55,10 @@ Section Public
}.elseif {e1.generating_type = e2.generating_type} then {
result := e1 == e2;
}; // end if
-
+
result
*/
(e1=e2) || {(e1!=NULL) && {e1==e2}}
);
-
+
diff --git a/lib/standard/property/traversable.li b/lib/standard/property/traversable.li
index c47a9cf..1aeaa68 100644
--- a/lib/standard/property/traversable.li
+++ b/lib/standard/property/traversable.li
@@ -19,18 +19,18 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TRAVERSABLE(V);
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "A `TRAVERSABLE(E_)' is a finite readable sequence of objects of type E_.";
-
+
// For instance, `COLLECTION's and `STRING's are `TRAVERSABLE'.
//
- // A good performance should always be obtained by sequentially acessing a
- // `TRAVERSABLE' with increasing indexes (from `lower' to `upper'), as
+ // A good performance should always be obtained by sequentially acessing a
+ // `TRAVERSABLE' with increasing indexes (from `lower' to `upper'), as
// demonstrated in the following code snippet :
//
// i := a_traversable.lower;
@@ -39,20 +39,20 @@ Section Header
// i := i + 1;
// };
//
- // Other accessing methods (including random access and sequential access
- // from `upper' to `lower') may or may not lead to acceptable performance,
+ // Other accessing methods (including random access and sequential access
+ // from `upper' to `lower') may or may not lead to acceptable performance,
// depending on the particular implementation of `TRAVERSABLE'.
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
//
// Indexing:
//
-
+
- lower:INTEGER <-
// Minimum index.
//
@@ -69,23 +69,23 @@ Section Public
(
deferred;
0
- );
-
+ );
+
- valid_index i:INTEGER :BOOLEAN <-
// True when `i' is valid (i.e., inside actual bounds).
//
// See also `lower', `upper', `item'.
- (
+ (
(lower <= i) && {i <= upper}
)
- [
+ [
"Definition." +? {Result = ((lower <= i) & (i <= upper))};
];
//
// Counting:
//
-
+
- count:INTEGER <-
// Number of available indices.
//
@@ -108,11 +108,11 @@ Section Public
[
"Definition." +? {Result = (count = 0)};
];
-
+
//
// Accessing:
//
-
+
- item i:INTEGER :V <-
// Item at the corresponding index `i'.
//
@@ -135,7 +135,7 @@ Section Public
(
item lower
)
- [
+ [
"Definition." +? {Result = item lower};
];
@@ -143,7 +143,7 @@ Section Public
// The `last' item.
//
// See also `first', `item'.
- [
+ [
-? {! is_empty};
]
(
@@ -152,7 +152,7 @@ Section Public
[
"Definition." +? {Result = item upper};
];
-
+
//
// Iterate:
//
diff --git a/lib/standard/string/character.li b/lib/standard/string/character.li
index 2a9d8e3..1517504 100644
--- a/lib/standard/string/character.li
+++ b/lib/standard/string/character.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded CHARACTER;
- export := INTEGER_8, CHAR_UNICODE;
@@ -30,25 +30,25 @@ Section Header
- type := `char`;
- default := '\0';
-
+
Section Insert
-
+
- parent_character_ref:CHARACTER_REF := CHARACTER_REF;
-
+
Section Public
-
+
- in_range lower:SELF to upper:SELF :BOOLEAN <- ((Self >= lower) && {Self<= upper});
-
+
//
// General :
//
-
+
- object_size:INTEGER := 1;
-
+
- maximum:INTEGER := 255;
-
+
- minimum:INTEGER := 0;
-
+
- to_integer:INTEGER <-
// Sign-extended conversion.
( + result:INTEGER;
@@ -56,7 +56,7 @@ Section Public
? {result.in_range (INTEGER_8.minimum) to (INTEGER_8.maximum)};
result
);
-
+
- code:INTEGER_8 <-
// ASCII code of Current.
// No Sign-extended conversion.
@@ -65,22 +65,22 @@ Section Public
//? {result.in_range minimum to maximum};
result
);
-
+
- to_integer_8:INTEGER_8 <- CONVERT(CHARACTER,INTEGER_8).on Self;
// Auto-cast.
-
+
- to_uinteger_8:UINTEGER_8 <- CONVERT(CHARACTER,UINTEGER_8).on Self;
-
+
//
// Print.
//
-
+
- print <- IO.put_character Self;
-
+
//
// Switch case :
//
-
+
- when value:CHARACTER then block:{} :CHARACTER <-
(
(Self=value).if block;
@@ -92,7 +92,7 @@ Section Public
((Self = value1) || {Self = value2}).if block;
Self
);
-
+
- when first_value:CHARACTER to last_value:CHARACTER then block:{} :CHARACTER <-
( ? {first_value<=last_value};
@@ -103,7 +103,7 @@ Section Public
//
// Looping.
//
-
+
- to limit_up:SELF do blc:{CHARACTER;} <-
(
(Self<=limit_up).if {
@@ -111,7 +111,7 @@ Section Public
(Self+1.to_character).to limit_up do blc;
};
);
-
+
- downto limit_down:SELF do blc:{CHARACTER;} <-
(
(Self>=limit_down).if {
@@ -119,7 +119,7 @@ Section Public
(Self-1.to_character).downto limit_down do blc;
};
);
-
+
- to limit_up:SELF by step:SELF do blc:{CHARACTER;} <-
(
(Self<=limit_up).if {
@@ -127,7 +127,7 @@ Section Public
(Self+step.to_character).to limit_up by step do blc;
};
);
-
+
- downto limit_down:SELF by step:SELF do blc:{CHARACTER;} <-
(
(Self>=limit_down).if {
@@ -135,33 +135,33 @@ Section Public
(Self-step.to_character).downto limit_down by step do blc;
};
);
-
+
//
// Binary operator :
//
-
+
- Self:SELF '+' other:CHARACTER :CHARACTER <- (code+other.code).to_character;
-
+
- Self:SELF '-' other:CHARACTER :CHARACTER <- (code-other.code).to_character;
- Self:SELF '-!' other:CHARACTER :INTEGER <- code - other.code;
-
+
- Self:SELF '+#' other:INTEGER :CHARACTER <- (code + other).to_character;
- Self:SELF '-#' other:INTEGER :CHARACTER <- (code - other).to_character;
-
+
- Self:SELF '<' other:SELF :BOOLEAN <- ( code < other.code );
// Comparison using `code'.
-
+
- Self:SELF '<=' other:SELF :BOOLEAN <- ( code <= other.code );
// Comparison using `code'.
-
+
- Self:SELF '>' other:SELF :BOOLEAN <- ( code > other.code );
// Comparison using `code'.
-
+
- Self:SELF '>=' other:SELF :BOOLEAN <- ( code >= other.code );
// Comparison using `code'.
-
+
- decimal_value:INTEGER <-
// Gives the value of a decimal digit.
( + result:INTEGER;
@@ -170,7 +170,7 @@ Section Public
? {result.in_range 0 to 9};
result
);
-
+
- binary_value:INTEGER <-
// Gives the value of a binary digit.
( + result:INTEGER;
@@ -179,7 +179,7 @@ Section Public
? {result.in_range 0 to 1};
result
);
-
+
- octal_value:INTEGER <-
// Gives the value of an octal digit.
( + result:INTEGER;
@@ -188,7 +188,7 @@ Section Public
? {result.in_range 0 to 7};
result
);
-
+
- hexadecimal_value:INTEGER <-
// Gives the value of an hexadecimal digit.
( + result:INTEGER;
@@ -203,7 +203,7 @@ Section Public
? {result.in_range 0 to 15};
result
);
-
+
- same_as other:CHARACTER :BOOLEAN <-
// Case insensitive comparison.
// No difference between upper/lower case letters.
@@ -222,7 +222,7 @@ Section Public
};
result
);
-
+
- to_upper:SELF <-
// Conversion to the corresponding upper case.
( + result:SELF;
@@ -233,7 +233,7 @@ Section Public
};
result
);
-
+
- to_lower:SELF <-
// Conversion to the corresponding lower case.
( + result:SELF;
@@ -244,7 +244,7 @@ Section Public
};
result
);
-
+
- is_letter:BOOLEAN <-
// Is it a letter ('a' .. 'z' or 'A' .. 'Z') ?
( + result:BOOLEAN;
@@ -256,7 +256,7 @@ Section Public
? {result = (in_range 'A' to 'Z' | in_range 'a' to 'z')};
result
);
-
+
- is_digit:BOOLEAN <-
// Belongs to '0'..'9'.
( + result:BOOLEAN;
@@ -266,7 +266,7 @@ Section Public
? {result = in_range '0' to '9'};
result
);
-
+
- is_binary_digit:BOOLEAN <-
// Belongs to '0'..'1'.
( + result:BOOLEAN;
@@ -274,7 +274,7 @@ Section Public
? {result = in_range '0' to '1'};
result
);
-
+
- is_octal_digit:BOOLEAN <-
// Belongs to '0'..'7'.
( + result:BOOLEAN;
@@ -284,7 +284,7 @@ Section Public
? {result = in_range '0' to '7'};
result
);
-
+
- is_hexadecimal_digit:BOOLEAN <-
// Is it one character of "0123456789abcdefABCDEF" ?
( + result:BOOLEAN;
@@ -298,7 +298,7 @@ Section Public
? {result = ("0123456789abcdefABCDEF".has Self)};
result
);
-
+
- is_lower:BOOLEAN <-
// Is it some lowercase letter ('a'..'z')?
( + result:BOOLEAN;
@@ -307,7 +307,7 @@ Section Public
};
result
);
-
+
- is_upper:BOOLEAN <-
// Is it some uppercase letter ('A'..'Z')?
( + result:BOOLEAN;
@@ -316,14 +316,14 @@ Section Public
};
result
);
-
+
- is_separator:BOOLEAN <-
// True when character is a separator (' ', '\t', '\n', '\r', '\0', '\f', '\v')?
(
(Self= ' ') || {Self = '\t'} || {Self='\n'} ||
{Self='\r'} || {Self = '\0'} || {Self='\f'} || {Self='\v'}
);
-
+
- is_letter_or_digit:BOOLEAN <-
// Is it a letter (see `is_letter') or a digit (see `is_digit') ?
( + result:BOOLEAN;
@@ -331,35 +331,35 @@ Section Public
? {result = (is_letter | is_digit)};
result
);
-
+
- is_identifier:BOOLEAN <-
// Is it a letter or a digit or '_' ?
(
(is_letter_or_digit) || {Self = '_'}
);
-
+
- is_ascii:BOOLEAN := TRUE;
// Is character a 8-bit ASCII character?
-
+
- is_bit:BOOLEAN <- ((Self='0') || {Self='1'});
// True for `0' and `1'.
-
+
- next:CHARACTER <-
// Give the next character (the following `code');
( ? {code<255};
(code + 1).to_character
);
-
+
- previous:CHARACTER <-
// Give the previous character (the `code' before);
( ? {code > 0};
(code - 1).to_character
);
-
+
//
// Conversions:
//
-
+
- to_string:STRING <-
// Create a new STRING containing only this character.
(
@@ -385,13 +385,13 @@ Section Public
? {result.count = 2};
result
);
-
+
- to_hexadecimal_in str:STRING <-
// Append the equivalent of `to_hexadecimal' at the end of
// `str'. Thus you can save memory because no other
// STRING is allocate for the job.
( + c, old_count:INTEGER;
-
+
old_count:=str.count;
c := code >> 4;
(c<10).if {
@@ -407,11 +407,11 @@ Section Public
};
? {str.count = (2 + old_count)};
);
-
+
//
// Miscellaneous:
//
-
+
- is_alpha:BOOLEAN <-
// See `is_letter' (yes this is just a call to `is_letter').
// Isn't `is_letter' better English ;-)
@@ -420,12 +420,12 @@ Section Public
? {result = is_letter};
result
);
-
+
//
// Hashing :
//
-
+
- hash_code: INTEGER <- code;
-
-
+
+
diff --git a/lib/standard/string/string.li b/lib/standard/string/string.li
index f3e7187..2f76595 100644
--- a/lib/standard/string/string.li
+++ b/lib/standard/string/string.li
@@ -76,7 +76,7 @@ Section Public
// characters of storage.
( ? {needed_capacity >= 0};
(needed_capacity > 0).if {
- (capacity < needed_capacity).if {
+ (capacity < needed_capacity).if {
storage := NATIVE_ARRAY(CHARACTER).create needed_capacity;
capacity := needed_capacity;
};
diff --git a/lib/standard/string/string_constant.li b/lib/standard/string/string_constant.li
index 2817305..06bab2a 100644
--- a/lib/standard/string/string_constant.li
+++ b/lib/standard/string/string_constant.li
@@ -19,64 +19,64 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
- + name := Strict STRING_CONSTANT;
+
+ + name := Strict STRING_CONSTANT;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "String built in.";
-
+
Section Inherit
-
+
- inherit_abstract_string:ABSTRACT_STRING := ABSTRACT_STRING;
-
+
Section Public
-
- + storage:NATIVE_ARRAY(CHARACTER);
-
+
+ + storage:NATIVE_ARRAY(CHARACTER);
+
+ count:INTEGER;
-
+
Section Public
-
+
- to_string:STRING <-
( + new:Strict STRING;
new := STRING.create capacity;
new.copy Self;
new
);
-
+
Section Public
- capacity:INTEGER <- count;
-
+
//
// Aliasing String.
//
-
+
- bucket:SET(STRING_CONSTANT) := SET(STRING_CONSTANT).make;
-
+
//
// The Guru section: The Compiler consideration.
//
-
+
- set_storage p:NATIVE_ARRAY(CHARACTER) count nb_char:INTEGER <-
// Do not use directly.
(
storage := p;
count := nb_char;
);
-
+
- new_intern p:NATIVE_ARRAY(CHARACTER) count nb_char:INTEGER :STRING_CONSTANT<-
- // Do not use directly. WARNING: Use by c_string and c_argument (COMMAND_LINE).
+ // Do not use directly. WARNING: Use by c_string and c_argument (COMMAND_LINE).
( + result:STRING_CONSTANT;
-
+
result := clone;
- result.set_storage p count nb_char;
+ result.set_storage p count nb_char;
//bucket.add result;
result
);
-
+
- 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
@@ -88,15 +88,15 @@ Section Public
- create_copy other:ABSTRACT_STRING :SELF <-
( + result:SELF;
-
+
result := clone;
result.make_copy other;
result
);
-
+
- make_copy other:ABSTRACT_STRING <-
( + c:INTEGER;
-
+
c := other.count;
(c != 0).if {
storage := NATIVE_ARRAY(CHARACTER).create (c+1);
@@ -109,11 +109,11 @@ Section Public
//
// Debug: Require / Ensure / Check
//
-
+
- Self:SELF '?' test:{BOOLEAN} <- test ? Self;
-
+
- Self:SELF '-?' test:{BOOLEAN} <- test -? Self;
-
+
- Self:SELF '+?' test:{BOOLEAN} <- test +? Self;
-
+
diff --git a/lib/standard/time/time.li b/lib/standard/time/time.li
index c5a1a01..3b4f127 100644
--- a/lib/standard/time/time.li
+++ b/lib/standard/time/time.li
@@ -19,23 +19,23 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded TIME;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+
- comment := "Time";
-
+
- type := `unsigned long`;
-
+
- default := `0`:TIME;
-
+
Section Insert
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Private
-
+
- to_raw:UINTEGER_32 <-
(
CONVERT(SELF, UINTEGER_32).on Self
@@ -47,12 +47,12 @@ Section Public
(
(to_raw >> 24).to_uinteger_8
);
-
+
- minute:UINTEGER_8 <-
(
((to_raw & 0FF0000h) >> 16).to_uinteger_8
);
-
+
- second:UINTEGER_8 <-
(
((to_raw & 0FF00h) >> 8).to_uinteger_8
@@ -62,73 +62,73 @@ Section Public
(
(to_raw & 0FFh).to_uinteger_8
);
-
+
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;
-
- - to_csecond:INTEGER <- hour.to_integer * (60*60*100) +
- minute.to_integer * (60*100) +
- second.to_integer * 100 +
+
+ - to_csecond:INTEGER <- hour.to_integer * (60*60*100) +
+ minute.to_integer * (60*100) +
+ second.to_integer * 100 +
csecond;
-
- - Self:SELF '-' Right 60 other:SELF :SELF <-
- (
+
+ - Self:SELF '-' Right 60 other:SELF :SELF <-
+ (
create_csecond (Self -# other)
);
-
+
// BSBS: A uniformiser -# +# ???
-
+
- Self:SELF '-#' Right 60 other:SELF :INTEGER <- to_csecond - other.to_csecond;
-
+
- Self:SELF '+#' Right 60 other:INTEGER :TIME <-
- (
+ (
create_csecond (to_csecond + other)
);
-
+
- create (h,m,s,cs:INTEGER) :TIME <-
( + t:UINTEGER_32;
? {h.in_range 0 to 23};
? {m.in_range 0 to 59};
? {s.in_range 0 to 59};
? {cs.in_range 0 to 99};
-
+
t := h.to_uinteger_32 <<24;
t := t | (m.to_uinteger_32 << 16);
t := t | (s.to_uinteger_32 << 8);
t := t | cs;
CONVERT(UINTEGER_32, SELF).on t
);
-
+
- create_csecond csec:INTEGER :SELF <-
( + h,m,s,cs,diff:INTEGER;
-
+
diff := csec;
h := diff / (60*60*100);
diff := diff % (60*60*100);
-
+
m := diff / (60*100);
diff := diff % (60*100);
-
+
s := diff / 100;
- cs := diff % 100;
-
+ cs := diff % 100;
+
create (h,m,s,cs)
);
-
+
- to_string:STRING <-
( + result:STRING;
result := STRING.create 8;
append_in result;
result
);
-
+
- append_in str:STRING <-
(
hour.append_in str format 2 with '0';
@@ -146,12 +146,12 @@ Section Public
str.add_last ':';
minute.append_in str format 2 with '0';
);
-
+
- update <-
(
- // JBJB A FAIRE !!
+ // JBJB A FAIRE !!
);
-
+
- print <-
(
to_string.print;
diff --git a/shorter/belinda.li b/shorter/belinda.li
index 052d54e..81c947d 100644
--- a/shorter/belinda.li
+++ b/shorter/belinda.li
@@ -11,100 +11,100 @@
\</head>\n\
\<body BGCOLOR=\"#FFFFFF\">\n\
\\n";
-
- - end :=
+
+ - end :=
"\n</body>\n\
\</html>\n";
-
+
//
// Syntax.
//
-
- - keyword :=
+
+ - keyword :=
"<strong><font color=\"#A020F0\">" + token + "</font></strong>";
- - keyword_section :=
+ - keyword_section :=
"<dd><strong><font color=\"#A020F0\">" + token + "</font></strong></dd>";
-
+
- operator :=
"<font color=\"#B8860B\">" + token + "</font>";
-
+
- keyprototype :=
" <font color=\"#008000\">"+token+"</font>";
- prototype :=
" <a href=\"" + token + ".html\">\
\<font color=\"#008000\">"+token+"</font></a>";
-
+
- comment_line :=
"<br><font FACE=\"Helvetica\" color=\"#000000\"><B>" + token + "</B></font>";
- comment_slot_line :=
"<dd>" + token + "</dd>";
-
+
- comment_new_line_extern := "<br>";
- comment_new_line_slot := "<br>";
-
- - slot :=
+
+ - slot :=
" <strong><font color=\"#0000FF\">" + token + "</font></strong> ";
-
+
- slot_style :=
"<dd><strong><font color=\"#FF0000\">" + token + " </font></strong>";
-
- - local := " "+token+" ";
- - block :=
- "<font color=\"#FF0000\">" + token + "</font>";
+ - local := " "+token+" ";
+
+ - block :=
+ "<font color=\"#FF0000\">" + token + "</font>";
+
+ - warning :=
+ "<font color=\"#FF0000\"><b>" + token + "</b></font><br>";
- - warning :=
- "<font color=\"#FF0000\"><b>" + token + "</b></font><br>";
-
//
// Java doc style.
- //
-
+ //
+
- title := "<td align=\"right\"><em><b>Lisaac<sup><font size=\"-2\">TM</font></sup> Platform</b></em></td><hr><h2>" + token + "</h2><hr>";
-
+
- table_begin := "<table summary=\"\" width=\"100%\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\"><tbody><tr class=\"TableHeadingColor\" bgcolor=\"#ccccff\"><td colspan=\"2\"><font size=\"+2\"><b>" + token + "</b></font></td></tr>";
-
+
- table_item := "<tr class=\"TableRowColor\" bgcolor=\"white\"><td>" + token + "</td></tr>";
-
+
- table_slot_name := "<code><dt><b><a href=\"#"+token+"\">" + token + "</a></b></code>";
- table_slot_comment := "<dd>" + token;
-
+
- table_end := "</tbody></table> ";
-
- - sub_title := "</dl></p><table summary=\"\" width=\"100%\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\"><tbody><tr class=\"TableHeadingColor\" bgcolor=\"#ccccff\"><td colspan=\"1\"><font size=\"+2\"><b>" + token + "</b></font></td></tr></tbody></table>";
-
+
+ - sub_title := "</dl></p><table summary=\"\" width=\"100%\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\"><tbody><tr class=\"TableHeadingColor\" bgcolor=\"#ccccff\"><td colspan=\"1\"><font size=\"+2\"><b>" + token + "</b></font></td></tr></tbody></table>";
+
- slot_title := "</dl><a name=\"" + token + "\"><!-- --></a><hr><h3>" + token + "</h3><dl>";
-
+
- subsub_title := "<dt><b><br>" + token + "</b></dt>";
-
+
- prototype_path := "<dd><code>" + token + "</code></dd>";
- identifier := "<em><b><font color=\"#000000\">" + token + "</font></em></b>";
-
+
- identifier_slot := "<code><b><a href=\"#"+token+"\">" + token + "</a></b></code>";
-
+
- parameter := "<dd>" + token + "</dd>";
- require := "<dd>" + token + "</dd>";
- ensure := "<dd>" + token + "</dd>";
- see := "<dd>" + token + "</dd>";
-
+
- description_en_francais := "<dd><em><strong><font color=\"#707070\">" + token + "</font></strong></em></dd>";
- necessite := "<dd><em><strong><font color=\"#707070\">" + token + "</font></strong></em></dd>";
- garantie := "<dd><em><strong><font color=\"#707070\">" + token + "</font></strong></em></dd>";
- - voir := "<dd><em><strong><font color=\"#707070\">" + token + "</font></strong></em></dd>";
-
+ - voir := "<dd><em><strong><font color=\"#707070\">" + token + "</font></strong></em></dd>";
+
- prototype_comment_light := "<strong>" + token + "</strong><hr>";
- prototype_comment := "<em>" + token + "</em>";
-
-
+
+
//
// Recursive Option.
//
-
+
- index :=
"<html><head><title>Lisaac Documentation</title></head>\n\
\<frameset cols=\"300,*\" border=\"3\" frameborder=\"yes\" \
@@ -121,9 +121,9 @@
\<h3>Frame Error</h3>\n\
\<p>This web site works only with frames.</p>\n\
\</noframes>\n\
- \</html>\n";
-
- - default :=
+ \</html>\n";
+
+ - default :=
"<html><head><title>Proto</title></head>\n\
\<body bgcolor=\"#FFFFFF\">\n\
\<H1>Lisaac documentation</H1>\n\
@@ -135,24 +135,24 @@
"<html><head><title>List Directories</title></head>\n\
\<body bgcolor=\"#FFFFFF\">\n\
\<a href=\"file_list.html\" target=\"file\">All</a>\n";
-
+
- directory_list_item :=
"<br><a href=\""+token+".html\" target=\"file\">"+token+"</a>\n";
-
- - directory_list_end :=
+
+ - directory_list_end :=
"</body>\n\
\</html>";
- file_list_begin :=
"<html><head><title>All Files</title></head>\n\
\<body bgcolor=\"#F0F0FF\" link=\"black\" vlink=\"black\">\n";
-
+
- file_list_item :=
"<br><a href=\""+token+".html\" target=\"content\">"+token+"</a>\n";
-
+
- file_list_end :=
"</body>\n\
\</html>";
-
+
diff --git a/shorter/html.li b/shorter/html.li
index 2d54772..c430a29 100644
--- a/shorter/html.li
+++ b/shorter/html.li
@@ -11,36 +11,36 @@
\</head>\n\
\<body BGCOLOR=\"#FFFFFF\">\n\
\\n";
-
- - end :=
+
+ - end :=
"\n</body>\n\
\</html>\n";
-
- - keyword :=
+
+ - keyword :=
"<strong><font color=\"#A020F0\">" + token + "</font></strong>";
- - keyword_section :=
+ - keyword_section :=
"<br><br><strong><font color=\"#A020F0\">" + token + "</font></strong>";
-
- - integer :=
+
+ - integer :=
"<font color=\"#A020F0\">" + token + "</font>";
-
- - character :=
+
+ - character :=
"<font color=\"#5F9EA0\">" + token + "</font>";
-
+
- string :=
"<font color=\"#BC8F8F\">" + token + "</font>";
-
+
- operator :=
"<font color=\"#B8860B\">" + token + "</font>";
-
+
- keyprototype :=
"<font color=\"#008000\">"+token+"</font>";
- prototype :=
"<a href=\"" + token + ".html\">\
\<font color=\"#008000\">"+token+"</font></a>";
-
+
- comment_header_line := " ";
- comment_line :=
@@ -48,29 +48,29 @@
- comment_slot_line :=
"<br><em><strong><font color=\"#707070\">        " + token + "</font></strong></em>";
-
- - comment :=
+
+ - comment :=
" ";
-
- - slot :=
+
+ - slot :=
"<strong><font color=\"#0000FF\">" + token + "</font></strong>";
- - slot_call :=
+ - slot_call :=
"<font color=\"#0000FF\">" + token + "</font>";
-
+
- slot_style :=
"<br><br><strong><font color=\"#FF0000\">    " + token + "</font></strong>";
-
- - block :=
- "<font color=\"#FF0000\">" + token + "</font>";
-
- - external :=
+
+ - block :=
+ "<font color=\"#FF0000\">" + token + "</font>";
+
+ - external :=
"<em><strong><font color=\"#A4DEA4\">" + token + "</font></strong></em>";
-
+
//
// Recursive Option.
//
-
+
- index :=
"<html><head><title>Lisaac Documentation</title></head>\n\
\<frameset cols=\"260,*\" border=\"3\" frameborder=\"yes\" \
@@ -87,9 +87,9 @@
\<h3>Frame Error</h3>\n\
\<p>This web site works only with frames.</p>\n\
\</noframes>\n\
- \</html>\n";
-
- - default :=
+ \</html>\n";
+
+ - default :=
"<html><head><title>Proto</title></head>\n\
\<body bgcolor=\"#FFFFFF\">\n\
\<H1>Lisaac documentation</H1>\n\
@@ -101,24 +101,24 @@
"<html><head><title>List Directories</title></head>\n\
\<body bgcolor=\"#FFFFFF\">\n\
\<a href=\"file_list.html\" target=\"file\">All</a>\n";
-
+
- directory_list_item :=
"<br><a href=\""+token+".html\" target=\"file\">"+token+"</a>\n";
-
- - directory_list_end :=
+
+ - directory_list_end :=
"</body>\n\
\</html>";
- file_list_begin :=
"<html><head><title>All Files</title></head>\n\
\<body bgcolor=\"#F0F0FF\" link=\"black\" vlink=\"black\">\n";
-
+
- file_list_item :=
"<br><a href=\""+token+".html\" target=\"content\">"+token+"</a>\n";
-
+
- file_list_end :=
"</body>\n\
\</html>";
-
+
diff --git a/shorter/html_raw.li b/shorter/html_raw.li
index bbeb4f5..ccc212d 100644
--- a/shorter/html_raw.li
+++ b/shorter/html_raw.li
@@ -11,36 +11,36 @@
\</head>\n\
\<body BGCOLOR=\"#FFFFFF\">\n\
\<pre>\n";
-
- - end :=
+
+ - end :=
"\n</body>\n\
\</html>\n";
-
- - keyword :=
+
+ - keyword :=
"<strong><font color=\"#A020F0\">" + token + "</font></strong>";
- - keyword_section :=
+ - keyword_section :=
"<strong><font color=\"#A020F0\">" + token + "</font></strong>";
-
- - integer :=
+
+ - integer :=
"<font color=\"#A020F0\">" + token + "</font>";
-
- - character :=
+
+ - character :=
"<font color=\"#5F9EA0\">" + token + "</font>";
-
+
- string :=
"<font color=\"#BC8F8F\">" + token + "</font>";
-
+
- operator :=
"<font color=\"#B8860B\">" + token + "</font>";
-
+
- keyprototype :=
"<font color=\"#008000\">"+token+"</font>";
- prototype :=
"<a href=\"" + token + ".html\">\
\<font color=\"#008000\">"+token+"</font></a>";
-
+
- comment_header_line :=
"<em><font color=\"#FF0000\">//" + token + "</font></em>";
@@ -49,38 +49,38 @@
- comment_slot_line :=
"<em><font color=\"#FF0000\">//" + token + "</font></em>";
-
- - french :=
+
+ - french :=
"<em><font color=\"#FF0FF0\">//" + token + "</font></em>";
- - english :=
+ - english :=
"<em><font color=\"#8080FF\">//" + token + "</font></em>";
-
- - greek :=
+
+ - greek :=
"<em><font color=\"#808000\">//" + token + "</font></em>";
- - comment :=
+ - comment :=
"<em><font color=\"#5F9EA0\">" + token + "</font></em>";
-
- - slot :=
+
+ - slot :=
"<strong><font color=\"#0000FF\">" + token + "</font></strong>";
- - slot_call :=
+ - slot_call :=
"<font color=\"#0000FF\">" + token + "</font>";
-
+
- slot_style :=
"<strong><font color=\"#FF0000\">" + token + "</font></strong>";
-
- - block :=
- "<font color=\"#FF0000\">" + token + "</font>";
-
- - external :=
+
+ - block :=
+ "<font color=\"#FF0000\">" + token + "</font>";
+
+ - external :=
"<em><strong><font color=\"#A4DEA4\">" + token + "</font></strong></em>";
-
+
//
// Recursive Option.
//
-
+
- index :=
"<html><head><title>Lisaac Documentation</title></head>\n\
\<frameset cols=\"260,*\" border=\"3\" frameborder=\"yes\" \
@@ -97,9 +97,9 @@
\<h3>Frame Error</h3>\n\
\<p>This web site works only with frames.</p>\n\
\</noframes>\n\
- \</html>\n";
-
- - default :=
+ \</html>\n";
+
+ - default :=
"<html><head><title>Proto</title></head>\n\
\<body bgcolor=\"red\">\n\
\Content proto documentation.\n\
@@ -110,24 +110,24 @@
"<html><head><title>List Directories</title></head>\n\
\<body bgcolor=\"#FFFFFF\">\n\
\<a href=\"file_list.html\" target=\"file\">All</a>\n";
-
+
- directory_list_item :=
"<br><a href=\""+token+".html\" target=\"file\">"+token+"</a>\n";
-
- - directory_list_end :=
+
+ - directory_list_end :=
"</body>\n\
\</html>";
- file_list_begin :=
"<html><head><title>All Files</title></head>\n\
\<body bgcolor=\"#F0F0FF\" link=\"black\" vlink=\"black\">\n";
-
+
- file_list_item :=
"<br><a href=\""+token+".html\" target=\"content\">"+token+"</a>\n";
-
+
- file_list_end :=
"</body>\n\
\</html>";
-
+
diff --git a/shorter/latex.li b/shorter/latex.li
index 77f2dd4..b0c0291 100644
--- a/shorter/latex.li
+++ b/shorter/latex.li
@@ -1,34 +1,34 @@
- begin :=
"\\begin{verbatim}\n";
-
- - end :=
+
+ - end :=
"\\end{verbatim}\n";
-
- - keyword :=
+
+ - keyword :=
"{\\bf{}" + last_string + "}";
-
+
- integer := last_string;
-
- - character :=
+
+ - character :=
"{\\it{}" + last_string + "}";
-
+
- string :=
"{\\it{}" + last_string + "}";
-
+
- operator := last_string;
-
+
- prototype :=
"<a href=\""+last_string+".html\">\
\<font color=\"#008000\">"+last_string+"</font></a>";
-
+
- comment_line :=
"{\\it{}" + last_string + "}";
-
+
- comment := "";
-
- - slot :=
+
+ - slot :=
"{\\bf{}" + last_string + "}";
-
+
- slot_style := last_string;
-
+
- block := "\\" + last_string;
\ No newline at end of file
diff --git a/src/aliaser_local.li b/src/aliaser_local.li
index 2004801..c013bc0 100644
--- a/src/aliaser_local.li
+++ b/src/aliaser_local.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ALIASER_LOCAL;
- copyright := "2003-2009 Sonntag Benoit";
@@ -30,27 +30,27 @@ Section Header
Section Inherit
- parent_any:ANY := ANY;
-
+
Section ALIASER_LOCAL,LIST
-
+
- free_context:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create_with_capacity 64;
-
+
- top_context:INTEGER;
-
+
- var_size:FAST_ARRAY(FAST_ARRAY(LOCAL)) :=
( + result:FAST_ARRAY(FAST_ARRAY(LOCAL));
-
+
result := FAST_ARRAY(FAST_ARRAY(LOCAL)).create_with_capacity 4;
0.to 3 do { j:INTEGER;
result.add_last (FAST_ARRAY(LOCAL).create_with_capacity 32);
};
result
);
-
+
Section Public
-
- - is_on:BOOLEAN := TRUE;
-
+
+ - is_on:BOOLEAN := TRUE;
+
- reset <-
(
(var_size.lower).to (var_size.upper) do { i:INTEGER;
@@ -60,13 +60,13 @@ Section Public
top_context := -1;
current_list_level := 0;
);
-
+
- write wr:WRITE_LOCAL :STRING_CONSTANT <-
( + loc,loc2:LOCAL;
+ result:STRING_CONSTANT;
-
+
loc := wr.local;
- ((is_on) && {loc.style = '+'}).if {
+ ((is_on) && {loc.style = '+'}).if {
loc2 := loc.my_alias;
(loc2 = NULL).if {
loc2 := search_alias loc;
@@ -81,7 +81,7 @@ Section Public
*/
loc2.set_ensure_count (loc.ensure_count);
};
- loc2.set_list_level current_list_level;
+ loc2.set_list_level current_list_level;
loc.set_my_alias loc2;
};
result := loc2.intern_name;
@@ -97,13 +97,13 @@ Section Public
- read rd:READ_LOCAL :STRING_CONSTANT <-
( + loc,loc2:LOCAL;
+ result:STRING_CONSTANT;
-
+
loc := rd.local;
loc2 := loc.my_alias;
- loc.unread rd;
+ loc.unread rd;
((loc2 = NULL) || {! is_on}).if {
result := loc.intern_name;
- } else {
+ } else {
/*
"----> READ ".print;
loc.intern_name.print; "->".print;
@@ -111,51 +111,51 @@ Section Public
loc.ensure_count.print;
'\n'.print;
*/
- loc2.set_ensure_count (loc.ensure_count);
+ loc2.set_ensure_count (loc.ensure_count);
result := loc2.intern_name;
};
result
);
-
+
- push p:PUSH :STRING_CONSTANT <-
- ( + loc,loc2:LOCAL;
+ ( + loc,loc2:LOCAL;
+ result:STRING_CONSTANT;
-
+
loc := p.context;
- (is_on).if {
- (p.is_first).if {
+ (is_on).if {
+ (p.is_first).if {
top_context := top_context + 1;
- (top_context <= free_context.upper).if {
+ (top_context <= free_context.upper).if {
loc2 := free_context.item top_context;
- } else {
+ } else {
free_context.add_last loc;
loc2 := loc;
add_var_size loc;
- };
+ };
loc.set_my_alias loc2;
- loc.set_list_level top_context;
+ loc.set_list_level top_context;
} else {
top_context := loc.list_level;
};
result := loc.my_alias.intern_name;
} else {
- (p.is_first).if {
+ (p.is_first).if {
add_var_size loc;
};
result := loc.intern_name;
};
result
);
-
+
Section ALIASER_LOCAL, READ_LOCAL
-
+
- add_var_size v:LOCAL <-
( + tab:FAST_ARRAY(LOCAL);
+ j:INTEGER;
+ t:TYPE_FULL;
-
+
? {v.style = '+'};
-
+
(v.style != '+').if {
v.intern_name.print; " style [".print; v.style.print; "] ".print;
'\n'.print;
@@ -164,7 +164,7 @@ Section ALIASER_LOCAL, READ_LOCAL
// BSBS: C'est pas top, avec des HASHED_SET ce serait mieux...
t := v.type;
tab := var_size.item (v.type.size);
- j := tab.lower;
+ j := tab.lower;
{(j <= tab.upper) && {tab.item j.type != t}}.while_do {
j := j + 1;
};
@@ -175,39 +175,39 @@ Section ALIASER_LOCAL, READ_LOCAL
j := j + 1;
};
((j > tab.upper) || {tab.item j != v}).if {
- tab.add v to j;
+ tab.add v to j;
};
};
);
-
+
Section Private
-
+
- search_alias v:LOCAL :LOCAL <-
( + tab:FAST_ARRAY(LOCAL);
+ j:INTEGER;
+ t:TYPE_FULL;
+ result:LOCAL;
+ is_void:BOOLEAN;
-
+
(v.name.first = 'R').if {
result := v;
} else {
t := v.type;
is_void := (! t.is_expanded) && {! t.is_strict} && {! t.raw.is_block};
tab := var_size.item (v.type.size);
- j := tab.lower;
+ j := tab.lower;
{
- (j <= tab.upper) &&
+ (j <= tab.upper) &&
{
(
- (tab.item j.type != t) &&
+ (tab.item j.type != t) &&
{
(! is_void) ||
{tab.item j.type.is_expanded} ||
{tab.item j.type.is_strict} ||
{tab.item j.type.raw.is_block}
}
- ) ||
+ ) ||
{tab.item j.ensure_count != 0} ||
{tab.item j.list_level < current_list_level}
}
diff --git a/src/any.li b/src/any.li
index 3eacb1b..cd8ee5f 100644
--- a/src/any.li
+++ b/src/any.li
@@ -56,7 +56,7 @@ Section Public
- loop_invariant:LOOP;
//
-
+
- late_binding_counter:INTEGER;
- null_counter:INTEGER;
diff --git a/src/code_life/call_slot.li b/src/code_life/call_slot.li
index c7aa7f3..6dd4582 100644
--- a/src/code_life/call_slot.li
+++ b/src/code_life/call_slot.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CALL_SLOT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Call slot method.";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
- count_no_recursive:INTEGER;
- count_context_sensitive:INTEGER;
-
+
- reset_count_no_recursive <-
(
count_no_recursive := 0;
@@ -46,59 +46,59 @@ Section Public
(
count_context_sensitive := 0;
);
-
+
+ profil:PROFIL;
-
+
- set_profil p:PROFIL <-
(
profil := p;
);
-
+
- source:LIST <- profil.code;
-
+
- is_interrupt:BOOLEAN <- profil.is_interrupt;
-
+
- is_external:BOOLEAN <- profil.is_external;
-
+
//
// Argument.
//
-
+
+ argument_list:FAST_ARRAY(WRITE);
-
+
+ result_list:Expanded SLIM_ARRAY(RESULT); // BSBS: utiliter de RESULT ? => WRITE_LOCAL
-
+
+ cop_argument:EXPR;
-
+
+ is_cop_return:BOOLEAN;
-
+
- set_args args:FAST_ARRAY(WRITE) <-
(
argument_list := args;
);
-
+
- set_cop_argument arg:EXPR <-
(
cop_argument := arg;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION profil prof:PROFIL with l_arg:FAST_ARRAY(WRITE) cop arg:EXPR :SELF <-
( + result:SELF;
result := clone;
result.make p profil prof with l_arg cop arg;
result
);
-
+
- make p:POSITION profil prof:PROFIL with l_arg:FAST_ARRAY(WRITE) cop arg:EXPR <-
- ( + n:INTEGER;
- position := p;
+ ( + n:INTEGER;
+ position := p;
cop_argument := arg;
// Choice profil.
- profil := prof;
+ profil := prof;
argument_list := l_arg;
profil.link Self;
//
@@ -107,24 +107,24 @@ Section Public
} else {
n := profil.result_list.count;
};
- result_list.make_with_capacity n;
+ result_list.make_with_capacity n;
);
-
+
- my_copy:SELF <-
( + result:SELF;
+ wrt:WRITE;
+ new_arg:FAST_ARRAY(WRITE);
+ res:RESULT;
result := clone;
-
+
new_arg := FAST_ARRAY(WRITE).create_with_capacity (argument_list.count);
(argument_list.lower).to (argument_list.upper) do { j:INTEGER;
(argument_list.item j = NULL).if {
wrt := NULL;
} else {
// No Alias := Alias.
- wrt := argument_list.item j;
- wrt := wrt.variable.write_direct (wrt.position) with NULL value (wrt.value.my_copy);
+ wrt := argument_list.item j;
+ wrt := wrt.variable.write_direct (wrt.position) with NULL value (wrt.value.my_copy);
//wrt := argument_list.item j.my_copy;
};
new_arg.add_last wrt;
@@ -135,7 +135,7 @@ Section Public
};
//
result.result_list.make_with_capacity (result_list.count);
- (result_list.lower).to (result_list.upper) do { j:INTEGER;
+ (result_list.lower).to (result_list.upper) do { j:INTEGER;
(result_list.item j = NULL).if {
res := NULL;
} else {
@@ -154,19 +154,19 @@ Section Public
- remove <-
( + e:WRITE;
-
+
((profil.link_count = 0) && {profil.cop_link_count = 0}).if { // BSBS: Debug...
"CALL_SLOT : ".print;
debug_display;
};
-
+
profil.unlink Self;
(argument_list.lower).to (argument_list.upper) do { j:INTEGER;
e := argument_list.item j;
(e != NULL).if {
e.remove;
};
- };
+ };
(cop_argument != NULL).if {
cop_argument.remove;
};
@@ -174,20 +174,20 @@ Section Public
result_list.item j.remove;
};
);
-
-Section Private
-
- - execute_inline:(BOOLEAN,INSTR) <-
+
+Section Private
+
+ - execute_inline:(BOOLEAN,INSTR) <-
// Simple inlining
( + result:INSTR;
+ is_good:BOOLEAN;
+ new_src:LIST;
+ wrt:WRITE;
- + old_val:EXPR;
+ + old_val:EXPR;
+ loc:LOCAL;
+ prof_block:PROFIL_BLOCK;
-
- (source = list_current).if {
+
+ (source = list_current).if {
POSITION.put_error semantic text "Recursivity without end (call_slot).";
source.position.put_position;
position.put_position;
@@ -196,7 +196,7 @@ Section Private
/*
(profil.name == "to__do__AAJH").if {
"HERE!\n".print;
- (profil.is_inlinable).if {
+ (profil.is_inlinable).if {
"YES!\n".print;
} else {
"NO\n".print;
@@ -207,30 +207,30 @@ Section Private
'\n'.print;
};
*/
- (profil.is_inlinable).if {
+ (profil.is_inlinable).if {
(profil.link_count = 1).if {
- //
+ //
// Inlining simple.
- //
+ //
(list_current.old_seq_or_and = seq_or_and).if {
- argument_to_assignment source index 1 alias FALSE style '+';
- (result_list.lower).to (result_list.upper) do { j:INTEGER;
+ argument_to_assignment source index 1 alias FALSE style '+';
+ (result_list.lower).to (result_list.upper) do { j:INTEGER;
source.add_last (result_list.item j.write);
};
- result := source.execute;
- profil.remove_inline;
+ result := source.execute;
+ profil.remove_inline;
new_execute_pass;
is_good := TRUE;
};
} else {
//
- // Inline by copy:
+ // Inline by copy:
//
- (list_current.old_seq_or_and = seq_or_and).if {
- profil.unlink Self;
-
+ (list_current.old_seq_or_and = seq_or_and).if {
+ profil.unlink Self;
+
prof_block ?= profil;
- (prof_block != NULL).if {
+ (prof_block != NULL).if {
(profil.argument_list.lower).to (profil.argument_list.upper) do { j:INTEGER;
loc := profil.argument_list.item j;
(loc != NULL).if {
@@ -241,17 +241,17 @@ Section Private
LOCAL.alias_on;
};
//LOCAL.alias_on;
-
- new_src := source.my_copy;
+
+ new_src := source.my_copy;
argument_to_assignment new_src index 1 alias TRUE style '+';
(result_list.lower).to (result_list.upper) do { j:INTEGER;
- wrt := result_list.item j.write;
- old_val := wrt.value;
- wrt.set_value (old_val.my_copy);
- old_val.remove;
+ wrt := result_list.item j.write;
+ old_val := wrt.value;
+ wrt.set_value (old_val.my_copy);
+ old_val.remove;
new_src.add_last wrt;
- };
-
+ };
+
(prof_block != NULL).if {
(profil.argument_list.lower).to (profil.argument_list.upper) do { j:INTEGER;
loc := profil.argument_list.item j;
@@ -261,39 +261,39 @@ Section Private
};
} else {
LOCAL.alias_off;
- };
- //LOCAL.alias_off;
-
+ };
+ //LOCAL.alias_off;
+
result := new_src.execute;
is_good := TRUE;
- new_execute_pass;
+ new_execute_pass;
};
};
};
is_good,
result
- );
-
+ );
+
- execute_normal <-
( + wrt:WRITE_LOCAL;
-
+
// Pour l'instant ne change pas le profil
// il faut faire une copie de l'ancien !!
-
+
//profil := profil.update self link FALSE;
-
- (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
- wrt ?= argument_list.item j;
- (wrt != NULL).if {
+
+ (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
+ wrt ?= argument_list.item j;
+ (wrt != NULL).if {
(wrt.execute_argument).if {
new_execute_pass;
- argument_list.put NULL to j;
+ argument_list.put NULL to j;
(wrt.ensure_count = 0).if {
profil.argument_list.put NULL to j;
};
};
};
- };
+ };
/* BSBS: A revoir avec pb `list' l.352 et `profil' pour result
(result_list.lower).to (result_list.upper) do { j:INTEGER;
result_list.item j.execute;
@@ -302,26 +302,26 @@ Section Private
(cop_argument != NULL).if {
cop_argument := cop_argument.execute_link;
(
- (! is_cop_return) &&
- {profil_current != NULL} &&
- {profil_current.cop_link_count != 0} &&
+ (! is_cop_return) &&
+ {profil_current != NULL} &&
+ {profil_current.cop_link_count != 0} &&
{profil_current.link_count = 0} &&
{profil_current.result_list.is_empty}
).if {
// BSBS: Il faut produire reellement 2 versions (une COP et une non COP)
// Ainsi tu pourras generaliser l'optim et l'appliquer que sur la version COP.
- is_cop_return := profil_current.i_am_the_last Self;
+ is_cop_return := profil_current.i_am_the_last Self;
};
- };
+ };
(profil.is_context_sensitive).if {
seq_call_local_and_loop := seq_call_local_and_loop + 1;
};
seq_call_and_loop := seq_call_and_loop + 1;
seq_inline := seq_inline + 1;
-
+
//
// Counter.
- //
+ //
(! profil.is_recursive).if {
count_no_recursive := count_no_recursive + 1;
};
@@ -329,26 +329,26 @@ Section Private
count_context_sensitive := count_context_sensitive + 1;
};
);
-
+
Section Public
-
+
- execute:INSTR <-
- ( + result:INSTR;
- + is_good:BOOLEAN;
+ ( + result:INSTR;
+ + is_good:BOOLEAN;
(is_good,result) := execute_inline;
- (! is_good).if {
+ (! is_good).if {
execute_normal;
(source.is_empty).if {
- // Suppression.
- profil.unlink Self;
+ // Suppression.
+ profil.unlink Self;
new_execute_pass;
} else {
result := Self;
profil.set_life;
};
};
-
+
result
);
@@ -360,7 +360,7 @@ Section Public
( + t:HASHED_SET(TYPE);
buffer.append (profil.name);
buffer.add_last '(';
-
+
type_list.lower.to (type_list.upper) do { j:INTEGER;
t := type_list.item j;
t.lower.to (t.upper - 1) do { k:INTEGER;
@@ -383,7 +383,7 @@ Section Public
argument_list.is_empty.if {
buffer.append "()";
} else {
- buffer.append "(";
+ buffer.append "(";
argument_list.lower.to (argument_list.upper) do { j:INTEGER;
arg := argument_list.item j;
(arg = NULL).if {
@@ -392,8 +392,8 @@ Section Public
arg.value.display buffer;
};
buffer.add_last ',';
- };
- buffer.put ')' to (buffer.upper);
+ };
+ buffer.put ')' to (buffer.upper);
};
);
@@ -416,7 +416,7 @@ Section Public
//
// Generation.
//
-
+
- genere buffer:STRING <-
( + val:WRITE;
+ arg:LOCAL;
@@ -424,40 +424,40 @@ Section Public
+ np:INTEGER;
+ low:INTEGER;
+ back:INTEGER;
-
+
(cop_argument != NULL).if {
(
- (argument_list.count >=1) &&
- {argument_list.first != NULL} &&
+ (argument_list.count >=1) &&
+ {argument_list.first != NULL} &&
{argument_list.first.variable.name = ALIAS_STR.variable_self}
).if {
low := 1;
};
- (argument_list.count-low > 0).if {
+ (argument_list.count-low > 0).if {
back := buffer.count;
buffer.append "pthread_mutex_lock (&(";
- cop_argument.genere buffer;
- buffer.append "->thread.mutex));\n";
- (low).to (argument_list.upper) do { j:INTEGER;
- val := argument_list.item j;
- (val != NULL).if {
+ cop_argument.genere buffer;
+ buffer.append "->thread.mutex));\n";
+ (low).to (argument_list.upper) do { j:INTEGER;
+ val := argument_list.item j;
+ (val != NULL).if {
buffer.append indent;
cop_argument.genere buffer;
buffer.append "->param_";
np.append_in buffer;
buffer.append "=(int)";
- val.genere_value buffer;
- buffer.append ";\n";
+ val.genere_value buffer;
+ buffer.append ";\n";
np := np + 1;
} else {
"arg null\n".print;
};
- };
+ };
buffer.append indent;
(np = 0).if {
buffer.keep_head back;
};
- };
+ };
cop_argument.genere buffer;
buffer.append "->thread.procedure = COP_";
buffer.append (profil.name);
@@ -471,23 +471,23 @@ Section Public
buffer.append "((lith_object *)";
cop_argument.genere buffer;
buffer.add_last ')';
- } else {
+ } else {
(result_list.is_empty).if_false {
wrt ?= result_list.first.write;
(wrt.local.ensure_count != 0).if {
- wrt.genere_first_result buffer;
- };
+ wrt.genere_first_result buffer;
+ };
};
buffer.append (profil.name);
-
+
(is_graph).if {
(profil_current = NULL).if {
- profil_main.add_call profil;
+ profil_main.add_call profil;
} else {
- profil_current.add_call profil;
- };
+ profil_current.add_call profil;
+ };
};
-
+
(is_interrupt || {is_external}).if {
(argument_list.first != NULL).if {
semantic_error (argument_list.first.position,
@@ -495,15 +495,15 @@ Section Public
};
};
(! is_interrupt).if {
- buffer.add_last '(';
- (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
+ buffer.add_last '(';
+ (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
val := argument_list.item j;
arg := profil.argument_list.item j;
- (val != NULL).if {
+ (val != NULL).if {
(buffer.last != '(').if {
buffer.add_last ',';
};
- val.genere_value buffer;
+ val.genere_value buffer;
};
};
(result_list.count > 1).if {
@@ -512,75 +512,75 @@ Section Public
buffer.add_last ',';
};
wrt ?= result_list.item j.write;
- wrt.genere_argument_result buffer;
+ wrt.genere_argument_result buffer;
};
};
buffer.add_last ')';
};
};
);
-
+
//
// Intern routine.
//
-
+
Section PROFIL
-/*
+/*
- to_tail_recursive:LOOP <-
( + switch:SWITCH;
- + msg_slot:CALL_SLOT;
- + body:LIST;
+ + msg_slot:CALL_SLOT;
+ + body:LIST;
+ wrt:WRITE;
+ new_val:EXPR;
+ new_wrt:INSTR;
+ result:LOOP;
+ push:PUSH;
-
+
result := LOOP.create position name (profil.name) body source;
-
+
//
// Main List.
//
-
- // Argument -> Affectation.
+
+ // Argument -> Affectation.
wrt := argument_list.first;
(wrt != NULL).if {
- argument_list.put NULL to 0;
- (! wrt.value.static_type.is_expanded).if {
+ argument_list.put NULL to 0;
+ (! wrt.value.static_type.is_expanded).if {
new_val := CAST.create (wrt.static_type) value (wrt.value);
wrt.set_value new_val;
- };
+ };
wrt.variable.set_style '+';
new_wrt := wrt.execute;
- (new_wrt != NULL).if {
- list_current.insert new_wrt to (list_current.index);
+ (new_wrt != NULL).if {
+ list_current.insert new_wrt to (list_current.index);
};
};
(argument_list.lower + 1).to (argument_list.upper) do { k:INTEGER;
wrt := argument_list.item k;
- (wrt != NULL).if {
- argument_list.put NULL to k;
+ (wrt != NULL).if {
+ argument_list.put NULL to k;
wrt.variable.set_style '+';
new_wrt := wrt.execute;
- (new_wrt != NULL).if {
+ (new_wrt != NULL).if {
list_current.insert new_wrt to (list_current.index);
};
};
};
-
- (debug_level_option != 0).if {
+
+ (debug_level_option != 0).if {
push ?= source.first;
- list_current.insert (push.my_copy) to (list_current.index);
+ list_current.insert (push.my_copy) to (list_current.index);
push.set_first FALSE;
};
-
+
// Extract Switch/body:
switch ?= source.last;
(switch.list.lower).to (switch.list.upper) do { k:INTEGER;
body := switch.list.item k.code;
- (body.is_empty).if_false {
+ (body.is_empty).if_false {
msg_slot ?= body.last;
- ((msg_slot != NULL) && {msg_slot.profil = profil}).if {
+ ((msg_slot != NULL) && {msg_slot.profil = profil}).if {
// DEBUG
(msg_slot = Self).if {
semantic_error (position,"CALL_SLOT : BUG!!!!");
@@ -588,33 +588,33 @@ Section PROFIL
// FIN DEBUG
msg_slot.argument_to_assignment body index (body.upper) alias FALSE;
body.put (LOOP_END.create (msg_slot.position) loop result) to (body.upper);
- };
+ };
};
};
result
);
*/
- - argument_to_assignment lst:LIST
- index idx:INTEGER
- alias is_alias:BOOLEAN
+ - argument_to_assignment lst:LIST
+ index idx:INTEGER
+ alias is_alias:BOOLEAN
style styl:CHARACTER <-
- ( + val,new_wrt:WRITE;
+ ( + val,new_wrt:WRITE;
+ loc:LOCAL;
-
+
// Argument -> Affectation.
(argument_list.upper).downto (argument_list.lower) do { k:INTEGER;
val := argument_list.item k;
- (val != NULL).if {
+ (val != NULL).if {
argument_list.put NULL to k;
(is_alias).if {
- loc ?= val.variable;
- new_wrt := loc.write (val.position) value (val.value);
- loc.unwrite val;
+ loc ?= val.variable;
+ new_wrt := loc.write (val.position) value (val.value);
+ loc.unwrite val;
} else {
- new_wrt := val;
+ new_wrt := val;
};
- lst.insert new_wrt to idx;
+ lst.insert new_wrt to idx;
new_wrt.variable.set_style styl;
};
- };
+ };
);
diff --git a/src/code_life/case.li b/src/code_life/case.li
index c758bfe..2142512 100644
--- a/src/code_life/case.li
+++ b/src/code_life/case.li
@@ -19,45 +19,45 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CASE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Case for Switch.";
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
+ id:TYPE;
-
- + code:LIST;
-
+
+ + code:LIST;
+
- set_code new_code:LIST <-
(
code := new_code;
);
-
+
//
// Creation.
//
-
+
- create val:TYPE with c:LIST :SELF <-
( + result:SELF;
-
+
result := clone;
result.make val with c;
result
);
-
+
- make val:TYPE with c:LIST <-
( + tb:PROFIL_BLOCK;
- id := val;
+ id := val;
code := c;
//
tb ?= val;
@@ -65,14 +65,14 @@ Section Public
tb.inc_id;
};
);
-
+
- my_copy:SELF <-
( + result:SELF;
-
+
result := SELF.create id with (code.my_copy);
- result
+ result
);
-
+
- remove <-
( + tb:PROFIL_BLOCK;
code.remove;
@@ -81,45 +81,44 @@ Section Public
tb.dec_id;
};
);
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' other:CASE :BOOLEAN <-
// BSBS : Naive implantation...
( + result:BOOLEAN;
+ wrt1,wrt2:WRITE_LOCAL;
-
+
((code.count = 1) && {code.count = other.code.count}).if {
wrt1 ?= code.first;
wrt2 ?= other.code.first;
result := (
- (wrt1 != NULL) &&
- {wrt2 != NULL} &&
- {wrt1.variable = wrt2.variable} &&
+ (wrt1 != NULL) &&
+ {wrt2 != NULL} &&
+ {wrt1.variable = wrt2.variable} &&
{wrt1.value ~= wrt2.value}
);
};
result
);
-
+
//
// Execute
//
-
+
- execute <-
- (
+ (
id.set_late_binding;
code.execute_case;
);
-
+
//
// Genere
//
-
+
- genere buffer:STRING <-
- (
+ (
code.genere buffer;
);
-
\ No newline at end of file
diff --git a/src/code_life/cast.li b/src/code_life/cast.li
index 989ffaa..d167f23 100644
--- a/src/code_life/cast.li
+++ b/src/code_life/cast.li
@@ -19,80 +19,80 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CAST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Cast type.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
+
Section Public
-
+
- is_invariant:BOOLEAN <- value.is_invariant;
-
+
+ static_type:TYPE_FULL;
-
+
+ value:EXPR;
-
+
//
// Creation.
//
-
+
- create t:TYPE_FULL value v:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make t value v;
- result
+ result
);
-
+
- make t:TYPE_FULL value v:EXPR <-
(
position := v.position;
static_type := t;
value := v;
);
-
+
- my_copy:SELF <-
(
create static_type value (value.my_copy)
);
-
+
//
// Searching.
//
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add (static_type.raw);
);
-
+
//
// Executing pass.
//
-
+
- remove <-
- (
+ (
value.remove;
);
-
- - execute_unlink:INSTR <-
+
+ - execute_unlink:INSTR <-
(
value.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ int:INTEGER_CST;
+ lst_typ:TYPES_TMP;
+ other:CAST;
-
+
value := value.execute_link;
result := Self;
//
@@ -100,12 +100,12 @@ Section Public
result := value;
new_execute_pass;
}.elseif {
- (ALIAS_STR.is_integer (static_type.raw.name)) &&
+ (ALIAS_STR.is_integer (static_type.raw.name)) &&
{value.is_constant} &&
{ int ?= value; // BSBS: Merde avc les prototype_cst de type type_id : INTEGER
int != NULL
}
- } then {
+ } then {
int.cast_type static_type;
result := value;
new_execute_pass;
@@ -124,27 +124,27 @@ Section Public
new_execute_pass;
};
lst_typ.free;
- };
+ };
//
result
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
- (
+ (
buffer.add_last '(';
buffer.add_last '(';
- static_type.genere_declaration buffer;
+ static_type.genere_declaration buffer;
buffer.add_last ' ';
- static_type.genere_star_declaration buffer;
+ static_type.genere_star_declaration buffer;
buffer.add_last ')';
value.genere buffer;
buffer.add_last ')';
);
-
+
//
// Display.
//
diff --git a/src/code_life/cop_lock.li b/src/code_life/cop_lock.li
index 7d3a921..f2edac3 100644
--- a/src/code_life/cop_lock.li
+++ b/src/code_life/cop_lock.li
@@ -19,63 +19,63 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COP_LOCK;
- copyright := "2003-2007 Benoit Sonntag";
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "COP in for data or function.";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
+ data:EXPR;
-
+
//
// Creation.
//
-
+
- create p:POSITION with dta:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with dta;
result
);
-
+
- make p:POSITION with dta:EXPR <-
(
position := p;
data := dta;
);
-
- - my_copy:SELF <-
- (
+
+ - my_copy:SELF <-
+ (
create position with (data.my_copy)
);
-
+
- remove <-
(
data.remove;
);
-
+
//
// Execute.
//
-
+
- execute:INSTR <-
(
Self
);
-
+
//
// Generation.
//
-
+
- genere buffer:STRING <-
(
buffer.append "// Pre thread.\n";
@@ -83,21 +83,21 @@ Section Public
// buffer.append "print_char('\\n');\n";
buffer.append indent;
buffer.append "{ lith_node node,*n;\n";
- indent.append " ";
+ indent.append " ";
buffer.append indent;
buffer.append "lith_object *obj;\n";
buffer.append indent;
- buffer.append "void *thread_save;\n";
+ buffer.append "void *thread_save;\n";
buffer.append indent;
buffer.append "obj = &((";
data.genere buffer;
- buffer.append ")->thread);\n";
+ buffer.append ")->thread);\n";
buffer.append indent;
buffer.append "node.next = NULL;\n";
buffer.append indent;
buffer.append "pthread_mutex_init(&node.mutex,NULL);\n";
buffer.append indent;
- buffer.append "pthread_mutex_lock(&obj->mutex);\n";
+ buffer.append "pthread_mutex_lock(&obj->mutex);\n";
buffer.append indent;
buffer.append "n = obj->last;\n";
buffer.append indent;
@@ -113,28 +113,28 @@ Section Public
buffer.append indent;
buffer.append "};\n";
buffer.append indent;
- buffer.append "obj->last = &node;\n";
+ buffer.append "obj->last = &node;\n";
buffer.append indent;
buffer.append "pthread_mutex_unlock(&obj->mutex);\n";
//
- buffer.append indent;
+ buffer.append indent;
buffer.append "pthread_mutex_lock (&node.mutex);\n";
- buffer.append indent;
+ buffer.append indent;
buffer.append "thread_save=pthread_getspecific(current_thread);\n";
buffer.append indent;
buffer.append "pthread_setspecific(current_thread,";
data.genere buffer;
- buffer.add_last ')';
+ buffer.add_last ')';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append "COP_LOCK(";
data.display buffer;
buffer.add_last ')';
);
-
+
diff --git a/src/code_life/cop_unlock.li b/src/code_life/cop_unlock.li
index ff69c56..84119f9 100644
--- a/src/code_life/cop_unlock.li
+++ b/src/code_life/cop_unlock.li
@@ -19,63 +19,63 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COP_UNLOCK;
- copyright := "2003-2007 Benoit Sonntag";
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "COP in for data or function.";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
//
// Creation.
//
-
+
- create p:POSITION :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p;
result
);
-
+
- make p:POSITION <-
(
- position := p;
+ position := p;
);
-
- - my_copy:SELF <-
- (
+
+ - my_copy:SELF <-
+ (
create position
);
-
+
- remove <-
(
// Nothing.
);
-
+
//
// Execute.
//
-
+
- execute:INSTR <-
(
Self
);
-
+
//
// Generation.
//
-
+
- genere buffer:STRING <-
(
- buffer.append "pthread_mutex_lock(&(obj->mutex));\n";
+ buffer.append "pthread_mutex_lock(&(obj->mutex));\n";
buffer.append indent;
buffer.append "n = obj->first->next;\n";
buffer.append indent;
@@ -91,20 +91,20 @@ Section Public
buffer.append indent;
buffer.append "obj->first = n;\n";
buffer.append indent;
- buffer.append "pthread_mutex_unlock(&obj->mutex);\n";
+ buffer.append "pthread_mutex_unlock(&obj->mutex);\n";
buffer.append indent;
- buffer.append "pthread_setspecific(current_thread,thread_save);\n";
+ buffer.append "pthread_setspecific(current_thread,thread_save);\n";
indent.remove_last 2;
buffer.append indent;
buffer.add_last '}';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append "COP_UNLOCK()";
);
-
+
diff --git a/src/code_life/expr.li b/src/code_life/expr.li
index 4e99ce2..bc4ff56 100644
--- a/src/code_life/expr.li
+++ b/src/code_life/expr.li
@@ -84,15 +84,15 @@ Section Public
result := Self;
} else {
? {list_current != NULL};
- (static_type.is_export_to t).if {
- // Auto-export.
+ (static_type.is_export_to t).if {
+ // Auto-export.
local := static_type.get_temporary position;
- instr := local.write position value Self;
+ instr := local.write position value Self;
list_current.add_last instr;
//
- slot_name := ALIAS_STR.get (TYPE.last_cast_name);
+ slot_name := ALIAS_STR.get (TYPE.last_cast_name);
slot_msg := static_type.get_slot slot_name;
- (slot_msg = NULL).if {
+ (slot_msg = NULL).if {
string_tmp.clear;
static_type.append_name_in string_tmp;
string_tmp.append " -> ";
@@ -107,14 +107,14 @@ Section Public
static_type.prototype.position.put_position;
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 {
+ ((ts = NULL) || {ts.to_run_for (t.raw) != t}).if {
string_tmp.copy "Type result `";
- slot_msg.result_type.append_in string_tmp;
+ slot_msg.result_type.append_in string_tmp;
string_tmp.append "' is incorrect (Used for auto-conversion to `";
t.append_name_in string_tmp;
string_tmp.append "').";
@@ -123,22 +123,22 @@ Section Public
position.put_position;
POSITION.send_error;
};
- //
+ //
rec := local.read position;
node := NODE.new_read position slot slot_msg
receiver rec self rec intern FALSE;
list_current.add_last node;
- //
+ //
result := node.result_expr;
}.elseif {t.is_import_to static_type} then {
// Auto-import.
local := static_type.get_temporary position;
- instr := local.write position value Self;
+ instr := local.write position value Self;
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 = NULL).if {
string_tmp.clear;
t.append_name_in string_tmp;
string_tmp.append " <- ";
@@ -153,13 +153,13 @@ Section Public
t.prototype.position.put_position;
POSITION.send_error;
//semantic_error p,string_tmp;
- };
+ };
(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 = 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;
@@ -169,19 +169,19 @@ Section Public
position.put_position;
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
receiver (args.first.my_copy) with args intern FALSE;
list_current.add_last node;
- //
- result := node.result_expr;
+ //
+ result := node.result_expr;
} else {
- // Type Error
+ // Type Error
string_tmp.copy "Type `";
- t.append_name_in string_tmp;
+ t.append_name_in string_tmp;
string_tmp.append "' is invalid with `";
static_type.append_name_in string_tmp;
string_tmp.append "'.";
diff --git a/src/code_life/expr_multiple.li b/src/code_life/expr_multiple.li
index 46a556a..dda8d7d 100644
--- a/src/code_life/expr_multiple.li
+++ b/src/code_life/expr_multiple.li
@@ -19,41 +19,41 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_MULTIPLE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Multiple expression manager";
-
- // BSBS: Utiliser ca une seule fois ! cela doit etre possible!
-
+
+ // BSBS: Utiliser ca une seule fois ! cela doit etre possible!
+
Section Inherit
-
+
- parent_expr:EXPR := EXPR;
-
+
Section Public
-
+
+ expr_list:FAST_ARRAY(EXPR);
-
+
- cardinality:INTEGER <- expr_list.count;
-
+
- static_type:TYPE_FULL <-
(
expr_list.first.static_type
);
-
+
- get_type t:TYPES_TMP <-
(
crash_with_message "EXPR_MULTIPLE.get_type";
);
-
+
//
// Creation
//
-
+
// BSBS: Optim : Il faut que ce soit alouer et free après !!!
- create l:FAST_ARRAY(EXPR) :SELF <-
( + result:SELF;
@@ -61,70 +61,70 @@ Section Public
result.make l;
result
);
-
+
- make l:FAST_ARRAY(EXPR) <-
(
expr_list := l;
position := l.last.position;
);
-
+
- my_copy:SELF <-
( + new_lst:FAST_ARRAY(EXPR);
-
+
new_lst := FAST_ARRAY(EXPR).create_with_capacity (expr_list.count);
(expr_list.lower).to (expr_list.upper) do { j:INTEGER;
new_lst.add_last (expr_list.item j.my_copy);
};
SELF.create new_lst
);
-
+
//
// Remove.
//
-
+
- remove <-
(
(expr_list.lower).to (expr_list.upper) do { j:INTEGER;
expr_list.item j.remove;
};
);
-
+
//
// Execute.
//
-
- - execute_unlink:INSTR <-
+
+ - execute_unlink:INSTR <-
(
(expr_list.lower).to (expr_list.upper) do { j:INTEGER;
expr_list.item j.remove;
};
NULL
);
-
+
- execute_link:EXPR <-
(
list_current.debug_display;
crash_with_message "EXPR_MULTIPLE.execute_link";
NULL
);
-
+
//
// Access facility.
//
-
+
- lower:INTEGER <- expr_list.lower;
- upper:INTEGER <- expr_list.upper;
-
+
- item i:INTEGER :EXPR <- expr_list.item i;
- last:EXPR <- expr_list.last;
- first:EXPR <- expr_list.first;
-
- - count:INTEGER <- expr_list.count;
-
+
+ - count:INTEGER <- expr_list.count;
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.add_last '(';
@@ -135,4 +135,3 @@ Section Public
expr_list.last.display buffer;
buffer.add_last ')';
);
-
\ No newline at end of file
diff --git a/src/code_life/instr.li b/src/code_life/instr.li
index 5ba2cd8..9b58bdc 100644
--- a/src/code_life/instr.li
+++ b/src/code_life/instr.li
@@ -19,58 +19,58 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := INSTR;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all Instruction.";
-
+
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
-
+
Section Public
-
+
- is_invariant:BOOLEAN <- FALSE;
-
+
//
//
//
-
+
- hash_code:INTEGER <- INTEGER.force_conversion position;
- - my_copy:SELF <-
- (
+ - my_copy:SELF <-
+ (
debug_display;
- deferred;
- NULL
- );
-
+ deferred;
+ NULL
+ );
+
//
// Executing pass.
//
- cmp other:INSTR :BOOLEAN := FALSE;
-
+
- i_am_the_last i:INSTR :BOOLEAN <- (i = Self);
-
- - execute:INSTR <-
- (
+
+ - execute:INSTR <-
+ (
debug_display;
- deferred;
+ deferred;
NULL
);
-
- - remove <-
+
+ - remove <-
(
- debug_display;
+ debug_display;
deferred;
);
- - genere buffer:STRING <-
+ - genere buffer:STRING <-
(
// BUG.
display buffer;
@@ -92,34 +92,34 @@ Section Public
};
);
- - display buffer:STRING <-
+ - display buffer:STRING <-
(
"INSTR.display\n".print;
- deferred;
+ deferred;
);
- debug_display <-
( + voir:STRING;
-
+
voir := STRING.create 250;
display voir;
voir.print;
'\n'.print;
);
-
+
- simplify_type v:VARIABLE <-
( + tmp_type:TYPES_TMP;
-
+
((! v.is_static) && {! v.type.is_strict}).if {
tmp_type := TYPES_TMP.new;
v.get_type tmp_type;
(tmp_type.count != 0).if {
(tmp_type.first = TYPE_NULL).if {
tmp_type.remove_first;
- (tmp_type.count = 1).if {
- v.set_type (tmp_type.first.default.to_strict);
+ (tmp_type.count = 1).if {
+ v.set_type (tmp_type.first.default.to_strict);
};
- };
+ };
};
tmp_type.free;
};
diff --git a/src/code_life/list.li b/src/code_life/list.li
index e417314..35dc7aa 100644
--- a/src/code_life/list.li
+++ b/src/code_life/list.li
@@ -19,29 +19,29 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Expression list, immediate evaluation";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
-Section Private
-
+
+Section Private
+
+ expr_list:FAST_ARRAY(INSTR);
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
-
+
result := TRUE;
j := expr_list.lower;
{(j <= expr_list.upper) && {result}}.while_do {
@@ -49,125 +49,125 @@ Section Public
j := j + 1;
};
result
- );
-
+ );
+
- old_seq_or_and:UINTEGER_32;
-
+
//
// Linked list INSTR.
//
-
+
- lower:INTEGER <- expr_list.lower + 1;
- upper:INTEGER <- expr_list.upper + 1;
- count:INTEGER <- expr_list.count;
-
- - first:INSTR <- expr_list.first;
+
+ - first:INSTR <- expr_list.first;
- second:INSTR <- expr_list.second;
-
+
- item i:INTEGER :INSTR <- expr_list.item (i-1);
-
+
- current_item:INSTR <- expr_list.item index;
-
+
- last:INSTR <- expr_list.last;
-
+
- add_first i:INSTR <-
(
expr_list.add_first i;
-
+
verify_once;
-
+
);
-
- - add_last i:INSTR <-
+
+ - add_last i:INSTR <-
(
expr_list.add_last i;
-
+
verify_once;
-
- );
-
+
+ );
+
- add e:INSTR to idx:INTEGER <-
(
expr_list.add e to (idx-1);
-
+
verify_once;
-
+
);
-
+
- put e:INSTR to idx:INTEGER <-
(
- expr_list.put e to (idx-1);
- );
+ expr_list.put e to (idx-1);
+ );
- remove_last <-
(
expr_list.remove_last;
);
-
+
- remove_index idx:INTEGER <-
(
((list_current = Self) && {idx != index}).if {
"LIST.remove_index ! ".print; idx.print; '/'.print; index.print; ' '.print; print; '\n'.print;
};
-
+
expr_list.remove (idx-1);
);
-
+
//
// Iterator.
- //
-
+ //
+
+ index:INTEGER;
-
+
- inc_index <-
(
index := index + 1;
);
-
+
- insert_before e:INSTR <-
- (
+ (
? {e != NULL};
expr_list.add e to (index - 1);
index := index + 1;
-
+
verify_once;
-
+
);
- insert e:INSTR to idx:INTEGER <-
- (
+ (
? {e != NULL};
expr_list.add e to (idx - 1);
(idx <= index).if {
index := index + 1;
};
-
+
verify_once;
-
+
);
-
+
//
// Flags.
//
-
+
- is_empty:BOOLEAN <- count = 0;
-
+
//
// Creation.
//
-
+
- create p:POSITION :SELF <-
( + result:SELF;
result := clone;
result.make p;
result
);
-
+
- make p:POSITION <-
(
new_depend_pass;
position := p;
- expr_list := FAST_ARRAY(INSTR).create_with_capacity 2;
+ expr_list := FAST_ARRAY(INSTR).create_with_capacity 2;
);
- my_copy:SELF <-
@@ -177,9 +177,9 @@ Section Public
(lower).to (upper) do { j:INTEGER;
result.add_last (item j.my_copy);
};
-
+
verify_once;
-
+
result
);
@@ -188,86 +188,86 @@ Section Public
//
- remove <-
- (
- (lower).to (upper) do { j:INTEGER;
+ (
+ (lower).to (upper) do { j:INTEGER;
item j.remove;
- };
+ };
);
-
+
//
// Execute.
//
-
- - i_am_the_last i:INSTR :BOOLEAN <-
+
+ - i_am_the_last i:INSTR :BOOLEAN <-
(
last.i_am_the_last i
);
-
+
- execute:INSTR <-
- ( + result:INSTR;
-
- execute_case;
+ ( + result:INSTR;
+
+ execute_case;
(list_current != NULL).if {
- // Fusion list.
+ // Fusion list.
(expr_list.is_empty).if_false {
lower.to (upper-1) do { j:INTEGER;
list_current.insert_before (item j);
- };
- result := last;
- ? {result != NULL};
+ };
+ result := last;
+ ? {result != NULL};
new_execute_pass;
};
- } else {
+ } else {
result := Self;
- };
-
+ };
+
verify_once;
-
- result
- );
-
- - execute_case <-
- ( + new_expr:INSTR;
+
+ result
+ );
+
+ - execute_case <-
+ ( + new_expr:INSTR;
+ old_list_current:LIST;
-
+
+ old_expr:INSTR;
+ old_index:INTEGER;
-
+
//
- seq_list.add_last Self;
+ seq_list.add_last Self;
seq_inline := seq_inline + 1;
-
- // Update Context.
+
+ // Update Context.
old_list_current := list_current;
- list_current := Self;
-
+ list_current := Self;
+
// Execute expression list.
? {index = 0};
-
+
//"LIST BEG : ".print; print; '\n'.print;
-
+
index := lower;
- {index <= upper}.while_do {
- old_seq_or_and := seq_or_and;
-
+ {index <= upper}.while_do {
+ old_seq_or_and := seq_or_and;
+
old_expr := item index;
old_index := index;
-
- new_expr := item index.execute;
- (new_expr != NULL).if {
-
+
+ new_expr := item index.execute;
+ (new_expr != NULL).if {
+
((index = old_index) && {index > 1} && {item (old_index-1) = new_expr}).if {
- `*((unsigned int *)@old_expr)`:INTEGER_32.print;
+ `*((unsigned int *)@old_expr)`:INTEGER_32.print;
'\n'.print;
old_expr.debug_display;
"\nDevient\n".print;
new_expr.debug_display;
semantic_error (new_expr.position,"ICI");
- };
-
- put new_expr to index;
-
+ };
+
+ put new_expr to index;
+
(verify_once).if_false {
old_index.print; '-'.print;
index.print; '\n'.print;
@@ -275,8 +275,8 @@ Section Public
debug_display;
crash;
};
-
- index := index + 1;
+
+ index := index + 1;
(new_expr = CALL_NULL).if {
// Delete all ...
{index <= upper}.while_do {
@@ -286,94 +286,94 @@ Section Public
};
} else {
remove_index index;
- };
+ };
};
-
+
//"LIST END : ".print; print; '\n'.print;
-
- // Last.
- old_seq_or_and := seq_or_and;
+
+ // Last.
+ old_seq_or_and := seq_or_and;
index := 0; // Debug necessity
-
+
// Restore Context.
- list_current := old_list_current;
+ list_current := old_list_current;
//
- seq_list.remove_last;
+ seq_list.remove_last;
seq_inline := seq_inline + 1;
-
+
verify_once;
);
-
+
Section Public
-
+
//
// Generation.
//
-
+
- genere buffer:STRING <-
- (
+ (
buffer.append "{\n";
indent.append " ";
-
+
current_list_level := current_list_level + 1;
-
+
genere_body buffer;
-
+
current_list_level := current_list_level - 1;
-
- indent.remove_last 2;
+
+ indent.remove_last 2;
buffer.append indent;
buffer.add_last '}';
);
-
+
- genere_extern buffer:STRING <-
- ( + pos_local:INTEGER;
-
- // Local.
+ ( + pos_local:INTEGER;
+
+ // Local.
pos_local := buffer.count+1;
stack_local.clear;
-
+
ALIASER_LOCAL.reset;
-
+
genere_body buffer;
-
- // Local.
- string_tmp.clear;
+
+ // Local.
+ string_tmp.clear;
add_local (ALIASER_LOCAL.var_size.item 3) in string_tmp; // 64 bits
add_local (ALIASER_LOCAL.var_size.item 2) in string_tmp; // 32 bits
add_local (ALIASER_LOCAL.var_size.item 1) in string_tmp; // 16 bits
add_local (ALIASER_LOCAL.var_size.item 0) in string_tmp; // 8 bits
- buffer.insert_string string_tmp to pos_local;
+ buffer.insert_string string_tmp to pos_local;
);
-
+
//
// Display.
//
- display buffer:STRING <-
- (
- // Begin List.
+ (
+ // Begin List.
buffer.add_last '(';
-
+
// Code.
buffer.add_last '\n';
indent.append " ";
-
+
(lower).to (upper) do { j:INTEGER;
- buffer.append indent;
+ buffer.append indent;
item j.display buffer;
buffer.add_last '\n';
- };
+ };
indent.remove_last 2;
buffer.append indent;
-
+
// End List.
buffer.add_last ')';
display_ref buffer;
);
-
-Section Private
-
+
+Section Private
+
- verify_once:BOOLEAN <-
( + result:BOOLEAN;
result := TRUE;
@@ -386,9 +386,9 @@ Section Private
};
result
);
-
+
- genere_body buffer:STRING <-
- ( + old_count,j:INTEGER;
+ ( + old_count,j:INTEGER;
j := lower;
{j <= upper}.while_do {
buffer.append indent;
@@ -396,26 +396,26 @@ Section Private
{
item j.genere buffer;
j := j + 1;
- }.do_while {(j <= upper) && {old_count = buffer.count}};
+ }.do_while {(j <= upper) && {old_count = buffer.count}};
buffer.append ";\n";
- };
- );
-
+ };
+ );
+
- add_local tab:FAST_ARRAY(LOCAL) in buf:STRING <-
( + loc:LOCAL;
+ t:TYPE_FULL;
+ cur:INTEGER;
//+ i:INTEGER;
-
+
(! tab.is_empty).if {
(tab.lower).to (tab.upper) do { j:INTEGER;
- loc := tab.item j;
+ loc := tab.item j;
loc.is_result.if_false {
(loc.type.raw = TYPE_CONTEXT).if {
context_counter := context_counter + 1;
} else {
local_counter := local_counter + 1;
- };
+ };
//
simplify_type loc; // BSBS: Pas utile (c est un pb de result non utiliser)
//
@@ -436,12 +436,12 @@ Section Private
buf.append (loc.intern_name);
};
};
- buf.append ";\n";
+ buf.append ";\n";
};
);
-
+
Section LISAAC
- local_counter:INTEGER;
-
+
- context_counter:INTEGER;
\ No newline at end of file
diff --git a/src/code_life/loop.li b/src/code_life/loop.li
index 1072b73..5cc23d9 100644
--- a/src/code_life/loop.li
+++ b/src/code_life/loop.li
@@ -19,72 +19,72 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LOOP;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Loop (call tail recursive).";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
+ link_count:INTEGER;
-
+
+ body:LIST;
-
+
+ name:STRING_CONSTANT;
-
+
- set_link <-
(
link_count := link_count + 1;
);
-
+
- unset_link <-
(
link_count := link_count - 1;
? {link_count >= 0};
);
-
+
//
// Creation.
//
-
+
- create p:POSITION name lab:STRING_CONSTANT body lst:LIST :SELF <-
( + result:SELF;
result := clone;
result.make p name lab body lst;
result
);
-
+
- make p:POSITION name lab:STRING_CONSTANT body lst:LIST <-
- (
- position := p;
+ (
+ position := p;
name := lab;
body := lst;
);
-
+
- my_copy:SELF <-
( + result:SELF;
+ new_body:LIST;
+ switch:SWITCH;
+ case:LIST;
+ loop_end:LOOP_END;
-
+
new_body := body.my_copy;
result := LOOP.create position name (ALIAS_STR.get_intern name) body new_body;
//
- switch ?= new_body.last;
+ switch ?= new_body.last;
(switch.list.lower).to (switch.list.upper) do { k:INTEGER;
case := switch.list.item k.code;
(! case.is_empty).if {
loop_end ?= case.last;
- (loop_end != NULL).if {
+ (loop_end != NULL).if {
? {loop_end.loop = Self};
(loop_end.loop != Self).if {
semantic_error (position,"LOOP.my_copy BUG!!!");
@@ -94,20 +94,20 @@ Section Public
};
};
};
-
- (result.link_count != link_count).if {
+
+ (result.link_count != link_count).if {
name.print;
" Origin:".print;
link_count.print;
" copy:".print;
result.link_count.print;
'\n'.print;
-
+
body.debug_display;
-
+
semantic_error (position,"LOOP: Bug in copy.");
};
-
+
? {result.link_count = link_count};
result
);
@@ -117,21 +117,21 @@ Section Public
//
- remove <-
- (
- body.remove;
+ (
+ body.remove;
? {link_count = 0};
);
-
+
- execute:INSTR <-
- ( + result:INSTR;
+ ( + result:INSTR;
+ cur_seq_call_local_and_loop:INTEGER;
+ cur_seq_call_and_loop:INTEGER;
-
+
(link_count = 0).if {
result := body.execute;
new_execute_pass;
- } else {
- cur_seq_call_local_and_loop :=
+ } else {
+ cur_seq_call_local_and_loop :=
seq_call_local_and_loop := seq_call_local_and_loop + link_count;
//
cur_seq_call_and_loop :=
@@ -140,7 +140,7 @@ Section Public
seq_inline := seq_inline + 1;
//
result := Self;
- body.execute_case;
+ body.execute_case;
(loop_invariant = Self).if {
loop_list := list_current;
loop_seq_index := Old seq_index;
@@ -150,19 +150,19 @@ Section Public
//
seq_call_local_and_loop := seq_call_local_and_loop + link_count;
seq_call_and_loop := seq_call_and_loop + link_count;
- body.execute_case;
+ body.execute_case;
loop_invariant := NULL;
};
};
result
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
- (
+ (
buffer.append name;
display_ref buffer;
buffer.append ":\n";
@@ -173,34 +173,34 @@ Section Public
//
// Generation.
//
-
+
- genere buffer:STRING <-
- (
+ (
(! genere_while buffer).if {
-
- current_list_level := current_list_level + link_count;
-
+
+ current_list_level := current_list_level + link_count;
+
buffer.append name;
buffer.append ":\n";
buffer.append indent;
body.genere buffer;
};
);
-
+
- genere_while buffer:STRING :BOOLEAN <-
( + switch:SWITCH;
+ lst_true,lst_false,lst:LIST;
+ inverse:BOOLEAN;
+ result:BOOLEAN;
-
- (body.is_empty).if {
+
+ (body.is_empty).if {
semantic_error (position,"LOOP BUG: Body loop empty !");
};
switch ?= body.last;
(
- (switch != NULL) &&
+ (switch != NULL) &&
{switch.list.count = 2} &&
- {switch.list.first.id = type_true } &&
+ {switch.list.first.id = type_true } &&
{switch.list.second.id = type_false}
).if {
lst_true := switch.list.first.code;
@@ -212,23 +212,23 @@ Section Public
lst_true := lst_false;
lst_false := lst;
};
-
- current_list_level := current_list_level + 1;
-
+
+ current_list_level := current_list_level + 1;
+
(body.count = 1).if {
//
// While (...) do {...}.
//
result := TRUE;
inverse.if {
- buffer.append "while (!";
+ buffer.append "while (!";
} else {
- buffer.append "while (";
+ buffer.append "while (";
};
switch.expr.genere buffer;
//
buffer.append ") ";
- lst_true.remove_last;
+ lst_true.remove_last;
lst_true.genere buffer;
}.elseif {lst_true.count = 1} then {
//
@@ -239,19 +239,19 @@ Section Public
body.remove_last;
body.genere buffer;
inverse.if {
- buffer.append " while (!";
+ buffer.append " while (!";
} else {
- buffer.append " while (";
- };
+ buffer.append " while (";
+ };
//
switch.expr.genere buffer;
buffer.add_last ')';
- };
-
- current_list_level := current_list_level - 1;
-
+ };
+
+ current_list_level := current_list_level - 1;
+
};
};
result
);
-
+
diff --git a/src/code_life/loop_end.li b/src/code_life/loop_end.li
index dfd5891..8746cf3 100644
--- a/src/code_life/loop_end.li
+++ b/src/code_life/loop_end.li
@@ -19,43 +19,43 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LOOP_END;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Loop end (call tail recursive).";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
+ loop:LOOP;
-
+
//
// Creation.
//
-
+
- create p:POSITION loop l:LOOP :SELF <-
( + result:SELF;
result := clone;
result.make p loop l;
result
);
-
+
- make p:POSITION loop l:LOOP <-
- (
- position := p;
+ (
+ position := p;
loop := l;
loop.set_link;
);
-
+
- my_copy:SELF <-
- (
+ (
// Warning: See LOOP.my_copy
Self
);
@@ -65,35 +65,35 @@ Section Public
//
- remove <-
- (
- loop.unset_link;
+ (
+ loop.unset_link;
);
-
+
- execute:INSTR <-
- (
+ (
(list_current = loop.body).if {
POSITION.put_error semantic text "Recursivity without end (LOOP_END).";
loop.position.put_position;
position.put_position;
POSITION.send_error;
};
-
+
((is_optimization) && {loop_invariant = NULL} && {loop.link_count = 1}).if {
loop_invariant := loop;
};
-
+
seq_call_local_and_loop := seq_call_local_and_loop - 1;
- seq_call_and_loop := seq_call_and_loop - 1;
+ seq_call_and_loop := seq_call_and_loop - 1;
seq_inline := seq_inline + 1;
Self
);
-
+
//
// Display.
//
- display buffer:STRING <-
- (
+ (
buffer.append "goto ";
buffer.append (loop.name);
display_ref buffer;
@@ -102,12 +102,12 @@ Section Public
//
// Generation.
//
-
+
- genere buffer:STRING <-
- (
+ (
buffer.append "goto ";
buffer.append (loop.name);
-
- current_list_level := current_list_level - 1;
+
+ current_list_level := current_list_level - 1;
);
-
+
diff --git a/src/code_life/nop.li b/src/code_life/nop.li
index 4c2e22e..e801b02 100644
--- a/src/code_life/nop.li
+++ b/src/code_life/nop.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NOP;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "The nop instruction";
-
+
// BSBS: il faurai voir si c'est encore utile... (attention à la phase recursive)
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
- my_copy:SELF <- Self;
-
+
//
// Execute.
//
@@ -46,7 +46,7 @@ Section Public
(
// Nothing.
);
-
+
- execute:INSTR <- NULL;
//
diff --git a/src/code_life/push.li b/src/code_life/push.li
index 08503e5..5dd2d34 100644
--- a/src/code_life/push.li
+++ b/src/code_life/push.li
@@ -19,73 +19,73 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PUSH;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Push context for debug mode";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section PUSH,LISAAC
-
- - source_line:HASHED_DICTIONARY(STRING,UINTEGER_32) :=
+
+ - source_line:HASHED_DICTIONARY(STRING,UINTEGER_32) :=
HASHED_DICTIONARY(STRING,UINTEGER_32).create;
-
+
Section Public
-
+
+ context:LOCAL;
-
+
+ is_first:BOOLEAN;
-
+
- set_first f:BOOLEAN <-
(
is_first := f;
);
-
+
//
// Creation.
//
-
+
- create pos:POSITION context v:LOCAL first f:BOOLEAN :SELF <-
( + result:SELF;
? {v != NULL};
-
+
result := clone;
result.make pos context v first f;
result
);
-
+
- make pos:POSITION context v:LOCAL first f:BOOLEAN <-
- ( ? {pos.code != 0};
+ ( ? {pos.code != 0};
? {v != NULL};
(v = NULL).if {
crash_with_message "PUSH";
- };
+ };
position := pos;
context := v;
- is_first := f;
+ is_first := f;
);
-
- - my_copy:SELF <-
+
+ - my_copy:SELF <-
( + result:SELF;
+ new_context:LOCAL;
-
+
(LOCAL.is_alias).if {
new_context := context.get_alias;
new_context.set_ensure_count 1;
result := create position context new_context first is_first;
- } else {
+ } else {
result := create position context context first is_first;
};
- result
+ result
);
-
+
//
// Execute.
//
@@ -94,11 +94,11 @@ Section Public
(
// Nothing.
);
-
- - execute:INSTR <-
+
+ - execute:INSTR <-
( + result:INSTR;
+ other:SELF;
-
+
result := Self;
(list_current.index < list_current.upper).if {
other ?= list_current.item (list_current.index + 1);
@@ -111,7 +111,7 @@ Section Public
}.elseif {(is_first) && {! other.is_first}} then {
result := NULL;
};
- };
+ };
};
result
);
@@ -119,13 +119,13 @@ Section Public
//
// Genere
//
-
+
- genere buffer:STRING <-
( + id:UINTEGER_32;
+ idf:STRING_CONSTANT;
-
- idf := ALIASER_LOCAL.push Self;
- (is_first).if {
+
+ idf := ALIASER_LOCAL.push Self;
+ (is_first).if {
buffer.append "lisaac_push_first(&";
} else {
buffer.append "lisaac_push(&";
@@ -140,12 +140,12 @@ Section Public
buffer.add_last 'L';
};
id.append_in buffer;
- buffer.add_last ')';
-
+ buffer.add_last ')';
+
buffer.append "; /* L";
position.line.append_in buffer;
buffer.add_last ' ';
- buffer.append (position.prototype.name);
+ buffer.append (position.prototype.name);
buffer.append "*/";
);
diff --git a/src/code_life/read.li b/src/code_life/read.li
index 4707212..60dbcbe 100644
--- a/src/code_life/read.li
+++ b/src/code_life/read.li
@@ -19,64 +19,64 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := READ;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Read for local, global or slot";
-
+
Section Inherit
+ parent_expr:Expanded EXPR;
-
+
Section Public
-
+
- is_slot:BOOLEAN <- FALSE;
-
- - variable:VARIABLE <-
+
+ - variable:VARIABLE <-
(
deferred;
NULL
);
- - static_type:TYPE_FULL <-
- (
+ - static_type:TYPE_FULL <-
+ (
variable.type
);
-
+
- my_copy:SELF <-
( + result:SELF;
result ?= variable.read position;
result
);
-
+
//
// Searching.
//
-
+
- get_type t:TYPES_TMP <-
- (
+ (
variable.get_type t;
);
-
+
- get_last_value:EXPR <- variable.get_last_value NULL;
-
+
//
// Executing pass.
//
- remove <-
(
- variable.unread Self;
+ variable.unread Self;
);
-
+
- is_require_constant:CONSTANT <-
( + result:CONSTANT;
+ j:INTEGER;
- + val:EXPR;
+ + val:EXPR;
+ req_list:FAST_ARRAY(WRITE);
//? { variable.require_first != NULL };
/* BSBS: A REVOIR
@@ -109,22 +109,22 @@ Section Public
result
);
- - execute_access_unlink:INSTR <-
+ - execute_access_unlink:INSTR <-
(
deferred;
NULL
);
-
+
- execute_access_link <- deferred;
-
+
- execute_unlink:INSTR <-
// Delete read
(
variable.unread Self;
new_execute_pass;
- execute_access_unlink
+ execute_access_unlink
);
-
+
- execute_link:EXPR <-
( + cst:CONSTANT;
+ rec:INSTR;
@@ -132,19 +132,19 @@ Section Public
+ val:EXPR;
+ s:SLOT_DATA;
+ l:LOCAL;
- + wrt:WRITE;
+ + wrt:WRITE;
//+ old_loop_invariant:LOOP;
-
+
simplify_type variable;
-
+
//
s ?= variable;
- (
+ (
(s = NULL) || {
((s.style != '+') || {! s.id_section.is_mapping}) &&
{(! variable.type.is_expanded) || {variable.type.is_default_expanded}}
}
- ).if {
+ ).if {
cst := is_require_constant; // BSBS: Ce cas devrait rentrer dans get_last_value
(cst != NULL).if {
//
@@ -157,30 +157,30 @@ Section Public
};
result := cst.my_copy;
new_execute_pass;
- }.elseif {
+ }.elseif {
(val := get_last_value) != NULL
} then {
//
// VALUE_EXPR propagation, step by step.
- //
+ //
result := val;
- variable.unread Self;
+ variable.unread Self;
new_execute_pass;
};
};
-
+
(result = NULL).if {
//
// Normal.
- //
- ((is_slot) && {loop_invariant != NULL} && {is_invariant}).if {
+ //
+ ((is_slot) && {loop_invariant != NULL} && {is_invariant}).if {
//old_loop_invariant := loop_invariant;
//loop_invariant := NULL;
//
l := static_type.get_temporary position;
wrt := l.write position value Self;
loop_list.insert_before wrt;
- result := l.read position;
+ result := l.read position;
//
//wrt.execute;
//result := result.execute_link;
@@ -190,7 +190,7 @@ Section Public
} else {
variable.set_read;
execute_access_link;
- result := Self;
+ result := Self;
};
};
result
@@ -223,7 +223,7 @@ Section Public
buffer.add_last '>';
//};
);
-
+
- display buffer:STRING <-
(
buffer.append (variable.intern_name);
diff --git a/src/code_life/read_global.li b/src/code_life/read_global.li
index 0c35093..7ce7d39 100644
--- a/src/code_life/read_global.li
+++ b/src/code_life/read_global.li
@@ -19,80 +19,80 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := READ_GLOBAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Read for global";
-
+
Section Inherit
-
+
+ parent_read:Expanded READ;
-
+
Section Public
-
- - is_invariant:BOOLEAN <- global.is_invariant NULL;
-
+
+ - is_invariant:BOOLEAN <- global.is_invariant NULL;
+
+ global:SLOT_DATA;
-
+
- variable:VARIABLE <- global;
-
+
//
// Comparison.
//
-
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + rd:READ_GLOBAL;
-
+
rd ?= other;
- ((rd != NULL) && {global = rd.global})
+ ((rd != NULL) && {global = rd.global})
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with g:SLOT_DATA :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with g;
- result
+ result
);
-
+
- make p:POSITION with g:SLOT_DATA <-
(
position := p;
global := g;
);
-
+
//
// Execute
//
-
- - execute_access_unlink:INSTR <-
+
+ - execute_access_unlink:INSTR <-
(
global.execute;
NULL
);
- - execute_access_link <-
+ - execute_access_link <-
(
global.execute;
);
-
+
//
// Genere
//
-
+
- genere buffer:STRING <-
- (
+ (
buffer.append (variable.intern_name);
);
-
+
diff --git a/src/code_life/read_local.li b/src/code_life/read_local.li
index 3974221..05074ea 100644
--- a/src/code_life/read_local.li
+++ b/src/code_life/read_local.li
@@ -19,86 +19,86 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := READ_LOCAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Read for local.";
-
+
Section Inherit
-
+
+ parent_read:Expanded READ;
-
+
Section Public
-
- - is_invariant:BOOLEAN <- local.is_invariant;
-
+
+ - is_invariant:BOOLEAN <- local.is_invariant;
+
+ local:LOCAL;
-
+
- variable:VARIABLE <- local;
-
+
//
// Comparison.
//
-
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + rd:READ_LOCAL;
-
+
rd ?= other;
- ((rd != NULL) && {local = rd.local})
+ ((rd != NULL) && {local = rd.local})
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with l:LOCAL :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with l;
- result
+ result
);
-
+
- make p:POSITION with l:LOCAL <-
(
position := p;
- local := l;
+ local := l;
);
-
+
//
// Execute
//
-
+
- execute_access_unlink:INSTR <- NULL;
-
+
- execute_access_link;
-
+
//
// Genere
//
-
+
- genere buffer:STRING <-
( + tb:PROFIL_BLOCK;
+ idf:STRING_CONSTANT;
-
+
idf := ALIASER_LOCAL.read Self;
(local.is_result /*ensure_count = -100*/).if {
buffer.add_last '*';
};
buffer.append idf;
//
-
- tb ?= local.type.raw;
+
+ tb ?= local.type.raw;
(tb != NULL).if {
ALIASER_LOCAL.add_var_size local;
};
-
+
);
-
+
diff --git a/src/code_life/read_slot.li b/src/code_life/read_slot.li
index b6eda5f..f2fa2a1 100644
--- a/src/code_life/read_slot.li
+++ b/src/code_life/read_slot.li
@@ -19,119 +19,119 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := READ_SLOT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Read for slot";
-
+
Section Inherit
-
+
+ parent_read:Expanded READ;
-
+
Section Public
-
+
- is_slot:BOOLEAN <- TRUE;
-
- - is_invariant:BOOLEAN <- slot.is_invariant receiver;
-
+
+ - is_invariant:BOOLEAN <- slot.is_invariant receiver;
+
+ slot:SLOT_DATA;
-
+
+ receiver:EXPR;
-
+
- variable:VARIABLE <- slot;
-
- - get_last_value:EXPR <- variable.get_last_value receiver;
-
+
+ - get_last_value:EXPR <- variable.get_last_value receiver;
+
//
// Comparison.
//
-
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + rd:READ_SLOT;
-
+
rd ?= other;
- ((rd != NULL) && {slot = rd.slot} && {receiver ~= rd.receiver})
+ ((rd != NULL) && {slot = rd.slot} && {receiver ~= rd.receiver})
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with (r:EXPR,s:SLOT_DATA) :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with (r,s);
- result
+ result
);
-
+
- make p:POSITION with (r:EXPR,s:SLOT_DATA) <-
(
position := p;
receiver := r;
slot := s;
);
-
+
- my_copy:SELF <-
( + result:SELF;
-
+
result ?= slot.read position with (receiver.my_copy);
result
);
-
+
//
// Executing pass.
//
-
+
- remove <-
(
receiver.remove;
parent_read.remove;
);
-
- - execute_access_unlink:INSTR <-
+
+ - execute_access_unlink:INSTR <-
(
slot.execute;
receiver.execute_unlink
);
-
- - execute_access_link <-
- (
+
+ - execute_access_link <-
+ (
slot.execute;
- receiver := receiver.execute_link;
+ receiver := receiver.execute_link;
);
//
// Genere
//
-
+
- genere buffer:STRING <-
( + tf,tf2:TYPE_FULL;
+ t:TYPE;
+ add_end:BOOLEAN;
+ ptr,ptr2:BOOLEAN;
-
+
(is_java).if {
receiver.genere buffer;
//not_yet_implemented;
buffer.add_last '.';
buffer.append (variable.intern_name);
- } else {
+ } else {
(slot.intern_name = ALIAS_STR.slot_self).if {
buffer.append "((";
tf := slot.type;
- tf.genere_declaration buffer;
+ tf.genere_declaration buffer;
buffer.add_last ' ';
- tf.genere_star_declaration buffer;
+ tf.genere_star_declaration buffer;
buffer.add_last ')';
receiver.genere buffer;
buffer.append ".self)";
} else {
- tf := receiver.static_type;
+ tf := receiver.static_type;
t := slot.receiver_type;
(t.alias_slot != NULL).if {
tf2 := slot.type;
@@ -150,38 +150,38 @@ Section Public
(tf.is_strict) || {tf.is_expanded_ref} || {tf.is_expanded}
).if {
receiver.genere buffer;
- } else {
- buffer.append "((";
- t.put_reference_declaration buffer;
+ } else {
+ buffer.append "((";
+ t.put_reference_declaration buffer;
buffer.add_last ' ';
- t.put_reference_star_declaration buffer;
+ t.put_reference_star_declaration buffer;
buffer.add_last ')';
receiver.genere buffer;
- buffer.add_last ')';
+ buffer.add_last ')';
};
(t.alias_slot = NULL).if {
((tf.is_expanded) && {! tf.is_expanded_ref} && {! tf.is_strict}).if {
buffer.add_last '.';
} else {
buffer.append "->";
- };
- buffer.append (variable.intern_name);
+ };
+ buffer.append (variable.intern_name);
}.elseif {add_end} then {
buffer.append "))";
};
- };
+ };
};
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
receiver.display buffer;
buffer.append "->";
- parent_read.display buffer;
+ parent_read.display buffer;
);
diff --git a/src/code_life/result.li b/src/code_life/result.li
index f3a4ad9..1247250 100644
--- a/src/code_life/result.li
+++ b/src/code_life/result.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := RESULT;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,16 +32,16 @@ Section Inherit
- parent_expr:EXPR := EXPR;
Section Public
-
+
- position:POSITION <- value.position;
-
- + write:WRITE;
-
+
+ + write:WRITE;
+
- set_write v:WRITE <-
(
write := v;
);
-
+
//
// Creation.
//
@@ -54,48 +54,47 @@ Section Public
);
- make v:WRITE <-
- (
+ (
write := v;
);
-
+
- my_copy:SELF <-
( + wrt:WRITE;
+ rd:READ;
rd ?= write.value;
(rd = NULL).if {
- wrt := write.variable.write (write.position) with NULL value (write.value.my_copy);
+ wrt := write.variable.write (write.position) with NULL value (write.value.my_copy);
} else {
- rd := rd.variable.read_direct (rd.position) with NULL;
- wrt := write.variable.write (write.position) with NULL value rd;
+ rd := rd.variable.read_direct (rd.position) with NULL;
+ wrt := write.variable.write (write.position) with NULL value rd;
};
create wrt
);
-
+
- execute:INSTR <-
(
write ?= write.execute;
Self
);
-
+
//
// Remove
//
-
+
- remove <-
(
write.remove;
);
-
+
//
// Expr definition.
- //
-
+ //
+
- static_type:TYPE_FULL <- write.value.static_type;
-
+
- get_type t:TYPES_TMP <- write.value.get_type t;
-
+
- execute_link:EXPR <- write.execute_link;
-
+
- execute_unlink:INSTR <- write.execute_unlink;
-
-
\ No newline at end of file
+
diff --git a/src/code_life/switch.li b/src/code_life/switch.li
index aafdecc..80c958a 100644
--- a/src/code_life/switch.li
+++ b/src/code_life/switch.li
@@ -19,28 +19,28 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SWITCH;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Switch for late binding resolution";
-
+
// BSBS: Optim. : Détecter les switch identique l'un après l'autre
// pour les fusionner...
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
-
+
(expr.is_invariant).if {
result := TRUE;
j := list.lower;
@@ -51,30 +51,30 @@ Section Public
};
result
);
-
+
+ expr:EXPR;
-
+
+ list:FAST_ARRAY(CASE);
-
+
- count:INTEGER <- list.count;
-
+
//
// Creation.
//
-
+
- create n:NODE with e:EXPR size s:INTEGER :SELF <-
[ -? {n.position != 0}; ]
( + result:SELF;
-
+
result := clone;
result.make n with e size s;
result
- );
-
-
- - make n:NODE with e:EXPR size s:INTEGER <-
+ );
+
+
+ - make n:NODE with e:EXPR size s:INTEGER <-
( + first:CASE;
-
+
position := n.position;
expr := e;
list := FAST_ARRAY(CASE).create_with_capacity s;
@@ -83,11 +83,11 @@ Section Public
list.add_last first;
};
);
-
+
//
// Copy.
//
-
+
- set_expr e:EXPR list l:FAST_ARRAY(CASE) <-
(
expr := e;
@@ -97,21 +97,21 @@ Section Public
- my_copy:SELF <-
( + result:SELF;
+ new_list:FAST_ARRAY(CASE);
-
+
new_list := FAST_ARRAY(CASE).create_with_capacity (list.count);
(list.lower).to (list.upper) do { j:INTEGER;
new_list.add_last (list.item j.my_copy);
};
-
+
result := clone;
result.set_expr (expr.my_copy) list new_list;
result
);
-
+
//
// Remove.
//
-
+
- remove <-
(
(expr != NULL).if {
@@ -119,17 +119,17 @@ Section Public
};
(list.lower).to (list.upper) do { j:INTEGER;
list.item j.remove;
- };
+ };
);
-
+
//
// Execute
//
-
- - i_am_the_last i:INSTR :BOOLEAN <-
+
+ - i_am_the_last i:INSTR :BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
-
+
j := list.lower;
{(j <= list.upper) && {!result}}.while_do {
result := list.item j.code.i_am_the_last i;
@@ -139,28 +139,28 @@ Section Public
);
- execute:INSTR <-
- ( + lst_typ:TYPES_TMP;
+ ( + lst_typ:TYPES_TMP;
+ result:INSTR;
+ typ:TYPE;
+ wrt:WRITE;
+ lst:LIST;
- + tb:PROFIL_BLOCK;
+ + tb:PROFIL_BLOCK;
+ is_end:BOOLEAN;
+ count_empty:INTEGER;
-
+
// Update.
- lst_typ := TYPES_TMP.new;
+ lst_typ := TYPES_TMP.new;
// BSBS: optim a voir si necessaire ...
- /*
+ /*
(expr.static_type.is_strict).if {
- lst_typ.add (expr.static_type.raw);
- } else {
+ lst_typ.add (expr.static_type.raw);
+ } else {
*/
- expr.get_type lst_typ;
+ expr.get_type lst_typ;
//};
- ? {lst_typ.count <= list.count};
-
- (lst_typ.count > list.count).if {
+ ? {lst_typ.count <= list.count};
+
+ (lst_typ.count > list.count).if {
"New type: ".print;
lst_typ.print;
"\nOld type: ".print;
@@ -175,23 +175,23 @@ Section Public
string_tmp.clear;
profil_current.display string_tmp;
string_tmp.print;
-
-
+
+
( + wrt2:WRITE;
+ rd:READ;
+ var:VARIABLE;
-
+
rd ?= expr;
var := rd.variable;
wrt2 := var.require_first;
rd ?= wrt2.value;
var := rd.variable;
-
+
wrt2 := var.require_first;
wrt2.debug_display;
"==============\n".print;
(var.require_list.lower).to (var.require_list.upper) do { i:INTEGER;
- "==============\n".print;
+ "==============\n".print;
i.print; '\n'.print;
wrt2 := var.require_list.item i;
wrt2.debug_display;
@@ -202,32 +202,32 @@ Section Public
);*/
syntax_error (expr.position,"*****SWITCH BUG********");
};
-
- //
+
+ //
// BSBS: Ajoute un pattern pour les elseif ...
- //
- (lst_typ.lower).to (lst_typ.upper) do { j:INTEGER;
- typ := lst_typ.item j;
+ //
+ (lst_typ.lower).to (lst_typ.upper) do { j:INTEGER;
+ typ := lst_typ.item j;
{typ = list.item j.id}.until_do {
list.item j.remove;
- list.remove j;
+ list.remove j;
};
(list.item j.code.is_empty).if {
count_empty := count_empty + 1;
};
- };
- {lst_typ.count = list.count}.until_do {
+ };
+ {lst_typ.count = list.count}.until_do {
list.last.remove;
- list.remove_last;
- };
+ list.remove_last;
+ };
lst_typ.free;
-
+
// Execute.
(
(list.count = 1) || {
- (list.count = 2) &&
- {debug_level_option = 0} &&
- {list.first.id = TYPE_NULL} &&
+ (list.count = 2) &&
+ {debug_level_option = 0} &&
+ {list.first.id = TYPE_NULL} &&
{! list.first.code.is_empty} &&
{
wrt ?= list.first.code.first; // For ?= with NULL type.
@@ -245,7 +245,7 @@ Section Public
};
result := list.last.code.execute;
is_end := TRUE;
- }.elseif {count_empty = list.count} then {
+ }.elseif {count_empty = list.count} then {
result := expr.execute_unlink;
(list.lower).to (list.upper) do { j:INTEGER;
list.item j.remove;
@@ -254,10 +254,10 @@ Section Public
};
//
(! is_end).if {
- // Normal execution.
+ // Normal execution.
(
- (expr.static_type.raw = type_boolean) &&
- {list.count = 2} &&
+ (expr.static_type.raw = type_boolean) &&
+ {list.count = 2} &&
{list.first.code.is_empty}
).if {
? {! list.second.code.is_empty};
@@ -270,34 +270,34 @@ Section Public
seq_or_and := seq_or_and + 1;
seq_inline := seq_inline + 1;
*/
- expr := expr.execute_link;
-
+ expr := expr.execute_link;
+
CALL_SLOT.reset_count_no_recursive;
- ((list.first.id = TYPE_NULL) && {list.count = 2}).if {
+ ((list.first.id = TYPE_NULL) && {list.count = 2}).if {
list.first .code.execute_case;
- list.second.code.execute_case;
+ list.second.code.execute_case;
((list.second.id.is_block) && {debug_level_option != 0}).if {
list.second.id.set_late_binding;
};
- } else {
+ } else {
(list.lower).to (list.upper) do { j:INTEGER;
- list.item j.execute;
+ list.item j.execute;
};
- };
+ };
result := detect_logic_expr;
- (result = NULL).if {
+ (result = NULL).if {
result := Self;
};
- };
+ };
result
);
-
+
//
// Genere.
//
-
+
- count_bug:INTEGER;
-
+
- genere buffer:STRING <-
( + lst:LIST;
+ first_case:INTEGER;
@@ -308,80 +308,80 @@ Section Public
+ c1,c2:CASE;
+ lst_case:FAST_ARRAY(CASE);
+ cases:FAST_ARRAY(FAST_ARRAY(CASE));
-
+
buffer.append "/* ";
- (list.lower).to (list.upper) do { i:INTEGER;
+ (list.lower).to (list.upper) do { i:INTEGER;
list.item i.id.put_id buffer;
buffer.add_last ' ';
};
buffer.append "*/\n";
(
- (list.first.id = TYPE_NULL) &&
- {debug_level_option = 0} &&
- {! list.first.code.is_empty} &&
+ (list.first.id = TYPE_NULL) &&
+ {debug_level_option = 0} &&
+ {! list.first.code.is_empty} &&
{
wrt ?= list.first.code.first; // For ?= with NULL type.
wrt = NULL
}
).if {
list.remove_first;
- };
+ };
typ_first := list.first.id;
- typ_id ?= typ_first;
+ typ_id ?= typ_first;
((list.count <= 2) || {typ_first = TYPE_NULL}).if {
buffer.append "if (";
- //
- ((expr.static_type.raw.is_block) && {typ_first = TYPE_NULL}).if {
+ //
+ ((expr.static_type.raw.is_block) && {typ_first = TYPE_NULL}).if {
expr.genere buffer;
is_genered := TRUE;
buffer.append ".__id==0";
- } else {
- typ_first.put_access_id expr in buffer;
+ } else {
+ typ_first.put_access_id expr in buffer;
is_genered := TRUE;
(expr.static_type.raw != type_boolean).if {
buffer.append "==";
- typ_first.put_id buffer;
+ typ_first.put_id buffer;
} else {
? {typ_first.name = ALIAS_STR.prototype_true};
};
};
buffer.append ") ";
//
- list.first.genere buffer;
+ list.first.genere buffer;
first_case := 1;
//
(list.count = 2).if {
- lst := list.second.code;
+ lst := list.second.code;
(! list.second.code.is_empty).if {
- buffer.append " else ";
- buffer.append "/* ";
+ buffer.append " else ";
+ buffer.append "/* ";
buffer.append (list.second.id.name);
- buffer.append " */ ";
- list.second.genere buffer;
+ buffer.append " */ ";
+ list.second.genere buffer;
};
first_case := 2;
}.elseif {list.count > 2} then {
buffer.append " else {\n";
indent.append " ";
- buffer.append indent;
+ buffer.append indent;
};
};
(first_case <= list.upper).if {
(is_genered).if {
- expr := expr.my_copy;
+ expr := expr.my_copy;
};
cases := case_fusion first_case;
(cases.count = 2).if {
(cases.first.count = 1).if {
c1 := cases.first.first;
- c2 := cases.second.first;
+ c2 := cases.second.first;
}.elseif {cases.second.count = 1} then {
c1 := cases.second.first;
- c2 := cases.first.first;
+ c2 := cases.first.first;
};
};
(c1 != NULL).if {
- buffer.append "if (";
+ buffer.append "if (";
c1.id.put_access_id expr in buffer;
buffer.append "==";
c1.id.put_id buffer;
@@ -390,36 +390,36 @@ Section Public
buffer.append " else /* Other types */ ";
c2.genere buffer;
} else {
- polymorphic_counter := polymorphic_counter + 1;
- buffer.append "switch (";
+ polymorphic_counter := polymorphic_counter + 1;
+ buffer.append "switch (";
list.item first_case.id.put_access_id expr in buffer;
buffer.append ") {\n";
(cases.lower).to (cases.upper) do { j:INTEGER;
lst_case := cases.item j;
(! lst_case.first.code.is_empty).if {
- (lst_case.lower).to (lst_case.upper) do { i:INTEGER;
- buffer.append indent;
+ (lst_case.lower).to (lst_case.upper) do { i:INTEGER;
+ buffer.append indent;
buffer.append "case ";
lst_case.item i.id.put_id buffer;
- buffer.append ": \n";
+ buffer.append ": \n";
};
- buffer.remove_last 1;
- lst_case.first.genere buffer;
+ buffer.remove_last 1;
+ lst_case.first.genere buffer;
buffer.append " break;\n";
- }
-
+ }
+
// Debug...
else {
- (lst_case.lower).to (lst_case.upper) do { i:INTEGER;
- buffer.append indent;
+ (lst_case.lower).to (lst_case.upper) do { i:INTEGER;
+ buffer.append indent;
buffer.append "case ";
lst_case.item i.id.put_id buffer;
- buffer.append ": \n";
+ buffer.append ": \n";
};
- buffer.remove_last 1;
+ buffer.remove_last 1;
buffer.append " break;\n";
- };
- };
+ };
+ };
// Debug...
(debug_level_option != 0).if {
buffer.append indent;
@@ -429,28 +429,28 @@ Section Public
\print_string(\"Call on twilight zone!!!\\n\"); \
\die_with_code(1);\n";
};
-
+
buffer.append indent;
buffer.add_last '}';
};
free_list_cases cases;
(first_case != 0).if {
buffer.add_last '\n';
- indent.remove_last 2;
+ indent.remove_last 2;
buffer.append indent;
buffer.add_last '}';
};
};
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
( + line:{INTEGER; };
-
- line :=
+
+ line :=
{ j:INTEGER;
+ i:LIST;
buffer.append indent;
@@ -466,30 +466,30 @@ Section Public
i.display buffer;
};
};
-
+
buffer.append "Switch ";
expr.display buffer;
buffer.add_last '\n';
(list.count > 0).if {
- indent.append "| ";
+ indent.append "| ";
0.to (list.upper - 1) do { j:INTEGER;
line.value j;
buffer.add_last '\n';
- };
+ };
indent.put ' ' to (indent.upper-1);
line.value (list.upper);
indent.remove_last 2;
};
);
-
+
- switch_new_pass:BOOLEAN;
- reset_switch_new_pass <-
(
switch_new_pass := FALSE;
);
-
+
Section Private
-
+
- detect_logic_expr:INSTR <-
// Detection !, |, &, ||, && :
( + result:INSTR;
@@ -499,37 +499,37 @@ Section Private
+ a,b,c,d:BOOLEAN;
(
- (expr.static_type.raw = type_boolean) &&
- {list.count = 2} &&
- {list.first.code.count = 1} &&
+ (expr.static_type.raw = type_boolean) &&
+ {list.count = 2} &&
+ {list.first.code.count = 1} &&
{list.second.code.count = 1}
).if {
? {list.first.id = type_true };
? {list.second.id = type_false};
-
+
((list.first.id != type_true) || {list.second.id != type_false}).if {
syntax_error (position,"PB dans SWITCH.");
};
-
+
wr_true ?= list.first .code.first;
wr_false ?= list.second.code.first;
(
- (wr_true != NULL) &&
+ (wr_true != NULL) &&
{wr_false != NULL} &&
{wr_true.static_type.raw = type_boolean} &&
{wr_true.variable = wr_false.variable}
).if {
val_true := wr_true .value;
- val_false := wr_false.value;
+ val_false := wr_false.value;
// BSBS: val_true.static_type = type_true ???
(
- (a := val_true.is_constant) &&
+ (a := val_true.is_constant) &&
{b := (val_true.static_type.raw = type_true)}
).if {
// | or ||
- rd ?= val_false;
+ rd ?= val_false;
(rd != NULL).if {
- // |
+ // |
wr_true.remove;
val_false := EXPR_OR_LOGIC.create position with expr and val_false;
wr_false.set_value val_false;
@@ -542,48 +542,48 @@ Section Private
wr_false.set_value val_false;
result := wr_false;
switch_new_pass := TRUE;
- };
+ };
}.elseif {
- (c := val_false.is_constant) &&
+ (c := val_false.is_constant) &&
{d := (val_false.static_type.raw = type_false)}
} then {
- // & or &&
- rd ?= val_true;
+ // & or &&
+ rd ?= val_true;
(rd != NULL).if {
- // &
- wr_false.remove;
+ // &
+ wr_false.remove;
val_true := EXPR_AND_LOGIC.create position with expr and val_true;
wr_true.set_value val_true;
- result := wr_true;
+ result := wr_true;
new_execute_pass;
}.elseif {(CALL_SLOT.count_no_recursive = 0) || {modify_count = 0}} then {
- // &&
+ // &&
wr_false.remove;
val_true := EXPR_AND_AND_LOGIC.create position with expr and val_true;
wr_true.set_value val_true;
result := wr_true;
switch_new_pass := TRUE;
- };
+ };
}.elseif {
(a) && {!b} && {c} && {!d}
} then {
// !
wr_false.remove;
wr_true.set_value (EXPR_NOT_LOGIC.create position with expr);
- result := wr_true;
+ result := wr_true;
new_execute_pass;
};
};
};
result
);
-
+
- switch_fusion <-
( + other:SWITCH;
+ index:INTEGER;
+ wrt:WRITE;
+ rd,rd2:READ;
-
+
index := list_current.index + 1;
other ?= list_current.item index;
((other != NULL) && {other.expr == expr} && {other.list.count = list.count}).if {
@@ -594,11 +594,11 @@ Section Private
// BSBS: Dans ce cas la, tu devrai en avoir 250 !!!!
// Regarde pourquoi tu n'as que 14 cas !
wrt ?= list_current.item index;
- rd ?= expr;
+ rd ?= expr;
((wrt != NULL) && {rd != NULL} && {wrt.variable != rd.variable}).if {
- rd2 ?= wrt.value;
+ rd2 ?= wrt.value;
other ?= list_current.item (index + 1);
- ((rd2 != NULL) && {other != NULL} &&
+ ((rd2 != NULL) && {other != NULL} &&
{other.expr == expr} && {other.list.count = list.count}).if {
(list.lower).to (list.upper-1) do { j:INTEGER;
list.item j.code.add_last (wrt.my_copy);
@@ -606,16 +606,16 @@ Section Private
list.last.code.add_last wrt;
list_current.put NOP to index;
concat_switch other;
- list_current.put NOP to (index + 1);
+ list_current.put NOP to (index + 1);
};
};
};
);
-
+
- concat_switch other:SWITCH <-
( + other_list:FAST_ARRAY(CASE);
+ code:LIST;
-
+
other.expr.remove;
other_list := other.list;
(list.lower).to (list.upper) do { j:INTEGER;
@@ -624,17 +624,17 @@ Section Private
};
new_execute_pass;
);
-
+
//
// Case fusion manager.
//
-
- - store_list_cases:FAST_ARRAY(FAST_ARRAY(FAST_ARRAY(CASE))) :=
+
+ - store_list_cases:FAST_ARRAY(FAST_ARRAY(FAST_ARRAY(CASE))) :=
FAST_ARRAY(FAST_ARRAY(FAST_ARRAY(CASE))).create_with_capacity 32;
-
- - store_cases:FAST_ARRAY(FAST_ARRAY(CASE)) :=
+
+ - store_cases:FAST_ARRAY(FAST_ARRAY(CASE)) :=
FAST_ARRAY(FAST_ARRAY(CASE)).create_with_capacity 32;
-
+
- new_cases:FAST_ARRAY(CASE) <-
( + result:FAST_ARRAY(CASE);
(store_cases.is_empty).if {
@@ -645,7 +645,7 @@ Section Private
};
result
);
-
+
- new_list_cases:FAST_ARRAY(FAST_ARRAY(CASE)) <-
( + result:FAST_ARRAY(FAST_ARRAY(CASE));
(store_list_cases.is_empty).if {
@@ -654,31 +654,31 @@ Section Private
result := store_list_cases.last;
store_list_cases.remove_last;
};
- result
+ result
);
-
+
- free_list_cases l:FAST_ARRAY(FAST_ARRAY(CASE)) <-
( + lst:FAST_ARRAY(CASE);
(l.lower).to (l.upper) do { i:INTEGER;
lst := l.item i;
lst.clear;
- store_cases.add_last lst;
+ store_cases.add_last lst;
};
l.clear;
store_list_cases.add_last l;
);
-
+
- case_fusion low:INTEGER :FAST_ARRAY(FAST_ARRAY(CASE)) <-
( + c1,c2:CASE;
+ lst:FAST_ARRAY(CASE);
- + j:INTEGER;
+ + j:INTEGER;
+ result:FAST_ARRAY(FAST_ARRAY(CASE));
-
+
result := new_list_cases;
(low).to (list.upper) do { i:INTEGER;
- c1 := list.item i;
+ c1 := list.item i;
lst := NULL;
- j := result.lower;
+ j := result.lower;
{(j <= result.upper) && {lst = NULL}}.while_do {
c2 := result.item j.first;
(c1 ~= c2).if {
@@ -689,7 +689,7 @@ Section Private
};
(lst = NULL).if {
lst := new_cases;
- result.add_last lst;
+ result.add_last lst;
};
lst.add_last c1;
};
diff --git a/src/code_life/write.li b/src/code_life/write.li
index a81151b..667bc1a 100644
--- a/src/code_life/write.li
+++ b/src/code_life/write.li
@@ -19,62 +19,62 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := WRITE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write local, global or slot";
-
+
Section Inherit
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
//
// Debug !!!!
//
-
+
+ is_delete:BOOLEAN;
-
+
+ is_create:BOOLEAN;
-
+
- set_delete <-
(
is_delete := TRUE;
);
-
+
- set_create <-
(
is_create := TRUE;
);
-
+
//
// Fin debug !!!!
//
-
+
+ quiet_generation:BOOLEAN;
-
+
- set_quiet_generation <-
(
quiet_generation := TRUE;
);
-
+
- is_invariant:BOOLEAN <- value.is_invariant;
-
+
- variable:VARIABLE <-
(
- deferred;
+ deferred;
NULL
);
-
- - static_type:TYPE_FULL <-
- (
+
+ - static_type:TYPE_FULL <-
+ (
variable.type
);
-
+
+ value:EXPR;
- set_value new:EXPR <-
@@ -83,63 +83,63 @@ Section Public
);
- ensure_count:INTEGER <- variable.ensure_count;
-
+
- get_type t:TYPES_TMP <-
(
(value != NULL).if {
value.get_type t;
};
);
-
+
- my_copy:SELF <-
- ( + new_val:EXPR;
+ ( + new_val:EXPR;
+ result:SELF;
-
+
new_val := value.my_copy;
result ?= variable.write position value new_val;
result
);
-
+
//
// Execute.
//
-
- - execute_access_unlink:INSTR <-
+
+ - execute_access_unlink:INSTR <-
(
deferred;
NULL
);
-
+
- execute_access_link <- deferred;
-
+
- execute:INSTR <-
( + result:INSTR;
+ read:READ;
+ val:INSTR;
+ slot:SLOT_DATA;
-
+
? { variable != NULL };
? { value != NULL };
-
+
simplify_type variable;
//debug_display;
-
+
slot ?= variable;
- (
+ (
( // First case : No link.
(ensure_count = 0) && {(slot = NULL) || {! slot.id_section.is_mapping}}
- ) ||
+ ) ||
{ // Second case : a := a;
read ?= value;
- (read != NULL) &&
+ (read != NULL) &&
{variable = read.variable} &&
{(variable.is_local) || {variable.style = '-'}} // BSBS: Ce cas dans rentrer dans set_write
}
).if {
//
// Supprime affectation.
- //
-
+ //
+
val := execute_access_unlink;
(val != NULL).if {
list_current.insert_before val;
@@ -150,58 +150,58 @@ Section Public
} else {
//
// Execution normal.
- //
+ //
/*( // BSBS: Bug, mais de toute facon le gain n'est pas la... (entre +5 a +20)
- (loop_invariant != NULL) && {list_current = loop_invariant.body} &&
+ (loop_invariant != NULL) && {list_current = loop_invariant.body} &&
{is_invariant} && {variable.get_last_index != -1}
- ).if {
+ ).if {
//old_loop_invariant := loop_invariant;
//loop_invariant := NULL;
//
variable.reset_last_write Self;
loop_list.insert_before Self;
//
- //execute_access_link;
- //value := value.execute_link;
+ //execute_access_link;
+ //value := value.execute_link;
//seq_index := seq_index + 1;
//
//loop_invariant := old_loop_invariant;
result := NOP;
count_invariant := count_invariant + 1;
} else { */
-
- execute_access_link;
- value := value.execute_link;
+
+ execute_access_link;
+ value := value.execute_link;
seq_index := seq_index + 1;
variable.set_write Self;
- result := Self;
+ result := Self;
//};
};
result
);
-
+
- remove <-
(
variable.unwrite Self;
value.remove;
);
-
+
//
// Genere
//
-
+
- genere_value buffer:STRING <-
- (
+ (
(is_java).if {
- value.genere buffer;
- } else {
+ value.genere buffer;
+ } else {
(
- (static_type.is_expanded_ref) &&
+ (static_type.is_expanded_ref) &&
{! value.static_type.is_expanded_ref}
).if {
? {value.static_type.is_expanded};
buffer.append "&(";
- value.genere buffer;
+ value.genere buffer;
buffer.add_last ')';
}.elseif {
(static_type.is_expanded) && {! static_type.is_expanded_ref} &&
@@ -209,32 +209,32 @@ Section Public
{value.static_type.raw != TYPE_NULL} // For Pointer := NULL
} then {
buffer.append "*(";
- value.genere buffer;
+ value.genere buffer;
buffer.add_last ')';
} else {
value.genere buffer;
};
};
);
-
+
//
// Display.
//
- display buffer:STRING <-
- (
+ (
//crash;
buffer.append (variable.intern_name);
-
+
buffer.add_last '[';
variable.type.append_name_in buffer;
buffer.add_last ']';
-
+
buffer.append " :=";
//to_pointer.append_in buffer;
display_ref buffer;
buffer.add_last ' ';
-
+
(value = NULL).if {
buffer.append "<NULL>";
} else {
@@ -247,8 +247,8 @@ Section Public
is_verbose.if {
buffer.add_last '<';
buffer.append (object_id.to_string);
- buffer.add_last '/';
- ensure_count.append_in buffer;
+ buffer.add_last '/';
+ ensure_count.append_in buffer;
buffer.add_last '>';
};
);
diff --git a/src/code_life/write_global.li b/src/code_life/write_global.li
index da4f6ed..3b0aa58 100644
--- a/src/code_life/write_global.li
+++ b/src/code_life/write_global.li
@@ -19,29 +19,29 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := WRITE_GLOBAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write global";
-
+
Section Inherit
+ parent_write:Expanded WRITE;
-
+
Section Public
-
+
+ global:SLOT_DATA;
-
+
- variable:VARIABLE <- global;
-
+
//
// Creation.
//
-
+
- create p:POSITION with val:EXPR in g:SLOT_DATA :SELF <-
( + result:SELF;
? {p.code != 0};
@@ -49,35 +49,35 @@ Section Public
result.make p with val in g;
result
);
-
+
- make p:POSITION with val:EXPR in g:SLOT_DATA <-
- (
+ (
position := p;
value := val;
global := g;
);
-
+
//
// Execute.
//
- - execute_access_unlink:INSTR <-
+ - execute_access_unlink:INSTR <-
(
global.execute;
NULL
);
- - execute_access_link <-
- (
+ - execute_access_link <-
+ (
global.execute;
);
//
// Genere
//
-
+
- genere buffer:STRING <-
- (
+ (
TYPE.add_genere_global global;
(quiet_generation).if_false {
buffer.append (global.intern_name);
@@ -85,12 +85,12 @@ Section Public
((value.static_type.raw = TYPE_NULL) && {variable.type.raw.is_block}).if {
buffer.append ".__id=0";
} else {
- buffer.add_last '=';
+ buffer.add_last '=';
genere_value buffer;
};
};
);
-
+
diff --git a/src/code_life/write_local.li b/src/code_life/write_local.li
index a1c9290..eed4c3c 100644
--- a/src/code_life/write_local.li
+++ b/src/code_life/write_local.li
@@ -19,29 +19,29 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := WRITE_LOCAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write local";
-
+
Section Inherit
+ parent_write:Expanded WRITE;
-
+
Section Public
-
+
+ local:LOCAL;
-
+
- variable:VARIABLE <- local;
-
+
//
// Creation.
//
-
+
- create p:POSITION with val:EXPR in l:LOCAL :SELF <-
( + result:SELF;
? {p.code != 0};
@@ -49,36 +49,36 @@ Section Public
result.make p with val in l;
result
);
-
+
- make p:POSITION with val:EXPR in l:LOCAL <-
- (
+ (
position := p;
local := l;
value := val;
);
-
+
//
// Execute.
//
-
+
- execute_access_unlink:INSTR <- NULL;
-
+
- execute_access_link;
- - execute_argument:BOOLEAN <-
+ - execute_argument:BOOLEAN <-
// BSBS: Cette methode foireuse ne doit plus etre necessaire (utilise execute normal)
( + new_val:INSTR;
- + read:READ;
+ + read:READ;
+ result:BOOLEAN;
-
+
? { variable != NULL };
? { value != NULL };
-
+
read ?= value;
(ensure_count = 0).if {
//
// Supprime affectation.
- //
+ //
new_val := value.execute_unlink;
(new_val = NULL).if {
result := TRUE;
@@ -91,56 +91,56 @@ Section Public
} else {
//
// Execution normal.
- //
+ //
execute_access_link;
- value := value.execute_link;
+ value := value.execute_link;
};
result
- );
-
+ );
+
//
// Genere
//
-
+
- genere buffer:STRING <-
( + idf:STRING_CONSTANT;
-
- idf := ALIASER_LOCAL.write Self;
+
+ idf := ALIASER_LOCAL.write Self;
(quiet_generation).if_false {
- (local.is_result).if {
+ (local.is_result).if {
buffer.add_last '*';
- };
- buffer.append idf;
+ };
+ buffer.append idf;
//
((value.static_type.raw = TYPE_NULL) && {variable.type.raw.is_block}).if {
buffer.append ".__id=0";
- } else {
- buffer.add_last '=';
+ } else {
+ buffer.add_last '=';
genere_value buffer;
};
};
);
-
+
- genere_first_result buffer:STRING <-
( + idf:STRING_CONSTANT;
-
- idf := ALIASER_LOCAL.write Self;
- (local.is_result).if {
+
+ idf := ALIASER_LOCAL.write Self;
+ (local.is_result).if {
buffer.add_last '*';
};
- buffer.append idf;
- //
- buffer.add_last '=';
+ buffer.append idf;
+ //
+ buffer.add_last '=';
);
-
+
- genere_argument_result buffer:STRING <-
( + idf:STRING_CONSTANT;
-
+
idf := ALIASER_LOCAL.write Self;
buffer.add_last '&';
- buffer.append idf;
+ buffer.append idf;
);
-
+
diff --git a/src/code_life/write_slot.li b/src/code_life/write_slot.li
index 3d26de0..9535ab1 100644
--- a/src/code_life/write_slot.li
+++ b/src/code_life/write_slot.li
@@ -19,33 +19,33 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := WRITE_SLOT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write slot";
-
+
Section Inherit
+ parent_write:Expanded WRITE;
-
+
Section Public
-
+
- is_invariant:BOOLEAN <- receiver.is_invariant && {value.is_invariant};
-
+
+ slot:SLOT_DATA;
-
+
- variable:VARIABLE <- slot;
-
+
+ receiver:EXPR;
-
+
//
// Creation.
//
-
+
- create p:POSITION with val:EXPR in (r:EXPR,s:SLOT_DATA) :SELF <-
( + result:SELF;
? {p.code != 0};
@@ -53,19 +53,19 @@ Section Public
result.make p with val in (r,s);
result
);
-
+
- make p:POSITION with val:EXPR in (r:EXPR,s:SLOT_DATA) <-
- (
- position := p;
+ (
+ position := p;
value := val;
receiver := r;
slot := s;
);
-
+
- my_copy:SELF <-
- ( + new_val:EXPR;
+ ( + new_val:EXPR;
+ result:SELF;
-
+
new_val := value.my_copy;
result ?= variable.write position with (receiver.my_copy) value new_val;
(quiet_generation).if {
@@ -73,80 +73,80 @@ Section Public
};
result
);
-
+
//
// Execute.
//
- - execute_access_unlink:INSTR <-
- (
+ - execute_access_unlink:INSTR <-
+ (
slot.execute;
receiver.execute_unlink
);
-
- - execute_access_link <-
- (
+
+ - execute_access_link <-
+ (
slot.execute;
- receiver := receiver.execute_link;
+ receiver := receiver.execute_link;
);
-
+
- remove <-
(
receiver.remove;
parent_write.remove;
);
-
+
//
// Genere
//
-
+
- genere buffer:STRING <-
( + tf:TYPE_FULL;
+ t:TYPE;
-
+
t := slot.receiver_type;
- t.add_genere_list;
+ t.add_genere_list;
(! quiet_generation).if {
(t.alias_slot = variable).if {
- tf := receiver.static_type;
+ tf := receiver.static_type;
((tf.is_strict) || {tf.is_expanded_ref}).if {
buffer.append "(*";
- receiver.genere buffer;
+ receiver.genere buffer;
buffer.add_last ')';
- }.elseif {tf.is_expanded} then {
- receiver.genere buffer;
+ }.elseif {tf.is_expanded} then {
+ receiver.genere buffer;
} else {
buffer.append "*((";
t := slot.receiver_type;
- t.put_reference_declaration buffer;
+ t.put_reference_declaration buffer;
buffer.add_last ' ';
- t.put_reference_star_declaration buffer;
+ t.put_reference_star_declaration buffer;
buffer.add_last ')';
receiver.genere buffer;
- buffer.add_last ')';
- };
+ buffer.add_last ')';
+ };
} else {
- // Receiver.
+ // Receiver.
(is_java).if {
receiver.genere buffer;
- buffer.add_last '.';
- } else {
- tf := receiver.static_type;
+ buffer.add_last '.';
+ } else {
+ tf := receiver.static_type;
((tf.is_strict) || {tf.is_expanded_ref}).if {
receiver.genere buffer;
buffer.append "->";
- }.elseif {tf.is_expanded} then {
+ }.elseif {tf.is_expanded} then {
receiver.genere buffer;
- buffer.add_last '.';
+ buffer.add_last '.';
} else {
buffer.append "((";
t := slot.receiver_type;
- t.put_reference_declaration buffer;
+ t.put_reference_declaration buffer;
buffer.add_last ' ';
- t.put_reference_star_declaration buffer;
+ t.put_reference_star_declaration buffer;
buffer.add_last ')';
receiver.genere buffer;
- buffer.append ")->";
+ buffer.append ")->";
};
};
//
@@ -156,12 +156,12 @@ Section Public
((value.static_type.raw = TYPE_NULL) && {variable.type.raw.is_block}).if {
buffer.append ".__id=0";
} else {
- buffer.add_last '=';
- genere_value buffer;
+ buffer.add_last '=';
+ genere_value buffer;
};
};
);
-
+
//
// Display.
//
@@ -170,11 +170,11 @@ Section Public
(
receiver.display buffer;
buffer.append "->";
- parent_write.display buffer;
+ parent_write.display buffer;
);
-
-
+
+
diff --git a/src/compiler_any/any_option.li b/src/compiler_any/any_option.li
index 9e48f18..48b256e 100644
--- a/src/compiler_any/any_option.li
+++ b/src/compiler_any/any_option.li
@@ -19,29 +19,29 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ANY_OPTION;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Option for compiler (see shorter)";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
- is_shorter :BOOLEAN := FALSE;
-
+
- is_shorter2:BOOLEAN := FALSE;
-
+
//
// Option du Shorter.
- //
-
+ //
+
- is_short_private:BOOLEAN;
- is_short_code:BOOLEAN;
-
+
diff --git a/src/constant/character_cst.li b/src/constant/character_cst.li
index 27feeb9..63f0f3a 100644
--- a/src/constant/character_cst.li
+++ b/src/constant/character_cst.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CHARACTER_CST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Character constant";
-
+
Section Inherit
-
+
+ parent_constant:Expanded CONSTANT;
-
+
Section Public
//
@@ -50,7 +50,7 @@ Section Public
result.make p char car;
result
);
-
+
- make p:POSITION char car:STRING_CONSTANT <-
(
position := p;
@@ -63,8 +63,8 @@ Section Public
//
// Comparaison.
//
-
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + s:SELF;
s ?= other;
(s != NULL) && {text = s.text}
@@ -88,7 +88,7 @@ Section Public
- display buffer:STRING <-
(
buffer.add_last '\'';
- buffer.append text;
+ buffer.append text;
buffer.add_last '\'';
display_ref buffer;
);
diff --git a/src/constant/constant.li b/src/constant/constant.li
index 77da3dd..264c420 100644
--- a/src/constant/constant.li
+++ b/src/constant/constant.li
@@ -19,37 +19,37 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CONSTANT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all constants";
-
+
Section Inherit
-
- + parent_expr:Expanded EXPR;
-
+
+ + parent_expr:Expanded EXPR;
+
Section Public
//
// Comparison.
//
-
+
- is_constant:BOOLEAN <- TRUE;
-
+
- is_invariant:BOOLEAN <- TRUE;
-
+
//
// Typing.
//
-
+
+ static_type:TYPE_FULL;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add (static_type.raw);
);
@@ -59,17 +59,17 @@ Section Public
- remove <-
(
- // Nothing.
+ // Nothing.
);
-
+
- execute_unlink:INSTR <-
(
new_execute_pass;
NULL
);
-
+
- execute_link:EXPR <- Self;
-
+
diff --git a/src/constant/integer_cst.li b/src/constant/integer_cst.li
index d782b6e..1d30c60 100644
--- a/src/constant/integer_cst.li
+++ b/src/constant/integer_cst.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := INTEGER_CST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Integer constant";
-
+
Section Inherit
-
+
+ parent_constant:Expanded CONSTANT;
-
+
Section Public
//
@@ -39,22 +39,22 @@ Section Public
//
+ value:INTEGER_64;
-
+
- set_value new_value:INTEGER_64 <-
(
value := new_value;
check_type;
);
-
+
- to_power:INTEGER_64 <-
// 2^Result = self or else -1
( + result,val:INTEGER_64;
-
+
val := value;
(val = 0).if {
result := -1;
- } else {
- {(val & 1) = 0}.while_do {
+ } else {
+ {(val & 1) = 0}.while_do {
val := val >> 1;
result := result + 1;
};
@@ -64,17 +64,17 @@ Section Public
};
result
);
-
+
- is_signed:BOOLEAN <-
( + typ:STRING_CONSTANT;
-
- typ := static_type.raw.name;
+
+ typ := static_type.raw.name;
(typ = ALIAS_STR.prototype_integer_64) ||
{typ = ALIAS_STR.prototype_integer_32} ||
{typ = ALIAS_STR.prototype_integer_16} ||
{typ = ALIAS_STR.prototype_integer_8 }
);
-
+
- is_saturated:BOOLEAN <-
( + result:BOOLEAN;
@@ -95,9 +95,9 @@ Section Public
result := value = 0FFh;
};
};
- result
+ result
);
-
+
//
// Creation.
//
@@ -108,12 +108,12 @@ Section Public
result.make p value v type t;
result
);
-
+
- make p:POSITION value v:INTEGER_64 type t:TYPE_FULL <-
(
position := p;
value := v;
- static_type := t;
+ static_type := t;
check_type;
);
@@ -122,7 +122,7 @@ Section Public
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + p:INTEGER_CST;
p ?= other;
@@ -145,14 +145,14 @@ Section Public
//
- genere buffer:STRING <-
- (
- buffer.add_last ' ';
- value.append_in buffer;
+ (
+ buffer.add_last ' ';
+ value.append_in buffer;
(value > UINTEGER_32.maximum.to_integer_64).if {
buffer.append "LLU";
}.elseif {value > INTEGER.maximum.to_integer_64} then {
buffer.append "LU";
- };
+ };
);
//
@@ -167,13 +167,13 @@ Section Public
value.append_in buffer;
display_ref buffer;
);
-
+
Section Private
-
+
- check_type <-
( + error:BOOLEAN;
+ min,max:INTEGER_64;
-
+
// Check Range.
(static_type.raw.name)
.when (ALIAS_STR.prototype_uinteger_64) then {
@@ -204,7 +204,7 @@ Section Private
// Nothing. (Pb: BSBS : Can't range test.)
}
.when (ALIAS_STR.prototype_integer_32) then {
- ((value < INTEGER.minimum) || {value > INTEGER.maximum.to_integer_64}).if {
+ ((value < INTEGER.minimum) || {value > INTEGER.maximum.to_integer_64}).if {
error := TRUE;
min := INTEGER.minimum;
max := INTEGER.maximum.to_integer_64;
@@ -224,12 +224,12 @@ Section Private
max := INTEGER_8.maximum.to_integer_64;
};
};
-
+
(error).if {
string_tmp.copy "Invalid constant integer (";
value.append_in string_tmp;
string_tmp.append ") cast into ";
- static_type.append_name_in string_tmp;
+ static_type.append_name_in string_tmp;
string_tmp.append " [";
min.append_in string_tmp;
string_tmp.append "..";
@@ -242,7 +242,7 @@ Section Private
value := 0;
};
);
-
+
diff --git a/src/constant/native_array_character_cst.li b/src/constant/native_array_character_cst.li
index 7a10894..9b5646c 100644
--- a/src/constant/native_array_character_cst.li
+++ b/src/constant/native_array_character_cst.li
@@ -19,21 +19,21 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NATIVE_ARRAY_CHARACTER_CST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "String constant";
-
+
Section Inherit
-
+
+ parent_constant:Expanded CONSTANT;
-
+
Section Public
-
+
//
// Value.
//
@@ -50,7 +50,7 @@ Section Public
result.make p text n;
result
);
-
+
- make p:POSITION text n:STRING_CONSTANT <-
(
position := p;
@@ -63,8 +63,8 @@ Section Public
//
// Comparaison.
//
-
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + p:NATIVE_ARRAY_CHARACTER_CST;
p ?= other;
(p != NULL) && {string = p.string}
@@ -75,12 +75,12 @@ Section Public
//
- genere buffer:STRING <-
- (
+ (
buffer.add_last '\"';
buffer.append string;
buffer.add_last '\"';
);
-
+
//
// Display.
//
@@ -92,8 +92,8 @@ Section Public
buffer.add_last '\"';
display_ref buffer;
);
-
-
+
+
diff --git a/src/constant/prototype_cst.li b/src/constant/prototype_cst.li
index 71185ff..448d536 100644
--- a/src/constant/prototype_cst.li
+++ b/src/constant/prototype_cst.li
@@ -19,43 +19,43 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PROTOTYPE_CST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Prototype constant";
-
+
Section Inherit
-
+
+ parent_constant:Expanded CONSTANT;
-
+
Section Public
//
// Creation.
//
-
+
- create p:POSITION type t:TYPE_FULL :SELF<-
( + result:SELF;
? {p.code != 0};
? {t != NULL};
-
+
result := clone;
result.make p type t;
result
);
-
+
- make p:POSITION type t:TYPE_FULL <-
(
- position := p;
- static_type := t.to_strict;
+ position := p;
+ static_type := t.to_strict;
);
- - my_copy:SELF <-
- (
+ - my_copy:SELF <-
+ (
SELF.create position type static_type
);
@@ -63,21 +63,21 @@ Section Public
// Comparaison.
//
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + p:PROTOTYPE_CST;
p ?= other;
(p != NULL) && {static_type = p.static_type}
);
-
+
//
// Execute
//
-
+
- execute_link:EXPR <-
- (
+ (
Self
- );
-
+ );
+
//
// Generation.
//
@@ -94,7 +94,7 @@ Section Public
- display buffer:STRING <-
(
static_type.display buffer;
- display_ref buffer;
+ display_ref buffer;
);
-
+
diff --git a/src/constant/real_cst.li b/src/constant/real_cst.li
index a5fc56d..6c6c25e 100644
--- a/src/constant/real_cst.li
+++ b/src/constant/real_cst.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := REAL_CST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Real float constant";
-
+
Section Inherit
-
+
+ parent_constant:Expanded CONSTANT;
-
+
Section Public
//
@@ -39,7 +39,7 @@ Section Public
//
+ value:STRING_CONSTANT;
-
+
//
// Creation.
//
@@ -50,12 +50,12 @@ Section Public
result.make p value v type t;
result
);
-
+
- make p:POSITION value v:STRING_CONSTANT type t:TYPE_FULL <-
(
position := p;
value := v;
- static_type := t;
+ static_type := t;
);
- my_copy:SELF <- SELF.create position value value type static_type;
@@ -63,7 +63,7 @@ Section Public
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + p:REAL_CST;
p ?= other;
@@ -77,7 +77,7 @@ Section Public
- cast_type p:TYPE_FULL <-
(
? { p != type_real };
- static_type := p;
+ static_type := p;
);
//
@@ -101,8 +101,8 @@ Section Public
buffer.append value;
display_ref buffer;
);
-
-
+
+
diff --git a/src/constant/string_cst.li b/src/constant/string_cst.li
index 4e05965..751f27e 100644
--- a/src/constant/string_cst.li
+++ b/src/constant/string_cst.li
@@ -19,37 +19,37 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := STRING_CST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "String constant";
-
+
Section Inherit
-
+
+ parent_constant:Expanded CONSTANT;
-
+
Section Public
-
- - output:STRING :=
+
+ - output:STRING :=
( + result:STRING;
-
+
result := STRING.create 256;
title "STRING CONSTANT" in result;
result
);
-
+
- output_count:INTEGER;
-
+
//
// Value.
//
+ string:STRING_CONSTANT;
-
+
//
// Creation.
//
@@ -60,7 +60,7 @@ Section Public
result.make p text n length len;
result
);
-
+
- make p:POSITION text n:STRING_CONSTANT length len:INTEGER <-
(
position := p;
@@ -74,8 +74,8 @@ Section Public
//
// Comparaison.
//
-
- - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
+
+ - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + p:STRING_CST;
p ?= other;
(p != NULL) && {string = p.string}
@@ -86,24 +86,24 @@ Section Public
//
- genere buffer:STRING <-
- ( + idx,count,cur:INTEGER;
+ ( + idx,count,cur:INTEGER;
- is_init:BOOLEAN;
- is_storage:BOOLEAN;
- is_count:BOOLEAN;
-
+
(is_init).if_false {
is_storage := type_string_constant.get_local_slot (ALIAS_STR.slot_storage)
.slot_data_intern.ensure_count != 0;
is_count := type_string_constant.get_local_slot (ALIAS_STR.slot_count)
- .slot_data_intern.ensure_count != 0;
+ .slot_data_intern.ensure_count != 0;
is_init := TRUE;
};
-
+
count := dico_string.fast_at string;
(count >= 0).if {
output_count := output_count + 1;
idx := output_count;
-
+
cur := output.count - 1;
(is_java).if {
output.append "private static ";
@@ -120,7 +120,7 @@ Section Public
(static_type.is_late_binding).if {
output.append "__";
output.append (static_type.raw.intern_name);
- output.append "__,";
+ output.append "__,";
};
};
(is_count).if {
@@ -133,7 +133,7 @@ Section Public
{(output.count - cur) > 78}.while_do {
output.insert_string "\\\n" to (cur+78);
cur := cur + 78;
- };
+ };
output.add_last '\"';
} else {
output.remove_last 1;
@@ -150,14 +150,14 @@ Section Public
//
(is_java).if {
buffer.append "__string_";
- idx.append_in buffer;
+ idx.append_in buffer;
} else {
buffer.append "(&__string_";
idx.append_in buffer;
buffer.add_last ')';
};
);
-
+
//
// Display.
//
@@ -169,10 +169,10 @@ Section Public
buffer.add_last '\"';
display_ref buffer;
);
-
-Section Private
-
- - dico_string:HASHED_DICTIONARY(INTEGER,STRING_CONSTANT) :=
+
+Section Private
+
+ - dico_string:HASHED_DICTIONARY(INTEGER,STRING_CONSTANT) :=
HASHED_DICTIONARY(INTEGER,STRING_CONSTANT).create;
diff --git a/src/dispatcher/dta.li b/src/dispatcher/dta.li
index f81870a..1a9792f 100644
--- a/src/dispatcher/dta.li
+++ b/src/dispatcher/dta.li
@@ -19,62 +19,62 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all late binding";
-
+
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
-
+
Section Public
-
+
+ result_expr:EXPR;
-
+
+ slot:SLOT;
-
+
+ self_arg:EXPR;
-
+
+ context:LOCAL;
-
+
//
// Service
//
-
+
- remove <-
(
// Nothing.
);
-
+
//
// Display.
//
-
- - display buffer:STRING <-
+
+ - display buffer:STRING <-
(
buffer.append "DTA";
deferred;
);
-
-Section NODE_TYPE, DTA
-
+
+Section NODE_TYPE, DTA
+
- product t:TYPE with e:EXPR self type_self:TYPE_FULL :LIST <-
( + result:LIST;
-
+
result := LIST.create (e.position);
- (t = TYPE_NULL).if {
- TYPE_NULL.product_error position in result with context;
+ (t = TYPE_NULL).if {
+ TYPE_NULL.product_error position in result with context;
? {result.count != 0};
} else {
lookup t with e in result;
};
- result
- );
+ result
+ );
- update_branch l:LIST self type_self:TYPE_FULL :BOOLEAN <-
[
@@ -82,12 +82,12 @@ Section NODE_TYPE, DTA
]
( + node:NODE;
+ result:BOOLEAN;
-
+
node ?= l.first;
(node = NULL).if {
result := TRUE;
} else {
-
+
/*
"DTA: ".print;
type_self.print;
@@ -101,43 +101,43 @@ Section NODE_TYPE, DTA
};
result
);
-
-Section NODE_STYLE, SELF
-
- - get_argument:FAST_ARRAY(EXPR) <-
+
+Section NODE_STYLE, SELF
+
+ - get_argument:FAST_ARRAY(EXPR) <-
( + result:FAST_ARRAY(EXPR);
-
+
result := FAST_ARRAY(EXPR).create_with_capacity 1;
result.add_last (self_arg.my_copy);
result
);
-
+
Section DTA
-
- - finalise typ:TYPE with (expr:EXPR,s:SLOT) in lst:LIST <-
+
+ - finalise typ:TYPE with (expr:EXPR,s:SLOT) in lst:LIST <-
( + node:NODE_STYLE;
-
+
node := NODE_STYLE.create (expr.my_copy,s) with Self result result_expr;
- lst.add_last node;
+ lst.add_last node;
);
-
+
Section Private
-
+
- lookup typ:TYPE with expr:EXPR in lst:LIST <-
( + s:SLOT;
+ name:STRING_CONSTANT;
+ node_style:NODE_STYLE;
+ r:EXPR;
-
+
name := slot.name;
- s := typ.get_local_slot name;
+ s := typ.get_local_slot name;
(s = NULL).if {
- // Lookup parent.
- s := typ.get_path_slot name;
+ // Lookup parent.
+ s := typ.get_path_slot name;
r := s.result_type.get_expr_for typ;
node_style := NODE_STYLE.create (expr.my_copy,s) with Self result r;
lst.add_last node_style;
- lst.add_last (NODE_TYPE.create r with Self);
+ lst.add_last (NODE_TYPE.create r with Self);
} else {
// Direct call.
s.is_equal_profil slot;
diff --git a/src/dispatcher/dta_block.li b/src/dispatcher/dta_block.li
index 18de214..85ba921 100644
--- a/src/dispatcher/dta_block.li
+++ b/src/dispatcher/dta_block.li
@@ -19,73 +19,73 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA_BLOCK;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Lisaac IS A Advanced Compiler";
-
+
Section Inherit
-
+
+ parent_dta_rd_args:Expanded DTA_RD_ARGS;
-
+
Section Public
-
+
+ result_expr:EXPR;
-
+
// Add.
-
+
+ model:TYPE_BLOCK;
-
+
//
// Creation.
//
-
+
- create mod:TYPE_BLOCK with larg:FAST_ARRAY(EXPR) :SELF <-
( + result:SELF;
- result := clone;
+ result := clone;
result.make mod with larg;
- result
+ result
);
-
+
- make mod:TYPE_BLOCK with larg:FAST_ARRAY(EXPR) <-
[ -? {mod.position != 0}; ]
- (
+ (
(profil_current = NULL).if {
context := context_main;
} else {
context := profil_current.context;
- };
+ };
model := mod;
position := mod.position;
argument_list := larg;
- result_expr := mod.get_expr_for (mod.position);
+ result_expr := mod.get_expr_for (mod.position);
);
-
+
//
// Display.
//
-
- - display buffer:STRING <-
+
+ - display buffer:STRING <-
(
buffer.append "DTA_BLOCK";
);
-Section NODE_STYLE, SELF
-
- - get_argument:FAST_ARRAY(EXPR) <-
+Section NODE_STYLE, SELF
+
+ - get_argument:FAST_ARRAY(EXPR) <-
( + result:FAST_ARRAY(EXPR);
+ rd:READ_SLOT;
(copy_argument).if {
- result := FAST_ARRAY(EXPR).create_with_capacity (argument_list.count);
+ result := FAST_ARRAY(EXPR).create_with_capacity (argument_list.count);
rd ?= argument_list.first;
result.add_last (rd.receiver.my_copy);
- (argument_list.lower+1).to (argument_list.upper) do { j:INTEGER;
+ (argument_list.lower+1).to (argument_list.upper) do { j:INTEGER;
result.add_last (argument_list.item j.my_copy);
- };
+ };
} else {
result := argument_list;
copy_argument := TRUE;
@@ -93,62 +93,62 @@ Section NODE_STYLE, SELF
result
);
-Section NODE_TYPE, DTA
-
+Section NODE_TYPE, DTA
+
- product t:TYPE with e:EXPR self type_self:TYPE_FULL :LIST <-
( + result:LIST;
+ t_block:PROFIL_BLOCK;
- + wrt:WRITE;
+ + wrt:WRITE;
+ wrt_larg:FAST_ARRAY(WRITE);
+ call:CALL_SLOT;
+ em:EXPR_MULTIPLE;
+ rd:READ;
+ result_var:VARIABLE;
-
+
result := LIST.create (e.position);
- (t = TYPE_NULL).if {
+ (t = TYPE_NULL).if {
TYPE_NULL.product_error (e.position) in result with context;
- } else {
- t_block ?= t;
-
-
- (t_block = NULL).if { // BSBS: debug
+ } else {
+ t_block ?= t;
+
+
+ (t_block = NULL).if { // BSBS: debug
"<<<".print;
t.print;
">>>".print; '\n'.print;
list_current.debug_display;
- syntax_error (argument_list.first.position,"Block not found");
+ syntax_error (argument_list.first.position,"Block not found");
};
-
+
wrt_larg := t_block.write_argument get_argument;
- call := CALL_SLOT.create (e.position) profil t_block with wrt_larg cop NULL;
- (result_expr.static_type.raw != TYPE_VOID).if {
+ call := CALL_SLOT.create (e.position) profil t_block with wrt_larg cop NULL;
+ (result_expr.static_type.raw != TYPE_VOID).if {
em ?= result_expr;
(em != NULL).if {
(em.lower).to (em.upper) do { j:INTEGER;
rd ?= em.item j;
? {rd != NULL};
- result_var := rd.variable;
+ result_var := rd.variable;
rd := call.profil.result_list.item j.read (e.position);
wrt := result_var.write (e.position) value rd;
- call.result_list.add_last (RESULT.create wrt);
- };
+ call.result_list.add_last (RESULT.create wrt);
+ };
} else {
rd ?= result_expr;
- result_var := rd.variable;
+ result_var := rd.variable;
rd := call.profil.result_list.first.read (e.position);
wrt := result_var.write (e.position) value rd;
- call.result_list.add_last (RESULT.create wrt);
- };
+ call.result_list.add_last (RESULT.create wrt);
+ };
};
result.add_last call;
};
- result
- );
-
+ result
+ );
+
- update_branch l:LIST self type_self:TYPE_FULL :BOOLEAN <-
(
TRUE
);
-
+
diff --git a/src/dispatcher/dta_cast.li b/src/dispatcher/dta_cast.li
index e8108f8..a060027 100644
--- a/src/dispatcher/dta_cast.li
+++ b/src/dispatcher/dta_cast.li
@@ -19,36 +19,36 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA_CAST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Cast base";
-
+
Section Inherit
-
+
- parent_dta:DTA := DTA;
-
+
Section Public
+ result_expr:EXPR;
-
+
//
// Creation.
//
-
+
- create p:POSITION type t:TYPE_FULL :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
-
+
result := clone;
result.make p type t;
result
);
-
+
- make p:POSITION type t:TYPE_FULL <-
(
position := p;
@@ -63,24 +63,24 @@ Section Public
//
// Display.
//
-
- - display buffer:STRING <-
+
+ - display buffer:STRING <-
(
buffer.append "DTA_CAST";
);
-
+
//
// Service
//
-
-Section NODE_TYPE, DTA
-
+
+Section NODE_TYPE, DTA
+
- product t:TYPE with e:EXPR self type_self:TYPE_FULL :LIST <-
( + cast:LOCAL;
+ rd:READ;
+ new_value:EXPR;
+ result:LIST;
-
+
result := LIST.create (e.position);
rd ?= result_expr;
cast ?= rd.variable;
@@ -89,7 +89,7 @@ Section NODE_TYPE, DTA
(cast.type.raw = t).if {
new_value := CAST.create (cast.type) value (e.my_copy);
};
- }.elseif {t.is_sub_type (cast.type.raw)} then {
+ }.elseif {t.is_sub_type (cast.type.raw)} then {
new_value := CAST.create (t.default) value (e.my_copy);
};
};
@@ -100,7 +100,7 @@ Section NODE_TYPE, DTA
result.add_last (PROTOTYPE_CST.create (e.position) type (TYPE_VOID.default)); // BSBS : Alias.
result
);
-
+
- update_branch l:LIST self type_self:TYPE_FULL :BOOLEAN <-
(
TRUE
diff --git a/src/dispatcher/dta_rd.li b/src/dispatcher/dta_rd.li
index 42e00b2..2af514b 100644
--- a/src/dispatcher/dta_rd.li
+++ b/src/dispatcher/dta_rd.li
@@ -19,59 +19,59 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA_RD;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Read site";
-
+
Section Inherit
-
+
+ parent_dta:Expanded DTA;
-
- - parent_parameter_to_type:Expanded PARAMETER_TO_TYPE;
-
+
+ - parent_parameter_to_type:Expanded PARAMETER_TO_TYPE;
+
Section Public
-
+
+ is_intern:BOOLEAN;
-
+
- parameter_to_type p:ITM_TYPE_PARAMETER :TYPE_FULL <-
( + result:TYPE_FULL;
-
+
(p.name = ALIAS_STR.prototype_self).if {
// For Self.
- result := self_arg.static_type;
+ result := self_arg.static_type;
} else {
- // For genericity.
+ // For genericity.
result := slot.receiver_type.parameter_to_type p;
- //result := self_arg.static_type.raw.parameter_to_type p;
+ //result := self_arg.static_type.raw.parameter_to_type p;
};
-
+
result
);
-
+
//
// Creation.
//
-
+
- create p:POSITION call sl:SLOT self arg:EXPR intern flag:BOOLEAN :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
-
+
result := clone;
- result.make p call sl self arg intern flag;
+ result.make p call sl self arg intern flag;
result
);
-
+
- make p:POSITION call sl:SLOT self arg:EXPR intern flag:BOOLEAN <-
- ( ? {sl != NULL};
- position := p;
+ ( ? {sl != NULL};
+ position := p;
slot := sl;
- self_arg := arg;
- result_expr := get_expr_result;
+ self_arg := arg;
+ result_expr := get_expr_result;
is_intern := flag;
(profil_current = NULL).if {
context := context_main;
@@ -79,24 +79,24 @@ Section Public
context := profil_current.context;
};
);
-
+
//
//
//
-
+
- display buffer:STRING <-
(
buffer.append "DTA_READ";
);
-
+
Section DTA_RD
-
+
- get_expr_result:EXPR <-
( + result:EXPR;
-
+
(slot.id_section.is_interrupt).if {
result := type_pointer.default.get_temporary_expr position;
- } else {
+ } else {
result := slot.result_type.get_expr_for Self;
};
result
diff --git a/src/dispatcher/dta_rd_args.li b/src/dispatcher/dta_rd_args.li
index d218cdc..4357ce2 100644
--- a/src/dispatcher/dta_rd_args.li
+++ b/src/dispatcher/dta_rd_args.li
@@ -19,38 +19,38 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA_RD_ARGS;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Read site with arguments";
-
+
Section Inherit
-
+
+ parent_dta_rd:Expanded DTA_RD;
-
+
Section Public
-
+
- self_arg:EXPR <- argument_list.first;
-
+
// Add.
-
+
+ argument_list:FAST_ARRAY(EXPR);
-
+
+ copy_argument:BOOLEAN;
-
+
- parameter_to_type p:ITM_TYPE_PARAMETER :TYPE_FULL <-
( + result:TYPE_FULL;
+ idx:INTEGER;
- // For Genericity.
+ // For Genericity.
result := slot.receiver_type.parameter_to_type p;
(result = NULL).if {
// For Self + type parametric.
idx := slot.get_index_argument_type p;
- (idx != - 1).if {
+ (idx != - 1).if {
result := argument_list.item idx.static_type;
};
};
@@ -60,42 +60,42 @@ Section Public
//
// Creation.
//
-
+
- create p:POSITION call sl:SLOT with args:FAST_ARRAY(EXPR) intern flag:BOOLEAN :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
-
+
result := clone;
result.make p call sl with args intern flag;
result
);
-
+
- make p:POSITION call sl:SLOT with args:FAST_ARRAY(EXPR) intern flag:BOOLEAN <-
(
- position := p;
+ position := p;
slot := sl;
argument_list := args;
result_expr := get_expr_result;
- is_intern := flag;
+ is_intern := flag;
(profil_current = NULL).if {
context := context_main;
} else {
context := profil_current.context;
};
);
-
+
//
// Just for ITM_EXPRESSION
//
-
+
- create_partial p:POSITION call sl:SLOT :SELF <-
( + result:SELF;
-
+
result := clone;
result.make_partial p call sl;
result
);
-
+
- make_partial p:POSITION call sl:SLOT <-
(
position := p;
@@ -105,13 +105,13 @@ Section Public
//
// Display.
//
-
- - display buffer:STRING <-
+
+ - display buffer:STRING <-
(
buffer.append "DTA_RD_ARGS:";
buffer.append (slot.name);
);
-
+
//
// Service
//
@@ -125,21 +125,21 @@ Section Public
copy_argument := TRUE;
};
);
-
-Section NODE_STYLE, SELF
-
- - get_argument:FAST_ARRAY(EXPR) <-
+
+Section NODE_STYLE, SELF
+
+ - get_argument:FAST_ARRAY(EXPR) <-
( + result:FAST_ARRAY(EXPR);
-
+
(copy_argument).if {
- result := FAST_ARRAY(EXPR).create_with_capacity (argument_list.count);
- (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
+ result := FAST_ARRAY(EXPR).create_with_capacity (argument_list.count);
+ (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
result.add_last (argument_list.item j.my_copy);
- };
+ };
} else {
result := argument_list;
copy_argument := TRUE;
};
result
);
-
+
diff --git a/src/dispatcher/dta_wr_code.li b/src/dispatcher/dta_wr_code.li
index 1d638eb..00791af 100644
--- a/src/dispatcher/dta_wr_code.li
+++ b/src/dispatcher/dta_wr_code.li
@@ -19,38 +19,38 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA_WR_CODE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write site with code";
-
+
Section Inherit
-
+
+ parent_dta:Expanded DTA;
-
+
Section Public
// Add.
-
+
+ code:ITM_CODE;
-
+
//
// Creation.
//
-
+
- create p:POSITION slot sl:SLOT self arg:EXPR code v:ITM_CODE :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
-
+
result := clone;
result.make p slot sl self arg code v;
result
);
-
+
- make p:POSITION slot sl:SLOT self arg:EXPR code v:ITM_CODE <-
(
position := p;
@@ -68,23 +68,23 @@ Section Public
//
// Display.
//
-
- - display buffer:STRING <-
+
+ - display buffer:STRING <-
(
buffer.append "DTA_WR_CODE:";
- buffer.append (slot.name);
+ buffer.append (slot.name);
);
-
+
//
// Service
//
-
-Section DTA
-
- - finalise typ:TYPE with (expr:EXPR,s:SLOT) in lst:LIST <-
+
+Section DTA
+
+ - finalise typ:TYPE with (expr:EXPR,s:SLOT) in lst:LIST <-
( + id:PROTOTYPE_CST;
+ pos:POSITION;
-
+
pos := expr.position;
id := PROTOTYPE_CST.create pos type (TYPE_ID.get_index (s.add_style code).default);
(s.style = '+').if {
@@ -93,4 +93,4 @@ Section DTA
lst.add_last (s.slot_id.write pos value id);
};
);
-
+
diff --git a/src/dispatcher/dta_wr_value.li b/src/dispatcher/dta_wr_value.li
index 7a0e9d9..dbd59c4 100644
--- a/src/dispatcher/dta_wr_value.li
+++ b/src/dispatcher/dta_wr_value.li
@@ -19,46 +19,46 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := DTA_WR_VALUE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write site with value";
-
+
Section Inherit
-
+
+ parent_dta:Expanded DTA;
-
+
Section Public
// Add.
-
+
+ value:EXPR;
-
+
+ copy_value:BOOLEAN;
//
// Creation.
//
-
+
- create p:POSITION slot sl:SLOT self arg:EXPR value v:EXPR :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
-
+
result := clone;
result.make p slot sl self arg value v;
result
);
-
+
- make p:POSITION slot sl:SLOT self arg:EXPR value v:EXPR <-
(
- position := p;
+ position := p;
slot := sl;
self_arg := arg;
- result_expr := v.my_copy;
+ result_expr := v.my_copy;
value := v;
(profil_current = NULL).if {
context := context_main;
@@ -70,13 +70,13 @@ Section Public
//
// Display.
//
-
- - display buffer:STRING <-
+
+ - display buffer:STRING <-
(
buffer.append "DTA_WR_VALUE:";
- buffer.append (slot.name);
+ buffer.append (slot.name);
);
-
+
//
// Service
//
@@ -88,31 +88,31 @@ Section Public
copy_value := TRUE;
};
);
-
-Section NODE_TYPE, DTA
+
+Section NODE_TYPE, DTA
- product t:TYPE with e:EXPR self type_self:TYPE_FULL :LIST <-
( + result:LIST;
-
+
result := LIST.create (e.position);
(t = TYPE_NULL).if {
TYPE_NULL.product_error position in result with context;
} else {
lookup t with e in result;
};
- result
- );
+ result
+ );
- update_branch l:LIST self type_self:TYPE_FULL :BOOLEAN <-
- ( + result:BOOLEAN;
+ ( + result:BOOLEAN;
+ wrt_slot:WRITE_SLOT;
+ wrt_glob:WRITE_GLOBAL;
-
+
result := parent_dta.update_branch l self type_self;
(l.count < 3).if {
- wrt_slot ?= l.first;
- wrt_glob ?= l.first;
- (wrt_slot != NULL).if {
+ wrt_slot ?= l.first;
+ wrt_glob ?= l.first;
+ (wrt_slot != NULL).if {
(wrt_slot.slot.slot_id != NULL).if {
add_write_id (wrt_slot.receiver,wrt_slot.slot) in l;
} else {
@@ -127,15 +127,15 @@ Section NODE_TYPE, DTA
};
};
result
- );
-
+ );
+
Section DTA
-
- - finalise typ:TYPE with (expr:EXPR,s:SLOT) in lst:LIST <-
+
+ - finalise typ:TYPE with (expr:EXPR,s:SLOT) in lst:LIST <-
( + new_value:EXPR;
+ sd:SLOT_DATA;
+ em:EXPR_MULTIPLE;
-
+
(copy_value).if {
new_value := value.my_copy;
} else {
@@ -144,10 +144,10 @@ Section DTA
};
sd := s.slot_data;
em ?= new_value;
- (em != NULL).if {
+ (em != NULL).if {
(em.lower).to (em.upper - 1) do { j:INTEGER;
lst.add_last (new_write (s.slot_data_list.item j) rec expr value (em.item j));
- };
+ };
new_value := em.last;
};
lst.add_last (new_write sd rec expr value new_value);
@@ -155,22 +155,22 @@ Section DTA
add_write_id (expr,s) in lst;
};
);
-
+
Section Private
-
+
- add_write_id (e:EXPR,s:SLOT) in lst:LIST <-
( + new_value:EXPR;
+ sd:SLOT_DATA;
-
+
new_value := PROTOTYPE_CST.create (lst.position) type (TYPE_ID.get_index 0.default);
sd := s.slot_id;
- lst.add (new_write sd rec e value new_value) to 2;
+ lst.add (new_write sd rec e value new_value) to 2;
);
-
+
- new_write sd:SLOT_DATA rec e:EXPR value val:EXPR :WRITE <-
( + result:WRITE;
-
- (sd.style = '+').if {
+
+ (sd.style = '+').if {
result := sd.write (e.position) with (e.my_copy) value val;
} else {
result := sd.write (e.position) value val;
diff --git a/src/dispatcher/node.li b/src/dispatcher/node.li
index f0eb0d4..780b9b9 100644
--- a/src/dispatcher/node.li
+++ b/src/dispatcher/node.li
@@ -19,113 +19,113 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NODE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all switch node";
-
+
Section Inherit
-
+
+ parent_instr:Expanded INSTR;
-
+
Section NODE, PROFIL_BLOCK, ITM_OLD
-
+
- node_list_base:LINKED_LIST(NODE_TYPE) := node_list;
-
+
- node_list:LINKED_LIST(NODE_TYPE) := LINKED_LIST(NODE_TYPE).create;
-
+
- set_node_list l:LINKED_LIST(NODE_TYPE) <-
(
node_list := l;
);
-
-Section PROTOTYPE
-
+
+Section PROTOTYPE
+
- extend_pass <-
( + j:INTEGER;
+ is_ok:BOOLEAN;
-
+
VARIABLE.update;
- j := node_list.lower;
+ j := node_list.lower;
{j <= node_list.upper}.while_do {
- is_ok := node_list.item j.update;
+ is_ok := node_list.item j.update;
(is_ok).if {
node_list.remove j;
- } else {
+ } else {
j := j + 1;
- };
- };
+ };
+ };
);
-
+
Section Public
-
+
//
// Extern Creation read.
//
-
- - new_read p:POSITION slot s:SLOT receiver rec:EXPR
+
+ - new_read p:POSITION slot s:SLOT receiver rec:EXPR
self my_self:EXPR intern is_intern:BOOLEAN :NODE <-
( + result:NODE_TYPE;
+ dta:DTA_RD;
- //
+ //
dta := DTA_RD.create p call s self my_self intern is_intern;
result := NODE_TYPE.create rec with dta;
- //
+ //
node_list.add_last result;
result
);
- - new_read p:POSITION slot s:SLOT receiver rec:EXPR
+ - new_read p:POSITION slot s:SLOT receiver rec:EXPR
with larg:FAST_ARRAY(EXPR) intern is_intern:BOOLEAN :NODE <-
- ( + dta:DTA_RD_ARGS;
+ ( + dta:DTA_RD_ARGS;
+ result:NODE_TYPE;
-
- // Control argument type.
+
+ // Control argument type.
dta := DTA_RD_ARGS.create p call s with larg intern is_intern;
- s.check_argument_type larg for dta;
+ s.check_argument_type larg for dta;
result := NODE_TYPE.create rec with dta;
- //
+ //
node_list.add_last result;
result
);
-
+
//
// Just for ITM_EXPRESSION.
//
-
+
- new_read_partial p:POSITION slot s:SLOT :NODE_TYPE <-
- ( + dta:DTA_RD_ARGS;
-
+ ( + dta:DTA_RD_ARGS;
+
dta := DTA_RD_ARGS.create_partial p call s;
NODE_TYPE.create_partial dta
);
-
+
- new_read_finalize (rec:EXPR,s:SLOT) with larg:FAST_ARRAY(EXPR) <-
- ( + dta:DTA_RD_ARGS;
- // Control argument type.
+ ( + dta:DTA_RD_ARGS;
+ // Control argument type.
dta ?= data;
-
+
dta.make (data.position) call s with larg intern FALSE;
- data.slot.check_argument_type larg for dta;
+ data.slot.check_argument_type larg for dta;
make rec with data;
- //
+ //
node_list.add_last Self;
);
-
+
//
// Extern creation writes.
//
-
+
- new_write p:POSITION slot s:SLOT receiver rec:EXPR value val:EXPR :NODE <-
- ( + dta:DTA_WR_VALUE;
+ ( + dta:DTA_WR_VALUE;
+ result:NODE_TYPE;
-
+
dta := DTA_WR_VALUE.create p slot s self rec value val;
result := NODE_TYPE.create rec with dta;
- //
+ //
node_list.add_last result;
result
);
@@ -133,54 +133,54 @@ Section Public
- new_write p:POSITION slot s:SLOT receiver rec:EXPR code val:ITM_CODE :NODE <-
( + dta:DTA_WR_CODE;
+ result:NODE_TYPE;
-
+
dta := DTA_WR_CODE.create p slot s self rec code val;
result := NODE_TYPE.create rec with dta;
//
node_list.add_last result;
result
);
-
+
//
// Extern creation cast.
//
-
- - new_cast p:POSITION type typ:TYPE_FULL with val:EXPR :NODE <-
+
+ - new_cast p:POSITION type typ:TYPE_FULL with val:EXPR :NODE <-
[ -? {p != 0}; ]
( + dta:DTA_CAST;
+ result:NODE_TYPE;
-
+
dta := DTA_CAST.create p type typ;
result := NODE_TYPE.create val with dta;
//
node_list.add_last result;
result
);
-
+
//
// Extern creation value block.
//
-
+
- new_block p:POSITION receiver e:EXPR with larg:FAST_ARRAY(EXPR) :NODE <-
( + dta:DTA_BLOCK;
- + result:NODE_TYPE;
+ + result:NODE_TYPE;
+ lst_typ_f:FAST_ARRAY(TYPE_FULL);
+ new_expr:EXPR;
+ block_model:TYPE_BLOCK;
+ pb:PROFIL_BLOCK;
+ pos:POSITION;
-
+
pb ?= e.static_type.raw;
(pb = NULL).if {
block_model ?= e.static_type.raw;
} else {
- block_model := pb.to_type_block;
+ block_model := pb.to_type_block;
};
- // Control argument type.
+ // Control argument type.
lst_typ_f := block_model.argument_list;
pos := block_model.position;
-
- (lst_typ_f.count+1 != larg.count).if {
+
+ (lst_typ_f.count+1 != larg.count).if {
string_tmp.copy "Incorrect size of vector argument for this block. (Value:";
larg.count.append_in string_tmp;
string_tmp.append ", Type:";
@@ -190,12 +190,12 @@ Section Public
pos.put_position;
p .put_position;
POSITION.send_error;
- };
- (larg.lower + 1).to (larg.upper) do { j:INTEGER;
+ };
+ (larg.lower + 1).to (larg.upper) do { j:INTEGER;
new_expr := larg.item j.check_type (lst_typ_f.item (j-1)) with pos;
larg.put new_expr to j;
};
- //
+ //
(debug_level_option != 0).if {
(profil_current = NULL).if {
crash_with_message "NODE";
@@ -206,30 +206,30 @@ Section Public
};
//
dta := DTA_BLOCK.create block_model with larg;
- result := NODE_TYPE.create e with dta;
+ result := NODE_TYPE.create e with dta;
//
node_list.add_last result;
result
);
-
-Section Public
-
- - position:POSITION <-
- (
+
+Section Public
+
+ - position:POSITION <-
+ (
data.position
);
-
+
+ data:DTA;
-
- + expr:EXPR;
-
+
+ + expr:EXPR;
+
+ first_code:LIST;
- + first_type:TYPE;
+ + first_type:TYPE;
+ switch:SWITCH;
-
- - count:INTEGER <-
+
+ - count:INTEGER <-
( + result:INTEGER;
-
+
(switch != NULL).if {
result := switch.count;
}.elseif {first_type != NULL} then {
@@ -237,69 +237,69 @@ Section Public
};
result
);
-
+
- result_expr:EXPR <- deferred;
-
+
//
// Execute.
//
-
+
- remove <-
(
data.remove;
- (switch = NULL).if {
+ (switch = NULL).if {
expr.remove;
(first_code != NULL).if {
first_code.remove;
};
- } else {
+ } else {
switch.remove;
};
);
-
+
- execute:INSTR <-
( + result:INSTR;
data.remove;
(switch != NULL).if {
- result := switch.execute;
- } else {
- expr.remove;
+ result := switch.execute;
+ } else {
+ expr.remove;
(first_code != NULL).if { // Warning: Dead Code!
result := first_code.execute;
};
};
result
);
-
+
- genere buffer:STRING <-
(
"Genere NODE!\n".print;
crash;
);
-
-
-Section NODE, DTA
+
+
+Section NODE, DTA
//
// Update.
//
-
+
- update_link self_type:TYPE_FULL :BOOLEAN <-
(
deferred;
);
-
+
Section Public
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
(switch = NULL).if {
- (first_code = NULL).if {
+ (first_code = NULL).if {
to_pointer.append_in buffer;
buffer.append "<NODE VIDE=";
expr.display buffer;
@@ -316,4 +316,4 @@ Section Public
switch.display buffer;
};
);
-
+
diff --git a/src/dispatcher/node_style.li b/src/dispatcher/node_style.li
index 396b074..42ae8a6 100644
--- a/src/dispatcher/node_style.li
+++ b/src/dispatcher/node_style.li
@@ -19,61 +19,61 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NODE_STYLE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Switch node for style";
-
+
Section Inherit
-
+
+ parent_node:Expanded NODE;
-
+
Section Public
-
+
+ result_expr:EXPR;
-
+
+ slot:SLOT;
Section NODE, DTA
-
+
//
// Creation.
//
-
+
- create (e:EXPR,sl:SLOT) with dta:DTA result r:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make (e,sl) with dta result r;
result
);
-
+
- make (e:EXPR,sl:SLOT) with dta:DTA result r:EXPR <-
- (
+ (
expr := e;
slot := sl;
data := dta;
result_expr := r;
);
-
+
Section Public
-
- - my_copy:SELF <-
- (
+
+ - my_copy:SELF <-
+ (
crash_with_message "NODE_STYLE.my_copy";
- NULL
+ NULL
);
-
-Section NODE, DTA
-
+
+Section NODE, DTA
+
//
// Update.
//
-
+
- update_link self_type:TYPE_FULL :BOOLEAN <-
[
-? {self_type != NULL};
@@ -83,15 +83,15 @@ Section NODE, DTA
+ case:CASE;
+ e:EXPR;
+ low,up,count:INTEGER;
-
+
(slot.slot_id = NULL).if {
(first_code = NULL).if {
first_type := TYPE_ID.get_index (slot.lower_style);
- first_code := call_for first_type self self_type;
+ first_code := call_for first_type self self_type;
};
- } else {
+ } else {
low := slot.lower_style;
- up := slot.upper_style;
+ up := slot.upper_style;
count := up-low + 1;
(switch = NULL).if {
(slot.style = '-').if {
@@ -104,21 +104,21 @@ Section NODE, DTA
};
list := switch.list;
(list.count != count).if {
- 0.to (count-1) do { j:INTEGER;
+ 0.to (count-1) do { j:INTEGER;
typ := TYPE_ID.get_index (j+low);
-
+
((j > list.upper) || {typ != list.item j.id}).if {
case := CASE.create typ with (call_for typ self self_type);
list.add case to j;
- };
- };
+ };
+ };
};
};
FALSE
);
-
-Section Private
-
+
+Section Private
+
- call_for t:TYPE self type_self:TYPE_FULL :LIST <-
[
-? {type_self != NULL};
@@ -128,12 +128,12 @@ Section Private
+ call:CALL_SLOT;
+ em:EXPR_MULTIPLE;
+ rd:READ;
- + wrt:WRITE;
+ + wrt:WRITE;
+ result_var:VARIABLE;
- + new_larg:FAST_ARRAY(EXPR);
+ + new_larg:FAST_ARRAY(EXPR);
+ slot_dta:SLOT_DATA;
+ slot_cod:SLOT_CODE;
- + idx:INTEGER;
+ + idx:INTEGER;
+ type:TYPE_FULL;
+ my_profil:PROFIL;
+ wrt_lst:FAST_ARRAY(WRITE);
@@ -143,23 +143,23 @@ Section Private
+ cop_arg:EXPR;
+ new_val:EXPR;
+ val:EXPR;
-
+
result := LIST.create position;
-
- data_rd ?= data;
+
+ data_rd ?= data;
((type_self.prototype.style = '-') && {data_rd != NULL} && {! data_rd.is_intern}).if {
cop_arg := data.self_arg.my_copy;
};
-
+
typ ?= t;
- idx := typ.index;
+ idx := typ.index;
(idx = 0).if {
- // Data.
+ // Data.
(cop_arg != NULL).if {
result.add_last (COP_LOCK.create position with cop_arg);
};
//
- slot_dta := slot.slot_data;
+ slot_dta := slot.slot_data;
slot_dta.init;
(slot.slot_data_list != NULL).if {
(slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { j:INTEGER;
@@ -171,40 +171,40 @@ Section Private
// BSBS: Pourquoi tu produit quelque chose qui serre à rien ???
(slot_dta.style = '-').if {
result.add_last (slot_dta.read position);
- } else {
+ } else {
result.add_last (slot_dta.read position with (expr.my_copy));
- };
- } else {
+ };
+ } else {
em ?= result_expr;
(em != NULL).if {
(em.lower).to (em.upper - 1) do { j:INTEGER;
rd ?= em.item j;
? {rd != NULL};
- result_var := rd.variable;
- result.add_last (new_write result_var with (expr,slot.slot_data_list.item j));
+ result_var := rd.variable;
+ result.add_last (new_write result_var with (expr,slot.slot_data_list.item j));
};
rd ?= em.last;
} else {
rd ?= result_expr;
- };
-
+ };
+
//(slot_dta.name == "storage").if {
/*
string_tmp.clear;
string_tmp.copy (type_self.raw.name);
string_tmp.add_last ' ';
- string_tmp.append (t.name);
+ string_tmp.append (t.name);
(data.slot != NULL).if {
string_tmp.add_last ' ';
- string_tmp.append (data.slot.name);
+ string_tmp.append (data.slot.name);
};
result.add_last (
EXTERNAL_C.create position text (ALIAS_STR.get string_tmp) access NULL persistant TRUE type (TYPE_NULL.default)
);
- */
+ */
/*
- "Data : ".print; slot_dta.intern_name.print;
- " dans ".print; type_self.raw.name.print;
+ "Data : ".print; slot_dta.intern_name.print;
+ " dans ".print; type_self.raw.name.print;
(profil_current != NULL).if {
profil_current.name.print;
};
@@ -215,21 +215,21 @@ Section Private
result.add_last (new_write result_var with (expr,slot_dta));
};
(cop_arg != NULL).if {
- result.add_last (COP_UNLOCK.create position);
+ result.add_last (COP_UNLOCK.create position);
};
} else {
// Function.
- slot_cod := slot.slot_code idx;
+ slot_cod := slot.slot_code idx;
(slot_cod.id_section.is_inherit_or_insert).if {
new_larg := FAST_ARRAY(EXPR).create_with_capacity 1;
new_larg.add_last (data.self_arg.my_copy);
} else {
new_larg := data.get_argument;
};
- type := new_larg.first.static_type;
+ type := new_larg.first.static_type;
? {type != NULL};
- //
- (debug_level_option != 0).if {
+ //
+ (debug_level_option != 0).if {
// BSBS: Poser le PUSH avant le NODE
//(data.context = NULL).if {
// ctext := context_main;
@@ -237,19 +237,19 @@ Section Private
(data.context = NULL).if {
crash_with_message "NODE_STYLE : data.context = NULL!\n";
};
-
+
ctext := data.context;
//};
result.add_last (
PUSH.create position context ctext first FALSE
- );
+ );
};
//
- rd ?= new_larg.first;
+ rd ?= new_larg.first;
((rd != NULL) && {rd.variable.name = ALIAS_STR.variable_self}).if {
- // Fix Self type for resend call (else it's fixed by NODE_TYPE)
- new_type_self := type;
- } else {
+ // Fix Self type for resend call (else it's fixed by NODE_TYPE)
+ new_type_self := type;
+ } else {
new_type_self := type_self;
};
/*
@@ -258,16 +258,16 @@ Section Private
string_tmp.append " / ";
type_self.display string_tmp;
result.add_last (
- EXTERNAL_C.create (data.position)
+ EXTERNAL_C.create (data.position)
text (ALIAS_STR.get string_tmp) access NULL persistant TRUE type (TYPE_VOID.default)
);
*/
new_val := CAST.create new_type_self value (new_larg.first);
- new_larg.put new_val to 0;
-
-
+ new_larg.put new_val to 0;
+
+
/*
- (new_larg.lower+1).to (new_larg.upper) do { j:INTEGER;
+ (new_larg.lower+1).to (new_larg.upper) do { j:INTEGER;
ts ?= slot_cod.get_argument_type j;
((ts != NULL) && {ts = ITM_TYPE_SIMPLE.type_self}).if {
(new_larg.item j.static_type != new_type_self).if {
@@ -276,9 +276,9 @@ Section Private
ts.print;
string_tmp.clear;
(slot_cod.argument_list.lower).to (slot_cod.argument_list.upper) do { h:INTEGER;
- slot_cod.argument_list.item h.append_in string_tmp;
+ slot_cod.argument_list.item h.append_in string_tmp;
};
- string_tmp.print;
+ string_tmp.print;
'\n'.print;
warning_error (position,"BUG");
semantic_error (new_larg.item j.position,"Type not compatible SELF.");
@@ -287,15 +287,15 @@ Section Private
//new_larg.put new_val to j;
};
};
- */
+ */
(my_profil, wrt_lst) := slot_cod.get_profil new_larg self new_type_self;
- //
- (result_expr.static_type.raw = TYPE_VOID).if {
+ //
+ (result_expr.static_type.raw = TYPE_VOID).if {
result.add_last (
CALL_SLOT.create position profil my_profil with wrt_lst cop cop_arg
);
- } else {
- call := CALL_SLOT.create position profil my_profil with wrt_lst cop NULL;
+ } else {
+ call := CALL_SLOT.create position profil my_profil with wrt_lst cop NULL;
(cop_arg != NULL).if {
result.add_last (COP_LOCK.create position with cop_arg);
result.add_last call;
@@ -308,42 +308,41 @@ Section Private
(em.lower).to (em.upper) do { j:INTEGER;
rd ?= em.item j;
? {rd != NULL};
- result_var := rd.variable;
+ result_var := rd.variable;
rd := call.profil.result_list.item j.read position;
wrt := result_var.write position value rd;
call.result_list.add_last (RESULT.create wrt);
- };
+ };
}.elseif {
- (call.profil.result_list.count != 0) ||
+ (call.profil.result_list.count != 0) ||
{call.is_interrupt}
} then {
rd ?= result_expr;
- result_var := rd.variable;
+ result_var := rd.variable;
(call.is_interrupt).if {
//val := PROTOTYPE_CST.create position type (TYPE_NULL.default);
- val := EXTERNAL_C.create position text "/* NODE_STYLE */"
+ val := EXTERNAL_C.create position text "/* NODE_STYLE */"
access NULL persistant FALSE type (type_pointer.default);
} else {
val := call.profil.result_list.first.read position;
};
wrt := result_var.write position value val;
- call.result_list.add_last (RESULT.create wrt);
- };
- };
- };
+ call.result_list.add_last (RESULT.create wrt);
+ };
+ };
+ };
result
);
-
-Section Private
-
+
+Section Private
+
- new_write var:VARIABLE with (e:EXPR,slot:SLOT_DATA) :WRITE <-
( + rd:READ;
-
+
(slot.style = '-').if {
rd := slot.read position;
- } else {
+ } else {
rd := slot.read position with (e.my_copy);
};
var.write position value rd
);
-
\ No newline at end of file
diff --git a/src/dispatcher/node_type.li b/src/dispatcher/node_type.li
index 91ae3e1..8549b5f 100644
--- a/src/dispatcher/node_type.li
+++ b/src/dispatcher/node_type.li
@@ -19,91 +19,91 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NODE_TYPE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Switch node for type";
-
+
Section Inherit
-
+
+ parent_node:Expanded NODE;
-
+
Section Public
-
+
- result_expr:EXPR <- data.result_expr;
-
+
+ is_self:BOOLEAN;
-
+
//
// Creation.
//
-
+
- create e:EXPR with d:DTA :SELF <-
// Create with back-link.
[ -? {d.position != 0}; ]
( + result:SELF;
-
+
result := clone;
result.make e with d;
result
);
-
+
- make e:EXPR with d:DTA <-
(
expr := e;
data := d;
late_binding_counter := late_binding_counter + 1;
);
-
+
//
// Just for ITM_EXPRESSION
//
-
+
- create_partial d:DTA :SELF <-
( + result:SELF;
-
+
result := clone;
- result.make_partial d;
+ result.make_partial d;
result
);
-
+
- make_partial d:DTA <-
(
data := d;
);
-
+
Section Public
-
+
- my_copy:SELF <-
( + result:SELF;
-
- result := SELF.create (expr.my_copy) with data;
- node_list.add_last result;
+
+ result := SELF.create (expr.my_copy) with data;
+ node_list.add_last result;
result
);
-
+
//
// Update.
//
-
+
- update:BOOLEAN <-
(
update_case NULL & update_depth NULL
);
-
+
Section NODE, DTA
-
+
- update_link self_type:TYPE_FULL :BOOLEAN <-
- (
- update_case self_type & update_depth self_type
+ (
+ update_case self_type & update_depth self_type
);
-
-Section Private
-
+
+Section Private
+
- update_case type_self:TYPE_FULL :BOOLEAN <-
( + typ_f:TYPE_FULL;
+ typ:TYPE;
@@ -111,27 +111,27 @@ Section Private
+ list:FAST_ARRAY(CASE);
+ case:CASE;
+ result:BOOLEAN;
-
+
typ_f := expr.static_type;
-
+
(typ_f.is_expanded && {typ_f.raw != type_boolean}).if {
(first_code = NULL).if {
first_type := typ_f.raw;
first_code := data.product first_type with expr self type_self;
- };
+ };
result := TRUE;
}.elseif {(typ_f.raw = type_boolean) && {count = 2}} then {
result := TRUE;
- } else {
+ } else {
((typ_f.raw.is_block) || {typ_f.raw.subtype_list.count != count}).if {
- lst_typ := TYPES_TMP.new;
- expr.get_type lst_typ;
-
+ lst_typ := TYPES_TMP.new;
+ expr.get_type lst_typ;
+
/*
- ((typ_f.raw = type_boolean) && {! lst_typ.is_empty}).if {
+ ((typ_f.raw = type_boolean) && {! lst_typ.is_empty}).if {
expr.debug_display; '\n'.print;
(lst_typ.first = type_boolean).if {
-
+
crash_with_message "NODE_TYPE : BUG";
};
/*
@@ -153,8 +153,8 @@ Section Private
};
list := switch.list;
(list.count != lst_typ.count).if {
- (lst_typ.lower).to (lst_typ.upper) do { j:INTEGER;
- typ := lst_typ.item j;
+ (lst_typ.lower).to (lst_typ.upper) do { j:INTEGER;
+ typ := lst_typ.item j;
((j > list.upper) || {typ != list.item j.id}).if {
add_stack_type typ;
//
@@ -162,7 +162,7 @@ Section Private
list.add case to j;
//
stack_type.remove_last;
- };
+ };
};
};
};
@@ -171,37 +171,37 @@ Section Private
} else {
//count_flat := count_flat + 1;
//"Yes\n".print;
- };
- };
+ };
+ };
result
);
-
- - update_depth self_type:TYPE_FULL :BOOLEAN <-
+
+ - update_depth self_type:TYPE_FULL :BOOLEAN <-
( + result:BOOLEAN;
+ list:FAST_ARRAY(CASE);
+ new_type_self:TYPE_FULL;
-
+
(switch = NULL).if {
(first_code != NULL).if {
- (self_type = NULL).if {
+ (self_type = NULL).if {
new_type_self := expr.static_type;
((! new_type_self.is_expanded) || {new_type_self.raw = type_boolean}).if {
new_type_self := first_type.default.to_strict;
- };
+ };
} else {
new_type_self := self_type;
};
-
+
add_stack_type first_type;
result := data.update_branch first_code self new_type_self;
stack_type.remove_last;
};
} else {
list := switch.list;
-
+
(list.lower).to (list.upper) do { j:INTEGER;
(self_type = NULL).if {
- new_type_self := list.item j.id.default.to_strict;
+ new_type_self := list.item j.id.default.to_strict;
} else {
new_type_self := self_type;
};
@@ -212,15 +212,15 @@ Section Private
};
result
);
-
-Section Private
-
+
+Section Private
+
- stack_type:FAST_ARRAY(TYPE) := FAST_ARRAY(TYPE).create_with_capacity 16;
-
+
- add_stack_type t:TYPE <-
(
stack_type.add_last t;
- ((stack_type.count > 1) && {stack_type.first = t}).if {
+ ((stack_type.count > 1) && {stack_type.first = t}).if {
string_tmp.copy "Cyclic inheritance : ";
(stack_type.lower).to (stack_type.upper) do { j:INTEGER;
stack_type.item j.append_name_in string_tmp;
diff --git a/src/external/arithmetic/expr_add.li b/src/external/arithmetic/expr_add.li
index 6386f7e..0883d5d 100644
--- a/src/external/arithmetic/expr_add.li
+++ b/src/external/arithmetic/expr_add.li
@@ -19,60 +19,60 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_ADD;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Add Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
+ symbol:STRING_CONSTANT := "+";
-
+
//
// Execute.
//
-
+
- exec_conservator_left left_cst :INTEGER_CST :EXPR <-
//-- 0 + E -> E
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := right;
left_cst.remove;
};
result
);
-
- - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E + 0 -> E
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := left;
right_cst.remove;
};
result
);
-
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 + C2 -> C3
(
- left_cst.set_value (left_cst.value + right_cst.value);
+ left_cst.set_value (left_cst.value + right_cst.value);
right_cst.remove;
left_cst
);
-
-
-
+
+
+
diff --git a/src/external/arithmetic/expr_and.li b/src/external/arithmetic/expr_and.li
index bf36757..56c2c10 100644
--- a/src/external/arithmetic/expr_and.li
+++ b/src/external/arithmetic/expr_and.li
@@ -19,83 +19,83 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_AND;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Add Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
- symbol:STRING_CONSTANT := "&";
-
+
//
// Execute.
//
-
+
- exec_conservator_left left_cst :INTEGER_CST :EXPR <-
- //-- -1 & E -> E
+ //-- -1 & E -> E
( + result:EXPR;
-
+
(left_cst.is_saturated).if {
result := right;
left_cst.remove;
};
result
);
-
- - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E & -1 -> E
( + result:EXPR;
-
+
(right_cst.is_saturated).if {
result := left;
right_cst.remove;
};
result
);
-
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 & C2 -> C3
- (
- left_cst.set_value (left_cst.value & right_cst.value);
+ (
+ left_cst.set_value (left_cst.value & right_cst.value);
right_cst.remove;
left_cst
);
-
+
- exec:EXPR <-
//-- E & E -> E
( + result:EXPR;
-
+
(left ~= right).if {
right.remove;
result := left;
};
- result
+ result
);
-
- - exec_left left_cst :INTEGER_CST :EXPR <-
+
+ - exec_left left_cst :INTEGER_CST :EXPR <-
//-- 0 & E -> 0
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := left_cst;
right.remove;
};
result
);
-
+
- exec_right right_cst:INTEGER_CST :EXPR <-
//-- E & 0 -> 0
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := right_cst;
left.remove;
@@ -103,7 +103,7 @@ Section Public
result
);
-
+
diff --git a/src/external/arithmetic/expr_binary.li b/src/external/arithmetic/expr_binary.li
index ba120a2..2ebf040 100644
--- a/src/external/arithmetic/expr_binary.li
+++ b/src/external/arithmetic/expr_binary.li
@@ -19,124 +19,124 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_BINARY;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- left.is_invariant && {right.is_invariant};
-
+
+ left:EXPR;
-
+
+ right:EXPR;
-
- - symbol:STRING_CONSTANT <-
+
+ - symbol:STRING_CONSTANT <-
(
deferred;
NULL
);
-
+
- static_type:TYPE_FULL <- left.static_type;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
left .get_type t;
//right.get_type t;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with l:EXPR and r:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with l and r;
result
);
-
+
- make p:POSITION with l:EXPR and r:EXPR <-
(
position := p;
left := l;
right := r;
);
-
+
- my_copy:SELF <- SELF.create position with (left.my_copy) and (right.my_copy);
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + same:SELF;
-
+
same ?= other;
(same != NULL) && {left ~= same.left} && {right ~= same.right}
);
-
+
//
// Remove
//
-
+
- remove <-
(
left .remove;
right.remove;
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- ( + instr:INSTR;
+ ( + instr:INSTR;
instr := left.execute_unlink;
(instr != NULL).if {
list_current.insert_before instr;
};
- right.execute_unlink
+ right.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ left_cst,right_cst:INTEGER_CST;
-
- old_seq := seq_call_and_loop;
+
+ old_seq := seq_call_and_loop;
left := left.execute_link;
- right := right.execute_link;
+ right := right.execute_link;
//
left_cst ?= left;
right_cst ?= right;
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {left_cst != NULL}).if {
+ ((result = NULL) && {left_cst != NULL}).if {
result := exec_conservator_left left_cst;
};
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_conservator_right right_cst;
};
(
- (result = NULL) &&
- {right_cst != NULL} &&
+ (result = NULL) &&
+ {right_cst != NULL} &&
{left_cst != NULL}
).if {
result := exec left_cst and right_cst;
- };
- ((result = NULL) && {old_seq = seq_call_and_loop}).if {
- // No conservator transformation.
+ };
+ ((result = NULL) && {old_seq = seq_call_and_loop}).if {
+ // No conservator transformation.
result := exec;
((result = NULL) && {left_cst != NULL}).if {
result := exec_left left_cst;
@@ -151,27 +151,27 @@ Section Public
result.set_position position;
new_execute_pass;
};
-
+
result
);
-
- - exec_conservator:EXPR <- NULL;
+
+ - exec_conservator:EXPR <- NULL;
- exec_conservator_left left_cst :INTEGER_CST :EXPR <- NULL;
- exec_conservator_right right_cst:INTEGER_CST :EXPR <- NULL;
-
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <- NULL;
-
+
- exec:EXPR <- NULL;
- exec_left left_cst :INTEGER_CST :EXPR <- NULL;
- exec_right right_cst:INTEGER_CST :EXPR <- NULL;
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
- (static_type.raw = type_pointer).if {
+ (static_type.raw = type_pointer).if {
buffer.append "(void *)";
} else {
buffer.add_last '(';
@@ -188,7 +188,7 @@ Section Public
buffer.add_last ' ';
buffer.append symbol;
buffer.add_last ' ';
- (static_type.raw = type_pointer).if {
+ (static_type.raw = type_pointer).if {
buffer.append "(unsigned long)";
}.elseif {! right.static_type.is_expanded} then {
buffer.append "(void *)"; // BSBS: A virer quand tu auras optim '=='
@@ -196,11 +196,11 @@ Section Public
right.genere buffer;
buffer.add_last ')';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.add_last '(';
diff --git a/src/external/arithmetic/expr_div.li b/src/external/arithmetic/expr_div.li
index bd518da..e988746 100644
--- a/src/external/arithmetic/expr_div.li
+++ b/src/external/arithmetic/expr_div.li
@@ -19,35 +19,35 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_DIV;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Div Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
- symbol:STRING_CONSTANT := "/";
-
+
//
// Execute.
//
-
- - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E / 0 -> Error.
//-- E / 1 -> E
//-- E / -1 -> - E
//-- E / 2^n -> E >> n
( + result:EXPR;
+ v:INTEGER_64;
-
+
(right_cst.value = 0).if {
warning_error (position,"Division by zero.");
}.elseif {right_cst.value = 1} then {
@@ -56,37 +56,37 @@ Section Public
}.elseif {right_cst.value = -1} then {
result := EXPR_NEG.create position with left;
right_cst.remove;
- }.elseif {(v := right_cst.to_power) != -1} then {
+ }.elseif {(v := right_cst.to_power) != -1} then {
right_cst.set_value v;
result := EXPR_SHIFT_R.create position with left and right_cst;
};
result
);
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 / C2 -> C3
( + result:EXPR;
-
+
(right_cst.value != 0).if {
- left_cst.set_value (left_cst.value / right_cst.value);
+ left_cst.set_value (left_cst.value / right_cst.value);
right_cst.remove;
result := left_cst;
};
result
);
-
+
- exec:EXPR <-
//-- E / E -> 1
//-- -E / E -> -1
//-- E / -E -> -1
( + result:EXPR;
+ neg:EXPR_NEG;
-
+
(right ~= left).if {
result := INTEGER_CST.create position value 1 type static_type;
right.remove;
left .remove;
- } else {
+ } else {
neg ?= left;
((neg != NULL) && {neg.right ~= right}).if {
result := INTEGER_CST.create position value (-1) type static_type;
@@ -99,15 +99,15 @@ Section Public
left.remove;
right.remove;
};
- };
+ };
};
result
);
-
+
- exec_left left_cst :INTEGER_CST :EXPR <-
//-- 0 / E -> 0
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := left_cst;
right.remove;
@@ -117,13 +117,13 @@ Section Public
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/external/arithmetic/expr_mod.li b/src/external/arithmetic/expr_mod.li
index d9a2dc8..0bb072b 100644
--- a/src/external/arithmetic/expr_mod.li
+++ b/src/external/arithmetic/expr_mod.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_MOD;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Add Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
+ symbol:STRING_CONSTANT := "%";
-
+
//
// Execute.
//
-
+
- exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E % 0 -> Error
//-- E % 2^n -> E & (2^n -1)
( + result:EXPR;
-
+
(right_cst.value = 0).if {
warning_error (position,"Division by zero.");
}.elseif {right_cst.to_power != -1} then {
@@ -53,31 +53,31 @@ Section Public
};
result
);
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 % C2 -> C3
(
- left_cst.set_value (left_cst.value % right_cst.value);
+ left_cst.set_value (left_cst.value % right_cst.value);
right_cst.remove;
left_cst
);
-
+
- exec:EXPR <-
//-- E % E -> 0
( + result:EXPR;
-
+
(left ~= right).if {
result := INTEGER_CST.create position value 0 type static_type;
left.remove;
right.remove;
};
- result
+ result
);
- exec_left left_cst :INTEGER_CST :EXPR <-
//-- 0 % E -> 0
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := left_cst;
right.remove;
@@ -85,25 +85,25 @@ Section Public
result
);
- - exec_right right_cst:INTEGER_CST :EXPR <-
+ - exec_right right_cst:INTEGER_CST :EXPR <-
//-- E % 1 -> 0
//-- E % -1 -> 0
( + result:EXPR;
-
+
(right_cst.value = 1).if {
right_cst.set_value 0;
left.remove;
result := right_cst;
- }.elseif {right_cst.value = -1} then {
+ }.elseif {right_cst.value = -1} then {
right_cst.set_value 0;
result := right_cst;
left.remove;
};
- result
+ result
);
-
-
-
+
+
+
diff --git a/src/external/arithmetic/expr_mul.li b/src/external/arithmetic/expr_mul.li
index ef87374..601e8c8 100644
--- a/src/external/arithmetic/expr_mul.li
+++ b/src/external/arithmetic/expr_mul.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_MUL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Mul Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
-Section Public
-
+
+Section Public
+
- symbol:STRING_CONSTANT := "*";
-
+
//
// Execute.
//
-
+
- exec_conservator_left left_cst :INTEGER_CST :EXPR <-
//-- 1 * E -> E
//-- -1 * E -> - E
//-- 2^n * E -> E << n
( + v:INTEGER_64;
+ result:EXPR;
-
+
(left_cst.value = 1).if {
left_cst.remove;
result := right;
@@ -57,16 +57,16 @@ Section Public
left_cst.set_value v;
result := EXPR_SHIFT_L.create position with right and left_cst;
};
- result
+ result
);
-
+
- exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E * 1 -> E
//-- E * -1 -> - E
//-- E * 2^n -> E << n
( + result:EXPR;
+ v:INTEGER_64;
-
+
(right_cst.value = 1).if {
right_cst.remove;
result := left;
@@ -79,38 +79,38 @@ Section Public
};
result
);
-
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 * C2 -> C3
(
- left_cst.set_value (left_cst.value * right_cst.value);
+ left_cst.set_value (left_cst.value * right_cst.value);
right_cst.remove;
left_cst
);
-
+
- exec_left left_cst :INTEGER_CST :EXPR <-
//-- 0 * E -> 0
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := left_cst;
right.remove;
};
result
);
-
+
- exec_right right_cst:INTEGER_CST :EXPR <-
//-- E * 0 -> 0
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := right_cst;
left.remove;
- };
+ };
result
);
-
-
+
+
diff --git a/src/external/arithmetic/expr_neg.li b/src/external/arithmetic/expr_neg.li
index fb36e0f..e837692 100644
--- a/src/external/arithmetic/expr_neg.li
+++ b/src/external/arithmetic/expr_neg.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_NEG;
- copyright := "2003-2007 Benoit Sonntag";
@@ -27,41 +27,41 @@ Section Header
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Negatif unary arithmetic expression.";
-
+
Section Inherit
-
+
+ parent_expr_unary:Expanded EXPR_UNARY;
-
+
Section Public
-
+
- symbol:CHARACTER <- '-';
-
+
//
// Execute.
//
-
+
- exec_conservator:EXPR <-
- //-- - - E -> E
+ //-- - - E -> E
( + sub:EXPR_NEG;
+ result:EXPR;
-
+
sub ?= right;
(sub != NULL).if {
result := sub.right;
};
result
);
-
+
- exec_right right_cst:INTEGER_CST :EXPR <-
//-- - C1 -> C2
( + result:EXPR;
(right_cst.is_signed).if {
- right_cst.set_value (- right_cst.value);
+ right_cst.set_value (- right_cst.value);
result := right_cst;
};
result
);
-
+
diff --git a/src/external/arithmetic/expr_not.li b/src/external/arithmetic/expr_not.li
index bdc046a..e17a5ad 100644
--- a/src/external/arithmetic/expr_not.li
+++ b/src/external/arithmetic/expr_not.li
@@ -19,27 +19,27 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_NOT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Not unary arithmetic expression.";
-
+
Section Inherit
-
+
+ parent_expr_unary:Expanded EXPR_UNARY;
-
+
Section Public
-
+
- symbol:CHARACTER <- '~';
-
+
//
// Execute.
//
-
+
- exec_conservator:EXPR <-
//-- ~ (~ E1 & ~ E2) -> E1 | E2
//-- ~ (~ E1 | ~ E2) -> E1 & E2
@@ -48,7 +48,7 @@ Section Public
+ and:EXPR_AND;
+ neg1,neg2:EXPR_NOT;
+ result:EXPR;
-
+
and ?= right;
(and != NULL).if {
neg1 ?= and.left;
@@ -73,8 +73,8 @@ Section Public
};
result
);
-
- - exec_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_right right_cst:INTEGER_CST :EXPR <-
//-- ~ C1 -> C2
( + result:EXPR;
(right_cst.is_signed).if {
@@ -82,9 +82,9 @@ Section Public
result := right_cst;
};
result
- );
-
-
+ );
+
+
diff --git a/src/external/arithmetic/expr_or.li b/src/external/arithmetic/expr_or.li
index edd6f86..bb07162 100644
--- a/src/external/arithmetic/expr_or.li
+++ b/src/external/arithmetic/expr_or.li
@@ -19,64 +19,64 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_OR;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Or binary arithmetic expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
- symbol:STRING_CONSTANT := "|";
-
+
//
// Execute.
//
-
+
- exec_conservator_left left_cst :INTEGER_CST :EXPR <-
//-- 0 | E -> E
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := right;
left_cst.remove;
};
result
);
-
- - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E | 0 -> E
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := left;
right_cst.remove;
};
result
);
-
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 | C2 -> C3
- (
- left_cst.set_value (left_cst.value | right_cst.value);
+ (
+ left_cst.set_value (left_cst.value | right_cst.value);
right_cst.remove;
left_cst
);
-
+
- exec:EXPR <-
//-- (! E1 & E2) | (E1 & ! E2) -> E1 ^ E2 (A lot of possibilities, but see '^' in INTEGER)
//-- E | E -> E
( + result:EXPR;
+ and_l,and_r:EXPR_AND;
+ not_l,not_r:EXPR_NOT;
-
+
(left ~= right).if {
right.remove;
result := left;
@@ -94,24 +94,24 @@ Section Public
};
};
};
- result
+ result
);
-
- - exec_left left_cst :INTEGER_CST :EXPR <-
- //-- -1 | E -> -1
+
+ - exec_left left_cst :INTEGER_CST :EXPR <-
+ //-- -1 | E -> -1
( + result:EXPR;
-
+
(left_cst.is_saturated).if {
result := left_cst;
right.remove;
};
result
);
-
+
- exec_right right_cst:INTEGER_CST :EXPR <-
//-- E | -1 -> -1
( + result:EXPR;
-
+
(right_cst.is_saturated).if {
result := right_cst;
left.remove;
@@ -119,7 +119,7 @@ Section Public
result
);
-
+
diff --git a/src/external/arithmetic/expr_shift_l.li b/src/external/arithmetic/expr_shift_l.li
index 2be4257..924b72d 100644
--- a/src/external/arithmetic/expr_shift_l.li
+++ b/src/external/arithmetic/expr_shift_l.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_SHIFT_L;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Add Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
+ symbol:STRING_CONSTANT := "<<";
-
+
//
// Execute.
//
-
- - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
- //-- E << 0 -> E
+
+ - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
+ //-- E << 0 -> E
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := left;
right_cst.remove;
};
result
);
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 << C2 -> C3
//-- C1 << -C2 -> Error.
(
@@ -59,27 +59,27 @@ Section Public
warning_error (position,"Left shift count is negative.");
left_cst.set_value 0;
} else {
- left_cst.set_value (left_cst.value << right_cst.value);
+ left_cst.set_value (left_cst.value << right_cst.value);
};
right_cst.remove;
left_cst
);
- - exec_left left_cst :INTEGER_CST :EXPR <-
+ - exec_left left_cst :INTEGER_CST :EXPR <-
//-- 0 << E -> 0
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := left_cst;
right.remove;
};
result
);
-
- - exec_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_right right_cst:INTEGER_CST :EXPR <-
//-- E << -C2 -> Error.
( + result:EXPR;
-
+
(right_cst.value < 0).if {
warning_error (position,"Left shift count is negative.");
right_cst.set_value 0;
@@ -89,5 +89,5 @@ Section Public
};
result
);
-
-
+
+
diff --git a/src/external/arithmetic/expr_shift_r.li b/src/external/arithmetic/expr_shift_r.li
index a2c159e..c3e73e0 100644
--- a/src/external/arithmetic/expr_shift_r.li
+++ b/src/external/arithmetic/expr_shift_r.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_SHIFT_R;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Add Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
+ symbol:STRING_CONSTANT := ">>";
-
+
//
// Execute.
//
-
- - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
- //-- E >> 0 -> E
+
+ - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
+ //-- E >> 0 -> E
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := left;
right_cst.remove;
};
result
);
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 >> C2 -> C3
//-- C1 >> -C2 -> Error.
(
@@ -59,12 +59,12 @@ Section Public
warning_error (position,"Right shift count is negative.");
left_cst.set_value 0;
} else {
- left_cst.set_value (left_cst.value >> right_cst.value);
+ left_cst.set_value (left_cst.value >> right_cst.value);
};
right_cst.remove;
left_cst
);
-
+
- exec:EXPR <-
//-- E(unsigned) >> E(unsigned) -> 0
( + result:EXPR;
@@ -77,12 +77,12 @@ Section Public
*/
result
);
-
- - exec_left left_cst:INTEGER_CST :EXPR <-
+
+ - exec_left left_cst:INTEGER_CST :EXPR <-
//-- 0 >> E -> 0
//-- -1(signed) >> E -> -1(signed)
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := left_cst;
right.remove;
@@ -92,11 +92,11 @@ Section Public
};
result
);
-
- - exec_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_right right_cst:INTEGER_CST :EXPR <-
//-- E >> -C2 -> Error.
( + result:EXPR;
-
+
(right_cst.value < 0).if {
warning_error (position,"Right shift count is negative.");
right_cst.set_value 0;
@@ -106,7 +106,7 @@ Section Public
};
result
);
-
-
-
-
+
+
+
+
diff --git a/src/external/arithmetic/expr_sub.li b/src/external/arithmetic/expr_sub.li
index decbb76..dabf611 100644
--- a/src/external/arithmetic/expr_sub.li
+++ b/src/external/arithmetic/expr_sub.li
@@ -19,44 +19,44 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_SUB;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Add Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
-Section Public
-
+
+Section Public
+
- symbol:STRING_CONSTANT := "-";
-
+
//
// Execute.
//
-
- - exec_conservator:EXPR <-
+
+ - exec_conservator:EXPR <-
//-- E1 - - E2 -> E1 + E2
( + neg:EXPR_NEG;
+ result:EXPR;
-
- neg ?= right;
+
+ neg ?= right;
(neg != NULL).if {
result := EXPR_ADD.create position with left and (neg.right);
};
result
);
-
- - exec_conservator_left left_cst :INTEGER_CST :EXPR <-
+
+ - exec_conservator_left left_cst :INTEGER_CST :EXPR <-
//-- 0 - E -> - E
- //-- -1 - E -> ~ E
+ //-- -1 - E -> ~ E
( + result:EXPR;
-
+
(left_cst.value = 0).if {
left_cst.remove;
result := EXPR_NEG.create position with right;
@@ -64,16 +64,16 @@ Section Public
left_cst.remove;
result := EXPR_NOT.create position with right;
};
- result
+ result
);
-
+
- exec_conservator_right right_cst:INTEGER_CST :EXPR <-
//-- E - 0 -> E
//-- -E - 1 -> ~ E
//-- E - -C -> E + C
( + result:EXPR;
+ neg:EXPR_NEG;
-
+
(right_cst.value = 0).if {
right_cst.remove;
result := left;
@@ -88,23 +88,23 @@ Section Public
result := EXPR_ADD.create position with left and right_cst;
};
result
- );
-
+ );
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 - C2 -> C3
(
- left_cst.set_value (left_cst.value - right_cst.value);
+ left_cst.set_value (left_cst.value - right_cst.value);
right_cst.remove;
left_cst
);
-
+
- exec:EXPR <-
//-- E - E -> 0
- //-- E1 - ((E1 / E2) * E2) -> E1 % E2
+ //-- E1 - ((E1 / E2) * E2) -> E1 % E2
( + result:EXPR;
+ mul:EXPR_MUL;
+ div:EXPR_DIV;
-
+
(left ~= right).if {
left.remove;
right.remove;
@@ -124,5 +124,4 @@ Section Public
result
);
-
-
\ No newline at end of file
+
diff --git a/src/external/arithmetic/expr_unary.li b/src/external/arithmetic/expr_unary.li
index 32bf833..246d5ab 100644
--- a/src/external/arithmetic/expr_unary.li
+++ b/src/external/arithmetic/expr_unary.li
@@ -19,100 +19,100 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_UNARY;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Unary Expression.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- right.is_invariant;
-
+
+ right:EXPR;
-
- - symbol:CHARACTER <-
+
+ - symbol:CHARACTER <-
(
deferred;
' '
);
-
+
- static_type:TYPE_FULL <- right.static_type;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add (static_type.raw);
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with r:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with r;
result
);
-
+
- make p:POSITION with r:EXPR <-
(
position := p;
right := r;
);
-
+
- my_copy:SELF <- SELF.create position with (right.my_copy);
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + same:SELF;
-
+
same ?= other;
(same != NULL) && {right ~= same.right}
);
-
+
- remove <-
- (
+ (
right.remove;
);
-
+
//
// Execute.
//
-
+
- execute_unlink:INSTR <-
(
right.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ right_cst:INTEGER_CST;
-
- old_seq := seq_call_and_loop;
- right := right.execute_link;
- //
+
+ old_seq := seq_call_and_loop;
+ right := right.execute_link;
+ //
right_cst ?= right;
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_right right_cst;
};
- ((result = NULL) && {old_seq = seq_call_and_loop}).if {
- // No conservator transformation.
- result := exec;
+ ((result = NULL) && {old_seq = seq_call_and_loop}).if {
+ // No conservator transformation.
+ result := exec;
};
(result = NULL).if {
result := Self;
@@ -120,20 +120,20 @@ Section Public
result.set_position position;
new_execute_pass;
};
-
+
result
);
-
- - exec_conservator:EXPR <- NULL;
-
+
+ - exec_conservator:EXPR <- NULL;
+
- exec_right right_cst:INTEGER_CST :EXPR <- NULL;
-
+
- exec:EXPR <- NULL;
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
buffer.add_last '(';
@@ -145,12 +145,12 @@ Section Public
buffer.add_last ' ';
right.genere buffer;
buffer.add_last ')';
- );
-
+ );
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.add_last '(';
diff --git a/src/external/arithmetic/expr_xor.li b/src/external/arithmetic/expr_xor.li
index 7e40b46..3383497 100644
--- a/src/external/arithmetic/expr_xor.li
+++ b/src/external/arithmetic/expr_xor.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_XOR;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Xor Binary arithmetic expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary:Expanded EXPR_BINARY;
-
+
Section Public
-
+
+ symbol:STRING_CONSTANT := "^";
-
+
//
// Execute.
//
-
- - exec_conservator_left left_cst :INTEGER_CST :EXPR <-
+
+ - exec_conservator_left left_cst :INTEGER_CST :EXPR <-
//-- 0 ^ E -> E
- //-- -1 ^ E -> ~ E
+ //-- -1 ^ E -> ~ E
( + result:EXPR;
-
+
(left_cst.value = 0).if {
result := right;
left_cst.remove;
@@ -59,7 +59,7 @@ Section Public
//-- E ^ 0 -> E
//-- E ^ -1 -> ~ E
( + result:EXPR;
-
+
(right_cst.value = 0).if {
result := left;
right_cst.remove;
@@ -69,23 +69,23 @@ Section Public
};
result
);
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 ^ C2 -> C3
(
- left_cst.set_value (left_cst.value ^ right_cst.value);
+ left_cst.set_value (left_cst.value ^ right_cst.value);
right_cst.remove;
left_cst
);
-
+
- exec:EXPR <-
//-- E ^ E -> 0
( + result:EXPR;
-
+
(left ~= right).if {
result := INTEGER_CST.create position value 0 type static_type;
left .remove;
right.remove;
};
- result
+ result
);
diff --git a/src/external/call_null.li b/src/external/call_null.li
index 1bb9a12..7ec5be3 100644
--- a/src/external/call_null.li
+++ b/src/external/call_null.li
@@ -19,62 +19,62 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := CALL_NULL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Call on NULL";
-
+
Section Inherit
-
- + parent_instr:Expanded INSTR;
-
-Section Public
-
+
+ + parent_instr:Expanded INSTR;
+
+Section Public
+
- my_copy:SELF <- Self;
-
+
- is_necessary:BOOLEAN;
-
+
//
// Remove
//
-
+
- remove; // Nothing.
-
+
//
// Execute
//
-
+
- execute:INSTR <- Self;
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
( + code:STRING_CONSTANT;
(debug_level_option != 0).if {
- code :=
+ code :=
"lisaac_stack_print(top_context); \
\print_string(\"Call on NULL\\n\"); \
\die_with_code(1)";
} else {
- code :=
+ code :=
"print_string(\"Call on NULL\\n\
- \(Use `-D' option)\\n\"); \
+ \(Use `-D' option)\\n\"); \
\die_with_code(1)";
};
buffer.append code;
is_necessary := TRUE;
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append "Call on NULL";
diff --git a/src/external/comparison/expr_binary_cmp.li b/src/external/comparison/expr_binary_cmp.li
index 4861d4f..9612f66 100644
--- a/src/external/comparison/expr_binary_cmp.li
+++ b/src/external/comparison/expr_binary_cmp.li
@@ -19,130 +19,130 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_BINARY_CMP;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Binary comparison expression.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- left.is_invariant && {right.is_invariant};
-
+
+ left:EXPR;
-
+
+ right:EXPR;
-
+
- set_left l:EXPR and_right r:EXPR <-
(
left := l;
right := r;
);
-
- - symbol:STRING_CONSTANT <-
+
+ - symbol:STRING_CONSTANT <-
(
deferred;
NULL
);
-
+
- static_type:TYPE_FULL <- type_boolean.default;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add type_true;
t.add type_false;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with l:EXPR and r:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with l and r;
result
);
-
+
- make p:POSITION with l:EXPR and r:EXPR <-
(
position := p;
left := l;
right := r;
);
-
+
- my_copy:SELF <- SELF.create position with (left.my_copy) and (right.my_copy);
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + same:SELF;
-
+
same ?= other;
(same != NULL) && {left ~= same.left} && {right ~= same.right}
- );
-
+ );
+
//
// Remove
//
-
+
- remove <-
(
left .remove;
right.remove;
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
( + instr:INSTR;
instr := left.execute_unlink;
(instr != NULL).if {
list_current.insert_before instr;
};
- right.execute_unlink
+ right.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ left_cst,right_cst:INTEGER_CST;
-
- old_seq := seq_call_and_loop;
+
+ old_seq := seq_call_and_loop;
left := left .execute_link;
- right := right.execute_link;
+ right := right.execute_link;
//
left_cst ?= left;
right_cst ?= right;
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {left_cst != NULL}).if {
+ ((result = NULL) && {left_cst != NULL}).if {
result := exec_conservator_left left_cst;
};
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_conservator_right right_cst;
- };
+ };
(
- (result = NULL) &&
- {right_cst != NULL} &&
+ (result = NULL) &&
+ {right_cst != NULL} &&
{left_cst != NULL}
).if {
result := exec left_cst and right_cst;
- };
- ((result = NULL) && {old_seq = seq_call_and_loop}).if {
- // No conservator transformation.
+ };
+ ((result = NULL) && {old_seq = seq_call_and_loop}).if {
+ // No conservator transformation.
result := exec;
((result = NULL) && {left_cst != NULL}).if {
result := exec_left left_cst;
@@ -150,7 +150,7 @@ Section Public
((result = NULL) && {right_cst != NULL}).if {
result := exec_right right_cst;
};
- };
+ };
//
(result = NULL).if {
result := Self;
@@ -158,33 +158,33 @@ Section Public
result.set_position position;
new_execute_pass;
};
-
+
result
);
-
- - exec_conservator:EXPR <- NULL;
+
+ - exec_conservator:EXPR <- NULL;
- exec_conservator_left left_cst :INTEGER_CST :EXPR <- NULL;
- exec_conservator_right right_cst:INTEGER_CST :EXPR <- NULL;
-
+
- exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <- NULL;
-
+
- exec:EXPR <- NULL;
- exec_left left_cst :INTEGER_CST :EXPR <- NULL;
- exec_right right_cst:INTEGER_CST :EXPR <- NULL;
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
buffer.add_last '(';
(
- (left.static_type.raw = type_pointer) &&
+ (left.static_type.raw = type_pointer) &&
{ALIAS_STR.is_integer (right.static_type.raw.name)}
).if {
buffer.append "(unsigned long)";
- }.elseif {! left.static_type.is_expanded} then {
+ }.elseif {! left.static_type.is_expanded} then {
buffer.append "(void *)"; // BSBS: A virer quand tu auras optim '=='
};
((left.static_type.raw = TYPE_NULL) && {right.static_type.raw.is_block}).if {
@@ -197,15 +197,15 @@ Section Public
(left.static_type.raw.is_block).if {
buffer.append ".__id";
};
- };
+ };
buffer.add_last ' ';
buffer.append symbol;
buffer.add_last ' ';
-
+
(
- (ALIAS_STR.is_integer (left.static_type.raw.name)) &&
+ (ALIAS_STR.is_integer (left.static_type.raw.name)) &&
{right.static_type.raw = type_pointer}
- ).if {
+ ).if {
buffer.append "(unsigned long)";
}.elseif {! right.static_type.is_expanded} then {
buffer.append "(void *)"; // BSBS: A virer quand tu auras optim '=='
@@ -217,18 +217,18 @@ Section Public
(right.static_type.raw.is_block).if {
buffer.append ".__id";
};
- };
+ };
buffer.add_last ')';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
- buffer.add_last '(';
- left.static_type.append_name_in buffer;
+ buffer.add_last '(';
+ left.static_type.append_name_in buffer;
buffer.add_last ' ';
left.display buffer;
buffer.append symbol;
diff --git a/src/external/comparison/expr_equal.li b/src/external/comparison/expr_equal.li
index ec04f85..019f7c2 100644
--- a/src/external/comparison/expr_equal.li
+++ b/src/external/comparison/expr_equal.li
@@ -19,47 +19,47 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_EQUAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Simple Equal Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_cmp:Expanded EXPR_BINARY_CMP;
-
+
Section Public
-
+
- symbol:STRING_CONSTANT := "==";
-
+
//
// Execute.
//
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 == C2 -> TRUE/FALSE
( + result:PROTOTYPE_CST;
-
+
(left_cst.value = right_cst.value).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
left_cst .remove;
right_cst.remove;
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E == E -> TRUE
//-- Expanded == NULL -> FALSE
( + result:PROTOTYPE_CST;
+ r:PROTOTYPE_CST;
-
+
(left ~= right).if {
result := PROTOTYPE_CST.create position type (type_true.default);
left .remove;
@@ -67,8 +67,8 @@ Section Public
} else {
r ?= right;
(
- (r != NULL) &&
- {r.static_type.raw = TYPE_NULL} &&
+ (r != NULL) &&
+ {r.static_type.raw = TYPE_NULL} &&
{left.static_type.is_expanded} &&
{left.static_type.raw != type_pointer}
).if {
@@ -77,19 +77,19 @@ Section Public
result := PROTOTYPE_CST.create position type (type_false.default);
};
};
-
+
result
);
-
+
//
// Genere
//
-
+
- genere buffer:STRING <-
(
(
- (left.static_type.is_expanded) &&
- {right.static_type.is_expanded} &&
+ (left.static_type.is_expanded) &&
+ {right.static_type.is_expanded} &&
{right.static_type.raw.type_c = NULL}
).if {
buffer.append "(memcmp(";
@@ -103,11 +103,11 @@ Section Public
};
right.genere buffer;
buffer.append ",sizeof(";
- left.static_type.raw.put_expanded_declaration buffer;
+ left.static_type.raw.put_expanded_declaration buffer;
buffer.append ")) == 0)";
} else {
parent_expr_binary_cmp.genere buffer;
- };
+ };
);
diff --git a/src/external/comparison/expr_inf.li b/src/external/comparison/expr_inf.li
index bf674fc..e352d40 100644
--- a/src/external/comparison/expr_inf.li
+++ b/src/external/comparison/expr_inf.li
@@ -19,59 +19,59 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_INF;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Inferior binary comparison expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_cmp:Expanded EXPR_BINARY_CMP;
-
-Section Public
-
+
+Section Public
+
- symbol:STRING_CONSTANT := "<";
-
+
//
// Execute.
//
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 < C2 -> TRUE/FALSE
( + result:PROTOTYPE_CST;
-
+
(left_cst.value < right_cst.value).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
left_cst .remove;
right_cst.remove;
-
+
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E < E -> FALSE
( + result:PROTOTYPE_CST;
-
+
(left ~= right).if {
result := PROTOTYPE_CST.create position type (type_false.default);
left .remove;
right.remove;
- };
-
+ };
+
result
);
-
- - exec_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_right right_cst:INTEGER_CST :EXPR <-
//-- E(unsigned) < 0 -> FALSE
( + result:EXPR;
-
+
((right_cst.value = 0) && {left.static_type.raw.name.first = 'U'}).if {
result := PROTOTYPE_CST.create position type (type_false.default);
left .remove;
diff --git a/src/external/comparison/expr_inf_eq.li b/src/external/comparison/expr_inf_eq.li
index 86c3955..f6c8aeb 100644
--- a/src/external/comparison/expr_inf_eq.li
+++ b/src/external/comparison/expr_inf_eq.li
@@ -19,52 +19,52 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_INF_EQ;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Inferior or equal binary comparison expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_cmp:Expanded EXPR_BINARY_CMP;
-
-Section Public
-
+
+Section Public
+
- symbol:STRING_CONSTANT := "<=";
-
+
//
// Execute.
//
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 <= C2 -> TRUE/FALSE
( + result:PROTOTYPE_CST;
-
+
(left_cst.value <= right_cst.value).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
left_cst .remove;
right_cst.remove;
-
+
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E <= E -> TRUE
( + result:PROTOTYPE_CST;
-
+
(left ~= right).if {
result := PROTOTYPE_CST.create position type (type_true.default);
left .remove;
right.remove;
- };
-
+ };
+
result
);
-
+
diff --git a/src/external/comparison/expr_not_equal.li b/src/external/comparison/expr_not_equal.li
index c7ebd0d..fb47c44 100644
--- a/src/external/comparison/expr_not_equal.li
+++ b/src/external/comparison/expr_not_equal.li
@@ -19,48 +19,48 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_NOT_EQUAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Not equal binary comparison expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_cmp:Expanded EXPR_BINARY_CMP;
-
+
Section Public
-
+
- symbol:STRING_CONSTANT := "!=";
-
+
//
// Execute.
//
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 != C2 -> TRUE/FALSE
( + result:PROTOTYPE_CST;
-
+
(left_cst.value != right_cst.value).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
left_cst .remove;
right_cst.remove;
-
+
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E != E -> FALSE
//-- Expanded != NULL -> TRUE
( + result:PROTOTYPE_CST;
+ r:PROTOTYPE_CST;
-
+
(left ~= right).if {
result := PROTOTYPE_CST.create position type (type_false.default);
left .remove;
@@ -68,29 +68,29 @@ Section Public
} else {
r ?= right;
(
- (r != NULL) &&
- {r.static_type.raw = TYPE_NULL} &&
+ (r != NULL) &&
+ {r.static_type.raw = TYPE_NULL} &&
{left.static_type.is_expanded} &&
{left.static_type.raw != type_pointer}
).if {
left .remove;
right.remove;
- result := PROTOTYPE_CST.create position type (type_true.default);
+ result := PROTOTYPE_CST.create position type (type_true.default);
};
- };
-
+ };
+
result
);
//
// Genere
//
-
+
- genere buffer:STRING <- // BSBS: a factoriser avec EXPR_EQUAL
(
(
- (left.static_type.is_expanded) &&
- {right.static_type.is_expanded} &&
+ (left.static_type.is_expanded) &&
+ {right.static_type.is_expanded} &&
{right.static_type.raw.type_c = NULL}
).if {
buffer.append "(memcmp(";
@@ -104,13 +104,13 @@ Section Public
};
right.genere buffer;
buffer.append ",sizeof(";
- left.static_type.raw.put_expanded_declaration buffer;
+ left.static_type.raw.put_expanded_declaration buffer;
buffer.append ")) != 0)";
} else {
parent_expr_binary_cmp.genere buffer;
- };
+ };
);
-
-
+
+
diff --git a/src/external/comparison/expr_sup.li b/src/external/comparison/expr_sup.li
index 65247f6..1a681f0 100644
--- a/src/external/comparison/expr_sup.li
+++ b/src/external/comparison/expr_sup.li
@@ -19,64 +19,64 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_SUP;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Superior binary comparison expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_cmp:Expanded EXPR_BINARY_CMP;
-
-Section Public
-
+
+Section Public
+
- symbol:STRING_CONSTANT := ">";
-
+
//
// Execute.
//
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 > C2 -> TRUE/FALSE
( + result:PROTOTYPE_CST;
-
+
(left_cst.value > right_cst.value).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
left_cst .remove;
right_cst.remove;
-
+
result
);
-
- - exec_left left_cst :INTEGER_CST :EXPR <-
+
+ - exec_left left_cst :INTEGER_CST :EXPR <-
//-- 0 > E (unsigned) -> FALSE
( + result:EXPR;
-
+
((left_cst.value = 0) && {right.static_type.raw.name.first = 'U'}).if {
result := PROTOTYPE_CST.create position type (type_false.default);
left .remove;
right.remove;
};
- result
+ result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E > E -> FALSE
( + result:PROTOTYPE_CST;
-
+
(left ~= right).if {
result := PROTOTYPE_CST.create position type (type_false.default);
left .remove;
right.remove;
- };
-
+ };
+
result
);
-
+
diff --git a/src/external/comparison/expr_sup_eq.li b/src/external/comparison/expr_sup_eq.li
index ad00424..d0ba6af 100644
--- a/src/external/comparison/expr_sup_eq.li
+++ b/src/external/comparison/expr_sup_eq.li
@@ -19,59 +19,59 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_SUP_EQ;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Superior or equal binary comparison expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_cmp:Expanded EXPR_BINARY_CMP;
-
-Section Public
-
+
+Section Public
+
- symbol:STRING_CONSTANT := ">=";
-
+
//
// Execute.
//
-
- - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
+
+ - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
//-- C1 >= C2 -> TRUE/FALSE
( + result:PROTOTYPE_CST;
-
+
(left_cst.value >= right_cst.value).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
left_cst .remove;
right_cst.remove;
-
+
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E >= E -> TRUE
( + result:PROTOTYPE_CST;
-
+
(left ~= right).if {
result := PROTOTYPE_CST.create position type (type_true.default);
left .remove;
right.remove;
- };
-
+ };
+
result
);
-
- - exec_right right_cst:INTEGER_CST :EXPR <-
+
+ - exec_right right_cst:INTEGER_CST :EXPR <-
//-- E(unsigned) >= 0 -> TRUE
( + result:EXPR;
-
+
((right_cst.value = 0) && {left.static_type.raw.name.first = 'U'}).if {
result := PROTOTYPE_CST.create position type (type_true.default);
left .remove;
diff --git a/src/external/external_c.li b/src/external/external_c.li
index d068ab5..188b041 100644
--- a/src/external/external_c.li
+++ b/src/external/external_c.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXTERNAL_C;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit";
- comment := "External C instruction.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
+ is_persistant:BOOLEAN;
+ static_type:TYPE_FULL;
- + living_type:TYPES;
-
+ + living_type:TYPES;
+
- set_living_type l:TYPES <-
(
living_type := l;
);
-
+
- get_type t:TYPES_TMP <-
(
(living_type = NULL).if {
@@ -57,18 +57,18 @@ Section Public
//
// External value.
//
-
+
+ code:STRING_CONSTANT;
+ access_list:FAST_ARRAY(EXPR);
//
// Creation.
//
-
- - create p:POSITION
+
+ - create p:POSITION
text c:STRING_CONSTANT
- access ac:FAST_ARRAY(EXPR)
- persistant per:BOOLEAN
+ access ac:FAST_ARRAY(EXPR)
+ persistant per:BOOLEAN
type t:TYPE_FULL :SELF <-
( + result:SELF;
result := clone;
@@ -76,10 +76,10 @@ Section Public
result
);
- - make p:POSITION
+ - make p:POSITION
text c:STRING_CONSTANT
- access ac:FAST_ARRAY(EXPR)
- persistant per:BOOLEAN
+ access ac:FAST_ARRAY(EXPR)
+ persistant per:BOOLEAN
type t:TYPE_FULL <-
(
position := p;
@@ -92,18 +92,18 @@ Section Public
- my_copy:SELF <-
( + result:SELF;
+ new_access:FAST_ARRAY(EXPR);
- + val:EXPR;
-
+ + val:EXPR;
+
(access_list != NULL).if {
new_access := FAST_ARRAY(EXPR).create_with_capacity (access_list.count);
(access_list.lower).to (access_list.upper) do { j:INTEGER;
- val := access_list.item j.my_copy;
+ val := access_list.item j.my_copy;
new_access.add_last val;
- };
+ };
};
- result := SELF.create position text code
- access new_access persistant is_persistant type static_type;
- result.set_living_type living_type;
+ result := SELF.create position text code
+ access new_access persistant is_persistant type static_type;
+ result.set_living_type living_type;
result
);
@@ -119,10 +119,10 @@ Section Public
};
};
);
-
+
- execute_unlink:INSTR <-
( + result,instr:INSTR;
-
+
(is_persistant).if {
// Normal.
static_type := TYPE_VOID.default;
@@ -130,7 +130,7 @@ Section Public
} else {
// Remove.
(access_list != NULL).if {
- (access_list.lower).to (access_list.upper) do { j:INTEGER;
+ (access_list.lower).to (access_list.upper) do { j:INTEGER;
instr := access_list.item j.execute_unlink;
(instr != NULL).if {
list_current.insert_before instr;
@@ -143,11 +143,11 @@ Section Public
- execute_link:EXPR <-
( + e:EXPR;
-
+
// Normal
- (access_list != NULL).if {
+ (access_list != NULL).if {
(access_list.lower).to (access_list.upper) do { j:INTEGER;
- e := access_list.item j.execute_link;
+ e := access_list.item j.execute_link;
access_list.put e to j;
};
};
@@ -164,18 +164,18 @@ Section Public
profil_main.set_external_present TRUE;
};
buffer.append "/* PERSISTANT */";
- };
-
+ };
+
(static_type.raw != TYPE_VOID).if {
buffer.append "((";
- static_type.genere_declaration buffer;
+ static_type.genere_declaration buffer;
buffer.add_last ' ';
- static_type.genere_star_declaration buffer;
- buffer.append ")(";
- } else {
+ static_type.genere_star_declaration buffer;
+ buffer.append ")(";
+ } else {
// buffer.append "if (";
- };
-
+ };
+
(access_list != NULL).if {
beg := code.lower;
idx := code.index_of '@' since beg;
@@ -184,7 +184,7 @@ Section Public
buffer.add_last (code.item k);
};
beg := idx + 1;
- access_list.item j.genere buffer;
+ access_list.item j.genere buffer;
idx := code.index_of '@' since beg;
};
// Copy end.
@@ -206,9 +206,9 @@ Section Public
//
- display buffer:STRING <-
- (
+ (
buffer.add_last '`';
- buffer.append code;
+ buffer.append code;
((access_list != NULL) && { ! access_list.is_empty}).if {
buffer.add_last '(';
access_list.lower.to (access_list.upper - 1) do { j:INTEGER;
@@ -217,12 +217,12 @@ Section Public
};
access_list.last.display buffer;
buffer.add_last ')';
- };
+ };
buffer.add_last '`';
static_type.append_name_in buffer;
(living_type != NULL).if {
- buffer.add_last '(';
- (living_type.lower).to (living_type.upper-1) do { j:INTEGER;
+ buffer.add_last '(';
+ (living_type.lower).to (living_type.upper-1) do { j:INTEGER;
buffer.append (living_type.item j.intern_name);
buffer.add_last ',';
};
@@ -231,7 +231,7 @@ Section Public
};
display_ref buffer;
);
-
+
diff --git a/src/external/forall_data.li b/src/external/forall_data.li
index e0ca3b8..ccbdad2 100644
--- a/src/external/forall_data.li
+++ b/src/external/forall_data.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FORALL_DATA;
- copyright := "2003-2009 Sonntag Benoit";
@@ -30,13 +30,13 @@ Section Header
Section Inherit
+ parent_instr:Expanded INSTR;
-
+
Section Public
-
+
+ action:ITM_READ_ARG2;
-
+
+ list_data:FAST_ARRAY(COUPLE(SLOT_DATA,EXPR));
-
+
//
// Creation.
//
@@ -52,9 +52,9 @@ Section Public
( + lst:FAST_ARRAY(SLOT);
+ dta:SLOT_DATA;
+ c:COUPLE(SLOT_DATA,EXPR);
-
+
action := ITM_READ_ARG2.create (ac.position) name (ALIAS_STR.slot_value) args (,);
- list_data := FAST_ARRAY(COUPLE(SLOT_DATA,EXPR)).create;
+ list_data := FAST_ARRAY(COUPLE(SLOT_DATA,EXPR)).create;
t.add_reflexivity Self;
lst := t.slot_run;
(lst.lower).to (lst.upper) do { i:INTEGER;
@@ -65,51 +65,51 @@ Section Public
};
};
);
-
+
//
//
//
-
+
- my_copy:SELF <-
(
clone
);
-
+
//
- // Depend.
+ // Depend.
//
-
+
- add var:SLOT_DATA <-
(
-
+
);
-
+
//
// Execute.
//
-
- - execute:INSTR <-
+
+ - execute:INSTR <-
(
-
+
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
(list_data.lower).to (list_data.upper) do { i:INTEGER;
list_data.item i.second.genere buffer;
};
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
- (
+ (
buffer.append "Forall_data:\n";
indent.append " ";
(list_data.lower).to (list_data.upper) do { i:INTEGER;
@@ -120,6 +120,5 @@ Section Public
buffer.append indent;
list_data.item i.second.genere buffer;
};
- indent.remove_last 2;
+ indent.remove_last 2;
);
-
\ No newline at end of file
diff --git a/src/external/get_type_id.li b/src/external/get_type_id.li
index 6ce0975..efa2941 100644
--- a/src/external/get_type_id.li
+++ b/src/external/get_type_id.li
@@ -19,80 +19,80 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := GET_TYPE_ID;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Get intern ID object";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- TRUE;
-
+
+ receiver:TYPE_FULL;
-
+
- static_type:TYPE_FULL <- type_integer.default;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add type_integer;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION receiver e:TYPE_FULL :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p receiver e;
result
);
-
+
- make p:POSITION receiver e:TYPE_FULL <-
(
- position := p;
- receiver := e;
+ position := p;
+ receiver := e;
);
-
+
- my_copy:SELF <- SELF.create position receiver receiver;
// BSBS: Tu peux renvoyer Self ! Non ?
-
+
//
// Remove
//
-
+
- remove <-
(
// Nothing.
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- (
+ (
NULL
);
-
+
- execute_link:EXPR <-
- (
+ (
Self
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
(receiver.is_late_binding).if {
@@ -103,11 +103,11 @@ Section Public
buffer.append (ALIAS_STR.separate); // <=> "__";
};
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append "type_id(";
diff --git a/src/external/is_expanded.li b/src/external/is_expanded.li
index 3e258fb..a2e8217 100644
--- a/src/external/is_expanded.li
+++ b/src/external/is_expanded.li
@@ -19,101 +19,101 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := IS_EXPANDED;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "True, if `Self' is Expanded type.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- TRUE;
-
+
+ receiver:EXPR;
-
+
- static_type:TYPE_FULL <- type_boolean.default;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add type_true;
t.add type_false;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION receiver e:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p receiver e;
result
);
-
+
- make p:POSITION receiver e:EXPR <-
(
- position := p;
- receiver := e;
+ position := p;
+ receiver := e;
);
-
+
- my_copy:SELF <- SELF.create position receiver (receiver.my_copy);
-
+
//
// Remove
//
-
+
- remove <-
(
receiver.remove;
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- (
+ (
receiver.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ instr:INSTR;
-
+
(receiver.static_type.is_expanded).if {
result := PROTOTYPE_CST.create position type (type_true.default);
} else {
result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ };
instr := receiver.execute_unlink;
(instr != NULL).if {
- list_current.insert_before instr;
+ list_current.insert_before instr;
};
new_execute_pass;
result
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
crash_with_message "IS_EXPANDED.genere !";
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append "is_expanded(";
diff --git a/src/external/item.li b/src/external/item.li
index 78fa5ec..4a8941f 100644
--- a/src/external/item.li
+++ b/src/external/item.li
@@ -19,108 +19,108 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITEM;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Item for NATIVE_ARRAY[type].";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- receiver.is_invariant && {index.is_invariant};
-
+
+ receiver:EXPR;
-
+
+ index:EXPR;
-
- - static_type:TYPE_FULL <-
+
+ - static_type:TYPE_FULL <-
( + t:TYPE_GENERIC;
-
+
t ?= receiver.static_type.raw;
- t.generic_list.first
+ t.generic_list.first
);
-
+
- get_type t:TYPES_TMP <-
- ( + typ_gen:TYPE_GENERIC;
-
+ ( + typ_gen:TYPE_GENERIC;
+
typ_gen ?= receiver.static_type.raw;
- typ_gen.get_type t;
+ typ_gen.get_type t;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION base rec:EXPR index idx:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p base rec index idx;
result
);
-
+
- make p:POSITION base rec:EXPR index idx:EXPR <-
(
- position := p;
+ position := p;
receiver := rec;
index := idx;
);
-
+
- my_copy:SELF <- SELF.create position base (receiver.my_copy) index (index.my_copy);
-
+
//
// Remove
//
-
+
- remove <-
(
receiver.remove;
index.remove;
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- ( + instr:INSTR;
+ ( + instr:INSTR;
instr := receiver.execute_unlink;
(instr != NULL).if {
list_current.insert_before instr;
};
- index.execute_unlink
+ index.execute_unlink
);
-
+
- execute_link:EXPR <-
- (
+ (
receiver := receiver.execute_link;
- index := index.execute_link;
+ index := index.execute_link;
Self
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
- receiver.genere buffer;
+ receiver.genere buffer;
buffer.add_last '[';
index.genere buffer;
- buffer.add_last ']';
+ buffer.add_last ']';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
receiver.display buffer;
diff --git a/src/external/logic/expr_and_and_logic.li b/src/external/logic/expr_and_and_logic.li
index b9b0adb..f0044e9 100644
--- a/src/external/logic/expr_and_and_logic.li
+++ b/src/external/logic/expr_and_and_logic.li
@@ -19,49 +19,49 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_AND_AND_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "&& Binary logical expression.";
-
+
Section Inherit
-
+
+ parent_expr_and_logic:Expanded EXPR_AND_LOGIC;
-
+
Section Public
-
+
+ symbol:STRING_CONSTANT := "&&";
-
+
//
// Execute.
//
-
+
- execute_unlink:INSTR <-
- (
+ (
execute_link
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ left_cst,right_cst:PROTOTYPE_CST;
+ left_t,right_t:TYPE;
-
- old_seq := seq_call_and_loop;
- left := left.execute_link;
+
+ old_seq := seq_call_and_loop;
+ left := left.execute_link;
//
seq_or_and := seq_or_and + 1;
seq_inline := seq_inline + 1;
- //
- right := right.execute_link;
+ //
+ right := right.execute_link;
//
left_cst ?= left;
right_cst ?= right;
-
+
(left_cst != NULL).if { // BSBS : Peux faire mieux !!!
(left_cst.static_type.raw = type_true).if {
left_t := type_true;
@@ -76,24 +76,24 @@ Section Public
right_t := type_false;
};
};
-
+
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {left_cst != NULL}).if {
+ ((result = NULL) && {left_cst != NULL}).if {
result := exec_conservator_left left_t;
};
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_conservator_right right_t;
};
(
- (result = NULL) &&
- {right_cst != NULL} &&
+ (result = NULL) &&
+ {right_cst != NULL} &&
{left_cst != NULL}
).if {
result := exec left_t and right_t;
- };
- ((result = NULL) && {(old_seq + 1) = seq_call_and_loop}).if {
- // No conservator transformation.
+ };
+ ((result = NULL) && {(old_seq + 1) = seq_call_and_loop}).if {
+ // No conservator transformation.
result := exec;
((result = NULL) && {left_cst != NULL}).if {
result := exec_left left_t;
@@ -108,28 +108,28 @@ Section Public
} else {
new_execute_pass;
};
-
+
result
);
-
+
- exec_conservator:EXPR <-
//-- E && Var -> E & Var
( + rd:READ;
+ result:EXPR;
-
+
rd ?= right;
(rd != NULL).if {
result := EXPR_AND_LOGIC.create position with left and right;
};
result
);
-
+
//-- for && same &
-
+
- exec_conservator_left left_cst :TYPE :EXPR <-
//-- FALSE && E -> FALSE
( + result:EXPR;
-
+
result := parent_expr_and_logic.exec_conservator_left left_cst;
((result = NULL) && {left_cst = type_false}).if {
result := left;
@@ -137,7 +137,7 @@ Section Public
};
result
);
-
+
diff --git a/src/external/logic/expr_and_logic.li b/src/external/logic/expr_and_logic.li
index d6f1826..504c57c 100644
--- a/src/external/logic/expr_and_logic.li
+++ b/src/external/logic/expr_and_logic.li
@@ -19,53 +19,53 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_AND_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "And binary logical expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_logic:Expanded EXPR_BINARY_LOGIC;
-
-Section Public
-
+
+Section Public
+
+ symbol:STRING_CONSTANT := "&";
-
+
//
// Execute.
//
-
- - exec_conservator_left left_cst :TYPE :EXPR <-
+
+ - exec_conservator_left left_cst :TYPE :EXPR <-
//-- TRUE & E -> E
( + result:EXPR;
-
+
(left_cst = type_true).if {
result := right;
left.remove;
};
result
);
-
- - exec_conservator_right right_cst:TYPE :EXPR <-
+
+ - exec_conservator_right right_cst:TYPE :EXPR <-
//-- E & TRUE -> E
( + result:EXPR;
-
+
(right_cst = type_true).if {
result := left;
right.remove;
};
result
);
-
+
- exec left_cst:TYPE and right_cst:TYPE :EXPR <-
//-- C1 & C2 -> C3
( + result:EXPR;
-
+
(left_cst = type_true).if {
result := right;
left.remove;
@@ -75,33 +75,33 @@ Section Public
};
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- E & E -> E
( + result:EXPR;
-
+
(left ~= right).if {
result := left;
right.remove;
};
- result
+ result
);
- - exec_left left_cst :TYPE :EXPR <-
+ - exec_left left_cst :TYPE :EXPR <-
//-- FALSE & E -> FALSE
( + result:EXPR;
-
+
(left_cst = type_false).if {
result := left;
right.remove;
};
result
);
-
- - exec_right right_cst:TYPE :EXPR <-
+
+ - exec_right right_cst:TYPE :EXPR <-
//-- E & FALSE -> FALSE
( + result:EXPR;
-
+
(right_cst = type_false).if {
result := right;
left.remove;
@@ -109,16 +109,16 @@ Section Public
result
);
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/external/logic/expr_binary_logic.li b/src/external/logic/expr_binary_logic.li
index 02e98d9..a366546 100644
--- a/src/external/logic/expr_binary_logic.li
+++ b/src/external/logic/expr_binary_logic.li
@@ -19,109 +19,109 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_BINARY_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Binary logical expression.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- left.is_invariant && {right.is_invariant};
-
+
+ left:EXPR;
-
+
+ right:EXPR;
-
- - symbol:STRING_CONSTANT <-
+
+ - symbol:STRING_CONSTANT <-
(
deferred;
NULL
);
-
+
- static_type:TYPE_FULL <- type_boolean.default;
-
+
- get_type t:TYPES_TMP <-
- (
- t.add type_true;
+ (
+ t.add type_true;
t.add type_false;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with l:EXPR and r:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with l and r;
result
);
-
+
- make p:POSITION with l:EXPR and r:EXPR <-
(
position := p;
left := l;
right := r;
);
-
+
- my_copy:SELF <- SELF.create position with (left.my_copy) and (right.my_copy);
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + same:SELF;
-
+
same ?= other;
(same != NULL) && {left ~= same.left} && {right ~= same.right}
- );
-
+ );
+
//
// Remove
//
-
+
- remove <-
(
left .remove;
right.remove;
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- ( + instr:INSTR;
+ ( + instr:INSTR;
instr := left.execute_unlink;
(instr != NULL).if {
list_current.insert_before instr;
};
- right.execute_unlink
+ right.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ left_cst,right_cst:PROTOTYPE_CST;
+ left_t,right_t:TYPE;
-
- old_seq := seq_call_and_loop;
+
+ old_seq := seq_call_and_loop;
left := left .execute_link;
- right := right.execute_link;
+ right := right.execute_link;
//
left_cst ?= left;
right_cst ?= right;
-
+
(left_cst != NULL).if { // BSBS : Peux faire mieux !!!
(left_cst.static_type.raw = type_true).if {
left_t := type_true;
@@ -136,24 +136,24 @@ Section Public
right_t := type_false;
};
};
-
+
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {left_cst != NULL}).if {
+ ((result = NULL) && {left_cst != NULL}).if {
result := exec_conservator_left left_t;
};
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_conservator_right right_t;
};
(
- (result = NULL) &&
- {right_cst != NULL} &&
+ (result = NULL) &&
+ {right_cst != NULL} &&
{left_cst != NULL}
).if {
result := exec left_t and right_t;
- };
- ((result = NULL) && {old_seq = seq_call_and_loop}).if {
- // No conservator transformation.
+ };
+ ((result = NULL) && {old_seq = seq_call_and_loop}).if {
+ // No conservator transformation.
result := exec;
((result = NULL) && {left_cst != NULL}).if {
result := exec_left left_t;
@@ -169,27 +169,27 @@ Section Public
result.set_position position;
new_execute_pass;
};
-
+
result
);
-
- - exec_conservator:EXPR <- NULL;
+
+ - exec_conservator:EXPR <- NULL;
- exec_conservator_left left_cst :TYPE :EXPR <- NULL;
- exec_conservator_right right_cst:TYPE :EXPR <- NULL;
-
+
- exec left_cst:TYPE and right_cst:TYPE :EXPR <- NULL;
-
+
- exec:EXPR <- NULL;
- exec_left left_cst :TYPE :EXPR <- NULL;
- exec_right right_cst:TYPE :EXPR <- NULL;
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
- buffer.add_last '(';
+ buffer.add_last '(';
left.genere buffer;
buffer.add_last ' ';
buffer.append symbol;
@@ -197,14 +197,14 @@ Section Public
right.genere buffer;
buffer.add_last ')';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
- buffer.add_last '(';
+ buffer.add_last '(';
left.display buffer;
buffer.append symbol;
right.display buffer;
diff --git a/src/external/logic/expr_not_logic.li b/src/external/logic/expr_not_logic.li
index e3cbf10..893eb5b 100644
--- a/src/external/logic/expr_not_logic.li
+++ b/src/external/logic/expr_not_logic.li
@@ -19,28 +19,28 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_NOT_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Unary not logical expression.";
-
+
Section Inherit
-
+
+ parent_expr_unary_logic:Expanded EXPR_UNARY_LOGIC;
-
-Section Public
-
+
+Section Public
+
- symbol:CHARACTER <- '!';
-
+
//
// Execute.
//
-
- - exec_conservator:EXPR <-
+
+ - exec_conservator:EXPR <-
//-- ! (E1 == E2) -> E1 != E2 (see INTEGER)
//-- ! (E1 >= E2) -> E1 < E2 (see INTEGER)
//-- ! (E1 > E2) -> E1 <= E2 (see INTEGER)
@@ -49,12 +49,12 @@ Section Public
+ sup_eq:EXPR_SUP_EQ;
+ sup:EXPR_SUP;
+ not:EXPR_NOT_LOGIC;
- + result:EXPR;
+ + result:EXPR;
not ?= right;
(not != NULL).if {
result := not.right;
- }.elseif {
+ }.elseif {
eq ?= right;
eq != NULL
} then {
@@ -62,7 +62,7 @@ Section Public
}.elseif {
sup_eq ?= right;
sup_eq != NULL
- } then {
+ } then {
result := EXPR_INF.create position with (sup_eq.left) and (sup_eq.right);
}.elseif {
sup ?= right;
@@ -72,21 +72,21 @@ Section Public
};
result
);
-
- - exec_right right_cst:TYPE :EXPR <-
+
+ - exec_right right_cst:TYPE :EXPR <-
// ! TRUE -> FALSE
// ! FALSE -> TRUE
( + pro:PROTOTYPE_CST;
-
+
pro ?= right;
- (right_cst = type_true).if {
+ (right_cst = type_true).if {
pro.make (pro.position) type (type_false.default);
} else {
pro.make (pro.position) type (type_true.default);
};
right
);
-
+
diff --git a/src/external/logic/expr_or_logic.li b/src/external/logic/expr_or_logic.li
index 21db1ce..554aa13 100644
--- a/src/external/logic/expr_or_logic.li
+++ b/src/external/logic/expr_or_logic.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_OR_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Or binary logical expression.";
-
+
Section Inherit
-
+
+ parent_expr_binary_logic:Expanded EXPR_BINARY_LOGIC;
-
-Section Public
-
+
+Section Public
+
+ symbol:STRING_CONSTANT := "|";
-
+
//
// Execute.
//
-
- - exec_conservator_left left_cst :TYPE :EXPR <-
+
+ - exec_conservator_left left_cst :TYPE :EXPR <-
//-- FALSE | E -> E
( + result:EXPR;
- (left_cst = type_false).if {
+ (left_cst = type_false).if {
result := right;
left.remove;
};
result
);
-
- - exec_conservator_right right_cst:TYPE :EXPR <-
+
+ - exec_conservator_right right_cst:TYPE :EXPR <-
//-- E | FALSE -> E
( + result:EXPR;
@@ -61,7 +61,7 @@ Section Public
};
result
);
-
+
- exec left_cst:TYPE and right_cst:TYPE :EXPR <-
//-- C1 | C2 -> C3
( + result:EXPR;
@@ -72,11 +72,11 @@ Section Public
} else {
result := right;
left.remove;
- };
+ };
result
);
-
- - exec:EXPR <-
+
+ - exec:EXPR <-
//-- (E1 > E2) | (E1 = E2) -> E1 >= E2 (a lot of possibilities, but see INTEGER)
//-- E | E -> E
( + result:EXPR;
@@ -96,10 +96,10 @@ Section Public
};
};
};
- result
+ result
);
- - exec_left left_cst :TYPE :EXPR <-
+ - exec_left left_cst :TYPE :EXPR <-
//-- TRUE | E -> TRUE
( + result:EXPR;
@@ -109,19 +109,19 @@ Section Public
};
result
);
-
- - exec_right right_cst:TYPE :EXPR <-
+
+ - exec_right right_cst:TYPE :EXPR <-
//-- E | TRUE -> TRUE
( + result:EXPR;
-
+
(right_cst = type_true).if {
result := right;
left.remove;
};
result
);
-
-
+
+
diff --git a/src/external/logic/expr_or_or_logic.li b/src/external/logic/expr_or_or_logic.li
index 8c4b798..8eeb3be 100644
--- a/src/external/logic/expr_or_or_logic.li
+++ b/src/external/logic/expr_or_or_logic.li
@@ -19,49 +19,49 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_OR_OR_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Or Binary Expression.";
-
+
Section Inherit
-
+
+ parent_expr_or_logic:Expanded EXPR_OR_LOGIC;
-
-Section Public
-
+
+Section Public
+
+ symbol:STRING_CONSTANT := "||";
-
+
//
// Execute.
//
-
+
- execute_unlink:INSTR <-
- (
+ (
execute_link
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ left_cst,right_cst:PROTOTYPE_CST;
+ left_t,right_t:TYPE;
-
- old_seq := seq_call_and_loop;
- left := left.execute_link;
+
+ old_seq := seq_call_and_loop;
+ left := left.execute_link;
//
seq_or_and := seq_or_and + 1;
seq_inline := seq_inline + 1;
//
- right := right.execute_link;
+ right := right.execute_link;
//
left_cst ?= left;
right_cst ?= right;
-
+
(left_cst != NULL).if { // BSBS : Peux faire mieux !!!
(left_cst.static_type.raw = type_true).if {
left_t := type_true;
@@ -79,21 +79,21 @@ Section Public
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {left_cst != NULL}).if {
+ ((result = NULL) && {left_cst != NULL}).if {
result := exec_conservator_left left_t;
};
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_conservator_right right_t;
};
(
- (result = NULL) &&
- {right_cst != NULL} &&
+ (result = NULL) &&
+ {right_cst != NULL} &&
{left_cst != NULL}
).if {
result := exec left_t and right_t;
- };
- ((result = NULL) && {(old_seq + 1) = seq_call_and_loop}).if {
- // No conservator transformation.
+ };
+ ((result = NULL) && {(old_seq + 1) = seq_call_and_loop}).if {
+ // No conservator transformation.
result := exec;
((result = NULL) && {left_cst != NULL}).if {
result := exec_left left_t;
@@ -108,24 +108,24 @@ Section Public
} else {
new_execute_pass;
};
-
+
result
);
-
+
- exec_conservator:EXPR <-
//-- E || Var -> E | Var
( + rd:READ;
+ result:EXPR;
-
+
rd ?= right;
(rd != NULL).if {
result := EXPR_OR_LOGIC.create position with left and right;
};
result
);
-
+
//-- for || same |
-
+
- exec_conservator_left left_cst :TYPE :EXPR <-
//-- TRUE || E -> TRUE
( + result:EXPR;
@@ -133,8 +133,7 @@ Section Public
((result = NULL) && {left_cst = type_true}).if {
result := left;
right.remove;
- };
+ };
result
);
-
-
\ No newline at end of file
+
diff --git a/src/external/logic/expr_unary_logic.li b/src/external/logic/expr_unary_logic.li
index 8b3e908..7684dbf 100644
--- a/src/external/logic/expr_unary_logic.li
+++ b/src/external/logic/expr_unary_logic.li
@@ -19,95 +19,95 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := EXPR_UNARY_LOGIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Unary logical expression.";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
+
+Section Public
+
- is_invariant:BOOLEAN <- right.is_invariant;
-
+
+ right:EXPR;
-
- - symbol:CHARACTER <-
+
+ - symbol:CHARACTER <-
(
deferred;
' '
);
-
+
- static_type:TYPE_FULL <- type_boolean.default;
-
+
- get_type t:TYPES_TMP <-
- (
- t.add type_true;
+ (
+ t.add type_true;
t.add type_false;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION with r:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p with r;
result
);
-
+
- make p:POSITION with r:EXPR <-
(
position := p;
right := r;
);
-
+
- my_copy:SELF <- SELF.create position with (right.my_copy);
-
+
//
// Comparaison.
//
-
+
- Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
( + same:SELF;
-
+
same ?= other;
(same != NULL) && {right ~= same.right}
- );
-
+ );
+
- remove <-
- (
+ (
right.remove;
);
-
+
//
// Execute.
//
-
+
- execute_unlink:INSTR <-
(
right.execute_unlink
);
-
+
- execute_link:EXPR <-
( + result:EXPR;
+ old_seq:UINTEGER_32;
+ right_cst:PROTOTYPE_CST;
+ right_t:TYPE;
-
- old_seq := seq_call_and_loop;
- right := right.execute_link;
- //
+
+ old_seq := seq_call_and_loop;
+ right := right.execute_link;
+ //
right_cst ?= right;
- (right_cst != NULL).if {
+ (right_cst != NULL).if {
(right_cst.static_type.raw = type_true).if {
right_t := type_true;
} else {
@@ -117,12 +117,12 @@ Section Public
// Conservator transformation.
result := exec_conservator;
- ((result = NULL) && {right_cst != NULL}).if {
+ ((result = NULL) && {right_cst != NULL}).if {
result := exec_right right_t;
};
- ((result = NULL) && {old_seq = seq_call_and_loop}).if {
- // No conservator transformation.
- result := exec;
+ ((result = NULL) && {old_seq = seq_call_and_loop}).if {
+ // No conservator transformation.
+ result := exec;
};
//
(result = NULL).if {
@@ -131,20 +131,20 @@ Section Public
result.set_position position;
new_execute_pass;
};
-
+
result
);
-
- - exec_conservator:EXPR <- NULL;
-
+
+ - exec_conservator:EXPR <- NULL;
+
- exec_right right_cst:TYPE :EXPR <- NULL;
-
+
- exec:EXPR <- NULL;
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
(
buffer.add_last '(';
@@ -152,12 +152,12 @@ Section Public
buffer.add_last ' ';
right.genere buffer;
buffer.add_last ')';
- );
-
+ );
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.add_last '(';
diff --git a/src/external/put_to.li b/src/external/put_to.li
index 0baefaf..88d5d35 100644
--- a/src/external/put_to.li
+++ b/src/external/put_to.li
@@ -19,54 +19,54 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PUT_TO;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Put for NATIVE_ARRAY(E) (see ITEM)";
-
+
Section Inherit
-
- + parent_expr:Expanded EXPR; // BSBS: C'est une INSTR, mais pb dans ITM_EXTERNAL
-
-Section Public
-
- - is_invariant:BOOLEAN <-
- receiver.is_invariant && {index.is_invariant} && {value.is_invariant};
-
+
+ + parent_expr:Expanded EXPR; // BSBS: C'est une INSTR, mais pb dans ITM_EXTERNAL
+
+Section Public
+
+ - is_invariant:BOOLEAN <-
+ receiver.is_invariant && {index.is_invariant} && {value.is_invariant};
+
+ receiver:EXPR;
-
+
+ index:EXPR;
-
+
+ value:EXPR;
-
+
- static_type:TYPE_FULL <- TYPE_VOID.default;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add TYPE_VOID;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION base rec:EXPR index idx:EXPR value v:EXPR :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p base rec index idx value v;
result
);
-
+
- make p:POSITION base rec:EXPR index idx:EXPR value v:EXPR <-
( + type_generic:TYPE_GENERIC;
+ first_type:TYPE_FULL;
-
- position := p;
+
+ position := p;
receiver := rec;
index := idx;
value := v;
@@ -74,28 +74,28 @@ Section Public
type_generic ?= receiver.static_type.raw;
first_type := type_generic.generic_list.first;
(
- (! first_type.is_expanded) ||
+ (! first_type.is_expanded) ||
{first_type.raw = type_boolean}
).if {
type_generic.add_put_to Self;
};
);
-
- - my_copy:SELF <-
+
+ - my_copy:SELF <-
SELF.create position base (receiver.my_copy) index (index.my_copy) value (value.my_copy);
-
+
//
// Remove
//
-
+
- remove <-
( + type_generic:TYPE_GENERIC;
+ first_type:TYPE_FULL;
-
+
type_generic ?= receiver.static_type.raw;
first_type := type_generic.generic_list.first;
(
- (! first_type.is_expanded) ||
+ (! first_type.is_expanded) ||
{first_type.raw = type_boolean}
).if {
type_generic.remove_put_to Self;
@@ -103,38 +103,38 @@ Section Public
//
receiver.remove;
index.remove;
- value.remove;
+ value.remove;
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- (
+ (
execute_link
);
-
+
- execute_link:EXPR <-
- (
+ (
receiver := receiver.execute_link;
- index := index.execute_link;
+ index := index.execute_link;
value := value.execute_link;
Self
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
( + type_generic:TYPE_GENERIC;
+ first_type:TYPE_FULL;
-
+
receiver.genere buffer;
buffer.add_last '[';
index.genere buffer;
- buffer.append "]=";
+ buffer.append "]=";
type_generic ?= receiver.static_type.raw;
first_type := type_generic.generic_list.first;
((first_type.is_expanded) && {! first_type.is_expanded_c}).if {
@@ -143,17 +143,17 @@ Section Public
value.genere buffer;
buffer.add_last ')';
} else {
- value.genere buffer;
+ value.genere buffer;
};
} else {
value.genere buffer;
};
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
receiver.display buffer;
diff --git a/src/external/size_of.li b/src/external/size_of.li
index f875ef8..f7b77a8 100644
--- a/src/external/size_of.li
+++ b/src/external/size_of.li
@@ -19,91 +19,91 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SIZE_OF;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Size of object";
-
+
Section Inherit
-
+
+ parent_expr:Expanded EXPR;
-
-Section Public
-
- - is_invariant:BOOLEAN <- TRUE;
-
+
+Section Public
+
+ - is_invariant:BOOLEAN <- TRUE;
+
+ receiver:TYPE_FULL;
-
+
- static_type:TYPE_FULL <- type_integer.default;
-
+
- get_type t:TYPES_TMP <-
- (
+ (
t.add type_integer;
);
-
+
//
// Creation.
//
-
+
- create p:POSITION receiver e:TYPE_FULL :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p receiver e;
result
);
-
+
- make p:POSITION receiver e:TYPE_FULL <-
(
- position := p;
- receiver := e;
+ position := p;
+ receiver := e;
);
-
- - my_copy:SELF <- SELF.create position receiver receiver;
+
+ - my_copy:SELF <- SELF.create position receiver receiver;
// BSBS: Tu peux meme juste renvoyer Self! Non ?
-
+
//
// Remove
//
-
+
- remove <-
(
// Nothing.
);
-
+
//
// Execute
//
-
+
- execute_unlink:INSTR <-
- (
+ (
NULL
);
-
+
- execute_link:EXPR <-
- (
+ (
Self
);
-
+
//
// Genere.
//
-
+
- genere buffer:STRING <-
- (
- buffer.append "sizeof(";
+ (
+ buffer.append "sizeof(";
receiver.raw.put_expanded_declaration buffer;
- buffer.add_last ')';
+ buffer.add_last ')';
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append "size_of(";
diff --git a/src/item/itm_arg.li b/src/item/itm_arg.li
index fe206ac..28be22f 100644
--- a/src/item/itm_arg.li
+++ b/src/item/itm_arg.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_ARG;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "One argument";
-
+
Section Inherit
-
+
+ parent_itm_argument:Expanded ITM_ARGUMENT;
-
+
Section Public
+ name:STRING_CONSTANT;
-
+
+ type:ITM_TYPE_MONO;
-
+
- upper:INTEGER := 0;
-
+
//
// Creation.
//
-
+
- create p:POSITION name n:STRING_CONSTANT type t:ITM_TYPE_MONO :SELF <-
( + result:SELF;
-
+
result := SELF.clone;
result.make p name n type t;
result
@@ -58,27 +58,27 @@ Section Public
name := n;
type := t;
);
-
+
//
// Running.
//
-
- - item idx:INTEGER :ITM_TYPE_MONO <-
+
+ - item idx:INTEGER :ITM_TYPE_MONO <-
( ? {idx = 0};
type
- );
+ );
- to_run_in arg_lst:FAST_ARRAY(LOCAL) for p:PARAMETER_TO_TYPE <-
( + t:ITM_TYPE_MONO;
-
+
(name = ALIAS_STR.variable_self).if {
t := ITM_TYPE_SIMPLE.type_self;
} else {
t := type;
- };
+ };
arg_lst.add_last (
LOCAL.create position name name style ' ' type (t.to_run_for p)
- );
+ );
);
- get_index_type p:ITM_TYPE_PARAMETER :INTEGER <-
@@ -88,24 +88,24 @@ Section Public
};
result
);
-
+
- check larg:FAST_ARRAY(EXPR) index idx:INTEGER for p:PARAMETER_TO_TYPE :INTEGER <-
( + new_expr:EXPR;
-
+
new_expr := larg.item idx.check_type (type.to_run_for p) with position;
larg.put new_expr to idx;
idx + 1
- );
+ );
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append name;
buffer.add_last ':';
- type.append_in buffer;
+ type.append_in buffer;
);
- shorter_in buf:STRING <-
@@ -116,7 +116,7 @@ Section Public
put name to buf like (ALIAS_STR.short_local);
};
buf.add_last ':';
- type.shorter_in buf;
+ type.shorter_in buf;
);
-
-
+
+
diff --git a/src/item/itm_args.li b/src/item/itm_args.li
index ef06909..a5a1a6e 100644
--- a/src/item/itm_args.li
+++ b/src/item/itm_args.li
@@ -19,71 +19,71 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_ARGS;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "One argument vector";
-
+
Section Inherit
-
+
+ parent_itm_argument:Expanded ITM_ARGUMENT;
-
+
Section Public
+ name:FAST_ARRAY(STRING_CONSTANT);
-
+
+ type:ITM_TYPE_MULTI;
-
+
- upper:INTEGER <- name.upper;
-
+
//
// Creation.
//
-
- - create p:POSITION name n:FAST_ARRAY(STRING_CONSTANT)
+
+ - create p:POSITION name n:FAST_ARRAY(STRING_CONSTANT)
type t:ITM_TYPE_MULTI :SELF <-
( + result:SELF;
-
+
result := SELF.clone;
result.make p name n type t;
result
);
- - make p:POSITION name n:FAST_ARRAY(STRING_CONSTANT)
+ - make p:POSITION name n:FAST_ARRAY(STRING_CONSTANT)
type t:ITM_TYPE_MULTI <-
(
position := p;
name := n;
type := t;
);
-
+
//
// Running.
//
- - item idx:INTEGER :ITM_TYPE_MONO <-
+ - item idx:INTEGER :ITM_TYPE_MONO <-
( ? {idx.in_range 0 to upper};
type.item idx
);
-
+
- to_run_in arg_lst:FAST_ARRAY(LOCAL) for p:PARAMETER_TO_TYPE <-
( + t:TYPE_FULL;
-
+
(name.lower).to (name.upper) do { j:INTEGER;
- t := type.item j.to_run_for p;
+ t := type.item j.to_run_for p;
arg_lst.add_last (
LOCAL.create position name (name.item j) style ' ' type t
);
};
);
-
+
- get_index_type p:ITM_TYPE_PARAMETER :INTEGER <-
( + i:INTEGER;
-
+
i := name.lower;
{(i <= name.upper) && {type.item i != p}}.while_do {
i := i + 1;
@@ -93,22 +93,22 @@ Section Public
- check larg:FAST_ARRAY(EXPR) index idx:INTEGER for p:PARAMETER_TO_TYPE :INTEGER <-
( + new_expr:EXPR;
-
+
(type.lower).to (type.upper) do { i:INTEGER;
new_expr := larg.item (idx+i).check_type (type.item i.to_run_for p) with position;
larg.put new_expr to (idx+i);
};
idx + type.count
- );
-
+ );
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
- (
+ (
buffer.add_last '(';
- (name.lower).to (name.upper - 1) do { j:INTEGER;
+ (name.lower).to (name.upper - 1) do { j:INTEGER;
buffer.append (name.item j);
buffer.add_last ':';
type.item j.append_in buffer;
@@ -116,14 +116,14 @@ Section Public
};
buffer.append (name.last);
buffer.add_last ':';
- type.last.append_in buffer;
+ type.last.append_in buffer;
buffer.add_last ')';
);
-
+
- shorter_in buf:STRING <-
(
buf.add_last '(';
- (name.lower).to (name.upper - 1) do { j:INTEGER;
+ (name.lower).to (name.upper - 1) do { j:INTEGER;
(name.item j = ALIAS_STR.variable_self).if {
put (name.item j) to buf like (ALIAS_STR.short_keyword);
} else {
@@ -135,8 +135,8 @@ Section Public
};
put (name.last) to buf like (ALIAS_STR.short_local);
buf.add_last ':';
- type.last.shorter_in buf;
+ type.last.shorter_in buf;
buf.add_last ')';
);
-
+
diff --git a/src/item/itm_argument.li b/src/item/itm_argument.li
index f39fc13..d9be173 100644
--- a/src/item/itm_argument.li
+++ b/src/item/itm_argument.li
@@ -19,62 +19,62 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_ARGUMENT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent argument";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_OBJECT;
-
+
Section Public
-
+
- lower:INTEGER <- 0;
-
+
- upper:INTEGER <- ( deferred; 0);
-
+
- count:INTEGER <- upper + 1;
//
// Running.
//
-
- - item idx:INTEGER :ITM_TYPE_MONO <-
+
+ - item idx:INTEGER :ITM_TYPE_MONO <-
(
deferred;
NULL
);
-
+
- to_run_in arg_lst:FAST_ARRAY(LOCAL) for p:PARAMETER_TO_TYPE <-
(
deferred;
);
-
+
- get_index_type p:ITM_TYPE_PARAMETER :INTEGER <-
(
deferred;
);
-
+
- check larg:FAST_ARRAY(EXPR) index idx:INTEGER for p:PARAMETER_TO_TYPE :INTEGER <-
(
deferred;
0
);
-
+
//
// Comparaison.
//
-
- - is_equal other:ITM_ARGUMENT <-
+
+ - is_equal other:ITM_ARGUMENT <-
( + o:SELF;
+ err:STRING_CONSTANT;
? {other != Self};
-
+
o ?= other;
(o = NULL).if {
err := "Invariance number vector argument invalid.";
@@ -90,19 +90,19 @@ Section Public
POSITION.send_error;
};
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
deferred;
);
-
+
- shorter_in buf:STRING <-
(
deferred;
);
-
-
+
+
diff --git a/src/item/itm_binary.li b/src/item/itm_binary.li
index 5b6e120..2dba8f5 100644
--- a/src/item/itm_binary.li
+++ b/src/item/itm_binary.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_BINARY;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Binary operator message";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
//
@@ -46,17 +46,17 @@ Section Public
//
// Constructor
- //
+ //
- - create p:FAST_ARRAY(POSITION) values v:FAST_ARRAY(ITM_CODE)
+ - create p:FAST_ARRAY(POSITION) values v:FAST_ARRAY(ITM_CODE)
operators o:FAST_ARRAY(STRING_CONSTANT) :SELF <-
( + result:SELF;
result := clone;
result.make p values v operators o;
result
);
-
- - make p:FAST_ARRAY(POSITION) values v:FAST_ARRAY(ITM_CODE)
+
+ - make p:FAST_ARRAY(POSITION) values v:FAST_ARRAY(ITM_CODE)
operators o:FAST_ARRAY(STRING_CONSTANT) <-
(
? { p.count=o.count };
@@ -75,7 +75,7 @@ Section Public
+ max_pri :STRING_CONSTANT;
+ expr :INSTR;
+ val_list:FAST_ARRAY(EXPR);
- + val:EXPR;
+ + val:EXPR;
+ typ_list:TYPES_TMP;
+ typ:TYPE;
+ slo_list:FAST_ARRAY(SLOT);
@@ -99,14 +99,14 @@ Section Public
slo_list := ALIAS_ARRAY(SLOT).new;
// ITM_CODE -> EXPR
- (value_list.lower).to (value_list.upper) do { j:INTEGER;
- val := value_list.item j.to_run_expr;
+ (value_list.lower).to (value_list.upper) do { j:INTEGER;
+ val := value_list.item j.to_run_expr;
val_list.add_last val;
- typ := val.static_type.raw;
+ typ := val.static_type.raw;
typ_list.add typ;
};
-
- // Error verification.
+
+ // Error verification.
(operator_list.lower).to (operator_list.upper) do { j:INTEGER;
nam := operator_list.item j;
((nam = ALIAS_STR.operator_equal) || {nam = ALIAS_STR.operator_not_equal}).if {
@@ -127,13 +127,13 @@ Section Public
error_slot (position_list.item j) name nam in typ list typ_list;
} else {
(slo_ref.priority_and_level != slo.priority_and_level).if {
- position.put_error semantic text
+ position.put_error semantic text
"Conflicting declaration associativity or priority.";
slo_ref.position.put_position;
slo.position.put_position;
- position_list.item j.put_position;
+ position_list.item j.put_position;
position.send_error;
- };
+ };
};
};
};
@@ -158,11 +158,11 @@ Section Public
};
} else {
// Other:
- (
+ (
(slo.priority > max_lev) ||
{
- (slo.priority = max_lev) &&
- {slo.associativity = max_pri} &&
+ (slo.priority = max_lev) &&
+ {slo.associativity = max_pri} &&
{max_pri = ALIAS_STR.keyword_right}
}
).if {
@@ -180,20 +180,20 @@ Section Public
{slo_list.item (max_pos+1).associativity != max_pri}
).if {
warning_error ((pos_list.item max_pos),
- "Conflicting left/right priority.");
+ "Conflicting left/right priority.");
};
-
+
(slo_list.item max_pos = NULL).if {
// '=' or '!='.
(ope_list.item max_pos = ALIAS_STR.operator_equal).if {
- extern := EXPR_EQUAL.create (pos_list.item max_pos) with
+ extern := EXPR_EQUAL.create (pos_list.item max_pos) with
(val_list.item max_pos) and (val_list.item (max_pos+1));
} else {
- extern := EXPR_NOT_EQUAL.create (pos_list.item max_pos) with
+ extern := EXPR_NOT_EQUAL.create (pos_list.item max_pos) with
(val_list.item max_pos) and (val_list.item (max_pos+1));
- };
+ };
loc := type_boolean.default.get_temporary (pos_list.item max_pos);
- expr := loc.write (pos_list.item max_pos) value extern;
+ expr := loc.write (pos_list.item max_pos) value extern;
list_current.add_last expr;
val := loc.read (pos_list.item max_pos);
} else {
@@ -201,42 +201,42 @@ Section Public
l_arg := FAST_ARRAY(EXPR).create_with_capacity 2;
l_arg.add_last (val_list.item max_pos);
l_arg.add_last (val_list.item (max_pos + 1));
-
- site := NODE.new_read (pos_list.item max_pos)
+
+ site := NODE.new_read (pos_list.item max_pos)
slot (slo_list.item max_pos)
receiver (l_arg.first.my_copy)
- with l_arg;
-
+ with l_arg;
+
list_current.add_last site;
val := site.result_expr;
};
-
+
// Delete operator.
- slo_list.remove max_pos;
- ope_list.remove max_pos;
- pos_list.remove max_pos;
+ slo_list.remove max_pos;
+ ope_list.remove max_pos;
+ pos_list.remove max_pos;
val_list.remove (max_pos+1);
//
- val_list.put val to max_pos;
+ val_list.put val to max_pos;
};
result := val_list.first;
-
+
// Free Array Temporary.
- ALIAS_ARRAY(STRING_CONSTANT).free ope_list;
- ALIAS_ARRAY(POSITION).free pos_list;
+ ALIAS_ARRAY(STRING_CONSTANT).free ope_list;
+ ALIAS_ARRAY(POSITION).free pos_list;
ALIAS_ARRAY(EXPR).free val_list;
typ_list.free;
ALIAS_ARRAY(SLOT).free slo_list;
-
+
result
);
-
-Section Private
-
+
+Section Private
+
- error_slot p:POSITION name s:STRING_CONSTANT in t:TYPE list st:TYPES_TMP <-
(
- string_tmp.copy "Slot '";
+ string_tmp.copy "Slot '";
string_tmp.append s;
string_tmp.append "' not found in ";
string_tmp.append (t.name);
diff --git a/src/item/itm_block.li b/src/item/itm_block.li
index a1342c5..e8c9057 100644
--- a/src/item/itm_block.li
+++ b/src/item/itm_block.li
@@ -19,65 +19,65 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_BLOCK;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Instruction block";
-
+
// BSBS: Memory : Faire la version sans argument (très courant)
-
+
Section Inherit
-
+
- parent_itm_code:ITM_CODE := ITM_CODE;
-
+
Section Public
-
+
- position:POSITION <- list.position;
-
+
+ list:ITM_LIST;
-
+
+ argument:ITM_ARGUMENT;
-
+
//
// Creation.
//
-
+
- create lst:ITM_LIST argument arg:ITM_ARGUMENT :SELF <-
( + result:SELF;
-
+
result := clone;
result.make lst argument arg;
result
);
-
+
- make lst:ITM_LIST argument arg:ITM_ARGUMENT <-
(
list := lst;
argument := arg;
);
-
+
//
// Runnable.
//
-
+
- to_run_expr:EXPR <-
- ( + tb:PROFIL_BLOCK;
- + t:TYPE_FULL;
- + loc,my_self:LOCAL;
+ ( + tb:PROFIL_BLOCK;
+ + t:TYPE_FULL;
+ + loc,my_self:LOCAL;
+ val,rec:EXPR;
+ wrt:WRITE;
-
+
tb := PROFIL_BLOCK.create Self;
t := tb.default;
//
- loc := t.get_temporary position;
+ loc := t.get_temporary position;
// tmp.id := id_block;
rec := loc.read position;
- val := PROTOTYPE_CST.create position type t;
+ val := PROTOTYPE_CST.create position type t;
wrt := tb.slot_value.write position with rec value val;
list_current.add_last wrt;
// tmp.self := Self;
@@ -89,13 +89,13 @@ Section Public
// tmp
loc.read position
);
-
- //
+
+ //
// Display.
//
-
+
- print <-
(
"{BLOCK}".print;
);
-
+
diff --git a/src/item/itm_character.li b/src/item/itm_character.li
index 95e98fe..9c6c314 100644
--- a/src/item/itm_character.li
+++ b/src/item/itm_character.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_CHARACTER;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Character constant";
-
+
Section Inherit
-
+
+ parent_itm_constant:Expanded ITM_CONSTANT;
-
+
Section Public
//
@@ -50,7 +50,7 @@ Section Public
result.make p char n;
result
);
-
+
- make p:POSITION char n:STRING_CONSTANT <-
(
position:=p;
@@ -62,14 +62,14 @@ Section Public
//
- to_run_expr:EXPR <-
- (
- CHARACTER_CST.create position char character
+ (
+ CHARACTER_CST.create position char character
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.add_last '\'';
diff --git a/src/item/itm_code.li b/src/item/itm_code.li
index 5c92dc4..579366c 100644
--- a/src/item/itm_code.li
+++ b/src/item/itm_code.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_CODE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all item code";
-
+
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
-
+
Section Public
-
- // Use by PARSER, for left expr assignment ( in EXPR1 := EXPR2, EXPR1.is_affect).
+
+ // Use by PARSER, for left expr assignment ( in EXPR1 := EXPR2, EXPR1.is_affect).
- is_affect:POSITION <- position;
-
+
//
// Flags.
//
@@ -45,32 +45,32 @@ Section Public
//
// Runnable.
- //
-
+ //
+
- to_run:INSTR <-
(
to_run_expr
);
-
+
- to_run_expr:EXPR <-
- (
+ (
warning_error (position,"Error: ITM_CODE.to_run");
deferred;
NULL
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
"ITM_CODE : Type:".print;
- type_id_intern.print;
+ type_id_intern.print;
'\n'.print;
deferred;
);
-
+
- print <-
(
string_tmp.clear;
diff --git a/src/item/itm_constant.li b/src/item/itm_constant.li
index cd48718..856123d 100644
--- a/src/item/itm_constant.li
+++ b/src/item/itm_constant.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_CONSTANT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all constant";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
- is_constant:BOOLEAN := TRUE;
diff --git a/src/item/itm_expression.li b/src/item/itm_expression.li
index 8b4adb6..8bf9ad8 100644
--- a/src/item/itm_expression.li
+++ b/src/item/itm_expression.li
@@ -90,7 +90,7 @@ Section Public
{
idx := idx + 1;
itm_op ?= value_list.item idx;
- }.do_while {(itm_op != NULL) && {idx != value_list.upper}};
+ }.do_while {(itm_op != NULL) && {idx != value_list.upper}};
(itm_op != NULL).if {
semantic_error (itm_op.position,"Operator postfix not found.");
};
@@ -99,7 +99,7 @@ Section Public
(typ = TYPE_VOID).if {
semantic_error (val.position,"Expression type `Void'.");
};
- // Post-fix.
+ // Post-fix.
idx_post := idx + 1;
continue := TRUE;
{(idx_post <= value_list.upper) && {continue}}.while_do {
@@ -110,7 +110,7 @@ Section Public
((idx_post = value_list.upper) || {itm_op != NULL}).if {
itm_op ?= value_list.item idx_post;
slo := typ.get_slot (operator (ALIAS_STR.slot_postfix) name (itm_op.name));
- (slo != NULL).if {
+ (slo != NULL).if {
site := NODE.new_read (itm_op.position) slot slo receiver val self val intern FALSE;
list_current.add_last site;
val := site.result_expr;
@@ -130,12 +130,12 @@ Section Public
((idx_pre = low) || {itm_op != NULL}).if {
itm_op ?= value_list.item idx_pre;
slo := typ.get_slot (operator (ALIAS_STR.slot_prefix) name (itm_op.name));
- (slo = NULL).if {
+ (slo = NULL).if {
error_slot (itm_op.position) name "prefix" operator (itm_op.name) in typ;
};
site := NODE.new_read (itm_op.position) slot slo receiver val self val intern FALSE;
list_current.add_last site;
- val := site.result_expr;
+ val := site.result_expr;
idx_pre := idx_pre - 1;
continue := TRUE;
};
@@ -182,7 +182,7 @@ Section Public
max_pri := ALIAS_STR.keyword_right;
max_pos := j;
};
- } else {
+ } else {
// Other:
slo := site.data.slot;
(
@@ -205,8 +205,8 @@ Section Public
right ?= val_list.item (max_pos + 1);
(n_t = NULL).if {
// '=' or '!='.
- extern ?= val_list.item max_pos;
- extern.set_left left and_right right;
+ extern ?= val_list.item max_pos;
+ extern.set_left left and_right right;
loc := type_boolean.default.get_temporary (extern.position);
instr:= loc.write (extern.position) value extern;
list_current.add_last instr;
diff --git a/src/item/itm_extern.li b/src/item/itm_extern.li
index a1beeae..0558ebf 100644
--- a/src/item/itm_extern.li
+++ b/src/item/itm_extern.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_EXTERN;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for externals";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
//
@@ -40,19 +40,19 @@ Section Public
+ extern:STRING_CONSTANT;
- //
+ //
// Constructor.
//
-
+
- last_code:STRING_CONSTANT;
-
+
- get_access:FAST_ARRAY(EXPR) <-
( + idx,base:INTEGER;
+ e:EXPR;
+ loc:STRING_CONSTANT;
+ var:VARIABLE;
+ access_list:FAST_ARRAY(EXPR);
-
+
string_tmp2.copy extern;
idx := string_tmp2.index_of '@' since (string_tmp2.lower);
(idx <= string_tmp2.count).if {
@@ -60,9 +60,9 @@ Section Public
{idx > string_tmp2.upper}.until_do {
base := idx;
idx := idx + 1;
- string_tmp.clear;
+ string_tmp.clear;
{
- (idx > string_tmp2.upper) ||
+ (idx > string_tmp2.upper) ||
{
(! string_tmp2.item idx.is_letter_or_digit) &&
{string_tmp2.item idx != '_'}
@@ -89,7 +89,7 @@ Section Public
};
e := var.read position;
access_list.add_last e;
-
+
string_tmp2.remove_between base to (base+loc.count);
string_tmp2.insert_string "(@)" to base;
idx := string_tmp2.index_of '@' since (base+2);
@@ -99,11 +99,11 @@ Section Public
last_code := ALIAS_STR.get string_tmp2;
access_list
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.add_last '`';
diff --git a/src/item/itm_external.li b/src/item/itm_external.li
index e67770b..30f41b7 100644
--- a/src/item/itm_external.li
+++ b/src/item/itm_external.li
@@ -73,7 +73,7 @@ Section Public
exp1 := profil_slot.argument_list.first.read position;
result := IS_EXPANDED.create position receiver exp1;
}
- .when 1 then { // type_id_intern:INTEGER
+ .when 1 then { // type_id_intern:INTEGER
result := GET_TYPE_ID.create position receiver
(profil_slot.argument_list.first.type);
}
@@ -85,32 +85,32 @@ Section Public
.when 3 then { // INTEGER - INTEGER -> INTEGER.
left := profil_slot.argument_list.first .read position;
right := profil_slot.argument_list.item 1.read position;
- result := EXPR_SUB.create position with left and right;
+ result := EXPR_SUB.create position with left and right;
}
.when 4 then { // INTEGER * INTEGER -> INTEGER.
left := profil_slot.argument_list.first .read position;
right := profil_slot.argument_list.item 1.read position;
- result := EXPR_MUL.create position with left and right;
+ result := EXPR_MUL.create position with left and right;
}
- .when 5 then { // INTEGER / INTEGER -> INTEGER.
+ .when 5 then { // INTEGER / INTEGER -> INTEGER.
left := profil_slot.argument_list.first .read position;
right := profil_slot.argument_list.item 1.read position;
- result := EXPR_DIV.create position with left and right;
+ result := EXPR_DIV.create position with left and right;
}
.when 6 then { // INTEGER & INTEGER -> INTEGER.
left := profil_slot.argument_list.first .read position;
right := profil_slot.argument_list.item 1.read position;
- result := EXPR_AND.create position with left and right;
+ result := EXPR_AND.create position with left and right;
}
.when 7 then { // INTEGER >> INTEGER -> INTEGER.
left := profil_slot.argument_list.first .read position;
right := profil_slot.argument_list.item 1.read position;
- result := EXPR_SHIFT_R.create position with left and right;
+ result := EXPR_SHIFT_R.create position with left and right;
}
.when 8 then { // INTEGER << INTEGER -> INTEGER.
left := profil_slot.argument_list.first .read position;
right := profil_slot.argument_list.item 1.read position;
- result := EXPR_SHIFT_L.create position with left and right;
+ result := EXPR_SHIFT_L.create position with left and right;
}
.when 9 then { // put OBJECT to INTEGER.
exp1 := profil_slot.argument_list.first .read position;
@@ -126,7 +126,7 @@ Section Public
.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.
+ .when 12 then { // object_size -> INTEGER.
result := SIZE_OF.create position receiver
(profil_slot.argument_list.first.type);
}
@@ -146,9 +146,9 @@ Section Public
.when 15 then { // is_cop_type:BOOLEAN
type := profil_slot.argument_list.first.type;
(type.prototype.style = '-').if {
- result := PROTOTYPE_CST.create position type (type_true.default);
+ result := PROTOTYPE_CST.create position type (type_true.default);
} else {
- result := PROTOTYPE_CST.create position type (type_false.default);
+ result := PROTOTYPE_CST.create position type (type_false.default);
};
}
.when 16 then { // LIST.upper:INTEGER
@@ -162,10 +162,10 @@ Section Public
}
.when 19 then { // compiler_optimization -> BOOLEAN.
(is_optimization).if {
- result := PROTOTYPE_CST.create position type (type_true.default);
+ result := PROTOTYPE_CST.create position type (type_true.default);
} else {
- result := PROTOTYPE_CST.create position type (type_false.default);
- };
+ result := PROTOTYPE_CST.create position type (type_false.default);
+ };
}
.when 20 then { // compiler_built_on -> STRING_CONSTANT.
string_tmp.clear;
diff --git a/src/item/itm_external_type.li b/src/item/itm_external_type.li
index 07880a7..58c2e25 100644
--- a/src/item/itm_external_type.li
+++ b/src/item/itm_external_type.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_EXTERNAL_TYPE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "External C with type result";
-
+
Section Inherit
-
+
+ parent_itm_extern:Expanded ITM_EXTERN;
-
+
Section Public
//
@@ -47,21 +47,21 @@ Section Public
//
// Constructor
//
-
+
- create p:POSITION text n:STRING_CONSTANT persistant per:BOOLEAN :SELF <-
( + result:SELF;
result := clone;
result.make p text n persistant per;
result
);
-
+
- make p:POSITION text n:STRING_CONSTANT persistant per:BOOLEAN <-
(
position := p;
extern := n;
is_persistant := per;
);
-
+
//
// Added
//
@@ -79,23 +79,23 @@ Section Public
//
// Runnable
//
-
- - to_run_expr:EXPR <-
+
+ - to_run_expr:EXPR <-
( + e:EXTERNAL_C;
+ lt:TYPES_TMP;
+ lst_acc:FAST_ARRAY(EXPR);
+ typ:TYPE;
- + tmp:VARIABLE;
+ + tmp:VARIABLE;
lst_acc := get_access;
last_position := position;
- e := EXTERNAL_C.create position text last_code
+ e := EXTERNAL_C.create position text last_code
access lst_acc persistant is_persistant type (type.to_run_for profil_slot);
-
+
(type_list != NULL).if {
lt := TYPES_TMP.new;
(type_list.lower).to (type_list.upper) do { j:INTEGER;
- typ := type_list.item j.to_run_for profil_slot.raw;
+ typ := type_list.item j.to_run_for profil_slot.raw;
lt.add typ;
};
e.set_living_type (lt.to_types);
diff --git a/src/item/itm_ldots.li b/src/item/itm_ldots.li
index 4427dcb..2e8dad5 100644
--- a/src/item/itm_ldots.li
+++ b/src/item/itm_ldots.li
@@ -19,37 +19,37 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_LDOTS;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "`...' for inherit contract";
-
+
Section Inherit
-
+
+ parent_itm_constant:Expanded ITM_CODE;
-
+
Section Public
//
// Constructor
//
-
+
- create p:POSITION :SELF <-
( + result:SELF;
result := clone;
result.make p;
result
);
-
+
- make p:POSITION <-
(
position := p;
);
-
+
//
// Runnable
//
@@ -58,7 +58,7 @@ Section Public
( + contract:ITM_LIST;
+ result:INSTR;
+ slot_code:SLOT_CODE;
-
+
slot_code ?= profil_slot.slot;
contract := slot_code.previous_contract;
(contract != NULL).if {
@@ -68,7 +68,7 @@ Section Public
};
result
);
-
+
- to_run_expr:EXPR <-
(
warning_error (position,"ITM_LDOTS.to_run_expr");
@@ -79,9 +79,8 @@ Section Public
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append "...";
);
-
\ No newline at end of file
diff --git a/src/item/itm_list.li b/src/item/itm_list.li
index f534a9d..6302b18 100644
--- a/src/item/itm_list.li
+++ b/src/item/itm_list.li
@@ -19,38 +19,38 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_LIST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Instruction list";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
-
+
// BSBS: OPTIM : Dans 95% des cas, les list sont sans local (il faudrait spécialiser)
// Mais pb avec le parser...
-
+
//
// Data
//
+ local_list:FAST_ARRAY(ITM_LOCAL); // `+'
-
+
+ static_list:FAST_ARRAY(ITM_LOCAL); // `-'
+ code:FAST_ARRAY(ITM_CODE);
-
+
+ is_check_name:BOOLEAN;
-
+
- is_check_local:INTEGER;
-
+
//
// Constructor
//
@@ -61,12 +61,12 @@ Section Public
result.make p;
result
);
-
+
- make p:POSITION <-
(
- position := p;
+ position := p;
);
-
+
//
// Added
//
@@ -82,19 +82,19 @@ Section Public
? {! l.is_empty};
static_list := l;
);
-
+
- set_code c:FAST_ARRAY(ITM_CODE) <-
(
code := c;
- );
-
+ );
+
Section Public
-
+
- is_affect:POSITION <-
( + result,default:POSITION;
+ j:INTEGER;
+ itm_r:ITM_RESULT;
-
+
j := code.lower;
{(j < code.upper) && {result = default}}.while_do {
itm_r ?= code.item j;
@@ -110,49 +110,49 @@ Section Public
};
result
);
-
+
//
// Runnable.
//
-
- - to_run_expr:EXPR <-
+
+ - to_run_expr:EXPR <-
// List intern.
( + i:INSTR;
- + var:LOCAL;
+ + var:LOCAL;
+ stack_top:INTEGER;
+ result_top:INTEGER;
+ result:EXPR;
+ nb_result:INTEGER;
+ lr:FAST_ARRAY(EXPR);
-
+
stack_top := stack_local .upper + 1;
result_top := stack_result.upper + 1;
-
+
// Push Local.
- (local_list != NULL).if {
+ (local_list != NULL).if {
(local_list.lower).to (local_list.upper) do { j:INTEGER;
var := local_list.item j.to_run;
stack_local.add_last var;
- var.init;
- };
+ var.init;
+ };
};
- (static_list != NULL).if {
+ (static_list != NULL).if {
(static_list.lower).to (static_list.upper) do { j:INTEGER;
var := static_list.item j.to_run_static;
- stack_local.add_last var;
- };
- };
+ stack_local.add_last var;
+ };
+ };
// Append code.
(code.lower).to (code.upper) do { j:INTEGER;
- i := code.item j.to_run;
+ i := code.item j.to_run;
list_current.add_last i;
- };
- // Compute result expr.
- nb_result := stack_result.upper - result_top + 1;
-
- (nb_result = 0).if {
- result := PROTOTYPE_CST.create position type (TYPE_VOID.default); // BSBS: Alias.
- } else {
+ };
+ // Compute result expr.
+ nb_result := stack_result.upper - result_top + 1;
+
+ (nb_result = 0).if {
+ result := PROTOTYPE_CST.create position type (TYPE_VOID.default); // BSBS: Alias.
+ } else {
(nb_result > 1).if {
// Creation Vector.
lr := FAST_ARRAY(EXPR).create_with_capacity nb_result;
@@ -163,40 +163,40 @@ Section Public
} else {
result := stack_result.last.read position;
};
- };
+ };
// Pop local / Result.
- pop_stack_until stack_top;
+ pop_stack_until stack_top;
stack_result.remove_since result_top;
? {stack_result.upper = Old stack_result.upper};
- //
+ //
result
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
(code.count = 1).if {
buffer.add_last '(';
code.first.append_in buffer;
- buffer.add_last ')';
+ buffer.add_last ')';
} else {
- buffer.append "(\n";
+ buffer.append "(\n";
(code.lower).to (code.upper) do { i:INTEGER;
indent.append " ";
code.item i.append_in buffer;
buffer.append ";\n";
};
indent.remove_last 2;
- buffer.append ")";
- };
+ buffer.append ")";
+ };
);
-
+
Section ITM_LIST, ITM_RESULT
-
- - stack_result:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create_with_capacity 16;
+
+ - stack_result:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create_with_capacity 16;
diff --git a/src/item/itm_list_idf.li b/src/item/itm_list_idf.li
index 9885897..35e8c35 100644
--- a/src/item/itm_list_idf.li
+++ b/src/item/itm_list_idf.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_LIST_IDF;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "List identifier for assignment.";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
-Section Public
-
+
+Section Public
+
- is_affect:POSITION; // Nothing (it s good with 0).
// BSBS: A quoi ca sert ca ??? (Stop the Whisky)
-
+
//
// Data
//
@@ -53,7 +53,7 @@ Section Public
result.make p with lst;
result
);
-
+
- make p:POSITION with lst:FAST_ARRAY(STRING_CONSTANT) <-
(
position := p;
@@ -63,11 +63,10 @@ Section Public
//
// Runnable
//
-
+
- to_run_expr:EXPR <-
- (
+ (
semantic_error (position,"ITM_LIST_IDF.to_run_expr");
NULL
);
-
-
\ No newline at end of file
+
diff --git a/src/item/itm_local.li b/src/item/itm_local.li
index 63224e2..54cdbb3 100644
--- a/src/item/itm_local.li
+++ b/src/item/itm_local.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_LOCAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Local declaration slot";
-
+
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
-
+
Section Public
//
@@ -60,7 +60,7 @@ Section Public
result.set_type t;
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT <-
(
name := n;
@@ -80,10 +80,10 @@ Section Public
// Runnable
//
- - to_run:LOCAL <-
+ - to_run:LOCAL <-
( + pos:POSITION;
+ result:LOCAL;
-
+
last_position := position;
result := LOCAL.create position name name style '+' type (type.to_run_for profil_slot);
last_position := pos;
@@ -97,11 +97,11 @@ Section Public
+ larg:FAST_ARRAY(ITM_ARGUMENT);
+ arg:ITM_ARGUMENT;
+ proto:PROTOTYPE;
-
+
(type = ITM_TYPE_SIMPLE.type_self).if {
semantic_error (position,"Type `SELF' is not possible for `-' style local.");
};
- result := LOCAL.create position name name style '-' type (type.to_run_for profil_slot);
+ result := LOCAL.create position name name style '-' type (type.to_run_for profil_slot);
//
proto := position.prototype;
slot := proto.first_slot;
@@ -109,7 +109,7 @@ Section Public
slot := slot.next;
};
(slot = NULL).if {
- slot := ITM_SLOT.create position name (result.intern_name)
+ slot := ITM_SLOT.create position name (result.intern_name)
feature (SECTION_.get_name (ALIAS_STR.section_private));
slot.set_style '-';
slot.set_result_type type;
@@ -118,7 +118,7 @@ Section Public
type (ITM_TYPE_SIMPLE.type_self);
larg.add_last arg;
larg := ALIAS_ARRAY(ITM_ARGUMENT).copy larg;
- slot.set_argument_list larg;
+ slot.set_argument_list larg;
proto.add_slot slot;
} else {
result.set_intern_name (slot.name);
@@ -126,18 +126,18 @@ Section Public
//
result
);
-
- //
+
+ //
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append name;
buffer.add_last ':';
type.append_in buffer;
);
-
+
diff --git a/src/item/itm_number.li b/src/item/itm_number.li
index a54a89b..2cee426 100644
--- a/src/item/itm_number.li
+++ b/src/item/itm_number.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_NUMBER;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Integer constant";
-
+
Section Inherit
-
+
+ parent_itm_constant:Expanded ITM_CONSTANT;
-
+
Section Public
//
@@ -49,29 +49,29 @@ Section Public
result.make p value n;
result
);
-
+
- make p:POSITION value n:INTEGER_64 <-
(
position:=p;
value:=n;
);
-
+
//
// Runnable
//
- to_run_expr:EXPR <-
- (
- INTEGER_CST.create position value value type (type_integer.default)
+ (
+ INTEGER_CST.create position value value type (type_integer.default)
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
value.append_in buffer;
);
-
+
diff --git a/src/item/itm_object.li b/src/item/itm_object.li
index 5f07b3e..837c296 100644
--- a/src/item/itm_object.li
+++ b/src/item/itm_object.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_OBJECT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent item object";
-
+
Section Inherit
-
+
+ parent_any:Expanded ANY;
-
+
- parent_hashable:HASHABLE := HASHABLE;
-
+
Section Public
-
+
- context_extern:LOCAL;
-
+
- bottom_index:INTEGER;
-
+
- push_context:(INTEGER,INTEGER,LOCAL) <-
(
bottom_index := stack_local.upper + 1;
context_extern := NULL;
bottom_index,Old bottom_index,Old context_extern
- );
-
+ );
+
- pop_context (stack_top:INTEGER,old_bottom_index:INTEGER,old_context:LOCAL) <-
(
stack_local.remove_since stack_top;
@@ -55,25 +55,25 @@ Section Public
context_extern := old_context;
};
);
-
+
- lookup n:STRING_CONSTANT :LOCAL <-
( + result:LOCAL;
+ j:INTEGER;
? {n = ALIAS_STR.get n};
-
+
j := stack_local.upper;
- {(j < stack_local.lower) || {stack_local.item j.name = n}}.until_do {
+ {(j < stack_local.lower) || {stack_local.item j.name = n}}.until_do {
j := j - 1;
};
- (j >= stack_local.lower).if {
- result := stack_local.item j;
+ (j >= stack_local.lower).if {
+ result := stack_local.item j;
((j < bottom_index) && {result.style != '-'} && {result.name != ALIAS_STR.variable_self}).if {
bottom_index := j;
context_extern := result;
};
}.elseif {profil_slot != NULL} then {
- result := profil_slot.lookup n;
+ result := profil_slot.lookup n;
((result != NULL) && {result.name != ALIAS_STR.variable_self}).if {
bottom_index := -1;
context_extern := result;
@@ -81,7 +81,7 @@ Section Public
};
result
);
-
+
//
// Source position.
//
@@ -92,30 +92,30 @@ Section Public
(
position := new_pos;
);
-
+
//
//
//
-
+
- verify:BOOLEAN;
-
+
- set_verify v:BOOLEAN <-
(
verify := v;
);
-
+
- pop_stack_until stack_top:INTEGER <-
( + var,var2:LOCAL;
+ n:STRING_CONSTANT;
-
+
(verify).if {
- // Verify local.
+ // Verify local.
{stack_local.upper >= stack_top}.while_do {
var := stack_local.last;
stack_local.remove_last;
n := var.name;
(
- (n != ALIAS_STR.variable_self) &&
+ (n != ALIAS_STR.variable_self) &&
{n != ALIAS_STR.variable_tmp}
).if {
((var.ensure_count = 0) && {var.style != ' '}).if {
diff --git a/src/item/itm_old.li b/src/item/itm_old.li
index 6163151..039076b 100644
--- a/src/item/itm_old.li
+++ b/src/item/itm_old.li
@@ -19,44 +19,44 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_OLD;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Old primitive for contract";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
-
+
+ value:ITM_CODE;
-
+
//
// Constructor
//
-
+
- create p:POSITION value val:ITM_CODE :SELF <-
( + result:SELF;
result := clone;
result.make p value val;
result
);
-
+
- make p:POSITION value val:ITM_CODE <-
(
position := p;
value := val;
);
-
+
//
// Runnable
//
-
+
- to_run_expr:EXPR <-
( + expr_old:EXPR;
+ instr:INSTR;
@@ -66,21 +66,21 @@ Section Public
+ node:NODE_TYPE;
+ old_stack_local:FAST_ARRAY(LOCAL);
+ old_profil:PROFIL;
-
+
old_stack_local := stack_local;
old_profil := profil_current;
- stack_local := stack_local_empty;
+ stack_local := stack_local_empty;
profil_current := profil_slot;
- ? {stack_local.is_empty};
+ ? {stack_local.is_empty};
//
old_upper := list_current.upper;
expr_old := value.to_run_expr;
result_old := expr_old.static_type.get_temporary position;
list_current.add_last (result_old.write position value expr_old);
diff := list_current.upper - old_upper;
- // Move instr to up.
+ // Move instr to up.
lst := profil_slot.code;
- {diff != 0}.while_do {
+ {diff != 0}.while_do {
instr := list_current.last;
//
(NODE.node_list != NODE.node_list_base).if {
@@ -90,36 +90,36 @@ Section Public
NODE.node_list_base.add_last node;
};
};
-
+
list_current.remove_last;
(debug_level_option != 0).if {
- ? { + push:PUSH;
+ ? { + push:PUSH;
push ?= lst.first;
(push != NULL) && {push.is_first}
};
lst.add instr to (lst.lower + 1);
} else {
- lst.add_first instr;
+ lst.add_first instr;
};
diff := diff - 1;
- };
+ };
//
profil_current := old_profil;
stack_local := old_stack_local;
//
result_old.read position
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append "Old ";
value.append_in buffer;
);
-
+
Section Private
-
+
- stack_local_empty:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create 0;
diff --git a/src/item/itm_operator.li b/src/item/itm_operator.li
index 75e5b28..6cdde1b 100644
--- a/src/item/itm_operator.li
+++ b/src/item/itm_operator.li
@@ -19,26 +19,26 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_OPERATOR;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "operator list message";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
+ name:STRING_CONSTANT;
-
+
//
// Constructor
- //
+ //
- create p:POSITION name n:STRING_CONSTANT :SELF <-
[
@@ -49,30 +49,30 @@ Section Public
result.make p name n;
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT <-
- (
+ (
position := p;
name := n;
);
-
+
//
// Runnable.
//
-
+
- to_run_expr:EXPR <-
(
crash_with_message "ITM_OPERATOR.to_run_expr";
NULL
- );
-
+ );
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
- buffer.append name;
+ buffer.append name;
);
diff --git a/src/item/itm_prototype.li b/src/item/itm_prototype.li
index e76d1f7..a70433d 100644
--- a/src/item/itm_prototype.li
+++ b/src/item/itm_prototype.li
@@ -19,74 +19,74 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_PROTOTYPE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Prototype constant";
-
+
Section Inherit
-
+
+ parent_itm_constant:Expanded ITM_CONSTANT;
-
+
Section Public
+ type:ITM_TYPE_MONO;
-
+
//
// Constructor
//
-
+
- create p:POSITION type n:ITM_TYPE_MONO :SELF <-
( + result:SELF;
result := clone;
result.make p type n;
result
);
-
+
- make p:POSITION type n:ITM_TYPE_MONO <-
- (
+ (
position := p;
- type := n;
+ type := n;
);
//
// Runnable
//
- - to_run_expr:EXPR <-
+ - to_run_expr:EXPR <-
( + t:TYPE_FULL;
+ result:EXPR;
-
- t := type.to_run_for profil_slot;
+
+ t := type.to_run_for profil_slot;
(t = NULL).if {
string_tmp.copy "Type `";
type.append_in string_tmp;
- string_tmp.append "' not found (Undefine type parameter).";
+ string_tmp.append "' not found (Undefine type parameter).";
semantic_error (position,string_tmp);
};
- // TYPE Classic.
+ // TYPE Classic.
(
- (t.is_expanded_c) &&
- {t.raw != type_boolean} &&
- {t.raw != type_true} &&
+ (t.is_expanded_c) &&
+ {t.raw != type_boolean} &&
+ {t.raw != type_true} &&
{t.raw != type_false}
).if {
result := t.default_value position;
result := result.check_type t with position;
- } else {
+ } else {
result := PROTOTYPE_CST.create position type t;
};
result
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
type.append_in buffer;
diff --git a/src/item/itm_read.li b/src/item/itm_read.li
index be614d6..e90a087 100644
--- a/src/item/itm_read.li
+++ b/src/item/itm_read.li
@@ -123,7 +123,7 @@ Section ITM_READ, SLOT_DATA
itm_list ?= first_itm;
(itm_list != NULL).if {
itm_read ?= itm_list.code.first;
- } else {
+ } else {
itm_read ?= first_itm;
};
is_resend := (
@@ -187,7 +187,7 @@ Section ITM_READ, SLOT_DATA
position.put_position;
POSITION.send_error;
};
- last_position := slot_msg.position;
+ last_position := slot_msg.position;
(
(profil_slot != NULL) &&
{! slot_msg.id_section.access rec_type with (profil_slot.type_self.raw)}
@@ -237,7 +237,7 @@ Section ITM_READ, SLOT_DATA
string_tmp.copy "Deferred in `";
profil_slot.slot.pretty_name_in string_tmp;
string_tmp.append "' for ";
- rec.static_type.append_name_in string_tmp;
+ rec.static_type.append_name_in string_tmp;
warning_error (position,string_tmp);
};
@@ -248,7 +248,7 @@ Section ITM_READ, SLOT_DATA
} else {
// Classic message with arguments.
(is_resend).if {
- args.put (lookup (ALIAS_STR.variable_self).read position) to 0;
+ args.put (lookup (ALIAS_STR.variable_self).read position) to 0;
} else {
args.put (args.first.my_copy) to 0;
};
@@ -286,7 +286,7 @@ Section Private
args.add_last e;
};
(verify).if {
- (! is_block_value).if {
+ (! is_block_value).if {
itm_arg := slot.argument_list.item idx;
(itm_arg.count != count).if {
string_tmp.copy "Incorrect vector size for #";
diff --git a/src/item/itm_read_arg1.li b/src/item/itm_read_arg1.li
index 27cb5c4..3656704 100644
--- a/src/item/itm_read_arg1.li
+++ b/src/item/itm_read_arg1.li
@@ -19,53 +19,53 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_READ_ARG1;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- - comment :=
- "For send message with one argument\
+ - comment :=
+ "For send message with one argument\
\ (receiver) or unary message";
-
+
Section Inherit
-
+
+ parent_itm_read:Expanded ITM_READ;
-
+
Section Public
-
+
//
// Data
//
-
+
+ arg:ITM_CODE;
//
// Constructor
//
-
+
- create p:POSITION name n:STRING_CONSTANT arg a:ITM_CODE :SELF <-
( + result:SELF;
result := clone;
result.make p name n arg a;
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT arg a:ITM_CODE <-
(
position := p;
name := n;
arg := a;
);
-
+
//
// Runnable
//
- to_run_expr:EXPR <-
- (
+ (
to_run_with arg args NULL
);
diff --git a/src/item/itm_read_arg2.li b/src/item/itm_read_arg2.li
index 98caee4..7b799a5 100644
--- a/src/item/itm_read_arg2.li
+++ b/src/item/itm_read_arg2.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_READ_ARG2;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "For send message with two argument (receiver + argument)\
\ or simple binary message";
-
+
Section Inherit
-
+
+ parent_itm_read:Expanded ITM_READ;
-
+
Section Public
-
+
- is_affect:POSITION <-
( + result:POSITION;
-
+
(arg_first != NULL).if {
result := arg_first.position;
} else {
@@ -45,26 +45,26 @@ Section Public
};
result
);
-
+
//
// Data
//
+ arg_first:ITM_CODE;
-
+
+ arg_second:ITM_CODE;
-
+
//
// Constructor
//
-
+
- create p:POSITION name n:STRING_CONSTANT args (a1,a2:ITM_CODE) :SELF <-
( + result:SELF;
result := clone;
result.make p name n args (a1,a2);
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT args (a1,a2:ITM_CODE) <-
(
? { a2 != NULL };
@@ -77,26 +77,26 @@ Section Public
//
// Runnable
//
-
+
- to_run_expr:EXPR <-
- ( + result:EXPR;
- + l_arg:FAST_ARRAY(ITM_CODE);
+ ( + result:EXPR;
+ + l_arg:FAST_ARRAY(ITM_CODE);
+ v1,v2:EXPR;
+ t1,t2:TYPE_FULL;
+ em1,em2:EXPR_MULTIPLE;
-
+
(
- (name = ALIAS_STR.operator_equal) ||
+ (name = ALIAS_STR.operator_equal) ||
{name = ALIAS_STR.operator_not_equal}
- ).if {
+ ).if {
v1 := arg_first .to_run_expr;
- v2 := arg_second.to_run_expr;
+ v2 := arg_second.to_run_expr;
(verify).if {
t1 := v1.static_type;
t2 := v2.static_type;
(
- (! t1.is_expanded) &&
- {! t2.is_expanded} &&
+ (! t1.is_expanded) &&
+ {! t2.is_expanded} &&
{! t1.is_sub_type t2} &&
{! t2.is_sub_type t1}
).if {
@@ -112,34 +112,34 @@ Section Public
(em1 != NULL).if {
em2 ?= v2;
result := product_cmp (em1.first) with (em2.first);
- (em1.lower+1).to (em1.upper) do { j:INTEGER;
+ (em1.lower+1).to (em1.upper) do { j:INTEGER;
v2 := product_cmp (em1.item j) with (em2.item j);
(name = ALIAS_STR.operator_equal).if {
result := EXPR_AND_AND_LOGIC.create position with result and v2;
} else {
result := EXPR_OR_OR_LOGIC.create position with result and v2;
};
- };
+ };
} else {
result := product_cmp v1 with v2;
};
} else {
- l_arg := ALIAS_ARRAY(ITM_CODE).new;
- l_arg.add_last arg_second;
+ l_arg := ALIAS_ARRAY(ITM_CODE).new;
+ l_arg.add_last arg_second;
result := to_run_with arg_first args l_arg;
};
result
- );
-
+ );
+
Section Private
-
- - product_cmp v1:EXPR with v2:EXPR :EXPR <-
+
+ - product_cmp v1:EXPR with v2:EXPR :EXPR <-
( + result:EXPR;
(name = ALIAS_STR.operator_equal).if {
result := EXPR_EQUAL.create position with v1 and v2;
} else {
result := EXPR_NOT_EQUAL.create position with v1 and v2;
- };
+ };
result
);
diff --git a/src/item/itm_read_args.li b/src/item/itm_read_args.li
index 6569559..5ea51da 100644
--- a/src/item/itm_read_args.li
+++ b/src/item/itm_read_args.li
@@ -19,29 +19,29 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_READ_ARGS;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Message with a lot of arguments";
-
+
Section Inherit
-
+
+ parent_itm_read:Expanded ITM_READ;
-
+
Section Public
-
+
- is_affect:POSITION <-
( + result,default:POSITION;
+ j:INTEGER;
-
+
(args.first != NULL).if {
result := args.first.position;
} else {
- j := args.lower + 1;
+ j := args.lower + 1;
{(j <= args.upper) && {result = default}}.while_do {
result := args.item j.is_affect;
j := j + 1;
@@ -49,7 +49,7 @@ Section Public
};
result
);
-
+
//
// Data
//
@@ -59,14 +59,14 @@ Section Public
//
// Constructor
//
-
+
- create p:POSITION name n:STRING_CONSTANT args arg:FAST_ARRAY(ITM_CODE) :SELF <-
( + result:SELF;
result := clone;
result.make p name n args arg;
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT args arg:FAST_ARRAY(ITM_CODE) <-
(
position := p;
@@ -79,15 +79,15 @@ Section Public
//
- to_run_expr:EXPR <-
- ( + l_arg:FAST_ARRAY(ITM_CODE);
-
- l_arg := ALIAS_ARRAY(ITM_CODE).new;
- (args.lower+1).to (args.upper) do { j:INTEGER;
+ ( + l_arg:FAST_ARRAY(ITM_CODE);
+
+ l_arg := ALIAS_ARRAY(ITM_CODE).new;
+ (args.lower+1).to (args.upper) do { j:INTEGER;
l_arg.add_last (args.item j);
- };
+ };
to_run_with (args.first) args l_arg
);
-
+
diff --git a/src/item/itm_real.li b/src/item/itm_real.li
index 17b1015..b67b001 100644
--- a/src/item/itm_real.li
+++ b/src/item/itm_real.li
@@ -19,19 +19,19 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_REAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Real float constant";
-
+
Section Inherit
-
+
+ parent_itm_constant:Expanded ITM_CONSTANT;
-
+
Section Public
//
@@ -49,26 +49,26 @@ Section Public
result.make p value n;
result
);
-
+
- make p:POSITION value n:STRING_CONSTANT <-
(
position:=p;
value:=n;
);
-
+
//
// Runnable
//
- to_run_expr:EXPR <-
- (
- REAL_CST.create position value value type (type_real.default)
+ (
+ REAL_CST.create position value value type (type_real.default)
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append value;
diff --git a/src/item/itm_result.li b/src/item/itm_result.li
index 0fd8f29..afaedfc 100644
--- a/src/item/itm_result.li
+++ b/src/item/itm_result.li
@@ -19,52 +19,52 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_RESULT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Result value";
-
+
Section Inherit
-
+
- parent_itm_code:ITM_CODE := ITM_CODE;
-
+
Section Public
-
+
- is_affect:POSITION <- value.is_affect;
-
+
- position:POSITION <- value.position;
-
+
//
// Data
//
-
+
+ value:ITM_CODE;
//
// Constructor
//
-
+
- create r:ITM_CODE :SELF <-
[
-? {r != NULL};
-? {r.position.code != 0};
]
( + result:SELF;
-
+
result := clone;
result.make r;
result
);
-
+
- make r:ITM_CODE <-
(
value := r;
);
-
+
//
// Runnable
//
@@ -73,8 +73,8 @@ Section Public
( + mul:EXPR_MULTIPLE;
+ val:EXPR;
+ result:INSTR;
-
- val := value.to_run_expr;
+
+ val := value.to_run_expr;
mul ?= val;
(mul != NULL).if {
(mul.lower).to (mul.upper-1) do { j:INTEGER;
@@ -87,17 +87,17 @@ Section Public
};
result
);
-
+
- to_run_expr:EXPR <-
(
crash;
NULL
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append "return(";
@@ -108,10 +108,10 @@ Section Public
Section Private
- to_run_intern val:EXPR :INSTR <-
- ( + var:LOCAL;
-
+ ( + var:LOCAL;
+
var := val.static_type.get_temporary position;
- ITM_LIST.stack_result.add_last var;
- var.write position value val
+ ITM_LIST.stack_result.add_last var;
+ var.write position value val
);
-
+
diff --git a/src/item/itm_slot.li b/src/item/itm_slot.li
index 32fbc1a..3349945 100644
--- a/src/item/itm_slot.li
+++ b/src/item/itm_slot.li
@@ -19,73 +19,73 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_SLOT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Slot item";
-
+
Section Inherit
-
+
+ parent_named:Expanded NAMED;
-
+
Section Public
-
+
//
// Shorter information.
//
-
+
+ comment:STRING_CONSTANT;
-
+
- set_comment str:STRING_CONSTANT <-
(
comment := str;
);
-
+
+ comment_chapter:STRING_CONSTANT;
-
+
- set_comment_chapter c:STRING_CONSTANT <-
(
comment_chapter := c;
);
-
+
+ stat_shorter:INTEGER_8;
-
+
- set_stat_shorter s:INTEGER_8 <-
(
stat_shorter := s;
);
-
+
//
// Profil
//
-
+
+ id_section:SECTION_;
-
+
- argument_count:INTEGER <-
( + result:INTEGER;
-
+
(argument_list.lower).to (argument_list.upper) do { j:INTEGER;
result := result + argument_list.item j.count;
};
result
);
-
+
+ argument_list:FAST_ARRAY(ITM_ARGUMENT);
+ result_type:ITM_TYPE;
-
+
- set_result_type t:ITM_TYPE <-
( + tm:ITM_TYPE_MONO;
-
+
(id_section.is_inherit_or_insert).if {
tm ?= t;
(
- (tm = NULL) ||
- {tm = ITM_TYPE_SIMPLE.type_self} ||
+ (tm = NULL) ||
+ {tm = ITM_TYPE_SIMPLE.type_self} ||
{tm = ITM_TYPE_SIMPLE.type_void}
).if {
semantic_error (position,"Incorrect type for inheritance slot.");
@@ -104,10 +104,10 @@ Section Public
*/
result_type := t;
);
-
+
- set_argument_list p:FAST_ARRAY(ITM_ARGUMENT) <-
- (
- ((p.count > 1) || {p.first.count > 1}).if {
+ (
+ ((p.count > 1) || {p.first.count > 1}).if {
(id_section.is_interrupt).if {
semantic_error (p.last.position,"No argument for interrupt slot.");
};
@@ -117,22 +117,22 @@ Section Public
};
argument_list := p;
);
-
+
- get_argument_type i:INTEGER :ITM_TYPE_MONO <-
( + idx,j:INTEGER;
+ arg:ITM_ARGUMENT;
-
+
{
arg := argument_list.item j;
idx := idx + arg.count;
j := j + 1;
}.do_while {idx <= i};
- arg.item (i-(idx - arg.count))
- );
-
+ arg.item (i-(idx - arg.count))
+ );
+
- is_equal_profil other:ITM_SLOT <-
- (
- (Self != other).if {
+ (
+ (Self != other).if {
(result_type != other.result_type).if {
string_tmp.copy "Invariance type result invalid."; // (";
//type.to_run.append_name_in string_tmp;
@@ -142,34 +142,34 @@ Section Public
POSITION.put_error semantic text string_tmp;
position.put_position;
(other.position).put_position;
- POSITION.send_error;
+ POSITION.send_error;
};
(id_section != other.id_section).if {
- POSITION.put_error warning text
+ POSITION.put_error warning text
"Invariance section declaration invalid.";
position.put_position;
(other.position).put_position;
POSITION.send_error;
};
(
- ((other.argument_list = NULL) ^ (argument_list = NULL)) ||
+ ((other.argument_list = NULL) ^ (argument_list = NULL)) ||
{(argument_list != NULL) && {argument_list.count != other.argument_list.count}}
).if {
- POSITION.put_error warning text
+ POSITION.put_error warning text
"Invariance argument number.";
position.put_position;
(other.position).put_position;
POSITION.send_error;
} else {
- (argument_list != NULL).if {
+ (argument_list != NULL).if {
(argument_list.lower).to (argument_list.upper) do { j:INTEGER;
argument_list.item j.is_equal (other.argument_list.item j);
- };
+ };
};
};
};
);
-
+
//
// Data.
//
@@ -178,32 +178,32 @@ Section Public
- set_affect a:CHARACTER <-
(
- affect := a;
+ affect := a;
);
+ next:ITM_SLOT;
-
+
- set_next n:ITM_SLOT <-
(
next := n;
);
-
+
//
// Access associativity & priority level.
//
-
+
- priority_and_level:INTEGER <-
- (
+ (
crash_with_message "ITM_SLOT.priority_and_level.";
0
);
-
+
- associativity:STRING_CONSTANT <-
- (
+ (
crash_with_message "ITM_SLOT.associativity.";
NULL
);
-
+
- priority:INTEGER <-
(
crash_with_message "ITM_SLOT.priority.";
@@ -213,63 +213,63 @@ Section Public
//
// Value.
//
-
+
+ require:ITM_LIST;
+ ensure:ITM_LIST;
-
+
+ value:ITM_CODE;
- set_value e:ITM_CODE type p:PROTOTYPE <-
// Static definition.
- [
+ [
-? {affect != '\0'};
]
- (
+ (
(affect = '<').if {
value := e;
} else {
//semantic_error (position,"not_yet_implemented");
value := default_value e in p;
};
- );
+ );
- set_require e:ITM_LIST <-
- (
+ (
require := e;
- );
+ );
- set_ensure e:ITM_LIST <-
- (
+ (
ensure := e;
- );
+ );
//
// Constructeur.
//
-
+
- create p:POSITION name n:STRING_CONSTANT feature sec:SECTION_ :SELF <-
( + result:SELF;
result := clone;
result.make p name n feature sec;
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT feature sec:SECTION_ <-
(
name := n;
- position := p;
+ position := p;
id_section := sec;
);
-
+
//
// Runnable.
//
-
+
- get_index_argument_type p:ITM_TYPE_PARAMETER :INTEGER <-
( + i,result,max:INTEGER;
+ arg:ITM_ARGUMENT;
-
- i := argument_list.lower;
+
+ i := argument_list.lower;
{(i <= argument_list.upper) && {result = max}}.while_do {
arg := argument_list.item i;
max := max + arg.count;
@@ -281,73 +281,73 @@ Section Public
};
result
);
-
- - check_argument_type larg:FAST_ARRAY(EXPR) for p:PARAMETER_TO_TYPE <-
+
+ - check_argument_type larg:FAST_ARRAY(EXPR) for p:PARAMETER_TO_TYPE <-
( + idx:INTEGER;
+ a:ITM_ARGUMENT;
-
+
(argument_list.lower).to (argument_list.upper) do { i:INTEGER;
a := argument_list.item i;
idx := a.check larg index idx for p;
};
- );
-
+ );
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.append name;
- (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
+ (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
buffer.add_last ' ';
argument_list.item j.append_in buffer;
- };
+ };
buffer.add_last ' ';
buffer.add_last ':';
- result_type.append_in buffer;
- );
-
+ result_type.append_in buffer;
+ );
+
- pretty_name:STRING_CONSTANT <-
(
crash_with_message "ITM_SLOT.pretty_name.";
NULL
);
-
+
- pretty_name_in buffer:STRING <-
( + j:INTEGER;
-
+
j := name.lower;
- {j < name.upper}.while_do {
+ {j < name.upper}.while_do {
((name.item j = '_') && {name.item (j+1) = '_'}).if {
buffer.add_last ' ';
j := j + 2;
} else {
buffer.add_last (name.item j);
j := j + 1;
- };
+ };
};
buffer.add_last (name.last);
);
-
+
- shorter_profile_in buf:STRING <-
- (
+ (
// style.
(style = '+').if {
put "+" to buf like (ALIAS_STR.short_slot_style);
} else {
put "-" to buf like (ALIAS_STR.short_slot_style);
- };
+ };
shorter_profile_intern_in buf;
// Result.
- (result_type != ITM_TYPE_SIMPLE.type_void).if {
- buf.add_last ':';
+ (result_type != ITM_TYPE_SIMPLE.type_void).if {
+ buf.add_last ':';
result_type.shorter_in buf;
};
);
-
+
Section ITM_SLOT
-
+
- shorter_profile_intern_in buf:STRING <-
( + j,i:INTEGER;
// Name + arguments.
@@ -355,20 +355,20 @@ Section ITM_SLOT
j := name.lower;
argument_list.first.shorter_in buf;
buf.add_last '.';
- i := argument_list.lower+1;
- {j < name.upper}.while_do {
+ i := argument_list.lower+1;
+ {j < name.upper}.while_do {
((name.item j = '_') && {name.item (j+1) = '_'}).if {
put string_tmp to buf like (ALIAS_STR.short_slot);
buf.add_last ' ';
argument_list.item i.shorter_in buf;
buf.add_last ' ';
- string_tmp.clear;
+ string_tmp.clear;
j := j + 2;
i := i + 1;
} else {
string_tmp.add_last (name.item j);
j := j + 1;
- };
+ };
};
string_tmp.add_last (name.last);
put string_tmp to buf like (ALIAS_STR.short_slot);
@@ -378,9 +378,9 @@ Section ITM_SLOT
buf.add_last ' ';
};
);
-
+
Section Private
-
+
- default_value v:ITM_CODE in t:PROTOTYPE :ITM_CODE <-
( //+ lst:ITM_LIST;
+ s:ITM_SLOT;
@@ -388,28 +388,28 @@ Section Private
+ sec:SECTION_;
+ larg:FAST_ARRAY(ITM_ARGUMENT);
+ a:ITM_CODE;
-
+
// Add function for init.
- string_tmp.copy "__init_";
+ string_tmp.copy "__init_";
string_tmp.append name;
n := ALIAS_STR.get string_tmp;
sec := SECTION_.get_name (ALIAS_STR.section_public);
larg := FAST_ARRAY(ITM_ARGUMENT).create_with_capacity 1;
larg.add_last (
ITM_ARG.create (v.position)
- name (ALIAS_STR.variable_self)
+ name (ALIAS_STR.variable_self)
type (ITM_TYPE_SIMPLE.type_self)
);
s := ITM_SLOT.create (v.position) name n feature sec;
s.set_affect '<';
? {result_type != NULL};
- s.set_value v type t;
- s.set_argument_list larg;
+ s.set_value v type t;
+ s.set_argument_list larg;
s.set_result_type result_type;
- t.slot_list.fast_put s to (s.name);
+ t.slot_list.fast_put s to (s.name);
(t.generic_count = 0).if {
- a := ITM_PROTOTYPE.create (v.position) type (ITM_TYPE_SIMPLE.get (t.name));
+ a := ITM_PROTOTYPE.create (v.position) type (ITM_TYPE_SIMPLE.get (t.name));
};
-
+
ITM_READ_ARG1.create (v.position) name n arg a
);
diff --git a/src/item/itm_slot_operator.li b/src/item/itm_slot_operator.li
index d22ca37..68335b6 100644
--- a/src/item/itm_slot_operator.li
+++ b/src/item/itm_slot_operator.li
@@ -19,28 +19,28 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_SLOT_OPERATOR;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Slot item";
-
+
Section Inherit
-
+
+ parent_itm_slot:Expanded ITM_SLOT;
-
+
Section Public
-
+
+ pretty_name:STRING_CONSTANT;
-
+
- set_pretty_name n:STRING_CONSTANT <-
(
pretty_name := n;
);
-
+
//
// Access associativity & priority level.
//
@@ -56,7 +56,7 @@ Section Public
};
result
);
-
+
- priority:INTEGER <-
(
priority_and_level.abs
@@ -70,28 +70,28 @@ Section Public
priority_and_level := -l;
};
);
-
+
//
// Display.
//
-
+
- pretty_name_in buffer:STRING <-
- (
+ (
(name.has_prefix (ALIAS_STR.slot_postfix)).if {
buffer.append "Postfix '";
}.elseif {name.has_prefix (ALIAS_STR.slot_infix)} then {
buffer.append "Infix '";
} else {
buffer.append "Prefix '";
- };
+ };
buffer.append pretty_name;
buffer.add_last '\'';
);
-
+
Section ITM_SLOT
-
+
- shorter_profile_intern_in buf:STRING <-
- (
+ (
(name.has_prefix (ALIAS_STR.slot_postfix)).if {
argument_list.first.shorter_in buf;
buf.add_last ' ';
@@ -123,5 +123,5 @@ Section ITM_SLOT
buf.add_last ' ';
argument_list.first.shorter_in buf;
buf.add_last ' ';
- };
+ };
);
\ No newline at end of file
diff --git a/src/item/itm_string.li b/src/item/itm_string.li
index b23e374..c0a9d0b 100644
--- a/src/item/itm_string.li
+++ b/src/item/itm_string.li
@@ -19,22 +19,22 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_STRING;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "String constant";
-
+
Section Inherit
-
+
+ parent_itm_constant:Expanded ITM_CONSTANT;
-
+
Section Public
-
- + string:STRING_CONSTANT;
+
+ + string:STRING_CONSTANT;
//
// Constructor
@@ -46,23 +46,23 @@ Section Public
result.make p text n;
result
);
-
+
- make p:POSITION text n:STRING_CONSTANT <-
(
- position := p;
+ position := p;
string := n;
);
-
+
//
// Runnable
//
- to_run_expr:EXPR <-
- ( + result:EXPR;
+ ( + result:EXPR;
+ slt:SLOT_DATA;
+ wrt:WRITE;
+ len:INTEGER;
-
+
len := length;
result := STRING_CST.create position text string length len;
// count
@@ -75,37 +75,37 @@ Section Public
// storage
slt := type_string_constant.get_local_slot (ALIAS_STR.slot_storage).slot_data_intern;
wrt := slt.write position with (result.my_copy) value (
- NATIVE_ARRAY_CHARACTER_CST.create position text string
+ NATIVE_ARRAY_CHARACTER_CST.create position text string
);
wrt.set_quiet_generation;
list_current.add_last wrt;
//
result
);
-
- //
+
+ //
// Display.
//
-
+
- append_in buffer:STRING <-
(
buffer.add_last '\"';
buffer.append string;
buffer.add_last '\"';
);
-
+
Section Private
-
+
- length:INTEGER <-
( + i,result:INTEGER;
i := string.lower;
{i <= string.upper}.while_do {
- (string.item i = '\\').if {
+ (string.item i = '\\').if {
i := i + 1;
(string.item i.is_digit).if {
i := i + 1;
(string.item i.is_digit).if {
- i := i + 2;
+ i := i + 2;
};
};
};
diff --git a/src/item/itm_type.li b/src/item/itm_type.li
index ef95eae..7c94b97 100644
--- a/src/item/itm_type.li
+++ b/src/item/itm_type.li
@@ -19,37 +19,37 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all type";
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
- print <-
(
string_tmp.clear;
append_in string_tmp;
string_tmp.print;
);
-
+
- append_in buffer:STRING <- deferred;
-
+
- shorter_in buf:STRING <- deferred;
-
+
- to_run_in lst:FAST_ARRAY(TYPE_FULL) for p:PARAMETER_TO_TYPE <-
(
deferred;
);
-
+
- get_expr_for p:PARAMETER_TO_TYPE :EXPR <-
(
deferred;
diff --git a/src/item/itm_type_block.li b/src/item/itm_type_block.li
index 9fe4333..1b89ef0 100644
--- a/src/item/itm_type_block.li
+++ b/src/item/itm_type_block.li
@@ -19,48 +19,48 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_BLOCK;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type block definition";
-
+
Section Inherit
-
+
+ parent_itm_type_mono:Expanded ITM_TYPE_MONO;
-
+
Section ITM_TYPE_SIMPLE, ITM_TYPE_SELF
-
+
- dico:FAST_ARRAY(ITM_TYPE_BLOCK) := FAST_ARRAY(ITM_TYPE_BLOCK).create_with_capacity 32;
-
-Section Private
-
+
+Section Private
+
- create typ_arg:ITM_TYPE and typ_res:ITM_TYPE :SELF <-
( + result:SELF;
-
+
result := clone;
result.make typ_arg and typ_res;
result
);
-
+
- make typ_arg:ITM_TYPE and typ_res:ITM_TYPE <-
(
type_argument := typ_arg;
type_result := typ_res;
);
-
+
Section Public
-
+
+ type_argument:ITM_TYPE;
+ type_result:ITM_TYPE;
-
+
- get typ_arg:ITM_TYPE and typ_res:ITM_TYPE :ITM_TYPE_BLOCK <-
- ( + result:ITM_TYPE_BLOCK;
+ ( + result:ITM_TYPE_BLOCK;
+ idx:INTEGER;
-
+
idx := dico.lower;
{
(idx <= dico.upper) && {
@@ -69,7 +69,7 @@ Section Public
}
}.while_do {
idx := idx + 1;
- };
+ };
(idx <= dico.upper).if {
result := dico.item idx;
} else {
@@ -78,12 +78,12 @@ Section Public
};
result
);
-
+
- to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
- (
+ (
TYPE_BLOCK.get Self with p
);
-
+
- append_in buffer:STRING <-
( + typ_mul:ITM_TYPE_MULTI;
buffer.add_last '{';
@@ -91,7 +91,7 @@ Section Public
type_argument.append_in buffer;
buffer.add_last ';';
buffer.add_last ' ';
- };
+ };
(type_result != NULL).if {
typ_mul ?= type_result;
(typ_mul = NULL).if {
@@ -102,7 +102,7 @@ Section Public
};
buffer.add_last '}';
);
-
+
- shorter_in buf:STRING <-
( + typ_mul:ITM_TYPE_MULTI;
put "{" to buf like (ALIAS_STR.short_block);
@@ -110,7 +110,7 @@ Section Public
type_argument.shorter_in buf;
buf.add_last ';';
buf.add_last ' ';
- };
+ };
(type_result != NULL).if {
typ_mul ?= type_result;
(typ_mul = NULL).if {
@@ -121,12 +121,12 @@ Section Public
};
put "}" to buf like (ALIAS_STR.short_block);
);
-
+
//
// Cast.
//
-
- - append_cast_name_in buf:STRING <-
+
+ - append_cast_name_in buf:STRING <-
(
crash_with_message "ITM_TYPE_BLOCK.append_cast_name_in ";
);
\ No newline at end of file
diff --git a/src/item/itm_type_generic.li b/src/item/itm_type_generic.li
index a960799..373d5a0 100644
--- a/src/item/itm_type_generic.li
+++ b/src/item/itm_type_generic.li
@@ -19,58 +19,58 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_GENERIC;
- copyright := "2003-2007 Benoit Sonntag";
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Generic style type";
-
+
Section Inherit
-
+
+ parent_itm_type_style:Expanded ITM_TYPE_STYLE;
-
+
Section Private
-
+
- dico_tg:FAST_ARRAY(ITM_TYPE_GENERIC) := FAST_ARRAY(ITM_TYPE_GENERIC).create_with_capacity 32;
- create n:STRING_CONSTANT style s:STRING_CONSTANT with lt:FAST_ARRAY(ITM_TYPE_MONO) :SELF <-
( + result:SELF;
-
+
result := clone;
result.make n style s with lt;
result
);
-
+
- make n:STRING_CONSTANT style s:STRING_CONSTANT with lt:FAST_ARRAY(ITM_TYPE_MONO) <-
(
name := n;
style := s;
list_type := lt;
);
-
+
Section Public
-
- - hash_code:INTEGER <- name.hash_code;
+
+ - hash_code:INTEGER <- name.hash_code;
+ list_type:FAST_ARRAY(ITM_TYPE_MONO);
-
- - get n:STRING_CONSTANT style s:STRING_CONSTANT
+
+ - get n:STRING_CONSTANT style s:STRING_CONSTANT
with lt:FAST_ARRAY(ITM_TYPE_MONO) :SELF <-
( + result:SELF;
+ idx:INTEGER;
-
+
idx := dico_tg.lower;
{
(idx <= dico_tg.upper) && {
- (dico_tg.item idx.name != n ) ||
- {dico_tg.item idx.style != s } ||
+ (dico_tg.item idx.name != n ) ||
+ {dico_tg.item idx.style != s } ||
{dico_tg.item idx.list_type != lt}
}
}.while_do {
idx := idx + 1;
- };
+ };
(idx <= dico_tg.upper).if {
result ?= dico_tg.item idx;
} else {
@@ -79,35 +79,35 @@ Section Public
};
result
);
-
+
- to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
( + lst:FAST_ARRAY(TYPE_FULL);
+ t:TYPE_FULL;
- + j:INTEGER;
+ + j:INTEGER;
+ result:TYPE_FULL;
+ path:STRING_CONSTANT;
-
+
lst := ALIAS_ARRAY(TYPE_FULL).new;
- j := list_type.lower;
+ j := list_type.lower;
{
- t := list_type.item j.to_run_for p;
+ t := list_type.item j.to_run_for p;
lst.add_last t;
j := j + 1;
}.do_while {(j <= list_type.upper) && {t != NULL}};
(t = NULL).if {
ALIAS_ARRAY(TYPE_FULL).free lst;
- } else {
- lst := ALIAS_ARRAY(TYPE_FULL).alias lst;
+ } else {
+ lst := ALIAS_ARRAY(TYPE_FULL).alias lst;
(p != NULL).if {
path := p.position.prototype.filename;
} else {
path := input_path;
- };
+ };
result := TYPE_GENERIC.get (path,Self) with lst;
};
result
);
-
+
- append_in buffer:STRING <-
(
(style != NULL).if {
@@ -123,7 +123,7 @@ Section Public
list_type.last.append_in buffer;
buffer.add_last ')';
);
-
+
- shorter_in buf:STRING <-
(
(style != NULL).if {
@@ -139,12 +139,12 @@ Section Public
list_type.last.shorter_in buf;
buf.add_last ')';
);
-
+
//
// Cast.
//
-
- - append_cast_name_in buf:STRING <-
+
+ - append_cast_name_in buf:STRING <-
(
parent_itm_type_style.append_cast_name_in buf;
buf.append "_of_";
diff --git a/src/item/itm_type_generic_elt.li b/src/item/itm_type_generic_elt.li
index eabafe4..982114a 100644
--- a/src/item/itm_type_generic_elt.li
+++ b/src/item/itm_type_generic_elt.li
@@ -19,78 +19,78 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_GENERIC_ELT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Virtual element for generic style type";
-
+
Section Inherit
-
+
+ parent_itm_type:Expanded ITM_TYPE_MONO;
-
+
Section Private
-
- - list:FAST_ARRAY(ITM_TYPE_GENERIC_ELT) :=
+
+ - list:FAST_ARRAY(ITM_TYPE_GENERIC_ELT) :=
// 'A' to 'Z'
( + result:FAST_ARRAY(ITM_TYPE_GENERIC_ELT);
-
- result := FAST_ARRAY(ITM_TYPE_GENERIC_ELT).create_with_capacity 26;
+
+ result := FAST_ARRAY(ITM_TYPE_GENERIC_ELT).create_with_capacity 26;
'A'.to 'Z' do { c:CHARACTER;
result.add_last (create c);
};
result
);
-
+
- create idf:CHARACTER :SELF <-
( + result:SELF;
-
+
result := clone;
result.make idf;
result
);
-
+
- make idf:CHARACTER <-
(
- index := idf -! 'A';
+ index := idf -! 'A';
);
Section Public
-
+
+ index:INTEGER;
-
+
- hash_code:INTEGER <- index;
-
+
- get idf:CHARACTER :ITM_TYPE_GENERIC_ELT <-
- (
+ (
list.item (idf -! 'A')
);
-
+
- display buffer:STRING <-
(
buffer.append "Generic[";
- buffer.add_last ('A' +# index);
+ buffer.add_last ('A' +# index);
buffer.add_last ']';
);
-
+
- shorter_in buf:STRING <-
(
string_tmp.clear;
- string_tmp.add_last ('A' +# index);
+ string_tmp.add_last ('A' +# index);
put string_tmp to buf like (ALIAS_STR.short_keyprototype);
- );
-
+ );
+
- string_tmp:STRING := STRING.create 100;
-
+
- to_run:TYPE_FULL <-
( + type_generic:TYPE_GENERIC;
+ result:TYPE_FULL;
+ t:CHARACTER;
-
+
t := 'A' +# index;
- type_generic ?= ITM_TYPE_SELF.self_up;
+ type_generic ?= ITM_TYPE_SELF.self_up;
(type_generic != NULL).if {
result := type_generic.generic_to_type t;
};
@@ -106,8 +106,8 @@ Section Public
//
// Cast.
//
-
- - append_cast_name_in buf:STRING <-
+
+ - append_cast_name_in buf:STRING <-
(
buf.add_last ('a' +# index);
);
\ No newline at end of file
diff --git a/src/item/itm_type_mono.li b/src/item/itm_type_mono.li
index eb426a8..4755917 100644
--- a/src/item/itm_type_mono.li
+++ b/src/item/itm_type_mono.li
@@ -19,62 +19,62 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_MONO;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type simple";
-
+
Section Inherit
-
+
+ parent_itm_type:Expanded ITM_TYPE;
-
+
Section Public
-
- - hash_code:INTEGER <-
+
+ - hash_code:INTEGER <-
(
deferred;
0
);
-
+
//
// Runnable.
//
- to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
- (
+ (
deferred;
NULL
);
-
+
- to_run_in lst:FAST_ARRAY(TYPE_FULL) for p:PARAMETER_TO_TYPE <-
(
lst.add_last (to_run_for p);
);
-
+
- get_expr_for p:PARAMETER_TO_TYPE :EXPR <-
( + t:TYPE_FULL;
+ result:EXPR;
-
- t := to_run_for p;
+
+ t := to_run_for p;
result := t.get_temporary_expr (p.position);
result
- );
-
+ );
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
deferred;
);
-
+
//
// Cast.
//
-
+
- append_cast_name_in buf:STRING <- deferred;
\ No newline at end of file
diff --git a/src/item/itm_type_multi.li b/src/item/itm_type_multi.li
index 4738baa..1ca68f4 100644
--- a/src/item/itm_type_multi.li
+++ b/src/item/itm_type_multi.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_MULTI;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "List of type";
-
+
Section Inherit
-
+
+ parent_itm_type:Expanded ITM_TYPE;
-
+
Section Private
-
+
- dico:FAST_ARRAY(ITM_TYPE_MULTI) := FAST_ARRAY(ITM_TYPE_MULTI).create_with_capacity 32;
- create lt:FAST_ARRAY(ITM_TYPE_MONO) :SELF <-
( + result:SELF;
-
+
result := clone;
result.make lt;
result
);
-
+
- make lt:FAST_ARRAY(ITM_TYPE_MONO) <-
(
list_type := lt;
);
-
+
Section Public
-
+
+ list_type:FAST_ARRAY(ITM_TYPE_MONO);
-
+
- count:INTEGER <- list_type.count;
-
+
- lower:INTEGER <- list_type.lower;
-
+
- upper:INTEGER <- list_type.upper;
-
+
- item i:INTEGER :ITM_TYPE_MONO <-
(
list_type.item i
);
-
+
- last:ITM_TYPE_MONO <-
(
list_type.last
@@ -73,15 +73,15 @@ Section Public
(
list_type.first
);
-
+
- get lt:FAST_ARRAY(ITM_TYPE_MONO) :SELF <-
( + result:SELF;
+ idx:INTEGER;
-
+
idx := dico.lower;
{(idx <= dico.upper) && {dico.item idx.list_type != lt}}.while_do {
idx := idx + 1;
- };
+ };
(idx <= dico.upper).if {
result ?= dico.item idx;
} else {
@@ -90,15 +90,15 @@ Section Public
};
result
);
-
+
//
// Runnable.
//
-
+
- get_expr_for p:PARAMETER_TO_TYPE :EXPR <-
( + lst:FAST_ARRAY(EXPR);
+ t:TYPE_FULL;
-
+
lst := FAST_ARRAY(EXPR).create_with_capacity count;
lower.to upper do { i:INTEGER;
t := item i.to_run_for p;
@@ -106,45 +106,45 @@ Section Public
};
EXPR_MULTIPLE.create lst
);
-
+
- to_run_in lst:FAST_ARRAY(TYPE_FULL) for p:PARAMETER_TO_TYPE <-
( + t:TYPE_FULL;
-
+
lower.to upper do { i:INTEGER;
t := item i.to_run_for p;
lst.add_last t;
};
);
-
+
//
// Display.
- //
-
+ //
+
- append_in buffer:STRING <-
- (
+ (
buffer.add_last '(';
display_raw buffer;
buffer.add_last ')';
);
-
+
- shorter_in buf:STRING <-
(
buf.add_last '(';
shorter_raw_in buf;
buf.add_last ')';
);
-
+
- display_raw buffer:STRING <-
- (
+ (
(list_type.lower).to (list_type.upper - 1) do { j:INTEGER;
list_type.item j.append_in buffer;
buffer.add_last ',';
};
list_type.last.append_in buffer;
);
-
+
- shorter_raw_in buf:STRING <-
- (
+ (
(list_type.lower).to (list_type.upper - 1) do { j:INTEGER;
list_type.item j.shorter_in buf;
buf.add_last ',';
diff --git a/src/item/itm_type_parameter.li b/src/item/itm_type_parameter.li
index 1f24b41..83a4f4f 100644
--- a/src/item/itm_type_parameter.li
+++ b/src/item/itm_type_parameter.li
@@ -19,24 +19,24 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_PARAMETER;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parameter type for argument define.";
-
+
Section Inherit
-
+
+ parent_itm_type_simple:Expanded ITM_TYPE_SIMPLE;
-
+
Section Public
-
+
- to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
( + result:TYPE_FULL;
-
- result := p.parameter_to_type Self;
+
+ result := p.parameter_to_type Self;
(result = NULL).if {
string_tmp.copy "Cannot resolve type for type parameter ";
append_in string_tmp;
@@ -44,16 +44,16 @@ Section Public
};
result
);
-
- //
+
+ //
// Display.
//
-
+
- shorter_in buf:STRING <-
(
(style != NULL).if {
put style to buf like (ALIAS_STR.short_keyword);
buf.add_last ' ';
- };
+ };
put name to buf like (ALIAS_STR.short_keyprototype);
);
diff --git a/src/item/itm_type_simple.li b/src/item/itm_type_simple.li
index 8af94b3..1b7444a 100644
--- a/src/item/itm_type_simple.li
+++ b/src/item/itm_type_simple.li
@@ -19,69 +19,69 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_SIMPLE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Simple type";
-
+
Section Inherit
-
+
+ parent_itm_type_mono:Expanded ITM_TYPE_MONO;
-
+
Section ITM_TYPE_SIMPLE, ITM_TYPE_SELF
-
- - dico:HASHED_DICTIONARY(ITM_TYPE_SIMPLE,STRING_CONSTANT) :=
+
+ - dico:HASHED_DICTIONARY(ITM_TYPE_SIMPLE,STRING_CONSTANT) :=
HASHED_DICTIONARY(ITM_TYPE_SIMPLE,STRING_CONSTANT).create;
Section ITM_TYPE_SIMPLE
-
+
- create n:STRING_CONSTANT :SELF <-
( + result:SELF;
-
+
result := clone;
result.make n;
result
);
-
+
- make n:STRING_CONSTANT <-
(
name := n;
dico.fast_put Self to n;
);
-
+
Section Public
-
+
- type_null:ITM_TYPE_SIMPLE := ITM_TYPE_SIMPLE.get (ALIAS_STR.variable_null);
- type_void:ITM_TYPE_SIMPLE := ITM_TYPE_SIMPLE.get (ALIAS_STR.variable_void);
- type_self:ITM_TYPE_SIMPLE := ITM_TYPE_PARAMETER.create (ALIAS_STR.prototype_self);
-
+
- hash_code:INTEGER <- name.hash_code;
-
+
+ name:STRING_CONSTANT;
-
+
- style:STRING_CONSTANT; // NULL
-
+
- get n:STRING_CONSTANT :ITM_TYPE_SIMPLE <-
[
- -? {n != NULL};
+ -? {n != NULL};
]
( + result:ITM_TYPE_SIMPLE;
-
- result := dico.fast_reference_at n;
+
+ result := dico.fast_reference_at n;
(result = NULL).if {
- result := create n;
- };
+ result := create n;
+ };
result
);
-
+
- to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
- ( + result:TYPE_FULL;
+ ( + result:TYPE_FULL;
+ path:STRING_CONSTANT;
-
+
(Self = type_null).if {
result := TYPE_NULL.default;
}.elseif {Self = type_void} then {
@@ -91,12 +91,12 @@ Section Public
path := p.position.prototype.filename;
} else {
path := input_path;
- };
+ };
result := TYPE.get (path,Self);
};
- result
+ result
);
-
+
- append_in buffer:STRING <-
(
(style != NULL).if {
@@ -105,7 +105,7 @@ Section Public
};
buffer.append name;
);
-
+
- shorter_in buf:STRING <-
(
(style != NULL).if {
@@ -114,16 +114,15 @@ Section Public
};
put name to buf like (ALIAS_STR.short_prototype);
);
-
+
//
// Cast.
//
-
- - append_cast_name_in buf:STRING <-
+
+ - append_cast_name_in buf:STRING <-
(
(name.lower).to (name.upper) do { j:INTEGER;
buf.add_last (name.item j.to_lower);
};
);
-
-
\ No newline at end of file
+
diff --git a/src/item/itm_type_style.li b/src/item/itm_type_style.li
index d3c52d0..510d387 100644
--- a/src/item/itm_type_style.li
+++ b/src/item/itm_type_style.li
@@ -19,49 +19,49 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_TYPE_STYLE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type with style";
-
+
Section Inherit
-
+
+ parent_itm_type_simple:Expanded ITM_TYPE_SIMPLE;
-
-Section Private
-
+
+Section Private
+
- dico_ts:FAST_ARRAY(ITM_TYPE_STYLE) := FAST_ARRAY(ITM_TYPE_STYLE).create_with_capacity 32;
-
+
- create n:STRING_CONSTANT style s:STRING_CONSTANT :SELF <-
( + result:SELF;
-
+
result := clone;
result.make n style s;
result
);
-
+
- make n:STRING_CONSTANT style s:STRING_CONSTANT <-
(
name := n;
style := s;
);
-
-Section Public
-
+
+Section Public
+
+ style:STRING_CONSTANT;
-
+
- get n:STRING_CONSTANT style s:STRING_CONSTANT :SELF <-
- ( + result:SELF;
+ ( + result:SELF;
+ idx:INTEGER;
-
+
idx := dico_ts.lower;
{
(idx <= dico_ts.upper) && {
- (dico_ts.item idx.name != n) ||
+ (dico_ts.item idx.name != n) ||
{dico_ts.item idx.style != s}
}
}.while_do {
@@ -75,5 +75,5 @@ Section Public
};
result
);
-
+
diff --git a/src/item/itm_write.li b/src/item/itm_write.li
index 5648718..5d96aeb 100644
--- a/src/item/itm_write.li
+++ b/src/item/itm_write.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_WRITE;
- copyright := "2003-2007 Benoit Sonntag";
@@ -27,11 +27,11 @@ Section Header
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all write";
-
+
Section Inherit
-
+
+ parent_itm_code:Expanded ITM_CODE;
-
+
Section Public
//
@@ -41,17 +41,17 @@ Section Public
+ assign:ITM_CODE;
+ value:ITM_CODE;
-
+
- type:STRING_CONSTANT <-
(
deferred;
NULL
);
-
+
//
// Constructor
//
-
+
- create p:POSITION assign n:ITM_CODE with v:ITM_CODE :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
@@ -59,7 +59,7 @@ Section Public
result.make p assign n with v;
result
);
-
+
- make p:POSITION assign n:ITM_CODE with v:ITM_CODE <-
(
position := p;
@@ -70,11 +70,11 @@ Section Public
//
// Access.
//
-
+
- get_simple_name:STRING_CONSTANT <-
( + result:STRING_CONSTANT;
+ without_arg:ITM_READ;
-
+
without_arg ?= assign;
(without_arg != NULL).if {
result := without_arg.name;
@@ -83,24 +83,24 @@ Section Public
};
result
);
-
+
//
// Display.
//
-
+
- append_in buffer:STRING <-
(
assign.append_in buffer;
buffer.append type;
value.append_in buffer;
);
-
+
Section Private
-
+
- affect name:STRING_CONSTANT with v:EXPR :EXPR <-
- ( + loc:LOCAL;
- + result:EXPR;
-
+ ( + loc:LOCAL;
+ + result:EXPR;
+
loc := lookup name;
(loc != NULL).if {
result := affect_local loc with v;
@@ -111,10 +111,10 @@ Section Private
);
- affect_local loc:LOCAL with v:EXPR :EXPR <-
- ( + e:INSTR;
- + result:EXPR;
+ ( + e:INSTR;
+ + result:EXPR;
+ val:EXPR;
-
+
(loc.style = '-').if {
result := affect_slot (loc.intern_name) with v;
} else {
@@ -122,11 +122,11 @@ Section Private
POSITION.put_error semantic text "Argument assignment is not possible.";
loc.position.put_position;
position.put_position;
- POSITION.send_error;
+ POSITION.send_error;
};
val := v.check_type (loc.type) with position;
- e := loc.write position value val;
- list_current.add_last e;
+ e := loc.write position value val;
+ list_current.add_last e;
result := loc.read position;
};
result
@@ -143,12 +143,12 @@ Section Private
+ em:EXPR_MULTIPLE;
+ new_val:EXPR;
+ lst:FAST_ARRAY(EXPR);
-
+
loc := lookup (ALIAS_STR.variable_self);
rec := loc.read position;
//
- type := rec.static_type.raw;
- slot := type.get_slot name;
+ type := rec.static_type.raw;
+ slot := type.get_slot name;
(slot = NULL).if {
string_tmp.copy "Slot `";
string_tmp.append name;
@@ -178,4 +178,4 @@ Section Private
result := node.result_expr;
result
);
-
+
diff --git a/src/item/itm_write_cast.li b/src/item/itm_write_cast.li
index 9784c45..5f91d5a 100644
--- a/src/item/itm_write_cast.li
+++ b/src/item/itm_write_cast.li
@@ -19,39 +19,39 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_WRITE_CAST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Assignment slot `?=' style";
-
+
Section Inherit
-
+
+ parent_itm_write:Expanded ITM_WRITE;
-
+
Section Public
- type:STRING_CONSTANT <- "?=";
//
- // Runnable
+ // Runnable
//
- to_run_expr:EXPR <-
( + val:EXPR;
+ loc:LOCAL;
- + node:NODE;
+ + node:NODE;
+ nm:STRING_CONSTANT;
+ typ_cast:TYPE_FULL;
+ slot:SLOT;
+ ts:ITM_TYPE_SIMPLE;
-
+
// Value -> local.
val := value.to_run_expr;
- loc := val.static_type.get_temporary position;
+ loc := val.static_type.get_temporary position;
list_current.add_last (loc.write position value val);
val := loc.read position;
// Assign.
@@ -60,7 +60,7 @@ Section Public
(loc != NULL).if {
typ_cast := loc.type;
} else {
- slot := profil_slot.type_self.get_slot nm;
+ slot := profil_slot.type_self.get_slot nm;
(slot = NULL).if {
string_tmp.copy "Slot `";
string_tmp.append nm;
@@ -70,7 +70,7 @@ Section Public
semantic_error (position,string_tmp);
};
ts ?= slot.result_type;
- typ_cast := ts.to_run_for profil_slot;
+ typ_cast := ts.to_run_for profil_slot;
};
(verify).if {
((typ_cast.affect_with (val.static_type)) && {! val.static_type.is_generic}).if {
@@ -79,7 +79,7 @@ Section Public
};
// Dispatch case.
node := NODE.new_cast position type typ_cast with val;
- list_current.add_last node;
+ list_current.add_last node;
// Assignment result.
affect nm with (node.result_expr)
// Value result.
diff --git a/src/item/itm_write_code.li b/src/item/itm_write_code.li
index 908b204..28c3d52 100644
--- a/src/item/itm_write_code.li
+++ b/src/item/itm_write_code.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_WRITE_CODE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Assignment slot with new code";
-
+
Section Inherit
-
+
+ parent_itm_write:Expanded ITM_WRITE;
-
+
Section Public
- type:STRING_CONSTANT <- "<-";
//
- // Runnable
+ // Runnable
//
- to_run_expr:EXPR <-
@@ -49,15 +49,15 @@ Section Public
+ type:TYPE_FULL;
+ slot:SLOT;
+ name:STRING_CONSTANT;
-
+
itm_read ?= assign;
name := itm_read.name;
- ? {itm_read != NULL};
+ ? {itm_read != NULL};
loc := lookup (ALIAS_STR.variable_self);
rec := loc.read position;
//
- type := rec.static_type;
- slot := type.get_slot name;
+ type := rec.static_type;
+ slot := type.get_slot name;
(slot = NULL).if {
string_tmp.copy "Slot `";
string_tmp.append name;
@@ -70,11 +70,11 @@ Section Public
node := NODE.new_write position slot slot receiver rec code value;
list_current.add_last node;
result := node.result_expr;
-
+
result
);
-
+
diff --git a/src/item/itm_write_value.li b/src/item/itm_write_value.li
index 19d75eb..43b8f57 100644
--- a/src/item/itm_write_value.li
+++ b/src/item/itm_write_value.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ITM_WRITE_VALUE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Write with a value";
-
+
Section Inherit
-
+
+ parent_itm_write:Expanded ITM_WRITE;
-
+
Section Public
- type:STRING_CONSTANT <- ":=";
//
- // Runnable
+ // Runnable
//
- to_run_expr:EXPR <-
@@ -49,26 +49,26 @@ Section Public
+ itm_read:ITM_READ;
+ lst_exp:FAST_ARRAY(EXPR);
+ result:EXPR;
-
+
val := value.to_run_expr;
-
- val_multiple ?= val;
+
+ val_multiple ?= val;
(val_multiple != NULL).if {
//
- // Assignment Vector.
+ // Assignment Vector.
//
lst_exp := FAST_ARRAY(EXPR).create_with_capacity (val_multiple.count);
ass_multiple ?= assign;
- (ass_multiple != NULL).if {
+ (ass_multiple != NULL).if {
lst_idf := ass_multiple.list_name;
(lst_idf.lower).to (lst_idf.upper-1) do { i:INTEGER;
j := affect (lst_idf.item i) with val_multiple index j in lst_exp;
- };
- j := affect (lst_idf.last) with val_multiple index j in lst_exp;
+ };
+ j := affect (lst_idf.last) with val_multiple index j in lst_exp;
} else {
itm_read ?= assign;
? {itm_read != NULL};
- j := affect (itm_read.name) with val_multiple index j in lst_exp;
+ j := affect (itm_read.name) with val_multiple index j in lst_exp;
};
(j <= val_multiple.upper).if {
semantic_error (position,"Incorrect size vector.");
@@ -77,30 +77,30 @@ Section Public
} else {
//
// Assignment simple.
- //
- itm_read ?= assign;
- ? {itm_read != NULL};
+ //
+ itm_read ?= assign;
+ ? {itm_read != NULL};
result := affect (itm_read.name) with val;
};
result
);
Section Private
-
- - affect idf:STRING_CONSTANT with val:EXPR_MULTIPLE
+
+ - affect idf:STRING_CONSTANT with val:EXPR_MULTIPLE
index n:INTEGER in lst:FAST_ARRAY(EXPR) :INTEGER <-
( + loc:LOCAL;
+ result:INTEGER;
+ slot:SLOT;
+ typ_multi:ITM_TYPE_MULTI;
+ lst_expr:FAST_ARRAY(EXPR);
-
+
(n > val.upper).if {
semantic_error (position,"Incorrect size vector.");
};
-
+
loc := lookup idf;
- (loc != NULL).if {
+ (loc != NULL).if {
lst.add_last (affect_local loc with (val.item n));
result := n + 1;
} else {
@@ -120,10 +120,10 @@ Section Private
semantic_error (position,"Incorrect size vector.");
};
//BSBS: Recycle les EXPR_MULTIPLE
- lst_expr := FAST_ARRAY(EXPR).create_with_capacity (typ_multi.count);
+ lst_expr := FAST_ARRAY(EXPR).create_with_capacity (typ_multi.count);
0.to (typ_multi.upper) do { i:INTEGER;
lst_expr.add_last (val.item (n+i));
- };
+ };
lst.add_last (affect_slot idf with (EXPR_MULTIPLE.create lst_expr));
} else {
lst.add_last (affect_slot idf with (val.item n));
diff --git a/src/lip/lip_affect.li b/src/lip/lip_affect.li
index 85595ae..9d87664 100644
--- a/src/lip/lip_affect.li
+++ b/src/lip/lip_affect.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_AFFECT;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,11 +32,11 @@ Section Inherit
+ parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ name:STRING_CONSTANT;
-
+
+ value:LIP_CODE;
-
+
//
// Creation.
//
@@ -49,20 +49,20 @@ Section Public
);
- make p:POSITION name n:STRING_CONSTANT value val:LIP_CODE <-
- (
+ (
position := p;
name := n;
value := val;
);
-
+
//
// Run.
//
-
+
- run <-
( + slot:LIP_SLOT_DATA;
+ val:LIP_CONSTANT;
-
+
slot := get_data name;
(slot = NULL).if {
string_tmp.copy "Slot `";
diff --git a/src/lip/lip_binary.li b/src/lip/lip_binary.li
index 077ee6a..35cdc14 100644
--- a/src/lip/lip_binary.li
+++ b/src/lip/lip_binary.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_BINARY;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,13 +32,13 @@ Section Inherit
+ parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ left:LIP_CODE;
-
+
+ right:LIP_CODE;
-
+
+ operator:CHARACTER;
-
+
//
// Creation.
//
@@ -51,23 +51,23 @@ Section Public
);
- make p:POSITION with l:LIP_CODE operator op:CHARACTER and r:LIP_CODE<-
- (
+ (
position := p;
left := l;
right := r;
operator := op;
);
-
+
//
// Run.
//
-
+
- run_expr:LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ lv,rv:LIP_CONSTANT;
-
+
lv := left.run_expr;
- rv := right.run_expr;
+ rv := right.run_expr;
(operator)
.when '|' then { result := lv | rv; }
.when '&' then { result := lv & rv; }
@@ -83,7 +83,7 @@ Section Public
operator.print; '\n'.print;
lv.print; '\n'.print;
rv.print; '\n'.print;
- semantic_error (position,"Incorrect type operator.");
+ semantic_error (position,"Incorrect type operator.");
};
- result
+ result
);
diff --git a/src/lip/lip_boolean.li b/src/lip/lip_boolean.li
index f55af7e..96d5d7a 100644
--- a/src/lip/lip_boolean.li
+++ b/src/lip/lip_boolean.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_BOOLEAN;
- copyright := "2003-2008 Sonntag Benoit";
@@ -30,31 +30,31 @@ Section Header
Section Inherit
+ parent_lip_constant:Expanded LIP_CONSTANT;
-
+
Section Private
-
- - true:LIP_BOOLEAN :=
+
+ - true:LIP_BOOLEAN :=
( + result:LIP_BOOLEAN;
result := clone;
result.set_value TRUE;
result
);
-
+
- false:LIP_BOOLEAN := LIP_BOOLEAN;
-
+
- set_value i:BOOLEAN <-
(
value := i;
);
-
+
Section Public
+ value:BOOLEAN;
-
+
//
// Creation.
//
-
+
- get b:BOOLEAN :LIP_BOOLEAN <-
( + result:LIP_BOOLEAN;
b.if {
@@ -64,45 +64,44 @@ Section Public
};
result
);
-
+
- free; // Nothing.
-
+
//
// Operation.
//
-
+
- name:STRING_CONSTANT <- "BOOLEAN";
-
+
- '!' Self:SELF :LIP_CONSTANT <- get (! value);
-
+
- copy:LIP_CONSTANT <- Self;
-
+
- print <-
(
value.print;
);
Section LIP_CONSTANT
-
+
- my_copy other:SELF :LIP_CONSTANT <- other;
-
- - Self:SELF '|#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '|#' other:SELF :LIP_CONSTANT <-
+ (
get (value | other.value)
);
-
- - Self:SELF '&#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '&#' other:SELF :LIP_CONSTANT <-
+ (
get (value & other.value)
);
-
- - Self:SELF '=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '=#' other:SELF :LIP_CONSTANT <-
+ (
get (value = other.value)
);
-
- - Self:SELF '!=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '!=#' other:SELF :LIP_CONSTANT <-
+ (
get (value != other.value)
);
-
\ No newline at end of file
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index fb2717f..7e5ab34 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_CALL;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,13 +32,13 @@ Section Inherit
+ parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ receiver:LIP_CODE;
-
+
+ name:STRING_CONSTANT;
-
+
+ argument:LIP_CODE;
-
+
//
// Creation.
//
@@ -54,7 +54,7 @@ Section Public
[
-? {p.code != 0};
]
- (
+ (
position := p;
receiver := rec;
name := n;
@@ -64,34 +64,34 @@ Section Public
//
// Run.
//
-
+
- run <-
( + slot:LIP_SLOT_CODE;
- + val,rec:LIP_CONSTANT;
- + str:LIP_STRING;
+ + val,rec:LIP_CONSTANT;
+ + str:LIP_STRING;
+ int:LIP_INTEGER;
+ path:STRING_CONSTANT;
+ is_rec:BOOLEAN;
+ idx:INTEGER;
-
-
+
+
(receiver != NULL).if {
rec := receiver.run_expr;
};
(argument != NULL).if {
- val := argument.run_expr;
- };
+ val := argument.run_expr;
+ };
(name = ALIAS_STR.slot_print).if {
(rec = NULL).if {
semantic_error (position,"Incorrect type.");
- };
- (val != NULL).if {
+ };
+ (val != NULL).if {
warning_error (position,"No argument for `print' method.");
};
- rec.print;
- }.elseif {name = ALIAS_STR.slot_die_with_code} then {
+ rec.print;
+ }.elseif {name = ALIAS_STR.slot_die_with_code} then {
int ?= val;
- (int = NULL).if {
+ (int = NULL).if {
semantic_error (position,"Integer argument needed.");
};
die_with_code (int.value);
@@ -110,22 +110,22 @@ Section Public
(str = NULL).if {
semantic_error (position,"String argument needed.");
};
- path := str.value;
+ path := str.value;
((! path.is_empty) && {path.last = '*'}).if {
- string_tmp.copy path;
- string_tmp.remove_last 1;
+ string_tmp.copy path;
+ string_tmp.remove_last 1;
path := ALIAS_STR.get string_tmp;
is_rec := TRUE;
- };
+ };
((path.is_empty) || {path.first != '/'}).if {
- string_tmp.copy (position.prototype.filename);
+ string_tmp.copy (position.prototype.filename);
idx := last_index_str (string_tmp,'/');
(idx < string_tmp.lower).if {
string_tmp.copy "./";
} else {
string_tmp.remove_last (string_tmp.upper-idx);
};
- string_tmp.append path;
+ string_tmp.append path;
path := ALIAS_STR.get string_tmp;
};
(path.is_empty).if_false {
@@ -135,11 +135,11 @@ Section Public
str ?= val;
(str = NULL).if {
semantic_error (position,"String argument needed.");
- };
+ };
string_tmp.clear;
str.append_in string_tmp;
- ENVIRONMENT.execute_command string_tmp;
- } else {
+ ENVIRONMENT.execute_command string_tmp;
+ } else {
slot := get_method name;
(slot = NULL).if {
string_tmp.copy "Slot `";
@@ -158,25 +158,25 @@ Section Public
val.free;
};
);
-
+
- run_expr:LIP_CONSTANT <-
( + slot:LIP_SLOT_DATA;
+ str:LIP_STRING;
+ val:LIP_CONSTANT;
+ result:LIP_CONSTANT;
+ res:INTEGER;
-
+
(argument != NULL).if {
- val := argument.run_expr;
- };
+ val := argument.run_expr;
+ };
(name = ALIAS_STR.slot_run).if {
str ?= val;
(str = NULL).if {
semantic_error (position,"String argument needed.");
- };
+ };
string_tmp.clear;
str.append_in string_tmp;
- res := ENVIRONMENT.execute_command string_tmp;
+ res := ENVIRONMENT.execute_command string_tmp;
result := LIP_INTEGER.get res;
}.elseif {name = ALIAS_STR.slot_get_integer} then {
{
@@ -184,8 +184,8 @@ Section Public
(IO.last_string.is_integer).if_false {
"Error INTEGER needed.\n".print;
};
- }.do_until {IO.last_string.is_integer};
- result := LIP_INTEGER.get (IO.last_string.to_integer);
+ }.do_until {IO.last_string.is_integer};
+ result := LIP_INTEGER.get (IO.last_string.to_integer);
}.elseif {name = ALIAS_STR.slot_get_string} then {
IO.read_line;
result := LIP_STRING.get (ALIAS_STR.get (IO.last_string));
@@ -199,7 +199,7 @@ Section Public
string_tmp.append "' not found.";
semantic_error (position,string_tmp);
};
- };
+ };
result := slot.get_value;
};
(val != NULL).if {
@@ -207,22 +207,22 @@ Section Public
};
result
);
-
+
- load_directory path:ABSTRACT_STRING is_recursive is_rec:BOOLEAN <-
( + entry:ENTRY;
+ dir:DIRECTORY;
-
- entry := FILE_SYSTEM.get_entry path;
+
+ entry := FILE_SYSTEM.get_entry path;
((entry != NULL) && {entry.is_directory} && {entry.open}).if {
- dir ?= entry;
+ dir ?= entry;
(dir.lower).to (dir.upper) do { j:INTEGER;
entry := dir.item j;
(entry.name.has_suffix ".li").if {
- path_file.add_last (entry.path);
+ path_file.add_last (entry.path);
}.elseif {(is_rec) && {entry.is_directory}} then {
load_directory (entry.path) is_recursive TRUE;
};
- };
+ };
} else {
string_tmp.copy "Incorrect directory `";
string_tmp.append path;
diff --git a/src/lip/lip_code.li b/src/lip/lip_code.li
index 94aeda6..9aecc01 100644
--- a/src/lip/lip_code.li
+++ b/src/lip/lip_code.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_CODE;
- copyright := "2003-2008 Sonntag Benoit";
@@ -28,29 +28,29 @@ Section Header
- comment := "The main prototype";
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
Section Public
-
+
- list_parent:FAST_ARRAY(STRING_CONSTANT) := FAST_ARRAY(STRING_CONSTANT).create_with_capacity 1;
-
- - list_method:FAST_ARRAY(LIP_SLOT_CODE) := FAST_ARRAY(LIP_SLOT_CODE).create_with_capacity 32;
-
+
+ - list_method:FAST_ARRAY(LIP_SLOT_CODE) := FAST_ARRAY(LIP_SLOT_CODE).create_with_capacity 32;
+
- list_data:HASHED_DICTIONARY(LIP_SLOT_DATA,STRING_CONSTANT) :=
HASHED_DICTIONARY(LIP_SLOT_DATA,STRING_CONSTANT).create;
-
+
- stack:FAST_ARRAY(LIP_SLOT_DATA) := FAST_ARRAY(LIP_SLOT_DATA).create_with_capacity 8;
-
+
- get_data n:STRING_CONSTANT :LIP_SLOT_DATA <-
(
list_data.fast_reference_at n
);
-
+
- get_method n:STRING_CONSTANT :LIP_SLOT_CODE <-
( + j:INTEGER;
+ result:LIP_SLOT_CODE;
-
+
j := list_method.lower;
{(j <= list_method.upper) && {list_method.item j.name != n}}.while_do {
j := j + 1;
@@ -60,11 +60,11 @@ Section Public
};
result
);
-
+
- print_usage <-
( + slot:LIP_SLOT_CODE;
+ is_ok:BOOLEAN;
-
+
(list_method.lower).to (list_method.upper) do { j:INTEGER;
slot := list_method.item j;
(slot.section = ALIAS_STR.section_public).if {
@@ -76,12 +76,12 @@ Section Public
"\t Sorry, no option (see `make.lip').\n".print;
};
);
-
+
- get_integer n:STRING_CONSTANT :INTEGER <-
( + d:LIP_SLOT_DATA;
+ int:LIP_INTEGER;
+ result:INTEGER;
-
+
d := get_data n;
(d = NULL).if {
"Warning: Slot `".print;
@@ -96,12 +96,12 @@ Section Public
};
result
);
-
+
- get_boolean n:STRING_CONSTANT :BOOLEAN <-
( + d:LIP_SLOT_DATA;
+ bool:LIP_BOOLEAN;
+ result:BOOLEAN;
-
+
d := get_data n;
(d = NULL).if {
"Warning: Slot `".print;
@@ -116,12 +116,12 @@ Section Public
};
result
);
-
+
- get_string n:STRING_CONSTANT :STRING_CONSTANT <-
( + d:LIP_SLOT_DATA;
+ str:LIP_STRING;
+ result:STRING_CONSTANT;
-
+
d := get_data n;
(d = NULL).if {
"Warning: Slot `".print;
@@ -136,78 +136,78 @@ Section Public
};
result
);
-
+
- put_string v:STRING_CONSTANT to n:STRING_CONSTANT <-
( + d:LIP_SLOT_DATA;
+ str:LIP_STRING;
-
+
d := get_data n;
(d = NULL).if {
"Warning: Slot `".print;
n.print;
- "' not found.\n".print;
+ "' not found.\n".print;
} else {
str ?= d.value;
(str = NULL).if {
semantic_error (d.position,"STRING type is needed.");
};
str.set_value v;
- };
+ };
);
-
+
- put_boolean v:BOOLEAN to n:STRING_CONSTANT <-
( + d:LIP_SLOT_DATA;
-
+
d := get_data n;
(d = NULL).if {
"Warning: Slot `".print;
n.print;
- "' not found.\n".print;
- } else {
+ "' not found.\n".print;
+ } else {
(d.set_value (LIP_BOOLEAN.get v)).if_false {
semantic_error (d.position,"BOOLEAN type is needed.");
- };
- };
+ };
+ };
);
-
+
//
// Run.
//
-
+
- run <-
(
warning_error (position,"Unreachable code.");
);
-
+
- run_expr:LIP_CONSTANT <-
(
semantic_error (position,"No expression result.");
NULL
);
-
+
- call_front_end <-
- ( + s:LIP_SLOT_CODE;
+ ( + s:LIP_SLOT_CODE;
// Executing `front_end':
s := LIP_CODE.get_method (ALIAS_STR.slot_front_end);
(s = NULL).if {
"Slot `front_end' not found in *.lip file.\n".print;
die_with_code exit_failure_code;
};
- s.run_with NULL;
+ s.run_with NULL;
);
-
+
- init_path_file order:BOOLEAN <-
( + k,i:INTEGER;
+ p1,p2:STRING_CONSTANT;
-
+
(order).if {
- path_file.bubble_sort_with { (a,b:STRING_CONSTANT);
+ path_file.bubble_sort_with { (a,b:STRING_CONSTANT);
b < a
- };
+ };
} else {
- path_file.bubble_sort_with { (a,b:STRING_CONSTANT);
+ path_file.bubble_sort_with { (a,b:STRING_CONSTANT);
b !< a
- };
+ };
};
k := path_file.upper;
path_begin := path_file.first.upper;
diff --git a/src/lip/lip_constant.li b/src/lip/lip_constant.li
index 6facb50..6ab138f 100644
--- a/src/lip/lip_constant.li
+++ b/src/lip/lip_constant.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_CONSTANT;
- copyright := "2003-2008 Sonntag Benoit";
@@ -28,19 +28,19 @@ Section Header
- comment := "The main prototype";
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
- name:STRING_CONSTANT <- ( deferred; NULL);
-
+
- copy:LIP_CONSTANT <-
(
deferred;
);
-
- - copy_of other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - copy_of other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -49,14 +49,14 @@ Section Public
};
result
);
-
+
- free <- deferred;
-
+
- '-' Self:SELF :LIP_CONSTANT <- NULL;
-
- - '!' Self:SELF :LIP_CONSTANT <- NULL;
- - Self:SELF '|' other:LIP_CONSTANT :LIP_CONSTANT <-
+ - '!' Self:SELF :LIP_CONSTANT <- NULL;
+
+ - Self:SELF '|' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -65,8 +65,8 @@ Section Public
};
result
);
-
- - Self:SELF '&' other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - Self:SELF '&' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -75,8 +75,8 @@ Section Public
};
result
);
-
- - Self:SELF '+' other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - Self:SELF '+' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -85,8 +85,8 @@ Section Public
};
result
);
-
- - Self:SELF '-' other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - Self:SELF '-' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -95,8 +95,8 @@ Section Public
};
result
);
-
- - Self:SELF '>' other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - Self:SELF '>' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -106,7 +106,7 @@ Section Public
result
);
- - Self:SELF '<' other:LIP_CONSTANT :LIP_CONSTANT <-
+ - Self:SELF '<' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -115,7 +115,7 @@ Section Public
};
result
);
-
+
- Self:SELF '~=' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
@@ -125,8 +125,8 @@ Section Public
};
result
);
-
- - Self:SELF '>=' other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - Self:SELF '>=' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -135,8 +135,8 @@ Section Public
};
result
);
-
- - Self:SELF '<=' other:LIP_CONSTANT :LIP_CONSTANT <-
+
+ - Self:SELF '<=' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
s ?= other;
@@ -145,7 +145,7 @@ Section Public
};
result
);
-
+
- Self:SELF '!~=' other:LIP_CONSTANT :LIP_CONSTANT <-
( + result:LIP_CONSTANT;
+ s:SELF;
@@ -155,30 +155,30 @@ Section Public
};
result
);
-
+
- print <- deferred;
-
+
Section LIP_CONSTANT
-
+
- my_copy other:SELF :LIP_CONSTANT <- NULL;
-
+
- Self:SELF '|#' other:SELF :LIP_CONSTANT <- NULL;
-
- - Self:SELF '&#' other:SELF :LIP_CONSTANT <- NULL;
-
+
+ - Self:SELF '&#' other:SELF :LIP_CONSTANT <- NULL;
+
- Self:SELF '+#' other:SELF :LIP_CONSTANT <- NULL;
-
- - Self:SELF '-#' other:SELF :LIP_CONSTANT <- NULL;
-
+
+ - Self:SELF '-#' other:SELF :LIP_CONSTANT <- NULL;
+
- Self:SELF '>#' other:SELF :LIP_CONSTANT <- NULL;
- Self:SELF '<#' other:SELF :LIP_CONSTANT <- NULL;
-
+
- Self:SELF '=#' other:SELF :LIP_CONSTANT <- NULL;
-
+
- Self:SELF '>=#' other:SELF :LIP_CONSTANT <- NULL;
-
+
- Self:SELF '<=#' other:SELF :LIP_CONSTANT <- NULL;
-
+
- Self:SELF '!=#' other:SELF :LIP_CONSTANT <- NULL;
diff --git a/src/lip/lip_if.li b/src/lip/lip_if.li
index 3e42fcc..a3637d5 100644
--- a/src/lip/lip_if.li
+++ b/src/lip/lip_if.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_IF;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,18 +32,18 @@ Section Inherit
+ parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ condition:LIP_CODE;
-
+
+ then:FAST_ARRAY(LIP_CODE);
-
+
+ else:FAST_ARRAY(LIP_CODE);
-
+
//
// Creation.
//
- - create p:POSITION if rec:LIP_CODE then the:FAST_ARRAY(LIP_CODE)
+ - create p:POSITION if rec:LIP_CODE then the:FAST_ARRAY(LIP_CODE)
else els:FAST_ARRAY(LIP_CODE) :SELF <-
( + result:SELF;
result := clone;
@@ -51,9 +51,9 @@ Section Public
result
);
- - make p:POSITION if rec:LIP_CODE then the:FAST_ARRAY(LIP_CODE)
+ - make p:POSITION if rec:LIP_CODE then the:FAST_ARRAY(LIP_CODE)
else els:FAST_ARRAY(LIP_CODE) <-
- (
+ (
position := p;
condition := rec;
then := the;
@@ -65,14 +65,14 @@ Section Public
warning_error (else.last.position,"Unreachable expression.");
};
);
-
+
//
// Run.
//
-
+
- run <-
( + val:LIP_BOOLEAN;
-
+
val ?= condition.run_expr;
(val = NULL).if {
semantic_error (position,"BOOLEAN needed.");
@@ -80,7 +80,7 @@ Section Public
(val.value).if {
(then.lower).to (then.upper-1) do { i:INTEGER;
then.item i.run;
- };
+ };
}.elseif {else != NULL} then {
(else.lower).to (else.upper-1) do { i:INTEGER;
else.item i.run;
diff --git a/src/lip/lip_integer.li b/src/lip/lip_integer.li
index 18c1d6e..10f8567 100644
--- a/src/lip/lip_integer.li
+++ b/src/lip/lip_integer.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_INTEGER;
- copyright := "2003-2008 Sonntag Benoit";
@@ -30,24 +30,24 @@ Section Header
Section Inherit
+ parent_lip_constant:Expanded LIP_CONSTANT;
-
+
Section Private
-
+
- storage:FAST_ARRAY(LIP_INTEGER) := FAST_ARRAY(LIP_INTEGER).create_with_capacity 10;
-
+
- set_value v:INTEGER <-
(
value := v;
);
-
+
Section Public
-
+
+ value:INTEGER;
-
+
//
// Creation.
//
-
+
- get i:INTEGER :LIP_INTEGER <-
( + result:LIP_INTEGER;
(storage.is_empty).if {
@@ -59,113 +59,113 @@ Section Public
result.set_value i;
result
);
-
+
- free <-
(
storage.add_last Self;
);
-
+
//
// Operation.
//
-
+
- name:STRING_CONSTANT <- "INTEGER";
-
+
- '-' Self:SELF :LIP_CONSTANT <-
- (
+ (
value := - value;
Self
);
- '!' Self:SELF :LIP_CONSTANT <-
- (
+ (
value := ~ value;
Self
);
-
+
- copy:LIP_CONSTANT <-
(
get value
);
-
+
- print <-
(
value.print;
);
-
+
Section LIP_CONSTANT
-
+
- my_copy other:SELF :LIP_CONSTANT <-
(
value := other.value;
Self
);
-
+
- Self:SELF '|#' other:SELF :LIP_CONSTANT <-
- (
+ (
value := value | other.value;
other.free;
Self
);
-
- - Self:SELF '&#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '&#' other:SELF :LIP_CONSTANT <-
+ (
value := value & other.value;
other.free;
Self
);
-
- - Self:SELF '+#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '+#' other:SELF :LIP_CONSTANT <-
+ (
value := value + other.value;
other.free;
- Self
+ Self
);
-
+
- Self:SELF '-#' other:SELF :LIP_CONSTANT <-
- (
+ (
value := value - other.value;
other.free;
Self
);
-
+
- Self:SELF '>#' other:SELF :LIP_CONSTANT <-
- (
+ (
other.free;
free;
LIP_BOOLEAN.get (value > other.value)
);
-
- - Self:SELF '<#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '<#' other:SELF :LIP_CONSTANT <-
+ (
other.free;
free;
LIP_BOOLEAN.get (value < other.value)
);
-
- - Self:SELF '=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '=#' other:SELF :LIP_CONSTANT <-
+ (
other.free;
free;
LIP_BOOLEAN.get (value = other.value)
);
-
- - Self:SELF '>=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '>=#' other:SELF :LIP_CONSTANT <-
+ (
other.free;
free;
LIP_BOOLEAN.get (value >= other.value)
);
-
+
- Self:SELF '<=#' other:SELF :LIP_CONSTANT <-
- (
+ (
other.free;
free;
LIP_BOOLEAN.get (value <= other.value)
);
-
- - Self:SELF '!=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '!=#' other:SELF :LIP_CONSTANT <-
+ (
other.free;
free;
LIP_BOOLEAN.get (value != other.value)
diff --git a/src/lip/lip_list.li b/src/lip/lip_list.li
index 8a4f5b6..2d791f1 100644
--- a/src/lip/lip_list.li
+++ b/src/lip/lip_list.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_LIST;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,9 +32,9 @@ Section Inherit
+ parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ list:FAST_ARRAY(LIP_CODE);
-
+
//
// Creation.
//
@@ -47,15 +47,15 @@ Section Public
);
- make p:POSITION with v:FAST_ARRAY(LIP_CODE) <-
- (
+ (
position := p;
list := v;
);
-
+
//
// Run.
//
-
+
- run <-
(
run_intern;
@@ -63,18 +63,18 @@ Section Public
semantic_error (position,"Incorrect expression.");
};
);
-
+
- run_expr:LIP_CONSTANT <-
- (
+ (
run_intern;
(list.last = NULL).if {
semantic_error (position,"Unreachable expression.");
};
list.last.run_expr
);
-
+
Section Private
-
+
- run_intern <-
(
(list.lower).to (list.upper-1) do { i:INTEGER;
diff --git a/src/lip/lip_slot_code.li b/src/lip/lip_slot_code.li
index 9521613..59d9917 100644
--- a/src/lip/lip_slot_code.li
+++ b/src/lip/lip_slot_code.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_SLOT_CODE;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,94 +32,94 @@ Section Inherit
- parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ section:STRING_CONSTANT;
-
+
+ name:STRING_CONSTANT;
-
+
+ argument:LIP_SLOT_DATA;
-
+
+ code:LIP_CODE;
-
+
+ comment:STRING_CONSTANT;
-
+
// + comment_chapter:STRING_CONSTANT;
-
+
- set_comment c:STRING_CONSTANT <-
(
comment := c;
);
-
+
/*
- set_comment_chapter cmt:STRING_CONSTANT <-
(
comment_chapter := cmt;
);
*/
-
+
//
// Creation.
//
- - create p:POSITION section sec:STRING_CONSTANT
- name n:STRING_CONSTANT
+ - create p:POSITION section sec:STRING_CONSTANT
+ name n:STRING_CONSTANT
argument arg:LIP_SLOT_DATA
code c:LIP_CODE :LIP_SLOT_CODE <-
( + result:LIP_SLOT_CODE;
-
+
result := get_method n;
(result != NULL).if {
((arg = NULL) ^ (result.argument = NULL)).if {
semantic_error (result.position,"Incorrect redefinition.");
- };
- } else {
+ };
+ } else {
result := clone;
- result.make p section sec name n argument arg code c;
+ result.make p section sec name n argument arg code c;
};
result
);
- - make p:POSITION section sec:STRING_CONSTANT
- name n:STRING_CONSTANT
- argument arg:LIP_SLOT_DATA
+ - make p:POSITION section sec:STRING_CONSTANT
+ name n:STRING_CONSTANT
+ argument arg:LIP_SLOT_DATA
code c:LIP_CODE <-
- (
+ (
position := p;
section := sec;
name := n;
- argument := arg;
- code := c;
+ argument := arg;
+ code := c;
list_method.add_last Self;
);
-
+
//
// Operation.
//
-
+
- run_with val:LIP_CONSTANT :BOOLEAN <-
( + result:BOOLEAN;
-
+
result := ! ((val = NULL) ^ (argument = NULL));
- (result).if {
+ (result).if {
(argument != NULL).if {
? { val != NULL };
- result := argument.set_value val;
- stack.add_last argument;
+ result := argument.set_value val;
+ stack.add_last argument;
} else {
stack.add_last NULL;
};
- (result).if {
+ (result).if {
code.run;
};
stack.remove_last;
};
result
);
-
+
//
// Print.
//
-
+
- print <-
(
" -".print;
@@ -130,7 +130,7 @@ Section Public
">".print;
};
":\n".print;
- (comment != NULL).if {
+ (comment != NULL).if {
'\t'.print;
(comment.lower).to (comment.upper) do { i:INTEGER;
comment.item i.print;
@@ -142,4 +142,4 @@ Section Public
"\t Sorry, no comment (see `make.lip').\n".print;
};
);
-
+
diff --git a/src/lip/lip_slot_data.li b/src/lip/lip_slot_data.li
index d52391b..0e5c930 100644
--- a/src/lip/lip_slot_data.li
+++ b/src/lip/lip_slot_data.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_SLOT_DATA;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,16 +32,16 @@ Section Inherit
+ parent_lip_slot:Expanded LIP_CODE;
Section Public
-
+
+ name:STRING_CONSTANT;
-
+
+ value:LIP_CONSTANT;
-
+
//
// Creation.
//
- - create p:POSITION name n:STRING_CONSTANT value v:LIP_CONSTANT
+ - create p:POSITION name n:STRING_CONSTANT value v:LIP_CONSTANT
argument is_arg:BOOLEAN :SELF <-
[
-? {v != NULL};
@@ -61,39 +61,38 @@ Section Public
semantic_error (s.position,"Double declaration.");
};
name := n;
- value := v;
+ value := v;
(is_arg).if_false {
list_data.add Self to n;
- };
+ };
);
-
+
//
// Value.
//
-
+
- set_value v:LIP_CONSTANT :BOOLEAN <-
( + new_val:LIP_CONSTANT;
-
+
new_val := value.copy_of v;
- (new_val != NULL).if {
- value := new_val;
- }
+ (new_val != NULL).if {
+ value := new_val;
+ }
);
-
+
- get_value:LIP_CONSTANT <-
(
value.copy
);
-
+
//
// Print.
//
-
+
- print <-
(
name.print;
':'.print;
value.name.print;
);
-
-
\ No newline at end of file
+
diff --git a/src/lip/lip_string.li b/src/lip/lip_string.li
index 04f11a5..d87c851 100644
--- a/src/lip/lip_string.li
+++ b/src/lip/lip_string.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_STRING;
- copyright := "2003-2008 Sonntag Benoit";
@@ -30,13 +30,13 @@ Section Header
Section Inherit
+ parent_lip_constant:Expanded LIP_CONSTANT;
-
+
Section Private
-
+
- storage:FAST_ARRAY(LIP_STRING) := FAST_ARRAY(LIP_STRING).create_with_capacity 10;
-
+
Section Public
-
+
+ value:STRING_CONSTANT;
- set_value v:STRING_CONSTANT <-
@@ -47,64 +47,64 @@ Section Public
//
// Creation.
//
-
+
- get str:STRING_CONSTANT :LIP_STRING <-
( + result:LIP_STRING;
(storage.is_empty).if {
result := clone;
} else {
result := storage.last;
- storage.remove_last;
+ storage.remove_last;
};
result.set_value str;
result
);
-
+
- free <-
- (
+ (
storage.add_last Self;
);
-
+
//
// Operation.
//
-
+
- name:STRING_CONSTANT <- "STRING";
-
+
- copy:LIP_CONSTANT <-
(
get value
);
-
+
- print <-
- (
- string_tmp.clear;
+ (
+ string_tmp.clear;
append_in string_tmp;
string_tmp.print;
);
-
+
- append_in str:STRING <-
( + i:INTEGER;
+ car:CHARACTER;
-
+
i := value.lower;
{i <= value.upper}.while_do {
car := value.item i;
- (car = '\\').if {
+ (car = '\\').if {
i := i + 1;
(i <= value.upper).if {
car := value.item i;
(car)
.when 'a' then { str.add_last '\a'; }
.when 'b' then { str.add_last '\b'; }
- .when 'f' then { str.add_last '\f'; }
- .when 'n' then { str.add_last '\n'; }
- .when 'r' then { str.add_last '\r'; }
- .when 't' then { str.add_last '\t'; }
- .when 'v' then { str.add_last '\v'; }
- .when '\\' then { str.add_last '\\'; }
- .when '?' then { str.add_last '\?'; }
- .when '\'' then { str.add_last '\''; }
+ .when 'f' then { str.add_last '\f'; }
+ .when 'n' then { str.add_last '\n'; }
+ .when 'r' then { str.add_last '\r'; }
+ .when 't' then { str.add_last '\t'; }
+ .when 'v' then { str.add_last '\v'; }
+ .when '\\' then { str.add_last '\\'; }
+ .when '?' then { str.add_last '\?'; }
+ .when '\'' then { str.add_last '\''; }
.when '\"' then { str.add_last '\"'; };
} else {
str.add_last car;
@@ -115,35 +115,34 @@ Section Public
i := i + 1;
};
);
-
+
Section LIP_CONSTANT
-
+
- my_copy other:SELF :LIP_CONSTANT <-
(
value := other.value;
Self
);
-
- - Self:SELF '=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '=#' other:SELF :LIP_CONSTANT <-
+ (
other.free;
free;
LIP_BOOLEAN.get (value = other.value)
);
-
- - Self:SELF '!=#' other:SELF :LIP_CONSTANT <-
- (
+
+ - Self:SELF '!=#' other:SELF :LIP_CONSTANT <-
+ (
other.free;
free;
LIP_BOOLEAN.get (value != other.value)
);
-
+
- Self:SELF '+#' other:SELF :LIP_CONSTANT <-
- (
+ (
string_tmp.copy value;
string_tmp.append (other.value);
value := ALIAS_STR.get string_tmp;
other.free;
Self
);
-
\ No newline at end of file
diff --git a/src/lip/lip_unary.li b/src/lip/lip_unary.li
index 979e143..10f5f2d 100644
--- a/src/lip/lip_unary.li
+++ b/src/lip/lip_unary.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_UNARY;
- copyright := "2003-2008 Sonntag Benoit";
@@ -29,14 +29,14 @@ Section Header
Section Inherit
- + parent_lip_code:Expanded LIP_CODE;
+ + parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ value:LIP_CODE;
-
+
+ operator:CHARACTER;
-
+
//
// Creation.
//
@@ -49,25 +49,25 @@ Section Public
);
- make p:POSITION operator op:CHARACTER with v:LIP_CODE <-
- (
- position := p;
+ (
+ position := p;
operator := op;
value := v;
);
-
+
//
// Run.
//
-
+
- run_expr:LIP_CONSTANT <-
( + result:LIP_CONSTANT;
-
- result := value.run_expr;
+
+ result := value.run_expr;
(operator)
.when '-' then { result := - result; }
.when '!' then { result := ! result; };
(result = NULL).if {
semantic_error (position,"Incorrect type.");
};
- result
+ result
);
diff --git a/src/lip/lip_value.li b/src/lip/lip_value.li
index 24a1179..24251c3 100644
--- a/src/lip/lip_value.li
+++ b/src/lip/lip_value.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LIP_VALUE;
- copyright := "2003-2008 Sonntag Benoit";
@@ -32,9 +32,9 @@ Section Inherit
+ parent_lip_code:Expanded LIP_CODE;
Section Public
-
+
+ value:LIP_CONSTANT;
-
+
//
// Creation.
//
@@ -47,15 +47,15 @@ Section Public
);
- make p:POSITION with v:LIP_CONSTANT <-
- (
+ (
position := p;
value := v;
);
-
+
//
// Run.
//
-
+
- run_expr:LIP_CONSTANT <-
(
value.copy
diff --git a/src/lisaac.li b/src/lisaac.li
index 6bb3318..ad94317 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -375,7 +375,7 @@ Section Private
+ key:UINTEGER_32;
title "SOURCE LINE REFERENCE" in output_decl;
-
+
buf.append
"struct __source {\n\
\ unsigned int pos;\n\
@@ -383,7 +383,7 @@ Section Private
\} __src[";
src := PUSH.source_line;
src.count.append_in buf;
- buf.append "]={\n";
+ buf.append "]={\n";
(src.lower).to (src.upper) do { j:INTEGER;
key := src.key j;
output_decl.append "#define L";
@@ -392,7 +392,7 @@ Section Private
(j-1).append_in output_decl;
output_decl.add_last '\n';
//
- buf.append " {";
+ buf.append " {";
key.append_in buf;
buf.append ",\"";
buf.append (src.item j);
@@ -416,12 +416,12 @@ Section Private
\ die_with_code(1); \n\
\} \n\n";
};
-
+
//
// Stack manager.
//
- buf.append
+ buf.append
"void lisaac_push_first(_____CONTEXT *path,unsigned long code)\n\
\{ \n";
(debug_level_option = 20).if {
@@ -430,7 +430,7 @@ Section Private
\ cur = top_context; \n\
\ while ((cur != (void *)0) && (cur != path)) cur = cur->back; \n\
\ if (cur == path) {\n\
- \ loop.back = top_context;\n\
+ \ loop.back = top_context;\n\
\ loop.code = code; \n\
\ lisaac_stack_print(&loop);\n\
\ print_string(\"COMPILER: Debug context looping detected !\\n\");\n\
@@ -444,7 +444,7 @@ Section Private
\} \n\
\ \n\
\void lisaac_push(_____CONTEXT *path,unsigned long code)\n\
- \{ \n\
+ \{ \n\
\ path->code = code;\n\
\ top_context = path;\n\
\} \n\
@@ -479,8 +479,8 @@ Section Private
\ }; \n\
\ print_char('^'); \n\
\ print_char('\\n'); \n\
-\ }; \n";
-
+\ }; \n";
+
} else {
buf.append
" print_string(\"Line #\"); \n\
@@ -500,7 +500,7 @@ Section Private
\ \n\
\void print_integer(unsigned short n) \n\
\{ unsigned short val; \n\
- \ char car; \n\
+ \ char car; \n\
\ car = (n % 10) + '0'; \n\
\ val = n / 10; \n\
\ if (val != 0) print_integer(val); \n\
@@ -859,14 +859,14 @@ Section Public
'\n'.print;
};
};
-
+
/*
PROFIL.list_cpa.lower.to (PROFIL.list_cpa.upper) do { i:INTEGER;
PROFIL.list_cpa.item i.print;
'\n'.print;
};
*/
-
+
//
// Execute finality command (front end).
//
diff --git a/src/make.lip b/src/make.lip
index 7c28fde..7dbf052 100644
--- a/src/make.lip
+++ b/src/make.lip
@@ -19,15 +19,15 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Inherit
-
+
+ parent:STRING;
Section Private
-
+
+ is_valid:BOOLEAN;
-
+
- src_path <-
- (
+ (
path "./";
path "tools/";
path "type/";
@@ -39,67 +39,66 @@ Section Private
path "external/arithmetic/";
path "external/comparison/";
path "dispatcher/";
- path "code_life/";
- path "lip/";
+ path "code_life/";
+ path "lip/";
);
-
+
- compiler_path <-
(
- src_path;
+ src_path;
input_file := "lisaac";
path "compiler_any/";
);
-
+
- shorter_path <-
(
- src_path;
+ src_path;
input_file := "shorter";
path "shorter_any/";
);
-
+
//
// Execute function.
//
-
+
- front_end <-
- (
- general_front_end;
- ((input_file = "") | (input_file = "lisaac")).if {
+ (
+ general_front_end;
+ ((input_file = "") | (input_file = "lisaac")).if {
compiler_path;
(is_valid).if {
boost;
};
- };
+ };
);
-
+
- back_end <-
(
general_back_end;
(is_valid).if {
execute "cp lisaac.c ../bin/.";
execute "cp lisaac ../bin/.";
- };
+ };
);
-
+
Section Public
-
+
- compiler <-
// Compile the Lisaac compiler.
(
compiler_path;
);
-
+
- shorter <-
// Compile the shorter.
(
shorter_path;
);
-
+
- valid <-
- // Compile the Lisaac compiler with `-boost' option and
+ // Compile the Lisaac compiler with `-boost' option and
// update your `/bin' compiler version.
(
- is_valid := TRUE;
+ is_valid := TRUE;
);
-
-
\ No newline at end of file
+
diff --git a/src/parameter_to_type.li b/src/parameter_to_type.li
index 50900ad..14bea7b 100644
--- a/src/parameter_to_type.li
+++ b/src/parameter_to_type.li
@@ -19,23 +19,23 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PARAMETER_TO_TYPE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type parameter -> type full";
-
+
Section Public
-
- - position:POSITION <-
+
+ - position:POSITION <-
( + result:POSITION;
deferred;
result
);
-
+
- parameter_to_type p:ITM_TYPE_PARAMETER :TYPE_FULL <-
(
deferred;
diff --git a/src/parser.li b/src/parser.li
index 87b085d..08a22d4 100644
--- a/src/parser.li
+++ b/src/parser.li
@@ -19,42 +19,42 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PARSER;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parser for Lisaac language.";
-
- // You can to get with
+
+ // You can to get with
// `grep "//++" parser.li' : Current grammar.
// `grep "//--" parser.li' : Syntax rules.
- // `grep "////" parser.li' : lip grammar.
+ // `grep "////" parser.li' : lip grammar.
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
//
// Shorter Section.
//
-
+
- is_active_short:BOOLEAN;
-
+
- short_dico:HASHED_DICTIONARY(LINKED_LIST(STRING_CONSTANT),STRING_CONSTANT) :=
HASHED_DICTIONARY(LINKED_LIST(STRING_CONSTANT),STRING_CONSTANT).create;
-
+
- short_derive:INTEGER;
-
+
- token:STRING := STRING.create 100;
-
+
- short key:STRING_CONSTANT token beg:INTEGER to end:INTEGER <-
( + pos:INTEGER;
+ add_text:ABSTRACT_STRING;
+ fmt:LINKED_LIST(STRING_CONSTANT);
-
+
(is_shorter).if {
(is_active_short).if {
//
@@ -66,57 +66,57 @@ Section Public
pos := beg + short_derive;
beg.to (end-1) do { j:INTEGER;
token.add_last (source.item j);
- output_code.remove pos;
- };
+ output_code.remove pos;
+ };
short_derive := short_derive - token.count;
// Insert format.
- fmt := short_dico.at key;
+ fmt := short_dico.at key;
fmt.lower.to (fmt.upper) do { j:INTEGER;
(fmt.item j = NULL).if {
add_text := token;
} else {
add_text := fmt.item j;
- };
- output_code.insert_string add_text to pos;
+ };
+ output_code.insert_string add_text to pos;
pos := pos + add_text.count;
- short_derive := short_derive + add_text.count;
+ short_derive := short_derive + add_text.count;
};
};
};
};
);
-
+
- short_remove begin:INTEGER to end:INTEGER <-
(
- output_code.remove_between
- (begin + short_derive) to (end + short_derive);
+ output_code.remove_between
+ (begin + short_derive) to (end + short_derive);
short_derive := short_derive - (end - begin + 1);
);
-
+
- short_local:HASHED_SET(STRING_CONSTANT);
-
-Section Private
-
+
+Section Private
+
//
// Source information.
//
-
+
- object : PROTOTYPE;
-
+
- source : STRING;
-
+
- position : INTEGER;
-
+
- pos_cur : INTEGER;
- pos_line : INTEGER;
- pos_col : INTEGER;
-
+
- begin_position:INTEGER; // begin item position
-
+
- current_position:POSITION <-
( + result:POSITION;
? {pos_cur <= position};
-
+
{pos_cur = position}.until_do {
(source.item pos_cur = '\n').if {
pos_col := 0;
@@ -136,18 +136,18 @@ Section Private
};
POSITION.create object line pos_line column pos_col
);
-
+
//
// AMBIGU Manager.
//
-
+
- old_position:INTEGER;
- old_pos_cur :INTEGER;
- old_pos_line:INTEGER;
- old_pos_col :INTEGER;
//
- old_short_derive:INTEGER;
-
+
- save_context <-
(
old_position := position;
@@ -157,27 +157,27 @@ Section Private
//
old_short_derive := short_derive;
);
-
+
- restore_context <-
( + beg:INTEGER;
-
+
(is_shorter).if {
- token.clear;
- beg := old_position + old_short_derive;
+ token.clear;
+ beg := old_position + old_short_derive;
output_code.remove_between beg to (position+short_derive-1);
(old_position).to (position-1) do { j:INTEGER;
token.add_last (source.item j);
- };
+ };
output_code.insert_string token to beg;
short_derive := old_short_derive;
};
-
+
position := old_position;
pos_cur := old_pos_cur;
pos_line := old_pos_line;
pos_col := old_pos_col;
);
-
+
//
// Syntax parser.
//
@@ -196,12 +196,12 @@ Section Private
- last_real : STRING_CONSTANT;
- last_string : STRING_CONSTANT;
- is_parameter_type:BOOLEAN;
-
+
- last_comment_extern:STRING_CONSTANT;
- last_comment_slot :STRING_CONSTANT;
- skip_comment:BOOLEAN;
-
- - put_new_line_comment str:STRING with cmt:STRING_CONSTANT <-
+
+ - put_new_line_comment str:STRING with cmt:STRING_CONSTANT <-
( + lst:LINKED_LIST(STRING_CONSTANT);
+ idx,idx_beg:INTEGER;
lst := PARSER.short_dico.fast_reference_at cmt;
@@ -210,75 +210,75 @@ Section Private
idx_beg := idx;
idx := idx + 1;
{
- (idx <= str.upper) &&
- {str.item idx <= ' ' } &&
+ (idx <= str.upper) &&
+ {str.item idx <= ' ' } &&
{str.item idx != '\n'}
}.while_do {
idx := idx + 1;
- };
+ };
(str.item idx = '\n').if {
str.replace_substring (lst.first) from idx_beg to (idx-1);
idx := idx_beg + (lst.first.count)-1;
};
};
- };
+ };
);
-
+
- read_space:BOOLEAN <-
- ( + posold,pos,pos2:INTEGER;
+ ( + posold,pos,pos2:INTEGER;
+ level_comment:INTEGER;
+ stat:INTEGER;
-
-
+
+
pos := position;
- posold := -1;
+ posold := -1;
(is_shorter2).if {
string_tmp3.clear;
string_tmp4.clear;
};
{posold = position}.until_do {
posold := position;
-
- // Skip spaces :
- {(last_character = 0.to_character) || {last_character > ' '}}.until_do {
+
+ // Skip spaces :
+ {(last_character = 0.to_character) || {last_character > ' '}}.until_do {
((is_shorter2) || {is_shorter}).if {
(last_character = '\n').if {
(stat)
.when 0 then { stat := 1; }
.when 1 then { stat := 2; }
- .when 2 then { };
+ .when 2 then { };
};
};
- position := position + 1;
+ position := position + 1;
};
-
+
(position < source.upper).if {
// Skip C++ comment style :
((last_character = '/') && {source.item (position + 1) = '/'}).if {
position := position + 2;
- pos2 := position;
- {
- (last_character = 0.to_character) ||
+ pos2 := position;
+ {
+ (last_character = 0.to_character) ||
{last_character = '\n'}
- }.until_do {
+ }.until_do {
(is_shorter2).if {
(stat)
- .when 0 or 1 then {
+ .when 0 or 1 then {
string_tmp3.add_last last_character;
}
- .when 2 then {
+ .when 2 then {
string_tmp4.add_last last_character;
- };
+ };
};
position := position + 1;
};
(is_shorter2).if {
(stat)
.when 0 or 1 then { string_tmp3.add_last '\n'; }
- .when 2 then { string_tmp4.add_last '\n'; };
+ .when 2 then { string_tmp4.add_last '\n'; };
};
(is_shorter).if {
- // BSBS: A revoir ...
+ // BSBS: A revoir ...
((pos2-2+short_derive).in_range (output_code.lower) to (output_code.upper)).if {
output_code.remove_between (pos2-2+short_derive) to (pos2-1+short_derive);
short_derive := short_derive - 2;
@@ -311,7 +311,7 @@ Section Private
// Skip C comment style :
pos2 := position;
((last_character = '/') && {source.item (position+1) = '*'}).if {
- position := position + 2;
+ position := position + 2;
level_comment := 1;
{
(last_character = 0.to_character) || {level_comment = 0}
@@ -337,12 +337,12 @@ Section Private
};
};
};
- ((is_shorter2) && {! skip_comment}).if {
+ ((is_shorter2) && {! skip_comment}).if {
(string_tmp3.is_empty).if {
last_comment_slot := NULL;
} else {
- put_new_line_comment string_tmp3 with (ALIAS_STR.short_comment_new_line_slot);
- last_comment_slot := ALIAS_STR.get string_tmp3;
+ put_new_line_comment string_tmp3 with (ALIAS_STR.short_comment_new_line_slot);
+ last_comment_slot := ALIAS_STR.get string_tmp3;
};
(string_tmp4.is_empty).if_false {
put_new_line_comment string_tmp4 with (ALIAS_STR.short_comment_new_line_extern);
@@ -353,7 +353,7 @@ Section Private
begin_position := position;
((position != pos) | (last_character != 0.to_character))
);
-
+
- read_symbol st:STRING_CONSTANT :BOOLEAN <-
( + posold,j:INTEGER;
+ result:BOOLEAN;
@@ -361,7 +361,7 @@ Section Private
(! read_space).if {
result := FALSE;
} else {
- posold := position;
+ posold := position;
j := st.lower;
{(last_character = 0.to_character) ||
{(j > st.upper) || {last_character != st.item j}}}.until_do {
@@ -392,15 +392,15 @@ Section Private
};
result
);
-
+
//-- affect -> ":=" | "<-" | "?="
- read_affect:BOOLEAN <-
- (
+ (
(read_symbol (ALIAS_STR.symbol_affect_immediate)) ||
{read_symbol (ALIAS_STR.symbol_affect_cast)} ||
{read_symbol (ALIAS_STR.symbol_affect_code)}
);
-
+
//-- style -> '-' | '+'
- read_style:CHARACTER <-
( + result:CHARACTER;
@@ -415,7 +415,7 @@ Section Private
};
result
);
-
+
//-- identifier -> 'a'-'z' {'a'-'z' | '0'-'9' | '_'}
- read_identifier:BOOLEAN <-
( + result:BOOLEAN;
@@ -425,22 +425,22 @@ Section Private
((! read_space) || {! last_character.is_lower}).if {
result := FALSE;
} else {
- posold := position;
+ posold := position;
string_tmp.clear;
{
- (last_character = 0.to_character) ||
+ (last_character = 0.to_character) ||
{
(! last_character.is_lower) &&
- {! last_character.is_digit} &&
+ {! last_character.is_digit} &&
{last_character != '_'}
}
}.until_do {
string_tmp.add_last last_character;
- position := position+1;
+ position := position+1;
};
(! string_tmp.is_empty).if {
idx := string_tmp.first_substring_index "__";
- (idx != 0).if {
+ (idx != 0).if {
position := posold+idx;
syntax_error (current_position,"Identifier is incorrect.");
};
@@ -450,9 +450,9 @@ Section Private
};
result
);
-
+
- read_word st:STRING_CONSTANT :BOOLEAN <-
- ( + posold,idx:INTEGER;
+ ( + posold,idx:INTEGER;
+ result:BOOLEAN;
// On passe les espaces :
(! read_space).if {
@@ -476,22 +476,22 @@ Section Private
- read_this_keyword st:STRING_CONSTANT :BOOLEAN <-
( + result:BOOLEAN;
-
+
result := read_word st;
(is_shorter).if {
- (result).if {
+ (result).if {
(st = ALIAS_STR.keyword_section).if {
- short (ALIAS_STR.short_keyword_section) token
+ short (ALIAS_STR.short_keyword_section) token
(position-last_string.count) to position;
} else {
- short (ALIAS_STR.short_keyword) token
+ short (ALIAS_STR.short_keyword) token
(position-last_string.count) to position;
};
};
};
result
);
-
+
//-- keyword -> 'A'-'Z' 'a'-'z' {'a'-'z' | '0'-'9' | '_'}
- read_keyword:BOOLEAN <-
( + result:BOOLEAN;
@@ -506,24 +506,24 @@ Section Private
string_tmp.add_last last_character;
position := position + 1;
{(last_character != 0.to_character) &&
- {(last_character.is_lower) ||
+ {(last_character.is_lower) ||
{last_character.is_digit} ||
{last_character = '_'}}}.while_do {
string_tmp.add_last last_character;
- position := position+1;
+ position := position+1;
};
last_string := ALIAS_STR.get string_tmp;
result := TRUE;
- short (ALIAS_STR.short_keyword) token
+ short (ALIAS_STR.short_keyword) token
(position-last_string.count) to position;
} else {
position := position - 1;
result := FALSE;
- };
+ };
};
result
- );
-
+ );
+
//-- cap_identifier -> 'A'-'Z' {'A'-'Z' | '0'-'9' | '_'}
- read_cap_identifier:BOOLEAN <-
( + posold,idx:INTEGER;
@@ -541,29 +541,29 @@ Section Private
{
(last_character = 0.to_character) ||
{
- (! last_character.is_upper) &&
+ (! last_character.is_upper) &&
{! last_character.is_digit} &&
{last_character != '_'}
}
}.until_do {
car := last_character;
is_parameter_type := is_parameter_type && {car.is_digit};
- string_tmp.add_last car;
- position := position+1;
- };
+ string_tmp.add_last car;
+ position := position+1;
+ };
idx := string_tmp.first_substring_index "__";
- (idx != 0).if {
+ (idx != 0).if {
position := posold + idx;
syntax_error (current_position,"Identifier is incorrect.");
- };
- last_string := ALIAS_STR.get string_tmp;
- result := TRUE;
+ };
+ last_string := ALIAS_STR.get string_tmp;
+ result := TRUE;
};
result
);
-
- //-- integer -> number
- //-- number -> {'0'-'9'} ['d']
+
+ //-- integer -> number
+ //-- number -> {'0'-'9'} ['d']
//-- | '0'-'9' {'0'-'9' | 'A'-'F' | 'a'-'f'} 'h'
//-- | {'0'-'7'} 'o'
//-- | {'0' | '1'} 'b'
@@ -575,7 +575,7 @@ Section Private
((read_space) && {last_character.is_digit}).if {
result := TRUE;
string_tmp.clear;
- string_tmp.add_last last_character;
+ string_tmp.add_last last_character;
pos_old := position;
position := position + 1;
{(last_character.is_hexadecimal_digit) || {last_character = '_'}}.while_do {
@@ -605,13 +605,13 @@ Section Private
last_integer := string_tmp.to_binary;
position := position+1;
} else {
- (last_character='d').if {
+ (last_character='d').if {
position := position+1;
};
(! string_tmp.is_integer_64).if {
syntax_error (current_position,"Incorrect decimal number.");
};
- last_integer := string_tmp.to_integer_64;
+ last_integer := string_tmp.to_integer_64;
};
};
};
@@ -627,20 +627,20 @@ Section Private
+ pos_old:INTEGER;
// On passe les espaces :
- ((read_space) && {last_character.is_digit}).if {
+ ((read_space) && {last_character.is_digit}).if {
string_tmp.clear;
- string_tmp.add_last last_character;
- pos_old := position;
+ string_tmp.add_last last_character;
+ pos_old := position;
position := position + 1;
{(last_character.is_digit) || {last_character = '_'}}.while_do {
(last_character != '_').if {
string_tmp.add_last last_character;
};
position := position + 1;
- };
- (last_character = '.').if {
+ };
+ (last_character = '.').if {
string_tmp.add_last '.';
- position := position + 1;
+ position := position + 1;
(last_character.is_digit).if {
result := TRUE;
string_tmp.add_last last_character;
@@ -653,7 +653,7 @@ Section Private
(last_character = 'E').if {
result := TRUE;
string_tmp.add_last 'E';
- position := position + 1;
+ position := position + 1;
((last_character = '+') || {last_character = '-'}).if {
string_tmp.add_last last_character;
position := position + 1;
@@ -664,7 +664,7 @@ Section Private
{last_character.is_digit}.while_do {
string_tmp.add_last last_character;
position := position + 1;
- };
+ };
} else {
syntax_error (current_position,"Incorrect real number.");
};
@@ -676,19 +676,19 @@ Section Private
position := pos_old;
};
};
- (result).if {
+ (result).if {
short (ALIAS_STR.short_integer) token pos_old to position;
- };
- result
+ };
+ result
);
-
+
- read_escape_character <-
( + nothing:BOOLEAN;
+ val:INTEGER;
- last_character.is_separator.if {
+ last_character.is_separator.if {
position := position+1;
{
- (last_character = 0.to_character) ||
+ (last_character = 0.to_character) ||
{! last_character.is_separator}
}.until_do {
position := position+1;
@@ -700,7 +700,7 @@ Section Private
syntax_error (current_position,"Unknown escape sequence.");
};
}.elseif {last_character != 0.to_character} then {
- ( (last_character = 'a') ||
+ ( (last_character = 'a') ||
{last_character = 'b'} ||
{last_character = 'f'} ||
{last_character = 'n'} ||
@@ -716,8 +716,8 @@ Section Private
position := position+1;
}.elseif {last_character.in_range '0' to '9'} then {
(
- (last_character='0') &&
- {position<source.upper} &&
+ (last_character='0') &&
+ {position<source.upper} &&
{! source.item(position+1).is_hexadecimal_digit}
).if {
string_tmp.add_last last_character;
@@ -737,23 +737,23 @@ Section Private
(last_character='\\').if {
position := position + 1;
} else {
- syntax_error (current_position,"Character '\' is needed.");
+ syntax_error (current_position,"Character '\' is needed.");
};
};
} else {
syntax_error (current_position,"Unknown escape sequence.");
- };
+ };
};
);
-
+
//-- character -> '\'' ascii '\''
- read_characters:BOOLEAN <-
( + result:BOOLEAN;
+ old_pos:INTEGER;
+ count:INTEGER;
// On passe les espaces :
- ((read_space) && {last_character='\''}).if {
- old_pos := position;
+ ((read_space) && {last_character='\''}).if {
+ old_pos := position;
position := position+1;
string_tmp.clear;
{
@@ -764,10 +764,10 @@ Section Private
string_tmp.add_last last_character;
(last_character='\\').if {
position := position+1;
- read_escape_character;
+ read_escape_character;
count := count + 1;
} else {
- position := position+1;
+ position := position+1;
count := count + 1;
};
};
@@ -787,30 +787,30 @@ Section Private
};
result
);
-
+
//-- string -> '\"' ascii_string '\"'
- read_string:BOOLEAN <-
( + result:BOOLEAN;
+ old_pos:INTEGER;
// On passe les espaces :
- ((read_space) && {last_character='\"'}).if {
+ ((read_space) && {last_character='\"'}).if {
old_pos := position;
position := position+1;
string_tmp.clear;
{
(last_character=0.to_character) ||
- {last_character='\n'} ||
+ {last_character='\n'} ||
{last_character='\"'}
- }.until_do {
+ }.until_do {
string_tmp.add_last last_character;
(last_character='\\').if {
position := position+1;
read_escape_character;
} else {
- position := position+1;
+ position := position+1;
};
};
- (last_character='\"').if {
+ (last_character='\"').if {
position := position+1;
last_string := ALIAS_STR.get string_tmp;
result := TRUE;
@@ -822,7 +822,7 @@ Section Private
};
result
);
-
+
//-- external -> '`' ascii_c_code '`'
- read_external:BOOLEAN <-
( + result:BOOLEAN;
@@ -830,7 +830,7 @@ Section Private
// On passe les espaces :
((! read_space) || {last_character != '`'}).if {
result := FALSE;
- } else {
+ } else {
pos_old:=position;
position := position+1;
string_tmp.clear;
@@ -857,15 +857,15 @@ Section Private
};
result
);
-
- //-- operator -> '!' | '@' | '#' | '$' | '%' | '^' | '&' | '<' | '|'
+
+ //-- operator -> '!' | '@' | '#' | '$' | '%' | '^' | '&' | '<' | '|'
//-- | '*' | '-' | '+' | '=' | '~' | '/' | '?' | '\' | '>'
- read_operator:BOOLEAN <-
( + result:BOOLEAN;
+ old_pos:INTEGER;
// On passe les espaces :
(read_space).if {
- };
+ };
old_pos:=position;
string_tmp.clear;
{(last_character = 0.to_character) ||
@@ -882,7 +882,7 @@ Section Private
).if {
syntax_error (current_position,"Incorrect operator.");
};
- short (ALIAS_STR.short_operator) token old_pos to position;
+ short (ALIAS_STR.short_operator) token old_pos to position;
result := TRUE;
};
result
@@ -891,58 +891,58 @@ Section Private
//
// Variable & function Global.
//
-
+
- last_slot:ITM_SLOT;
- last_group:ITM_LIST;
- last_section:SECTION_;
-
+
//
// PARSER
//
-
- //++ PROGRAM -> { "Section" (section|TYPE_LIST) { SLOT } } [CONTRACT ';']
+
+ //++ PROGRAM -> { "Section" (section|TYPE_LIST) { SLOT } } [CONTRACT ';']
- read_program:BOOLEAN <-
( + result:BOOLEAN;
+ pos_sec,old_derive:INTEGER;
+ t:FAST_ARRAY(ITM_TYPE_MONO);
-
+
result := TRUE;
-
+
pos_sec := position;
old_derive := short_derive;
-
+
read_space;
-
+
(is_shorter).if {
output_code.remove_between (source.lower+old_derive) to (position-1+short_derive);
short_derive := short_derive - ((position+short_derive) - (source.lower+old_derive));
- };
+ };
pos_sec := position;
old_derive := short_derive;
last_comment_extern := NULL;
//
// Read Section Header.
- //
+ //
(read_this_keyword (ALIAS_STR.keyword_section)).if_false {
syntax_error (current_position,"`Section' is needed.");
};
(read_this_keyword (ALIAS_STR.section_header)).if_false {
syntax_error (current_position,"Section `Header' is needed.");
- };
+ };
(read_slot_header TRUE).if_false {
- syntax_error (current_position,"Slot `name' not found.");
+ syntax_error (current_position,"Slot `name' not found.");
};
{read_slot_header FALSE}.while_do {
}; // loop
-
+
(is_shorter2).if {
object.set_comment_header last_comment_extern;
};
-
+
//
- // Read Section Other.
+ // Read Section Other.
//
{read_this_keyword (ALIAS_STR.keyword_section)}.while_do {
last_comment_extern := NULL;
@@ -950,31 +950,31 @@ Section Private
// Public, Private, ...
(ALIAS_STR.is_section last_string).if_false {
syntax_error (current_position,"Incorrect type section.");
- };
- last_section := SECTION_.get_name last_string;
+ };
+ last_section := SECTION_.get_name last_string;
(last_section.is_mapping).if {
object.set_mapping;
}.elseif {last_section.is_external} then {
object.set_external;
}.elseif {
- (last_section.is_inherit_or_insert) &&
- {object.last_slot != NULL} &&
+ (last_section.is_inherit_or_insert) &&
+ {object.last_slot != NULL} &&
{! object.last_slot.id_section.is_inherit_or_insert}
- } then {
+ } then {
syntax_error (current_position,
"`Section Inherit/Insert' must to be first section.");
- }.elseif {
- (last_section.is_inherit) &&
+ }.elseif {
+ (last_section.is_inherit) &&
{object.type_style = ALIAS_STR.keyword_expanded} &&
- {object.name != ALIAS_STR.prototype_true } &&
+ {object.name != ALIAS_STR.prototype_true } &&
{object.name != ALIAS_STR.prototype_false}
- } then {
+ } then {
warning_error (current_position,
"`Section Inherit' is not possible with Expanded object (Use `Section Insert').");
};
} else {
// TYPE_LIST.
- t := read_type_list TRUE;
+ t := read_type_list TRUE;
(t = NULL).if {
syntax_error (current_position,"Incorrect type section.");
};
@@ -982,26 +982,26 @@ Section Private
};
{read_slot}.while_do {
}; // loop
-
+
(is_shorter).if {
(
- (! is_short_private) &&
+ (! is_short_private) &&
{last_section.is_private}
).if {
- output_code.remove_between
- (pos_sec + old_derive) to (position + short_derive - 1);
+ output_code.remove_between
+ (pos_sec + old_derive) to (position + short_derive - 1);
short_derive := old_derive - (position - pos_sec);
};
-
+
pos_sec:=position;
old_derive:=short_derive;
};
-
+
}; // loop
- (read_invariant).if {
+ (read_invariant).if {
warning_error (current_position,"Invariant: Sorry, Not yet implemented.");
};
-
+
// End of file :
result := result | read_space;
(last_character != 0.to_character).if {
@@ -1019,27 +1019,27 @@ Section Private
+ affect:CHARACTER;
+ old_pos,old_derive:INTEGER;
+ s:ITM_SLOT;
-
+
style := read_style;
- (style != ' ').if {
+ (style != ' ').if {
//
// Classic slot.
- //
+ //
result := TRUE;
//
last_slot := read_type_slot;
(last_slot = NULL).if {
syntax_error (current_position,"Incorrect slot declaration.");
- };
-
+ };
+
last_slot.set_style style;
-
+
(read_affect).if {
affect := last_string.first;
} else {
affect := ' ';
};
-
+
// ':' (TYPE|'('TYPE_LIST')'
((affect = ' ') && {read_character ':'}).if {
(read_character '(').if {
@@ -1052,24 +1052,24 @@ Section Private
};
t := ITM_TYPE_MULTI.get lt;
} else {
- t := read_type FALSE;
+ t := read_type FALSE;
(t = NULL).if {
syntax_error (current_position,"Incorrect result type.");
};
- };
-
+ };
+
(read_affect).if {
affect := last_string.first;
};
} else {
t := ITM_TYPE_SIMPLE.type_void;
- };
+ };
last_slot.set_result_type t;
last_slot.set_affect affect;
-
+
(affect != ' ').if {
read_space;
- (is_shorter2).if {
+ (is_shorter2).if {
(last_comment_slot != NULL).if {
last_slot.set_comment last_comment_slot;
};
@@ -1077,7 +1077,7 @@ Section Private
last_slot.set_comment_chapter last_comment_extern;
};
skip_comment := TRUE;
- };
+ };
old_pos := position;
old_derive := short_derive;
read_def_slot;
@@ -1093,14 +1093,14 @@ Section Private
last_slot.set_comment last_comment_slot;
};
};
-
+
(is_shorter).if {
(
- (! is_short_code) &&
+ (! is_short_code) &&
{old_pos != 0} &&
{! last_section.is_header}
).if {
- (current_position.column<5).if {
+ (current_position.column<5).if {
{
(last_character != 0.to_character) &&
{last_character.is_separator} &&
@@ -1112,8 +1112,8 @@ Section Private
position := position + 1;
};
};
- output_code.remove_between
- (old_pos + old_derive) to (position + short_derive - 1);
+ output_code.remove_between
+ (old_pos + old_derive) to (position + short_derive - 1);
short_derive := old_derive - (position - old_pos);
};
};
@@ -1134,62 +1134,62 @@ Section Private
};
result
); // read_slot
-
+
//++ TYPE_SLOT -> [ LOC_ARG '.' ] identifier [ LOC_ARG { identifier LOC_ARG } ]
//++ | [ LOC_ARG ] '\'' operator '\'' [("Left"|"Right") [integer]] [LOC_ARG]
- read_type_slot:ITM_SLOT <-
( + arg:ITM_ARGUMENT;
+ result:ITM_SLOT;
+ list_arg:FAST_ARRAY(ITM_ARGUMENT);
-
+
list_arg := ALIAS_ARRAY(ITM_ARGUMENT).new;
arg := read_loc_arg FALSE with_self TRUE;
-
+
(arg = NULL).if {
(read_character '\'').if {
result := read_slot_operator list_arg;
} else {
- arg := ITM_ARG.create current_position
+ arg := ITM_ARG.create current_position
name (ALIAS_STR.variable_self) type (ITM_TYPE_SIMPLE.type_self);
- list_arg.add_last arg;
+ list_arg.add_last arg;
result := read_slot_keyword list_arg;
};
} else {
list_arg.add_last arg;
(read_character '.').if {
result := read_slot_keyword list_arg;
- }.elseif {read_character '\''} then {
+ }.elseif {read_character '\''} then {
result := read_slot_operator list_arg;
};
};
(result != NULL).if {
list_arg := ALIAS_ARRAY(ITM_ARGUMENT).copy list_arg;
- result.set_argument_list list_arg;
+ result.set_argument_list list_arg;
};
result
);
-
+
- read_slot_keyword list_arg:FAST_ARRAY(ITM_ARGUMENT) :ITM_SLOT <-
( + n:STRING;
+ arg:ITM_ARGUMENT;
+ result:ITM_SLOT;
-
+
read_identifier.if {
- short (ALIAS_STR.short_slot) token
+ short (ALIAS_STR.short_slot) token
(position-last_string.count) to position;
-
- n := ALIAS_STR.new;
- n.copy last_string;
+
+ n := ALIAS_STR.new;
+ n.copy last_string;
arg := read_loc_arg FALSE with_self FALSE;
(arg != NULL).if {
- list_arg.add_last arg;
+ list_arg.add_last arg;
(read_identifier).if {
(last_section.is_external).if {
syntax_error (current_position,"Incorrect in `Section External'.");
- };
- {
- short (ALIAS_STR.short_slot) token
- (position-last_string.count) to position;
+ };
+ {
+ short (ALIAS_STR.short_slot) token
+ (position-last_string.count) to position;
n.append (ALIAS_STR.separate);
n.append last_string;
arg := read_loc_arg FALSE with_self FALSE;
@@ -1204,14 +1204,14 @@ Section Private
};
result
);
-
+
- read_slot_operator list_arg:FAST_ARRAY(ITM_ARGUMENT) :ITM_SLOT <-
- ( + name,pretty_name:STRING_CONSTANT;
+ ( + name,pretty_name:STRING_CONSTANT;
+ associativity:STRING_CONSTANT;
+ priority:INTEGER;
+ arg:ITM_ARGUMENT;
+ result:ITM_SLOT_OPERATOR;
-
+
(! read_operator).if {
syntax_error (current_position,"Operator is needed.");
};
@@ -1220,7 +1220,7 @@ Section Private
{last_string = ALIAS_STR.symbol_not_equal}
).if {
syntax_error (current_position,"Incorrect operator.");
- };
+ };
pretty_name := name := last_string;
(! read_character '\'').if {
warning_error (current_position,"Added `''.");
@@ -1232,9 +1232,9 @@ Section Private
associativity := last_string;
(read_integer).if {
priority := last_integer.to_integer;
- };
+ };
};
-
+
(list_arg.is_empty).if {
// Prefix operator.
arg := read_loc_arg FALSE with_self TRUE;
@@ -1251,10 +1251,10 @@ Section Private
(arg != NULL).if {
// Infix operator.
list_arg.add_last arg;
- name := operator (ALIAS_STR.slot_infix) name name;
+ name := operator (ALIAS_STR.slot_infix) name name;
(associativity = NULL).if {
associativity := ALIAS_STR.keyword_left;
- };
+ };
} else {
// Postfix operator.
name := operator (ALIAS_STR.slot_postfix) name name;
@@ -1262,17 +1262,17 @@ Section Private
syntax_error (current_position,"Not associativity for prefix operator.");
};
};
- };
+ };
result := ITM_SLOT_OPERATOR.create current_position name name feature last_section;
result.set_associativity associativity priority priority;
- result.set_pretty_name pretty_name;
+ result.set_pretty_name pretty_name;
result
); // read_slot_operator
-
+
//++ DEF_SLOT -> [CONTRACT] EXPR [CONTRACT]
- read_def_slot <-
( + expr:ITM_CODE;
-
+
read_require;
expr := read_expr;
(expr = NULL).if {
@@ -1281,7 +1281,7 @@ Section Private
last_slot.set_value expr type object;
read_ensure;
);
-
+
//++ LOC_ARG -> identifier ':' TYPE
//++ | '(' LOCAL ')'
- read_loc_arg mute:BOOLEAN with_self self_first:BOOLEAN :ITM_ARGUMENT <-
@@ -1290,11 +1290,11 @@ Section Private
+ pos:POSITION;
+ n:STRING_CONSTANT;
+ tb:ITM_TYPE_BLOCK;
-
+
(
- (( self_first) && {read_this_keyword (ALIAS_STR.variable_self)}) ||
+ (( self_first) && {read_this_keyword (ALIAS_STR.variable_self)}) ||
{(! self_first) && {read_identifier}}
- ).if {
+ ).if {
pos := current_position;
n := last_string;
((read_character ':') && {last_character != '='}).if {
@@ -1302,19 +1302,19 @@ Section Private
(t = NULL).if {
syntax_error (current_position,"Incorrect type.");
};
-
+
(
- (self_first) &&
- {t != ITM_TYPE_SIMPLE.type_self} &&
+ (self_first) &&
+ {t != ITM_TYPE_SIMPLE.type_self} &&
{
- (object.name != ALIAS_STR.prototype_block) ||
+ (object.name != ALIAS_STR.prototype_block) ||
{tb ?= t; tb = NULL}
}
- ).if {
+ ).if {
syntax_error (current_position,"Type `SELF' is needed.");
};
result := ITM_ARG.create pos name n type t;
-
+
(is_shorter).if {
short_local.add n;
};
@@ -1322,14 +1322,14 @@ Section Private
mute.if_false {
warning_error (current_position,"Added ':' is needed.");
};
- };
- }.elseif {read_character '('} then {
+ };
+ }.elseif {read_character '('} then {
result := read_local_arg mute with_self self_first;
(result = NULL).if {
mute.if_false {
syntax_error (current_position,"Incorrect argument definition.");
};
- } else {
+ } else {
(read_character ')').if_false {
warning_error (current_position,"Added ')'.");
};
@@ -1337,18 +1337,18 @@ Section Private
};
result
);
-
+
//++ LOCAL -> { identifier [ ':' TYPE ] ',' } identifier ':' TYPE
- read_local m:BOOLEAN :FAST_ARRAY(ITM_LOCAL) <-
( + t:ITM_TYPE_MONO;
+ loc:ITM_LOCAL;
- + result:FAST_ARRAY(ITM_LOCAL);
+ + result:FAST_ARRAY(ITM_LOCAL);
+ beg:INTEGER;
+ mute:BOOLEAN;
-
+
mute := m;
(read_identifier).if {
- result := ALIAS_ARRAY(ITM_LOCAL).new;
+ result := ALIAS_ARRAY(ITM_LOCAL).new;
beg := result.lower;
{
((result.count != 0) && {! read_identifier} && {! mute}).if {
@@ -1366,7 +1366,7 @@ Section Private
result.item j.set_type t;
};
beg := result.upper + 1;
- };
+ };
}.do_while {read_character ','};
(beg != result.upper + 1).if {
(mute).if {
@@ -1374,10 +1374,10 @@ Section Private
result := NULL;
} else {
syntax_error (current_position,"Incorrect local type.");
- };
+ };
} else {
result := ALIAS_ARRAY(ITM_LOCAL).copy result;
-
+
(is_shorter).if {
(result.lower).to (result.upper) do { j:INTEGER;
short_local.add (result.item j.name);
@@ -1385,27 +1385,27 @@ Section Private
};
};
};
-
+
result
); // read_local
-
+
- read_local_arg m:BOOLEAN with_self s:BOOLEAN :ITM_ARGUMENT <-
( + t:ITM_TYPE_MONO;
+ tm:ITM_TYPE_MULTI;
+ type:FAST_ARRAY(ITM_TYPE_MONO);
- + name:FAST_ARRAY(STRING_CONSTANT);
+ + name:FAST_ARRAY(STRING_CONSTANT);
+ beg:INTEGER;
+ mute:BOOLEAN;
+ result:ITM_ARGUMENT;
+ tb:ITM_TYPE_BLOCK;
-
+
mute := m;
(
((s) && {read_this_keyword (ALIAS_STR.variable_self)}) ||
{read_identifier}
- ).if {
+ ).if {
name := ALIAS_ARRAY(STRING_CONSTANT).new;
- type := ALIAS_ARRAY(ITM_TYPE_MONO).new;
+ type := ALIAS_ARRAY(ITM_TYPE_MONO).new;
beg := name.lower;
{
((name.count != 0) && {! read_identifier} && {! mute}).if {
@@ -1422,19 +1422,19 @@ Section Private
type.add_last t;
};
beg := name.upper + 1;
- };
+ };
}.do_while {read_character ','};
(beg != name.upper + 1).if {
(mute).if_false {
syntax_error (current_position,"Incorrect argument type.");
- };
+ };
ALIAS_ARRAY(STRING_CONSTANT).free name;
ALIAS_ARRAY(ITM_TYPE_MONO).free type;
} else {
(
(s) && {
(type.first != ITM_TYPE_SIMPLE.type_self) || {
- (object.name = ALIAS_STR.prototype_block) &&
+ (object.name = ALIAS_STR.prototype_block) &&
{tb ?= type.first; tb = NULL}
}
}
@@ -1443,7 +1443,7 @@ Section Private
};
(name.count = 1).if {
// Single Argument.
- result := ITM_ARG.create current_position
+ result := ITM_ARG.create current_position
name (name.first)
type (type.first);
ALIAS_ARRAY(STRING_CONSTANT).free name;
@@ -1455,7 +1455,7 @@ Section Private
tm := ITM_TYPE_MULTI.get type;
result := ITM_ARGS.create current_position name name type tm;
};
-
+
(is_shorter).if {
(name.lower).to (name.upper) do { j:INTEGER;
short_local.add (name.item j);
@@ -1463,18 +1463,18 @@ Section Private
};
};
};
-
+
result
- ); // read_local
-
+ ); // read_local
+
//++ TYPE_LIST -> TYPE { ',' TYPE }
- read_type_list is_section:BOOLEAN :FAST_ARRAY(ITM_TYPE_MONO) <-
( + lst:FAST_ARRAY(ITM_TYPE_MONO);
+ t:ITM_TYPE_MONO;
+ ts:ITM_TYPE_SIMPLE;
-
- t := read_type FALSE;
- (t != NULL).if {
+
+ t := read_type FALSE;
+ (t != NULL).if {
(is_section).if {
ts ?= t;
(ts = NULL).if {
@@ -1483,7 +1483,7 @@ Section Private
};
};
lst := ALIAS_ARRAY(ITM_TYPE_MONO).new;
- lst.add_last t;
+ lst.add_last t;
{read_character ','}.while_do {
t := read_type FALSE;
(t = NULL).if {
@@ -1502,7 +1502,7 @@ Section Private
};
lst
);
-
+
//++ TYPE -> '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
//++ | [type] PROTOTYPE [ CONTRACT ]
- read_type is_local:BOOLEAN :ITM_TYPE_MONO <-
@@ -1511,9 +1511,9 @@ Section Private
+ lst:FAST_ARRAY(ITM_TYPE_MONO);
+ typ_arg,typ_res:ITM_TYPE;
+ contract:ITM_LIST;
-
+
(read_character '{').if {
- // '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
+ // '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
(read_character '(').if {
// Read vector argument.
lst := read_type_list FALSE;
@@ -1521,13 +1521,13 @@ Section Private
syntax_error (current_position,"Incorrect type list.");
};
(lst.count = 1).if {
- typ_arg := lst.first;
+ typ_arg := lst.first;
} else {
typ_arg := ITM_TYPE_MULTI.get lst;
};
(! read_character ')').if {
warning_error (current_position,"Added ')'.");
- }; // if
+ }; // if
(! read_character ';').if {
warning_error (current_position,"Added ';'.");
}; // if
@@ -1535,7 +1535,7 @@ Section Private
} else {
lst := read_type_list FALSE;
(lst != NULL).if {
- (read_character ';').if {
+ (read_character ';').if {
(lst.count = 1).if {
typ_arg := lst.first;
} else {
@@ -1546,8 +1546,8 @@ Section Private
warning_error (current_position,string_tmp);
};
lst := read_type_list FALSE;
- };
- };
+ };
+ };
};
(lst != NULL).if {
(lst.count = 1).if {
@@ -1558,19 +1558,19 @@ Section Private
};
(! read_character '}').if {
warning_error (current_position,"Added '}'.");
- }; // if
- result := ITM_TYPE_BLOCK.get typ_arg and typ_res;
- } else {
- // Expanded | Strict
+ }; // if
+ result := ITM_TYPE_BLOCK.get typ_arg and typ_res;
+ } else {
+ // Expanded | Strict
(
- (read_this_keyword (ALIAS_STR.keyword_expanded)) ||
- {read_this_keyword (ALIAS_STR.keyword_strict)}
- ).if {
+ (read_this_keyword (ALIAS_STR.keyword_expanded)) ||
+ {read_this_keyword (ALIAS_STR.keyword_strict)}
+ ).if {
style := last_string;
((is_local) && {last_string = ALIAS_STR.keyword_expanded}).if {
syntax_error (current_position,"`Expanded' is not possible.");
};
- };
+ };
// PROTOTYPE
result := read_prototype style;
contract := read_contract;
@@ -1580,17 +1580,17 @@ Section Private
};
result
); // read_type
-
+
//++ PROTOTYPE -> cap_identifier{('.'|'...')cap_identifier}['('PARAM_TYPE{','PARAM_TYPE}')']
- read_prototype styl:STRING_CONSTANT :ITM_TYPE_MONO <-
- ( + nam:STRING_CONSTANT;
- + genericity:FAST_ARRAY(ITM_TYPE_MONO);
- + result,t:ITM_TYPE_MONO;
+ ( + nam:STRING_CONSTANT;
+ + genericity:FAST_ARRAY(ITM_TYPE_MONO);
+ + result,t:ITM_TYPE_MONO;
+ old_pos,old_derive,sav_derive,pos_before:INTEGER;
+ continue:BOOLEAN;
-
-
- (read_cap_identifier).if {
+
+
+ (read_cap_identifier).if {
old_pos := position;
old_derive := short_derive;
string_tmp2.copy last_string;
@@ -1612,10 +1612,10 @@ Section Private
position := pos_before;
};
};
- }.do_while {continue};
+ }.do_while {continue};
nam := ALIAS_STR.get string_tmp2;
//
- (read_character '(').if {
+ (read_character '(').if {
// Multiple Genericity.
genericity := ALIAS_ARRAY(ITM_TYPE_MONO).new;
{
@@ -1624,14 +1624,14 @@ Section Private
syntax_error (current_position,"Type needed.");
};
genericity.add_last t;
- }.do_while {read_character ','};
+ }.do_while {read_character ','};
genericity := ALIAS_ARRAY(ITM_TYPE_MONO).alias genericity;
result := ITM_TYPE_GENERIC.get nam style styl with genericity;
(read_character ')').if_false {
warning_error (current_position,"Added ')'.");
};
- } else {
- // Simple type.
+ } else {
+ // Simple type.
(is_parameter_type).if {
(styl != NULL).if {
string_tmp.copy "Style `";
@@ -1647,7 +1647,7 @@ Section Private
string_tmp.copy "Style `";
string_tmp.append styl;
string_tmp.append "' ignored.";
- warning_error (current_position,string_tmp);
+ warning_error (current_position,string_tmp);
result := ITM_TYPE_SIMPLE.type_self;
} else {
result := ITM_TYPE_STYLE.get nam style styl;
@@ -1658,13 +1658,13 @@ Section Private
sav_derive := short_derive;
short_derive := old_derive;
(
- (result = ITM_TYPE_SIMPLE.type_self) ||
+ (result = ITM_TYPE_SIMPLE.type_self) ||
{result = ITM_TYPE_SIMPLE.type_null}
).if {
- short (ALIAS_STR.short_keyprototype) token
+ short (ALIAS_STR.short_keyprototype) token
(old_pos - nam.count) to old_pos;
} else {
- short (ALIAS_STR.short_prototype) token
+ short (ALIAS_STR.short_prototype) token
(old_pos - nam.count) to old_pos;
};
short_derive := sav_derive + (short_derive - old_derive);
@@ -1672,41 +1672,41 @@ Section Private
}; // if
result
); // read_prototype
-
+
- read_param_type:ITM_TYPE_MONO <-
//++ PARAM_TYPE -> TYPE
//++ | CONSTANT
//++ | identifier
( + result:ITM_TYPE_MONO;
+ cst:ITM_CONSTANT;
-
+
result := read_type FALSE;
- (result = NULL).if {
+ (result = NULL).if {
cst := read_constant;
(cst != NULL).if {
syntax_error (current_position,"1) Sorry, not yet implemented.");
- //result :=
+ //result :=
}.elseif {read_identifier} then {
syntax_error (current_position,"2) Sorry, not yet implemented.");
- //result :=
+ //result :=
};
};
result
);
-
+
//++ EXPR -> { ASSIGN !!AMBIGU!! affect } EXPR_OPERATOR
//++ ASSIGN -> '(' IDF_ASSIGN { ',' IDF_ASSIGN } ')'
//++ | IDF_ASSIGN
//++ IDF_ASSIGN -> identifier { identifier }
- read_expr:ITM_CODE <-
- ( + result,value:ITM_CODE;
- + affect:CHARACTER;
+ ( + result,value:ITM_CODE;
+ + affect:CHARACTER;
+ again:BOOLEAN;
+ l_assignment:FAST_ARRAY(STRING_CONSTANT);
+ p:INTEGER;
+ name:STRING_CONSTANT;
-
- // !! AMBIGU resolution !!
+
+ // !! AMBIGU resolution !!
save_context;
(read_character '(').if {
l_assignment := ALIAS_ARRAY(STRING_CONSTANT).new;
@@ -1721,22 +1721,22 @@ Section Private
};
name := ALIAS_STR.get string_tmp2;
l_assignment.add_last name;
-
+
(is_shorter).if {
- (! short_local.fast_has name).if {
- short (ALIAS_STR.short_slot_call) token p to position;
+ (! short_local.fast_has name).if {
+ short (ALIAS_STR.short_slot_call) token p to position;
};
};
-
+
(read_character ',').if {
again := TRUE;
};
};
}.do_while {again};
- ((! l_assignment.is_empty) && {read_character ')'} && {read_affect}).if {
+ ((! l_assignment.is_empty) && {read_character ')'} && {read_affect}).if {
l_assignment := ALIAS_ARRAY(STRING_CONSTANT).copy l_assignment;
result := ITM_LIST_IDF.create current_position with l_assignment;
- affect := last_string.first;
+ affect := last_string.first;
value := read_expr;
(value = NULL).if {
syntax_error (current_position,"Incorrect expression.");
@@ -1751,7 +1751,7 @@ Section Private
.when '?' then {
syntax_error (current_position,"Sorry, Not yet implemented !");
result := ITM_WRITE_CAST.create (result.position) assign result with value;
- };
+ };
} else {
ALIAS_ARRAY(STRING_CONSTANT).free l_assignment;
};
@@ -1763,16 +1763,16 @@ Section Private
string_tmp2.append last_string;
};
name := ALIAS_STR.get string_tmp2;
-
+
(is_shorter).if {
- (! short_local.fast_has name).if {
- short (ALIAS_STR.short_slot_call) token p to position;
+ (! short_local.fast_has name).if {
+ short (ALIAS_STR.short_slot_call) token p to position;
};
};
-
+
(read_affect).if {
result := ITM_READ.create current_position name name;
- affect := last_string.first;
+ affect := last_string.first;
value := read_expr;
(value = NULL).if {
syntax_error (current_position,"Incorrect expression.");
@@ -1786,7 +1786,7 @@ Section Private
}
.when '?' then {
result := ITM_WRITE_CAST.create (result.position) assign result with value;
- };
+ };
};
};
(result = NULL).if {
@@ -1794,45 +1794,45 @@ Section Private
result := read_expr_operator;
};
result
- );
-
+ );
+
//++ EXPR_OPERATOR-> { operator } EXPR_MESSAGE { operator {operator} EXPR_MESSAGE } {operator}
- read_expr_operator:ITM_CODE <-
( + result:ITM_CODE;
+ expr :ITM_CODE;
- + l_expr:FAST_ARRAY(ITM_CODE);
- + itm_op:ITM_OPERATOR;
+ + l_expr:FAST_ARRAY(ITM_CODE);
+ + itm_op:ITM_OPERATOR;
+ last_msg,first_msg:INTEGER;
-
+
l_expr := ALIAS_ARRAY(ITM_CODE).new;
{read_operator}.while_do {
expr := ITM_OPERATOR.create current_position name last_string;
l_expr.add_last expr;
};
expr := read_expr_message;
- (expr = NULL).if {
+ (expr = NULL).if {
// Error.
(! l_expr.is_empty).if {
syntax_error (current_position,"Incorrect expression.");
};
- ALIAS_ARRAY(ITM_CODE).free l_expr;
+ ALIAS_ARRAY(ITM_CODE).free l_expr;
} else {
- // { operator {operator} EXPR_MESSAGE } {operator}
+ // { operator {operator} EXPR_MESSAGE } {operator}
first_msg := l_expr.count;
{
last_msg := l_expr.count;
- l_expr.add_last expr;
+ l_expr.add_last expr;
(read_operator).if {
{
expr := ITM_OPERATOR.create current_position name last_string;
l_expr.add_last expr;
- }.do_while {read_operator};
+ }.do_while {read_operator};
expr := read_expr_message;
- } else {
+ } else {
expr := NULL;
};
}.do_while {expr != NULL};
-
+
// Last Post-fix operator.
{last_msg < l_expr.upper}.while_do {
itm_op ?= l_expr.item (last_msg + 1);
@@ -1841,7 +1841,7 @@ Section Private
arg (l_expr.item last_msg);
l_expr.put expr to last_msg;
l_expr.remove (last_msg + 1);
- };
+ };
((last_msg - first_msg) < 3).if {
// First Pre-fix operator.
{first_msg != 0}.while_do {
@@ -1852,19 +1852,19 @@ Section Private
l_expr.put expr to first_msg;
first_msg := first_msg - 1;
l_expr.remove first_msg;
- };
+ };
};
(l_expr.count = 1).if {
- result := l_expr.first;
+ result := l_expr.first;
ALIAS_ARRAY(ITM_CODE).free l_expr;
}.elseif {l_expr.count = 3} then {
- // Simple binary message.
+ // Simple binary message.
itm_op ?= l_expr.second;
- result := ITM_READ_ARG2.create (itm_op.position)
- name (operator (ALIAS_STR.slot_infix) name (itm_op.name))
+ result := ITM_READ_ARG2.create (itm_op.position)
+ name (operator (ALIAS_STR.slot_infix) name (itm_op.name))
args (l_expr.first,l_expr.item 2);
//
- ALIAS_ARRAY(ITM_CODE).free l_expr;
+ ALIAS_ARRAY(ITM_CODE).free l_expr;
} else {
// Complex expression.
l_expr := ALIAS_ARRAY(ITM_CODE).copy l_expr;
@@ -1877,9 +1877,9 @@ Section Private
//++ EXPR_MESSAGE -> EXPR_BASE { '.' SEND_MSG }
- read_expr_message:ITM_CODE <-
( + result:ITM_CODE;
-
+
result := read_expr_base;
- (result != NULL).if {
+ (result != NULL).if {
{read_character '.'}.while_do {
result := read_send_msg result;
(result=NULL).if {
@@ -1894,15 +1894,15 @@ Section Private
//++ | EXPR_PRIMARY
//++ | SEND_MSG
- read_expr_base:ITM_CODE <-
- ( + result,old_value:ITM_CODE;
-
+ ( + result,old_value:ITM_CODE;
+
(read_this_keyword (ALIAS_STR.keyword_old)).if {
old_value := read_expr;
- (old_value = NULL).if {
- syntax_error (current_position,"Incorrect `Old' expression.");
- };
+ (old_value = NULL).if {
+ syntax_error (current_position,"Incorrect `Old' expression.");
+ };
result := ITM_OLD.create current_position value old_value;
- } else {
+ } else {
result := read_expr_primary;
(result = NULL).if {
result := read_send_msg NULL;
@@ -1925,8 +1925,8 @@ Section Private
+ ext :ITM_EXTERNAL_TYPE;
+ group_sav:ITM_LIST;
+ arg:ITM_ARGUMENT;
- + result_id:STRING_CONSTANT;
-
+ + result_id:STRING_CONSTANT;
+
(read_this_keyword (ALIAS_STR.variable_self)).if {
result := ITM_READ.create current_position name last_string;
}.elseif {read_this_keyword (ALIAS_STR.keyword_result)} then {
@@ -1949,50 +1949,50 @@ Section Private
}.elseif {
type := read_prototype NULL;
type != NULL
- } then {
- result := ITM_PROTOTYPE.create current_position type type;
- }.elseif {(result := read_constant) != NULL} then {
- }.elseif {read_character '(' } then {
+ } then {
+ result := ITM_PROTOTYPE.create current_position type type;
+ }.elseif {(result := read_constant) != NULL} then {
+ }.elseif {read_character '(' } then {
group_sav := last_group;
last_group := ITM_LIST.create current_position;
result := last_group;
last_group.set_code read_group;
- (read_character ')').if_false {
+ (read_character ')').if_false {
warning_error (current_position,"Added ')'.");
}; // if
last_group := group_sav;
}.elseif {read_character '{' } then {
short (ALIAS_STR.short_block) token (position-1) to position;
- group_sav := last_group;
+ group_sav := last_group;
last_group := ITM_LIST.create current_position;
-
+
save_context; // !! SAVE CONTEXT !!
-
+
//
arg := read_loc_arg TRUE with_self FALSE;
- //
- (arg != NULL).if {
- (read_character ';').if_false {
+ //
+ (arg != NULL).if {
+ (read_character ';').if_false {
warning_error (current_position,"Added ';'.");
}; // if
} else {
-
+
restore_context; // !! RESTORE CONTEXT !!
-
+
};
result := ITM_BLOCK.create last_group argument arg;
-
+
last_group.set_code read_group;
(! read_character '}').if {
warning_error (current_position,"Added '}'.");
}; // if
short (ALIAS_STR.short_block) token (position-1) to position;
- last_group := group_sav;
+ last_group := group_sav;
}.elseif {read_external} then {
(! read_character ':').if {
result := ITM_EXTERNAL.create current_position text last_string;
} else {
- ext := ITM_EXTERNAL_TYPE.create current_position text
+ ext := ITM_EXTERNAL_TYPE.create current_position text
last_string persistant (read_character '(');
type := read_type FALSE;
(type = NULL).if {
@@ -2009,7 +2009,7 @@ Section Private
};
ext.set_type_list ltype;
};
- ((ext.is_persistant) && {! read_character ')'}).if {
+ ((ext.is_persistant) && {! read_character ')'}).if {
warning_error (current_position,"Added ')'.");
};
result := ext;
@@ -2017,14 +2017,14 @@ Section Private
};
result
); // read_expr_primaire
-
+
- read_constant:ITM_CONSTANT <-
//++ CONSTANT -> integer
//++ | real
//++ | characters
//++ | string
( + result:ITM_CONSTANT;
-
+
(read_real).if {
result := ITM_REAL.create current_position value last_real;
}.elseif {read_integer} then {
@@ -2032,18 +2032,18 @@ Section Private
}.elseif {read_characters} then {
result := ITM_CHARACTER.create current_position char last_string;
}.elseif {read_string} then {
- result := ITM_STRING.create current_position text last_string;
+ result := ITM_STRING.create current_position text last_string;
};
result
);
-
+
//++ GROUP -> DEF_LOCAL {EXPR ';'} [ EXPR {',' {EXPR ';'} EXPR } ]
- read_group:FAST_ARRAY(ITM_CODE) <-
- ( + e:ITM_CODE;
+ ( + e:ITM_CODE;
+ result:FAST_ARRAY(ITM_CODE);
-
+
read_def_local;
-
+
result := ALIAS_ARRAY(ITM_CODE).new;
e := read_expr;
{(e != NULL) && {read_character ';'}}.while_do {
@@ -2051,7 +2051,7 @@ Section Private
e := read_expr;
};
(e != NULL).if {
- (read_character ',').if {
+ (read_character ',').if {
{
e := ITM_RESULT.create e;
result.add_last e;
@@ -2062,26 +2062,26 @@ Section Private
};
(e = NULL).if {
syntax_error (current_position,"Incorrect multiple result expression.");
- };
- }.do_while {read_character ','};
+ };
+ }.do_while {read_character ','};
};
e := ITM_RESULT.create e;
result.add_last e;
- };
+ };
ALIAS_ARRAY(ITM_CODE).copy result
);
-
+
- read_invariant:BOOLEAN <-
( + lst:ITM_LIST;
-
+
lst := read_contract;
- lst != NULL
+ lst != NULL
);
-
+
- read_require:BOOLEAN <-
( + lst:ITM_LIST;
+ result:BOOLEAN;
-
+
lst := read_contract;
(lst != NULL).if {
last_slot.set_require lst;
@@ -2093,7 +2093,7 @@ Section Private
- read_ensure:BOOLEAN <-
( + lst:ITM_LIST;
+ result:BOOLEAN;
-
+
lst := read_contract;
(lst != NULL).if {
last_slot.set_ensure lst;
@@ -2101,18 +2101,18 @@ Section Private
};
result
);
-
+
//++ CONTRACT -> '[' DEF_LOCAL { ( EXPR ';' | "..." ) } ']'
- read_contract:ITM_LIST <-
( + continue:BOOLEAN;
+ e:ITM_CODE;
+ result:ITM_LIST;
+ lst:FAST_ARRAY(ITM_CODE);
-
+
(read_character '[').if {
result := last_group := ITM_LIST.create current_position;
read_def_local;
-
+
lst := ALIAS_ARRAY(ITM_CODE).new;
{
e := read_expr;
@@ -2129,7 +2129,7 @@ Section Private
continue := TRUE;
};
}.do_while {continue};
-
+
(! read_character ']').if {
warning_error (current_position,"Added ']'.");
};
@@ -2140,15 +2140,15 @@ Section Private
};
result
);
-
+
//++ DEF_LOCAL -> { style LOCAL ';' } !! AMBIGU !!
- read_def_local <-
( + loc_lst:FAST_ARRAY(ITM_LOCAL);
- + local_list,static_list:FAST_ARRAY(ITM_LOCAL);
+ + local_list,static_list:FAST_ARRAY(ITM_LOCAL);
+ styl:CHARACTER;
-
+
save_context; // !! SAVE CONTEXT !!
-
+
styl := read_style;
local_list := ALIAS_ARRAY(ITM_LOCAL).new;
static_list := ALIAS_ARRAY(ITM_LOCAL).new;
@@ -2163,16 +2163,16 @@ Section Private
(read_character ';').if_false {
warning_error (current_position,"Added ';'.");
};
-
+
save_context; // !! SAVE CONTEXT !!
-
+
styl := read_style;
} else {
-
+
restore_context; // !! RESTORE CONTEXT !!
-
+
styl := ' ';
- };
+ };
};
(local_list.is_empty).if {
ALIAS_ARRAY(ITM_LOCAL).free local_list;
@@ -2182,10 +2182,10 @@ Section Private
(static_list.is_empty).if {
ALIAS_ARRAY(ITM_LOCAL).free static_list;
} else {
- last_group.set_static_list (ALIAS_ARRAY(ITM_LOCAL).copy static_list);
+ last_group.set_static_list (ALIAS_ARRAY(ITM_LOCAL).copy static_list);
};
);
-
+
//++ SEND_MSG -> identifier [ ARGUMENT { identifier ARGUMENT } ]
- read_send_msg first_arg:ITM_CODE :ITM_CODE <-
( + result:ITM_CODE;
@@ -2194,7 +2194,7 @@ Section Private
+ l_arg:FAST_ARRAY(ITM_CODE);
+ arg:ITM_CODE;
+ p1,p2,old_derive,sav_derive:INTEGER;
-
+
read_identifier.if {
//
// Classic Message.
@@ -2202,19 +2202,19 @@ Section Private
p1 := position - last_string.count;
p2 := position;
old_derive := short_derive;
-
+
n := ALIAS_STR.new;
n.copy last_string;
// Argument list.
l_arg := ALIAS_ARRAY(ITM_CODE).new;
arg := read_argument;
- (arg != NULL).if {
- l_arg.add_last arg;
+ (arg != NULL).if {
+ l_arg.add_last arg;
{read_identifier}.while_do {
-
- short (ALIAS_STR.short_slot_call) token
+
+ short (ALIAS_STR.short_slot_call) token
(position-last_string.count) to position;
-
+
n.append (ALIAS_STR.separate);
n.append last_string;
arg := read_argument;
@@ -2225,10 +2225,10 @@ Section Private
}; // loop
}; // if
name := ALIAS_STR.alias n;
-
+
(is_shorter).if {
(
- (! l_arg.is_empty) ||
+ (! l_arg.is_empty) ||
{first_arg != NULL} ||
{! short_local.fast_has last_string}
).if {
@@ -2238,23 +2238,23 @@ Section Private
short_derive := sav_derive + (short_derive-old_derive);
};
};
-
+
l_arg.is_empty.if {
(first_arg=NULL).if {
// Local ou Implicite Slot without argument.
- result := ITM_READ.create current_position name name;
- } else {
- result := ITM_READ_ARG1.create current_position name name arg first_arg;
+ result := ITM_READ.create current_position name name;
+ } else {
+ result := ITM_READ_ARG1.create current_position name name arg first_arg;
};
ALIAS_ARRAY(ITM_CODE).free l_arg;
}.elseif {l_arg.count=1} then {
- result := ITM_READ_ARG2.create current_position name
- name args (first_arg,(l_arg.first));
+ result := ITM_READ_ARG2.create current_position name
+ name args (first_arg,(l_arg.first));
ALIAS_ARRAY(ITM_CODE).free l_arg;
} else {
l_arg.add_first first_arg;
- l_arg := ALIAS_ARRAY(ITM_CODE).copy l_arg;
- result := ITM_READ_ARGS.create current_position name name args l_arg;
+ l_arg := ALIAS_ARRAY(ITM_CODE).copy l_arg;
+ result := ITM_READ_ARGS.create current_position name name args l_arg;
};
}; // if
result
@@ -2268,7 +2268,7 @@ Section Private
((result = NULL) && {read_identifier}).if {
(is_shorter).if {
(short_local.fast_has last_string).if_false {
- short (ALIAS_STR.short_slot_call) token
+ short (ALIAS_STR.short_slot_call) token
(position-last_string.count) to position;
};
};
@@ -2276,12 +2276,12 @@ Section Private
};
result
); // read_argument
-
+
// name, export, import, type, default, external, version, lip,
- // date, comment, author, bibliography, language, bug_report,
+ // date, comment, author, bibliography, language, bug_report,
// copyright.
- read_slot_header first:BOOLEAN :BOOLEAN <-
- ( + result:BOOLEAN;
+ ( + result:BOOLEAN;
+ v:ITM_CODE;
+ cast:FAST_ARRAY(ITM_TYPE_MONO);
+ style:CHARACTER;
@@ -2289,7 +2289,7 @@ Section Private
+ parameter_type:ITM_TYPE_PARAMETER;
+ instr:LIP_CODE;
+ param:{ITM_TYPE_PARAMETER};
-
+
style := read_style;
(style != ' ').if {
result := TRUE;
@@ -2301,14 +2301,14 @@ Section Private
//
// Read `name' slot.
//
-
- (style = '-').if {
+
+ (style = '-').if {
semantic_error (current_position,"COP not yet implemented.");
- is_cop := TRUE;
+ is_cop := TRUE;
(is_java).if {
semantic_error (current_position,"COP not yet implemented.");
} else {
- output_decl.append
+ output_decl.append
"#include <pthread.h>\n\
\#include <limits.h>\n\n\
\void print_char(char car);\n\
@@ -2316,7 +2316,7 @@ Section Private
\static pthread_key_t current_thread;\n\
\static pthread_attr_t thread_attr;\n\
\pthread_t c_thread;\n\
- \int thread_counter;\n\n\
+ \int thread_counter;\n\n\
\static char thread_stack[512][PTHREAD_STACK_MIN];\n\n\
\typedef struct lith_object_struct lith_object;\n\
\typedef struct lith_node_struct lith_node;\n\
@@ -2324,7 +2324,7 @@ Section Private
\ pthread_mutex_t mutex;\n\
\ lith_node *next;\n\
\ lith_object *object;\n\
- \};\n\
+ \};\n\
\struct lith_object_struct {\n\
\ unsigned long __id; // Just for late binding.\n\
\ lith_node *first;\n\
@@ -2338,7 +2338,7 @@ Section Private
\} pool;\n\n\
\void *thread_life(void *ptr)\n\
\{ lith_node node,*n;\n\
- \ lith_object *obj,*new_obj;\n\n\
+ \ lith_object *obj,*new_obj;\n\n\
\ pthread_mutex_init(&node.mutex,NULL);\n\
\ pthread_mutex_lock(&node.mutex);\n\
\ node.object = (lith_object *)ptr;\n\
@@ -2392,7 +2392,7 @@ Section Private
\ };\n\
\ pthread_mutex_unlock(&pool.mutex);\n\
\ // Run thread.\n\
- \ if (node == NULL) {\n\
+ \ if (node == NULL) {\n\
\ pthread_attr_setstack(&thread_attr, thread_stack[thread_counter++],PTHREAD_STACK_MIN);\n\
\ if ((thread_counter>512) || pthread_create(&c_thread,&thread_attr, thread_life, (void *)obj)) {\n\
\ while (*msg != 0) print_char(*(msg++));\n\
@@ -2405,40 +2405,40 @@ Section Private
\};\n\n";
};
};
-
+
// style "name" ':=' [type] cap_identifier [ '(' PARAM {',' PARAM}')' ]
// PARAM -> cap_identifier | identifier ':' TYPE
- short (ALIAS_STR.short_slot) token
- (position-last_string.count) to position;
-
+ short (ALIAS_STR.short_slot) token
+ (position-last_string.count) to position;
+
object.set_position current_position;
- object.set_style style;
+ object.set_style style;
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if_false {
warning_error (current_position,"Added ':='.");
};
-
+
(
(read_this_keyword (ALIAS_STR.keyword_expanded)) ||
- {read_this_keyword (ALIAS_STR.keyword_strict)}
+ {read_this_keyword (ALIAS_STR.keyword_strict)}
).if {
- object.set_type_style last_string;
+ object.set_type_style last_string;
};
-
+
(! read_cap_identifier).if {
syntax_error (current_position,"Prototype identifier is needed.");
};
short (ALIAS_STR.short_prototype) token
(position-last_string.count) to position;
-
+
(object.shortname != last_string).if {
syntax_error (current_position,"Incorrect name (filename != name).");
- };
+ };
(read_character '(').if {
//
// Generic loader.
//
param := { + res:ITM_TYPE_PARAMETER;
- (read_identifier).if {
+ (read_identifier).if {
(read_character ':').if_false {
warning_error (current_position,"Added ':'.");
};
@@ -2457,44 +2457,44 @@ Section Private
};
res
};
-
- ((! is_shorter) && {! is_shorter2}).if {
- (object.generic_count = 0).if {
+
+ ((! is_shorter) && {! is_shorter2}).if {
+ (object.generic_count = 0).if {
syntax_error (current_position,"Object can't be generic.");
};
};
parameter_type := param.value;
(parameter_type = NULL).if {
syntax_error (current_position,"Identifier parameter type is needed.");
- };
-
- object.idf_generic_list.add_last parameter_type;
- {read_character ','}.while_do {
+ };
+
+ object.idf_generic_list.add_last parameter_type;
+ {read_character ','}.while_do {
parameter_type := param.value;
(parameter_type = NULL).if {
syntax_error (current_position,"Identifier parameter type is needed.");
- };
+ };
object.idf_generic_list.add_last parameter_type;
}; // loop
-
+
(! read_character ')').if {
warning_error (current_position,"Added ')'.");
};
-
- ((! is_shorter) && {! is_shorter2}).if {
+
+ ((! is_shorter) && {! is_shorter2}).if {
(object.idf_generic_list.count != object.generic_count).if {
syntax_error (current_position,"Invalid generic list number.");
};
};
- };
+ };
} else {
syntax_error (current_position,"Slot `name' must to be first slot.");
};
}.elseif {
- (is_export := read_word (ALIAS_STR.slot_export)) ||
+ (is_export := read_word (ALIAS_STR.slot_export)) ||
{read_word (ALIAS_STR.slot_import)}
} then {
- // - ("export"|"import") ':=' TYPE_LIST
+ // - ("export"|"import") ':=' TYPE_LIST
short (ALIAS_STR.short_slot) token
(position-last_string.count) to position;
@@ -2514,7 +2514,7 @@ Section Private
//
// Read `external' slot.
//
-
+
// - "external" ':=' `<code_c>`
short (ALIAS_STR.short_slot) token
(position-last_string.count) to position;
@@ -2528,17 +2528,17 @@ Section Private
output_decl.append "/* ";
output_decl.append (object.name);
output_decl.append " */\n";
- output_decl.append last_string;
+ output_decl.append last_string;
output_decl.add_last '\n';
}.elseif {read_word(ALIAS_STR.slot_default)} then {
//
// Read `default' slot.
//
-
+
// '-' "default" ':=' EXPR_PRIMARY
short (ALIAS_STR.short_slot) token
(position-last_string.count) to position;
-
+
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if_false {
warning_error (current_position,"Added ':='.");
};
@@ -2554,11 +2554,11 @@ Section Private
//
// Read `type' slot.
//
-
+
// '-' "type" ':=' `<type C>`
short (ALIAS_STR.short_slot) token
(position-last_string.count) to position;
-
+
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if_false {
warning_error (current_position,"Added ':='.");
};
@@ -2573,32 +2573,32 @@ Section Private
//
// Read `version' slot.
//
-
+
// '-' "version" ':=' integer
short (ALIAS_STR.short_slot) token
(position-last_string.count) to position;
-
+
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if_false {
warning_error (current_position,"Added ':='.");
};
(read_integer).if_false {
syntax_error (current_position,"Incorrect number.");
};
-
+
}.elseif {read_word (ALIAS_STR.slot_lip)} then {
//
// LIP interpreter.
//
-
+
// '-' lip <- ( { LIP_EXPR ';' } )
(read_symbol (ALIAS_STR.symbol_affect_code)).if_false {
warning_error (current_position,"Added '<-' is needed.");
- };
+ };
(read_character '(').if_false {
warning_error (current_position,"Added '(' is needed.");
- };
+ };
{(instr := readlip_expr) != NULL}.while_do {
- ((! is_shorter) && {! is_shorter2}).if {
+ ((! is_shorter) && {! is_shorter2}).if {
instr.run;
};
(read_character ';').if_false {
@@ -2607,7 +2607,7 @@ Section Private
};
(read_character ')').if_false {
warning_error (current_position,"Added ')' is needed.");
- };
+ };
}.elseif {
(read_word (ALIAS_STR.slot_date)) ||
{read_word (ALIAS_STR.slot_comment)} ||
@@ -2617,22 +2617,22 @@ Section Private
{read_word (ALIAS_STR.slot_copyright)} ||
{read_word (ALIAS_STR.slot_bug_report)}
} then {
- //
- // Read `date', `comment', `author', `bibliography',
+ //
+ // Read `date', `comment', `author', `bibliography',
// `language', `copyright' or `bug_report' slots.
//
-
- // '-' ("date"|"comment"|"author"|"bibliography"|"language"|"copyright"|"bug_report")
+
+ // '-' ("date"|"comment"|"author"|"bibliography"|"language"|"copyright"|"bug_report")
// ':=' string
- short (ALIAS_STR.short_slot) token
- (position-last_string.count) to position;
-
+ short (ALIAS_STR.short_slot) token
+ (position-last_string.count) to position;
+
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if_false {
warning_error (current_position,"Added ':='.");
- };
+ };
(read_string).if_false {
syntax_error (current_position,"Incorrect string.");
- };
+ };
(is_shorter2).if {
object.set_comment_slot last_string;
};
@@ -2645,20 +2645,20 @@ Section Private
};
result
);
-
+
//
// Parser for LIP file.
- //
-
- - readlip_program <-
- //// PROGRAM -> { 'Section' ('Inherit' | 'Public' | 'Private') { SLOT ';' } }
+ //
+
+ - readlip_program <-
+ //// PROGRAM -> { 'Section' ('Inherit' | 'Public' | 'Private') { SLOT ';' } }
( + idx:INTEGER;
+ section:STRING_CONSTANT;
-
- idx := LIP_CODE.list_parent.lower;
- {read_this_keyword (ALIAS_STR.keyword_section)}.while_do {
+
+ idx := LIP_CODE.list_parent.lower;
+ {read_this_keyword (ALIAS_STR.keyword_section)}.while_do {
(read_this_keyword (ALIAS_STR.section_inherit)).if {
- // { '+' string ':' STRING [ ':=' string ] ';' }
+ // { '+' string ':' STRING [ ':=' string ] ';' }
{read_character '+'}.while_do {
(read_identifier).if_false {
warning_error (current_position,"Identifier needed.");
@@ -2669,19 +2669,19 @@ Section Private
(read_word (ALIAS_STR.prototype_string)).if_false {
warning_error (current_position,"`STRING' type needed.");
};
- (read_symbol (ALIAS_STR.symbol_affect_immediate)).if {
- (read_string).if_false {
- syntax_error (current_position,"String needed.");
- };
+ (read_symbol (ALIAS_STR.symbol_affect_immediate)).if {
+ (read_string).if_false {
+ syntax_error (current_position,"String needed.");
+ };
string_tmp.copy (object.filename);
{
- (!string_tmp.is_empty) &&
- {string_tmp.last != '/'} &&
+ (!string_tmp.is_empty) &&
+ {string_tmp.last != '/'} &&
{string_tmp.last != '\\'}
}.while_do {
string_tmp.remove_last 1;
};
- string_tmp.append last_string;
+ string_tmp.append last_string;
} else {
string_tmp.clear;
};
@@ -2693,7 +2693,7 @@ Section Private
};
}.elseif {
(read_this_keyword (ALIAS_STR.section_public)) ||
- {read_this_keyword (ALIAS_STR.section_private)}
+ {read_this_keyword (ALIAS_STR.section_private)}
} then {
section := last_string;
{readlip_slot section}.while_do {
@@ -2706,19 +2706,19 @@ Section Private
};
};
);
-
+
- readlip_slot sec:STRING_CONSTANT :BOOLEAN <-
//// SLOT -> '+' identifier ':' TYPE [ ':=' EXPR_CONSTANT ]
- //// | '-' identifier [ identifier ':' TYPE ] '<-' EXPR
+ //// | '-' identifier [ identifier ':' TYPE ] '<-' EXPR
( + result:BOOLEAN;
+ t:LIP_CONSTANT;
+ n,na:STRING_CONSTANT;
+ data:LIP_SLOT_DATA;
+ slot_code:LIP_SLOT_CODE;
- + exp:LIP_CODE;
+ + exp:LIP_CODE;
+ pos:POSITION;
+ cst:LIP_CONSTANT;
-
+
(read_character '+').if {
// Data.
result := TRUE;
@@ -2735,14 +2735,14 @@ Section Private
t := readlip_type;
(t = NULL).if {
syntax_error (current_position,"type is incorrect.");
- };
+ };
data := LIP_SLOT_DATA.create current_position name n value t argument FALSE;
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if {
cst := readlip_expr_constant;
(cst = NULL).if {
syntax_error (current_position,"Incorrect expression.");
};
- data.set_value cst;
+ data.set_value cst;
cst.free;
};
}.elseif {read_character '-'} then {
@@ -2751,7 +2751,7 @@ Section Private
(read_identifier).if_false {
syntax_error (current_position,"Identifier is incorrect.");
};
- pos := current_position;
+ pos := current_position;
n := last_string;
(read_identifier).if {
na := last_string;
@@ -2763,19 +2763,19 @@ Section Private
syntax_error (current_position,"Incorrect type.");
};
data := LIP_SLOT_DATA.create current_position name na value t argument TRUE;
- };
- //
+ };
+ //
(read_symbol (ALIAS_STR.symbol_affect_code)).if_false {
warning_error (current_position,"Added '<-' is needed.");
- };
+ };
is_shorter2 := TRUE;
read_space;
is_shorter2 := FALSE;
exp := readlip_expr;
(exp = NULL).if {
syntax_error (current_position,"Expression needed.");
- };
- slot_code := LIP_SLOT_CODE.create pos section sec
+ };
+ slot_code := LIP_SLOT_CODE.create pos section sec
name n argument data code exp;
(sec = ALIAS_STR.section_public).if {
(last_comment_slot = NULL).if {
@@ -2783,61 +2783,61 @@ Section Private
} else {
slot_code.set_comment (ALIAS_STR.get last_comment_slot);
};
- };
+ };
};
result
);
-
+
- readlip_type:LIP_CONSTANT <-
//// TYPE -> 'BOOLEAN' | 'STRING' | 'INTEGER' | 'LIP'
( + result:LIP_CONSTANT;
-
- (read_cap_identifier).if {
+
+ (read_cap_identifier).if {
(last_string = ALIAS_STR.prototype_integer).if {
result := LIP_INTEGER.get 0;
- }.elseif {last_string = ALIAS_STR.prototype_string} then {
- result := LIP_STRING.get (ALIAS_STR.get "");
- }.elseif {last_string = ALIAS_STR.prototype_boolean} then {
+ }.elseif {last_string = ALIAS_STR.prototype_string} then {
+ result := LIP_STRING.get (ALIAS_STR.get "");
+ }.elseif {last_string = ALIAS_STR.prototype_boolean} then {
result := LIP_BOOLEAN.get FALSE;
}.elseif {last_string = ALIAS_STR.prototype_lip} then {
not_yet_implemented;
} else {
syntax_error (current_position,"Incorrect type.");
- };
+ };
};
result
);
-
- - readlip_expr_affect:LIP_CODE <-
+
+ - readlip_expr_affect:LIP_CODE <-
//// EXPR_AFFECT -> [ identifier !!AMBIGU!! ':=' ] EXPR
( + result,val:LIP_CODE;
+ nam:STRING_CONSTANT;
-
+
save_context; // !! SAVE CONTEXT !!
-
+
(read_identifier).if {
nam := last_string;
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if {
val := readlip_expr;
(val = NULL).if {
syntax_error (current_position,"Incorrect expression.");
- };
+ };
result := LIP_AFFECT.create current_position name nam value val;
} else {
restore_context; // !! RESTORE CONTEXT !!
};
- };
+ };
(result = NULL).if {
- result := readlip_expr;
+ result := readlip_expr;
};
result
);
-
- - readlip_expr:LIP_CODE <-
- //// EXPR -> EXPR_CMP { ('|' | '&') EXPR_CMP }
+
+ - readlip_expr:LIP_CODE <-
+ //// EXPR -> EXPR_CMP { ('|' | '&') EXPR_CMP }
( + result,right:LIP_CODE;
- + is_or:BOOLEAN;
-
+ + is_or:BOOLEAN;
+
result := readlip_expr_cmp;
(result != NULL).if {
{(is_or := read_character '|') || {read_character '&'}}.while_do {
@@ -2854,21 +2854,21 @@ Section Private
};
result
);
-
+
- readlip_expr_cmp:LIP_CODE <-
//// EXPR_CMP -> EXPR_BINARY { ('='|'!='|'>'|'<'|'>='|'<=') EXPR_BINARY }
( + result,right:LIP_CODE;
- + op:STRING_CONSTANT;
+ + op:STRING_CONSTANT;
+ type:CHARACTER;
-
+
result := readlip_expr_binary;
(result != NULL).if {
{
- (read_symbol (ALIAS_STR.symbol_great_equal)) ||
+ (read_symbol (ALIAS_STR.symbol_great_equal)) ||
{read_symbol (ALIAS_STR.symbol_less_equal)} ||
- {read_symbol (ALIAS_STR.symbol_not_equal)} ||
+ {read_symbol (ALIAS_STR.symbol_not_equal)} ||
{read_symbol (ALIAS_STR.symbol_equal)} ||
- {read_symbol (ALIAS_STR.symbol_great)} ||
+ {read_symbol (ALIAS_STR.symbol_great)} ||
{read_symbol (ALIAS_STR.symbol_less)}
}.while_do {
op := last_string;
@@ -2888,12 +2888,12 @@ Section Private
};
result
);
-
- - readlip_expr_binary:LIP_CODE <-
+
+ - readlip_expr_binary:LIP_CODE <-
//// EXPR_BINARY -> EXPR_UNARY { ('-'|'+') EXPR_UNARY }
( + result,right:LIP_CODE;
+ is_sub:BOOLEAN;
-
+
result := readlip_expr_unary;
(result != NULL).if {
{(is_sub := read_character '-') || {read_character '+'}}.while_do {
@@ -2910,15 +2910,15 @@ Section Private
};
result
);
-
- - readlip_expr_unary:LIP_CODE <-
+
+ - readlip_expr_unary:LIP_CODE <-
//// EXPR_UNARY -> ( '-' | '!' ) EXPR_UNARY
- //// | EXPR_BASE
+ //// | EXPR_BASE
( + result:LIP_CODE;
+ is_neg:BOOLEAN;
+ type:CHARACTER;
-
- ((is_neg := read_character '-') || {read_character '!'}).if {
+
+ ((is_neg := read_character '-') || {read_character '!'}).if {
result := readlip_expr_unary;
(result = NULL).if {
syntax_error (current_position,"Incorrect expression.");
@@ -2934,7 +2934,7 @@ Section Private
};
result
);
-
+
- readlip_expr_list cod:FAST_ARRAY(LIP_CODE) <-
//// EXPR_LIST -> { EXPR_AFFECT ';' } [ EXPR_AFFECT ]
( + instr:LIP_CODE;
@@ -2942,15 +2942,15 @@ Section Private
((instr := readlip_expr_affect) != NULL) &&
{read_character ';'}
}.while_do {
- cod.add_last instr;
+ cod.add_last instr;
};
cod.add_last instr;
);
-
- - readlip_expr_base:LIP_CODE <-
- //// EXPR_BASE -> EXPR_RECEIVER { '.' EXPR_MESSAGE }
+
+ - readlip_expr_base:LIP_CODE <-
+ //// EXPR_BASE -> EXPR_RECEIVER { '.' EXPR_MESSAGE }
( + result:LIP_CODE;
-
+
result := readlip_expr_receiver;
{read_character '.'}.while_do {
result := readlip_expr_message result;
@@ -2960,9 +2960,9 @@ Section Private
};
result
);
-
+
- readlip_expr_receiver:LIP_CODE <-
- //// EXPR_RECEIVER-> EXPR_PRIMARY
+ //// EXPR_RECEIVER-> EXPR_PRIMARY
//// | EXPR_MESSAGE
( + result:LIP_CODE;
result := readlip_expr_primary;
@@ -2971,20 +2971,20 @@ Section Private
};
result
);
-
+
- readlip_expr_message rec:LIP_CODE :LIP_CODE <-
- //// EXPR_MESSAGE -> identifier [ EXPR_ARGUMENT ]
- //// | 'if' '{' EXPR_LIST '}' [ 'else' '{' EXPR_LIST '}' ]
+ //// EXPR_MESSAGE -> identifier [ EXPR_ARGUMENT ]
+ //// | 'if' '{' EXPR_LIST '}' [ 'else' '{' EXPR_LIST '}' ]
( + result,arg:LIP_CODE;
+ nam:STRING_CONSTANT;
+ the,els:FAST_ARRAY(LIP_CODE);
-
+
(read_word (ALIAS_STR.slot_if)).if {
- the := ALIAS_ARRAY(LIP_CODE).new;
+ the := ALIAS_ARRAY(LIP_CODE).new;
(read_character '{').if_false {
warning_error (current_position,"Added '(' is needed.");
};
- readlip_expr_list the;
+ readlip_expr_list the;
(read_character '}').if_false {
warning_error (current_position,"Added '(' is needed.");
};
@@ -2994,66 +2994,66 @@ Section Private
(read_character '{').if_false {
warning_error (current_position,"Added '(' is needed.");
};
- readlip_expr_list els;
+ readlip_expr_list els;
(read_character '}').if_false {
warning_error (current_position,"Added '(' is needed.");
};
els := ALIAS_ARRAY(LIP_CODE).copy els;
};
- result := LIP_IF.create current_position if rec then the else els;
+ result := LIP_IF.create current_position if rec then the else els;
}.elseif {read_identifier} then {
nam := last_string;
arg := readlip_expr_argument;
- result := LIP_CALL.create current_position
+ result := LIP_CALL.create current_position
receiver rec name nam with arg;
};
result
);
-
+
- readlip_expr_argument:LIP_CODE <-
- //// EXPR_ARGUMENT-> identifier
+ //// EXPR_ARGUMENT-> identifier
//// | EXPR_PRIMARY
( + result:LIP_CODE;
-
+
(read_identifier).if {
- result := LIP_CALL.create current_position
+ result := LIP_CALL.create current_position
receiver NULL name last_string with NULL;
} else {
result := readlip_expr_primary;
};
result
);
-
+
- readlip_expr_primary:LIP_CODE <-
//// EXPR_PRIMARY -> EXPR_CONSTANT
//// | '(' EXPR_LIST ')'
( + result:LIP_CODE;
+ val:LIP_CONSTANT;
+ lst:FAST_ARRAY(LIP_CODE);
-
- val := readlip_expr_constant;
+
+ val := readlip_expr_constant;
(val != NULL).if {
result := LIP_VALUE.create current_position with val;
}.elseif {read_character '('} then {
- lst := ALIAS_ARRAY(LIP_CODE).new;
- readlip_expr_list lst;
+ lst := ALIAS_ARRAY(LIP_CODE).new;
+ readlip_expr_list lst;
(read_character ')').if_false {
warning_error (current_position,"Added ')'.");
};
lst := ALIAS_ARRAY(LIP_CODE).copy lst;
result := LIP_LIST.create current_position with lst;
};
- result
+ result
);
-
+
- readlip_expr_constant:LIP_CONSTANT <-
- //// EXPR_CONSTANT-> integer
+ //// EXPR_CONSTANT-> integer
//// | string
//// | TRUE
//// | FALSE
( + result:LIP_CONSTANT;
- (read_integer).if {
+ (read_integer).if {
result := LIP_INTEGER.get last_integer;
}.elseif {read_string} then {
result := LIP_STRING.get last_string;
@@ -3065,21 +3065,21 @@ Section Private
} else {
syntax_error (current_position,"Type incorrect.");
};
- };
+ };
result
);
-
+
//
// Parser for FORMAT.LI
- //
+ //
//|| FORMAT -> { '-' identifier ':=' SHORT_DEF ';' }
- read_format <-
( + def:LINKED_LIST(STRING_CONSTANT);
-
+
{read_character '-'}.while_do {
(read_identifier).if_false {
- syntax_error (current_position,"Incorrect slot identifier.");
+ syntax_error (current_position,"Incorrect slot identifier.");
};
def := LINKED_LIST(STRING_CONSTANT).create;
(short_dico.fast_has last_string).if {
@@ -3088,15 +3088,15 @@ Section Private
short_dico.fast_put def to last_string;
(read_symbol (ALIAS_STR.symbol_affect_immediate)).if_false {
syntax_error (current_position,"Assignment ':=' is needed.");
- };
+ };
(read_short_def def).if_false {
syntax_error (current_position,"Incorrect definition.");
};
(read_character ';').if_false {
warning_error (current_position,"Added ';' is needed.");
- };
+ };
};
-
+
// End of file :
read_space;
(last_character != 0.to_character).if {
@@ -3107,10 +3107,10 @@ Section Private
//|| SHORT_DEF -> { SHORT_ELT '+' } SHORT_ELT
- read_short_def def:LINKED_LIST(STRING_CONSTANT) :BOOLEAN <-
( + result:BOOLEAN;
-
+
read_short_elt.if {
result := TRUE;
- def.add_last last_string;
+ def.add_last last_string;
{read_character '+'}.while_do {
(read_short_elt).if_false {
syntax_error (current_position,"Incorrect format expression.");
@@ -3125,7 +3125,7 @@ Section Private
- read_short_elt:BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
-
+
read_identifier.if {
(last_string != ALIAS_STR.short_token).if {
warning_error (current_position,"Variable not `token'.");
@@ -3137,7 +3137,7 @@ Section Private
j := last_string.lower;
{j <= last_string.upper}.while_do {
(last_string.item j = '\\').if {
- j := j+1;
+ j := j+1;
last_string.item j
.when 'a' then { string_tmp.add_last '\a'; }
.when 'b' then { string_tmp.add_last '\b'; }
@@ -3160,17 +3160,17 @@ Section Private
};
result
);
-
-Section Public
-
+
+Section Public
+
//
// Parser Entry.
//
-
+
- go_on obj:PROTOTYPE <-
(
? { object=NULL};
-
+
// Source information.
object := obj;
source := obj.source;
@@ -3178,52 +3178,52 @@ Section Public
pos_cur := source.lower;
pos_line := 1;
pos_col := 0;
-
+
(is_shorter).if {
- is_active_short := TRUE;
+ is_active_short := TRUE;
short_derive := 0;
output_code.copy source;
short_local := HASHED_SET(STRING_CONSTANT).create;
short (ALIAS_STR.short_begin) token 1 to 1;
};
-
+
// Parse.
(! read_program).if {
syntax_error (current_position,"Incorrect symbol.");
};
-
+
short (ALIAS_STR.short_end) token (source.upper) to (source.upper);
-
+
object := NULL; // Parser is Free (see require test...)
);
-
+
- read_lip path_lip:STRING_CONSTANT :BOOLEAN <-
- ( + entry:POINTER;
-
+ ( + entry:POINTER;
+
entry := FS_MIN.open_read path_lip;
(entry != NULL).if {
FS_MIN.close entry;
object := PROTOTYPE.create path_lip
name path_lip generic_count 0;
-
+
source := object.source;
position := source.lower;
pos_cur := source.lower;
pos_line:=1;
pos_col :=0;
is_shorter := is_shorter2 := FALSE;
-
+
// Parse.
readlip_program;
//
is_shorter := Old is_shorter;
is_shorter2 := Old is_shorter2;
object := NULL; // Parser is Free (see require test...)
- }
+ }
);
- parse_format fmt_name:STRING_CONSTANT <-
- (
+ (
// Source information.
(FILE_SYSTEM.get_entry fmt_name = NULL).if {
STD_ERROR.put_string "Error: File format `";
@@ -3231,20 +3231,20 @@ Section Public
STD_ERROR.put_string "' is not open !\n";
die_with_code exit_failure_code;
};
-
- object := PROTOTYPE.create fmt_name
- name (ALIAS_STR.short_format)
- generic_count 0;
-
+
+ object := PROTOTYPE.create fmt_name
+ name (ALIAS_STR.short_format)
+ generic_count 0;
+
source := object.source;
position := source.lower;
pos_cur := source.lower;
pos_line := 1;
pos_col := 0;
-
+
// Parse.
read_format;
-
+
object := NULL; // Parser is Free (see require test...)
);
diff --git a/src/profil.li b/src/profil.li
index ed344cd..3b4f12d 100644
--- a/src/profil.li
+++ b/src/profil.li
@@ -227,10 +227,10 @@ Section Public
(argument_list.lower).to (argument_list.upper) do { j:INTEGER;
loc := argument_list.item j;
val := args.item j;
- (loc != NULL).if {
+ (loc != NULL).if {
wrt := loc.write (val.position) value val;
result.add_last wrt;
- } else {
+ } else {
result.add_last NULL;
val.remove;
};
@@ -324,20 +324,20 @@ Section Public
{result_list.is_empty}
).if {
switch ?= code.last;
- (switch != NULL).if {
+ (switch != NULL).if {
// Verification cases:
(switch.list.lower).to (switch.list.upper) do { j:INTEGER;
lst := switch.list.item j.code;
(lst.is_empty).if_false {
msg ?= lst.last;
- ((msg != NULL) && {msg.profil = Self}).if {
+ ((msg != NULL) && {msg.profil = Self}).if {
count_recur := count_recur + 1;
};
};
};
(count_recur = switch.list.count).if {
semantic_error (slot.position,"Recursivity without end.");
- };
+ };
((count_intern_call - 1) = count_recur).if {
((link_count = count_intern_call) || {! is_context_sensitive}).if {
new_execute_pass;
@@ -360,21 +360,21 @@ Section Public
(stat = -1).if {
count_intern_call := count_intern_call + 1;
- (count_intern_call = 1).if {
+ (count_intern_call = 1).if {
old_list_current := list_current;
old_profil_current := profil_current;
//
profil_current := Self;
execute 3;
- //
+ //
list_current := old_list_current;
profil_current := old_profil_current;
? {code != NULL};
- (count_intern_call = 1).if {
+ (count_intern_call = 1).if {
stat := 0;
} else {
stat := recursivity_bit;
- };
+ };
};
};
);
@@ -474,7 +474,7 @@ Section Public
v := argument_list.item j;
(v != NULL).if {
? {(v.style = ' ') || {v.style = '!'}};
- genere v result FALSE in buffer;
+ genere v result FALSE in buffer;
buffer.add_last ',';
};
};
@@ -552,7 +552,7 @@ Section Public
{! t.is_expanded_c}
).if {
buffer.add_last '&';
- };
+ };
(loc.my_alias = NULL).if {
idf := loc.intern_name;
} else {
@@ -578,7 +578,7 @@ Section Public
buffer.append indent;
v := argument_list.first;
((v != NULL) && {v.name = ALIAS_STR.variable_self}).if {
- genere v result FALSE in buffer;
+ genere v result FALSE in buffer;
buffer.add_last '=';
put_cast_self buffer;
buffer.append "obj;\n";
@@ -590,12 +590,12 @@ Section Public
v := argument_list.item j;
(v != NULL).if {
buffer.append indent;
- genere v result FALSE in buffer;
+ genere v result FALSE in buffer;
buffer.append "=(";
ts := v.type;
ts.genere_declaration buffer;
buffer.add_last ' ';
- ts.genere_star_declaration buffer;
+ ts.genere_star_declaration buffer;
buffer.append ")((";
put_cast_self buffer;
buffer.append "obj)->param_";
@@ -649,7 +649,7 @@ Section Private
- put_cast_self buffer:STRING <-
(
buffer.add_last '(';
- type_self.genere_declaration buffer;
+ type_self.genere_declaration buffer;
buffer.add_last ' ';
type_self.genere_star_declaration buffer;
buffer.add_last ')';
@@ -676,7 +676,7 @@ Section Private
};
buffer.append " */\n";
);
-
+
/*
- recur_cpa buf:STRING arg n:INTEGER <-
( + var:LOCAL;
@@ -702,7 +702,7 @@ Section Private
};
);
*/
-
+
- append_type buffer:STRING <-
( + v:VARIABLE;
+ nb_arg,nb_arg_poly,tmp:INTEGER;
@@ -775,7 +775,7 @@ Section Private
ts.genere_declaration buffer;
buffer.add_last ' ';
- ts.genere_star_declaration buffer;
+ ts.genere_star_declaration buffer;
(is_res).if {
buffer.add_last '*';
};
@@ -811,13 +811,13 @@ Section Private
switch ?= code.last;
(switch.list.lower).to (switch.list.upper) do { k:INTEGER;
body := switch.list.item k.code;
- (body.is_empty).if_false {
+ (body.is_empty).if_false {
msg_slot ?= body.last;
- ((msg_slot != NULL) && {msg_slot.profil = Self}).if {
+ ((msg_slot != NULL) && {msg_slot.profil = Self}).if {
link_count := link_count - 1;
msg_slot.argument_to_assignment body index (body.upper) alias FALSE style '!';
body.put (LOOP_END.create (msg_slot.position) loop loop) to (body.upper);
- };
+ };
};
};
count_intern_call := 1;
diff --git a/src/profil_block.li b/src/profil_block.li
index 9d8c354..bf3246a 100644
--- a/src/profil_block.li
+++ b/src/profil_block.li
@@ -254,7 +254,7 @@ Section Public
lst.add_last (loc.type.get_temporary_expr (loc.position));
};
result := EXPR_MULTIPLE.create lst;
- }.elseif {result_list.count = 1} then {
+ }.elseif {result_list.count = 1} then {
loc := result_list.first;
result := loc.type.get_temporary_expr (loc.position);
} else {
diff --git a/src/profil_list.li b/src/profil_list.li
index ce68f19..6d76ab9 100644
--- a/src/profil_list.li
+++ b/src/profil_list.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PROFIL_LIST;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Profil list manager.";
-
+
Section Inherit
-
- + parent_any:Expanded ANY;
-
+
+ + parent_any:Expanded ANY;
+
Section LISAAC
-
- - profil_list:FAST_ARRAY(PROFIL) := FAST_ARRAY(PROFIL).create_with_capacity 65536;
-
+
+ - profil_list:FAST_ARRAY(PROFIL) := FAST_ARRAY(PROFIL).create_with_capacity 65536;
+
- life_limit:INTEGER;
-
+
- life_limit_base:INTEGER;
-
+
- current:INTEGER;
-
+
- swap i1:INTEGER with i2:INTEGER <-
(
profil_list.item i2.set_life_index i1;
profil_list.item i1.set_life_index i2;
- profil_list.swap i1 with i2;
+ profil_list.swap i1 with i2;
);
- clean <-
(
reduce_profil := profil_list.upper >= life_limit;
- {profil_list.upper >= life_limit}.while_do {
- profil_list.last.remove;
+ {profil_list.upper >= life_limit}.while_do {
+ profil_list.last.remove;
profil_list.remove_last;
};
);
-
+
Section Public
-
+
- reduce_profil:BOOLEAN := TRUE;
-
+
- add p:PROFIL <-
- (
+ (
(p.is_external).if {
profil_list.add_first p;
life_limit_base := life_limit_base + 1;
@@ -72,13 +72,13 @@ Section Public
profil_list.item i.set_life_index i;
};
} else {
- profil_list.add_last p;
+ profil_list.add_last p;
p.set_life_index (profil_list.upper);
};
);
-
+
- set_life p:PROFIL <-
- [
+ [
(p.life_index = -1).if {
p.name.print;
semantic_error (p.slot.position,"LA");
@@ -87,57 +87,57 @@ Section Public
-? { profil_list.item (p.life_index) = p };
]
( + idx:INTEGER;
-
+
idx := p.life_index;
(idx = life_limit).if {
life_limit := life_limit + 1;
- }.elseif {idx > life_limit} then {
- swap idx with life_limit;
+ }.elseif {idx > life_limit} then {
+ swap idx with life_limit;
life_limit := life_limit + 1;
};
)
- [
+ [
+? { profil_list.item (p.life_index) = p };
+? { p.life_index < life_limit };
];
-
+
- unset_life p:PROFIL <-
[
-? { p.life_index != -1 };
]
( + idx:INTEGER;
-
+
idx := p.life_index;
(idx < life_limit).if {
- life_limit := life_limit - 1;
+ life_limit := life_limit - 1;
(idx < life_limit).if {
(idx > current).if {
- swap idx with life_limit;
- } else {
+ swap idx with life_limit;
+ } else {
swap idx with current;
- swap current with life_limit;
+ swap current with life_limit;
current := current - 1;
};
};
- };
+ };
);
-
+
- remove p:PROFIL <-
[
-? { p.life_index != -1 };
]
( + idx:INTEGER;
-
+
unset_life p;
idx := p.life_index;
(idx != profil_list.upper).if {
swap idx with (profil_list.upper);
};
profil_list.remove_last;
- // Debug.
+ // Debug.
! {p.set_life_index (-1)};
);
-
+
- execute_pass_recursive <-
(
(profil_list.lower).to (profil_list.upper) do { i:INTEGER;
@@ -147,30 +147,30 @@ Section Public
life_limit := life_limit_base;
PROFIL.set_mode_recursive TRUE;
profil_current := profil_slot := NULL;
- list_current := NULL;
- list_main.execute;
+ list_current := NULL;
+ list_main.execute;
PROFIL.set_mode_recursive FALSE;
clean;
reduce_profil := TRUE;
);
-
+
- inline_level_current:INTEGER := 3;
-
+
- execute_pass <-
- (
+ (
VARIABLE.update;
life_limit := life_limit_base;
profil_slot := NULL;
- list_current := NULL;
- list_main.execute;
+ list_current := NULL;
+ list_main.execute;
current := profil_list.lower;
- {current < life_limit}.while_do {
+ {current < life_limit}.while_do {
profil_current := profil_list.item current;
profil_current.execute inline_level_current;
current := current + 1;
- };
+ };
current := 0;
- clean;
+ clean;
((! reduce_profil) && {inline_level_current < inline_level}).if {
inline_level_current := inline_level_current + 3;
new_execute_pass;
@@ -180,35 +180,34 @@ Section Public
TYPE_GENERIC.detect_alias;
};
);
-
+
//
// Genere.
//
-
+
- genere_handler buffer:STRING <-
(
(profil_list.lower).to (profil_list.upper) do { j:INTEGER;
- profil_list.item j.genere_handler buffer;
+ profil_list.item j.genere_handler buffer;
};
);
-
+
- genere buffer:STRING <-
(
(profil_list.lower).to (profil_list.upper) do { j:INTEGER;
- profil_list.item j.genere buffer;
+ profil_list.item j.genere buffer;
};
);
//
// Display.
//
-
+
- display <-
- (
+ (
string_tmp.clear;
(profil_list.upper).downto (profil_list.lower) do { j:INTEGER;
profil_list.item j.display_all string_tmp;
};
string_tmp.print;
);
-
\ No newline at end of file
diff --git a/src/profil_slot.li b/src/profil_slot.li
index ec5e9a9..60dbcfc 100644
--- a/src/profil_slot.li
+++ b/src/profil_slot.li
@@ -19,35 +19,35 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PROFIL_SLOT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Method with costumization";
-
+
Section Inherit
-
- + parent_profil:Expanded PROFIL;
-
+
+ + parent_profil:Expanded PROFIL;
+
- parent_parameter_to_type:Expanded PARAMETER_TO_TYPE;
-
+
Section Public
-
+
- position:POSITION <- slot.position;
-
+
- slot:SLOT <- slot_code;
-
- - is_interrupt:BOOLEAN <- slot_code.id_section.is_interrupt;
- - is_external:BOOLEAN <- slot_code.id_section.is_external;
+
+ - is_interrupt:BOOLEAN <- slot_code.id_section.is_interrupt;
+ - is_external:BOOLEAN <- slot_code.id_section.is_external;
+ slot_code:SLOT_CODE;
-
- + is_context_sensitive:BOOLEAN;
+
+ + is_context_sensitive:BOOLEAN;
// BSBS: Le bloc passé en argument peux ne pas etre context sensitive
// Et puis, cet stat peu changer dans le temps...
-
+
- set_context_sensitive <-
(
is_context_sensitive := TRUE;
@@ -56,21 +56,21 @@ Section Public
//
// Creation.
//
-
+
- arg_type_tmp:FAST_ARRAY(EXPR);
- parameter_to_type p:ITM_TYPE_PARAMETER :TYPE_FULL <-
( + idx:INTEGER;
+ result:TYPE_FULL;
-
+
(p.name = ALIAS_STR.prototype_self).if {
// For Self.
- result := type_self;
- } else {
- // For Genericity.
+ result := type_self;
+ } else {
+ // For Genericity.
//result := type_self.raw.parameter_to_type p;
result := slot_code.receiver_type.parameter_to_type p;
- (result = NULL).if {
- // For Type parametric.
+ (result = NULL).if {
+ // For Type parametric.
idx := slot_code.get_index_argument_type p;
(idx != - 1).if {
result := arg_type_tmp.item idx.static_type + TYPE_FULL.generic_bit;
@@ -79,56 +79,56 @@ Section Public
};
result
);
-
- - make s:SLOT_CODE
- with (typ_self:TYPE_FULL,call_lst:FAST_ARRAY(EXPR))
+
+ - make s:SLOT_CODE
+ with (typ_self:TYPE_FULL,call_lst:FAST_ARRAY(EXPR))
verify is_first:BOOLEAN :FAST_ARRAY(WRITE) <-
- [
+ [
-? {typ_self != NULL};
]
( + loc:LOCAL;
+ typ:TYPE_FULL;
- + item_lst:FAST_ARRAY(ITM_ARGUMENT);
+ + item_lst:FAST_ARRAY(ITM_ARGUMENT);
+ result:FAST_ARRAY(WRITE);
+ tm:ITM_TYPE_MULTI;
- + ts:ITM_TYPE_MONO;
-
+ + ts:ITM_TYPE_MONO;
+
(is_graph).if {
set_call := HASHED_DICTIONARY(INTEGER,PROFIL).create;
set_back := HASHED_SET(PROFIL).create;
- };
+ };
(s.id_section.is_external).if {
name := s.name;
} else {
- name := ALIAS_STR.get_intern (s.name);
+ name := ALIAS_STR.get_intern (s.name);
};
-
+
slot_code := s;
type_self := typ_self;
PROFIL_LIST.add Self;
//
list_current := LIST.create (s.position);
- profil_current := profil_slot := Self;
+ profil_current := profil_slot := Self;
//
(debug_level_option != 0).if {
// Debug mode : Add context local.
- context := TYPE_CONTEXT.default.new_local (s.position)
+ context := TYPE_CONTEXT.default.new_local (s.position)
name (ALIAS_STR.variable_context) style '+';
- context.set_ensure_count 1;
+ context.set_ensure_count 1;
list_current.add_last (PUSH.create (slot_code.position) context context first TRUE);
};
//
- code := list_current;
+ code := list_current;
//
- // Arguments.
+ // Arguments.
arg_type_tmp := call_lst;
- item_lst := s.argument_list;
- argument_list := FAST_ARRAY(LOCAL).create_with_capacity (s.argument_count);
+ item_lst := s.argument_list;
+ argument_list := FAST_ARRAY(LOCAL).create_with_capacity (s.argument_count);
(item_lst.lower).to (item_lst.upper) do { j:INTEGER;
item_lst.item j.to_run_in argument_list for Self;
};
((s.id_section.is_external) && {argument_list.count > 1}).if {
- (argument_list.lower+1).to (argument_list.upper) do { j:INTEGER;
+ (argument_list.lower+1).to (argument_list.upper) do { j:INTEGER;
loc := argument_list.item j;
loc.set_ensure_count 1;
loc.write (loc.position) value (
@@ -136,55 +136,55 @@ Section Public
access NULL persistant FALSE type (loc.type)
);
};
- };
-
+ };
+
// Results
- tm ?= s.result_type;
- (tm != NULL).if {
- result_list.make_with_capacity (tm.count);
- (tm.lower).to (tm.upper) do { k:INTEGER;
- typ := tm.item k.to_run_for Self;
+ tm ?= s.result_type;
+ (tm != NULL).if {
+ result_list.make_with_capacity (tm.count);
+ (tm.lower).to (tm.upper) do { k:INTEGER;
+ typ := tm.item k.to_run_for Self;
loc := typ.get (s.position) result (k+1);
- result_list.add_last loc;
- };
- } else {
- ts ?= s.result_type;
+ result_list.add_last loc;
+ };
+ } else {
+ ts ?= s.result_type;
(ts != ITM_TYPE_SIMPLE.type_void).if {
- typ := ts.to_run_for Self;
+ typ := ts.to_run_for Self;
result_list.add_last (typ.get (s.position) result 0);
(is_external).if {
result_list.last.set_ensure_count 1;
};
};
- };
+ };
//
(call_lst != NULL).if {
result := write_argument call_lst;
};
- //
- slot_code.create_code is_first;
+ //
+ slot_code.create_code is_first;
//
result
);
-
+
//
// Execute.
//
-
+
- remove_inline <-
(
parent_profil.remove_inline;
- slot_code.remove_profil Self;
+ slot_code.remove_profil Self;
);
-
+
- remove <-
- (
- parent_profil.remove;
- slot_code.remove_profil Self;
+ (
+ parent_profil.remove;
+ slot_code.remove_profil Self;
);
-
+
//
// Genere.
//
-
+
- is_static:BOOLEAN <- (! slot.id_section.is_interrupt) && {! slot.id_section.is_external};
diff --git a/src/shorter.li b/src/shorter.li
index 80ed3b7..6f6eced 100644
--- a/src/shorter.li
+++ b/src/shorter.li
@@ -19,44 +19,44 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SHORTER;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- bibliography:= "http://IsaacOS.com";
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Shorter source code.";
-
+
- external := `#include "path.h"`;
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Private
-
+
- is_lip:BOOLEAN;
-
+
- output_name : STRING_CONSTANT;
-
+
- input_name : STRING_CONSTANT;
-
+
- format_name : STRING_CONSTANT;
-
+
- proto_input:PROTOTYPE;
-
+
//
// Buffer.
//
-
+
- directory_list:STRING;
-
+
- file_list:STRING;
-
+
- current_list:STRING;
-
+
//
// Command.
//
@@ -83,7 +83,7 @@ Section Private
\ \n\
\Examples: \n\
\ * Output format file: \n\
- \ shorter -c -p -f latex hello_world.li \n\
+ \ shorter -c -p -f latex hello_world.li \n\
\ \n\
\ * Build html documentation: \n\
\ shorter -r -f html ~/lisaac/lib \n\
@@ -92,7 +92,7 @@ Section Private
\ - With directory: \n\
\ shorter -d -f belinda ~/lisaac/lib \n\
\ - With current `make.lip' \n\
- \ shorter -d -f belinda \n\
+ \ shorter -d -f belinda \n\
\ - With specific `make.lip' \n\
\ shorter -d -f belinda ../make.lip \n\
\ \n\
@@ -104,17 +104,17 @@ Section Private
usage.print;
die_with_code exit_failure_code;
);
-
+
//
// Options.
//
-
+
- read_options <-
( + cmd:STRING;
+ j:INTEGER;
+ var_lisaac:STRING_CONSTANT;
+ path:NATIVE_ARRAY(CHARACTER);
-
+
// Read argument.
is_shorter := TRUE;
j := 1;
@@ -129,13 +129,13 @@ Section Private
j := j+1;
(j > COMMAND_LINE.count).if {
display_usage;
- };
+ };
output_name := ALIAS_STR.get (COMMAND_LINE.item j);
}.elseif {cmd.item 2 = 'f'} then {
j := j+1;
(j > COMMAND_LINE.count).if {
display_usage;
- };
+ };
format_name := ALIAS_STR.get (COMMAND_LINE.item j);
}.elseif {cmd.item 2 = 'c'} then {
is_short_code := TRUE;
@@ -144,7 +144,7 @@ Section Private
}.elseif {cmd.item 2 = 'r'} then {
is_short_recursive := TRUE;
}.elseif {cmd.item 2 = 'd'} then {
- is_shorter := FALSE;
+ is_shorter := FALSE;
is_shorter2 := TRUE;
is_short_recursive := TRUE;
} else {
@@ -158,14 +158,14 @@ Section Private
display_usage;
};
string_tmp.copy (COMMAND_LINE.item j);
- input_name := ALIAS_STR.get string_tmp;
+ input_name := ALIAS_STR.get string_tmp;
};
j := j+1;
};
-
+
(input_name = NULL).if {
- (is_shorter2).if {
- load_lip "make.lip";
+ (is_shorter2).if {
+ load_lip "make.lip";
is_lip := TRUE;
} else {
display_usage;
@@ -174,7 +174,7 @@ Section Private
load_lip input_name;
is_lip := TRUE;
};
-
+
(format_name != NULL).if {
path := `LISAAC_DIRECTORY`:NATIVE_ARRAY(CHARACTER);
var_lisaac := STRING_CONSTANT.new_intern path
@@ -200,26 +200,26 @@ Section Private
PARSER.parse_format (ALIAS_STR.get string_tmp);
};
);
-
+
- extract_proto_name st:ABSTRACT_STRING :STRING_CONSTANT <-
( + i:INTEGER;
-
+
string_tmp.copy st;
string_tmp.replace_all '\\' with '/';
i := last_index_str (string_tmp,'/');
- (i >= string_tmp.lower).if {
+ (i >= string_tmp.lower).if {
string_tmp.remove_first i;
};
i := last_index_str (string_tmp,'.');
- ? {i > string_tmp.lower};
- string_tmp.remove_last (string_tmp.upper-i+1);
+ ? {i > string_tmp.lower};
+ string_tmp.remove_last (string_tmp.upper-i+1);
string_tmp.to_upper;
ALIAS_STR.get string_tmp
);
-
+
- add_ext n:STRING_CONSTANT :STRING_CONSTANT <-
( + txt:STRING_CONSTANT;
- string_tmp.copy n;
+ string_tmp.copy n;
(PARSER.short_dico.fast_has (ALIAS_STR.short_type_file)).if {
txt := PARSER.short_dico.fast_at (ALIAS_STR.short_type_file).first;
string_tmp.append txt;
@@ -228,11 +228,11 @@ Section Private
};
ALIAS_STR.get string_tmp
);
-
+
- save_file n:STRING_CONSTANT with buf:STRING <-
( + file:FILE;
+ entry:ENTRY;
-
+
(is_short_recursive).if {
(output_name != NULL).if {
string_tmp.copy output_name;
@@ -266,13 +266,13 @@ Section Private
- build_with_path_file <-
( + tok:STRING_CONSTANT;
- + tok_lst:LINKED_LIST(STRING_CONSTANT);
+ + tok_lst:LINKED_LIST(STRING_CONSTANT);
+ idx:INTEGER;
-
- (path_file.lower).to (path_file.upper) do { i:INTEGER;
+
+ (path_file.lower).to (path_file.upper) do { i:INTEGER;
string_tmp.copy (path_file.item i);
idx := last_index_str (string_tmp,'/');
- (idx >= string_tmp.lower).if {
+ (idx >= string_tmp.lower).if {
string_tmp.remove_first idx;
};
string_tmp.remove_last 3;
@@ -290,11 +290,11 @@ Section Private
};
};
} else {
- current_list.append tok;
+ current_list.append tok;
current_list.add_last '\n';
file_list.append tok;
file_list.add_last '\n';
- };
+ };
// Creation prototype file.
(PROTOTYPE.prototype_dico.fast_has tok).if {
"Error: Double definition prototype:\n".print;
@@ -306,15 +306,15 @@ Section Private
//
PARSER.go_on proto_input;
(is_shorter).if {
- save_file (add_ext tok) with output_code;
+ save_file (add_ext tok) with output_code;
};
(
- (i = path_file.upper) ||
- {path_file.item (i+1).first_difference_index (path_file.item i) < idx} ||
+ (i = path_file.upper) ||
+ {path_file.item (i+1).first_difference_index (path_file.item i) < idx} ||
{last_index_str (path_file.item (i+1),'/') != idx}
).if {
// Detect new directory.
- current_list.is_empty.if_false {
+ current_list.is_empty.if_false {
(PARSER.short_dico.fast_has (ALIAS_STR.short_file_list_begin)).if {
tok := PARSER.short_dico.fast_at (ALIAS_STR.short_file_list_begin).first;
current_list.prepend tok;
@@ -327,9 +327,9 @@ Section Private
string_tmp.remove_last (string_tmp.upper-idx+1);
string_tmp.remove_first path_begin;
string_tmp.is_empty.if_false {
- string_tmp.replace_all '/' with '-';
- tok := ALIAS_STR.get string_tmp;
-
+ string_tmp.replace_all '/' with '-';
+ tok := ALIAS_STR.get string_tmp;
+
(PARSER.short_dico.fast_has (ALIAS_STR.short_directory_list_item)).if {
tok_lst := PARSER.short_dico.fast_at (ALIAS_STR.short_directory_list_item);
(tok_lst.lower).to (tok_lst.upper) do { j:INTEGER;
@@ -340,27 +340,27 @@ Section Private
};
};
} else {
- directory_list.append tok;
+ directory_list.append tok;
directory_list.add_last '\n';
};
-
+
save_file (add_ext tok) with current_list;
current_list.clear;
};
};
};
- };
+ };
);
-
+
- check_in entry:ENTRY begin n:INTEGER <-
- ( + name:STRING_CONSTANT;
- + dir:DIRECTORY;
+ ( + name:STRING_CONSTANT;
+ + dir:DIRECTORY;
(! entry.open).if {
"Warning: directory `".print;
entry.path.print;
"\' not open.\n".print;
- } else {
+ } else {
dir ?= entry;
// Directory
(dir.lower).to (dir.upper) do { i:INTEGER;
@@ -373,46 +373,46 @@ Section Private
(! dir.item i.is_directory).if {
name := dir.item i.name;
(name.has_suffix ".li").if {
- path_file.add_last (dir.item i.path);
+ path_file.add_last (dir.item i.path);
};
}; // Lisaac file `.li'
- };
+ };
};
);
-
-Section Public
-
+
+Section Public
+
//
// Creation.
//
- main <-
- ( + txt:STRING_CONSTANT;
+ ( + txt:STRING_CONSTANT;
+ p:PROTOTYPE;
-
+
ALIAS_STR.make;
-
+
//
read_options;
-
+
// SELF, NULL, VOID, CONTEXT
- TYPE_NULL.make_null;
+ TYPE_NULL.make_null;
TYPE_VOID.make_void;
TYPE_CONTEXT.make_context;
TYPE_ID.make_type_id; // Pas utile !
-
+
(is_short_recursive).if {
+ dir:DIRECTORY;
+ ent:ENTRY;
-
+
directory_list := STRING.create 100;
file_list := STRING.create 100;
current_list := STRING.create 100;
-
+
(is_lip).if {
LIP_CODE.call_front_end;
LIP_CODE.init_path_file TRUE;
- } else {
+ } else {
ent := FILE_SYSTEM.get_entry input_name;
((ent = NULL) || {! ent.is_directory}).if {
"Error: directory `".print;
@@ -451,7 +451,7 @@ Section Public
directory_list.append txt;
};
save_file (add_ext "directory_list") with directory_list;
-
+
// file_list file.
(PARSER.short_dico.fast_has (ALIAS_STR.short_file_list_begin)).if {
txt := PARSER.short_dico.fast_at (ALIAS_STR.short_file_list_begin).first;
@@ -461,24 +461,24 @@ Section Public
txt := PARSER.short_dico.fast_at (ALIAS_STR.short_file_list_end).first;
file_list.append txt;
};
- save_file (add_ext "file_list") with file_list;
+ save_file (add_ext "file_list") with file_list;
} else {
- // Input.
+ // Input.
(input_name.has_suffix ".li").if_false {
string_tmp.copy input_name;
string_tmp.append ".li";
input_name := ALIAS_STR.get string_tmp;
};
-
- proto_input := PROTOTYPE.create input_name
+
+ proto_input := PROTOTYPE.create input_name
name (extract_proto_name input_name)
generic_count 0;
PARSER.go_on proto_input;
-
+
(output_name = NULL).if {
output_name := add_ext (proto_input.name);
- };
- save_file output_name with output_code;
+ };
+ save_file output_name with output_code;
};
(is_shorter2).if {
(PROTOTYPE.prototype_list.lower).to (PROTOTYPE.prototype_list.upper) do { j:INTEGER;
@@ -487,7 +487,7 @@ Section Public
put "" to output_code like (ALIAS_STR.short_begin);
p.shorter_out output_code;
put "" to output_code like (ALIAS_STR.short_end);
- save_file (add_ext (p.name)) with output_code;
+ save_file (add_ext (p.name)) with output_code;
};
};
);
diff --git a/src/shorter_any/any_option.li b/src/shorter_any/any_option.li
index ed17ed4..7f450d9 100644
--- a/src/shorter_any/any_option.li
+++ b/src/shorter_any/any_option.li
@@ -19,36 +19,36 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ANY_OPTION;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
-
+
Section Inherit
-
+
- parent_object:OBJECT := OBJECT;
-
+
Section Public
-
+
- is_shorter2:BOOLEAN;
-
+
- is_shorter :BOOLEAN;
-
+
- is_short_code:BOOLEAN;
- is_short_private:BOOLEAN;
- is_short_recursive:BOOLEAN;
-
+
- put tok:ABSTRACT_STRING to buf:STRING like key:STRING_CONSTANT <-
( + lst:LINKED_LIST(STRING_CONSTANT);
-
+
(key != NULL).if {
lst := PARSER.short_dico.fast_reference_at key;
(lst != NULL).if {
(lst.lower).to (lst.upper) do { j:INTEGER;
- (lst.item j = NULL).if {
+ (lst.item j = NULL).if {
buf.append tok;
} else {
buf.append (lst.item j);
diff --git a/src/tools/alias_array.li b/src/tools/alias_array.li
index f387252..e164f12 100644
--- a/src/tools/alias_array.li
+++ b/src/tools/alias_array.li
@@ -19,51 +19,51 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ALIAS_ARRAY(E);
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Aliser collection.";
-
-Section Inherit
-
+
+Section Inherit
+
- parent_any:ANY := ANY;
-
+
Section Private
-
- - bucket:HASHED_SET(FAST_ARRAY(E)) :=
+
+ - bucket:HASHED_SET(FAST_ARRAY(E)) :=
HASHED_SET(FAST_ARRAY(E)).create;
-
- - free_list:FAST_ARRAY(FAST_ARRAY(E)) :=
+
+ - free_list:FAST_ARRAY(FAST_ARRAY(E)) :=
FAST_ARRAY(FAST_ARRAY(E)).create_with_capacity 5;
-
+
- empty_list:FAST_ARRAY(E) := FAST_ARRAY(E).create_with_capacity 0;
-
+
Section Public
-
+
//
// Temporary manager.
//
-
+
- new:FAST_ARRAY(E) <-
( + result:FAST_ARRAY(E);
-
+
(free_list.is_empty).if {
result := FAST_ARRAY(E).create_with_capacity 16;
} else {
result := free_list.last;
free_list.remove_last;
};
-
+
result
);
-
+
- alias tmp:FAST_ARRAY(E) :FAST_ARRAY(E) <-
( + result:FAST_ARRAY(E);
-
+
(tmp.is_empty).if {
result := empty_list;
} else {
@@ -74,21 +74,21 @@ Section Public
bucket.fast_add result;
};
};
- free tmp;
+ free tmp;
result
);
-
+
- copy tmp:FAST_ARRAY(E) :FAST_ARRAY(E) <-
( + result:FAST_ARRAY(E);
-
+
result := FAST_ARRAY(E).create_with_capacity (tmp.count);
- result.copy_collection tmp;
+ result.copy_collection tmp;
free tmp;
result
- );
-
+ );
+
- free tmp:FAST_ARRAY(E) <-
- (
+ (
tmp.clear;
free_list.add_last tmp;
);
diff --git a/src/tools/couple.li b/src/tools/couple.li
index a5a4db0..c4a1d4c 100644
--- a/src/tools/couple.li
+++ b/src/tools/couple.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COUPLE(E,F);
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Couple object";
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
+ first :E;
+ second:F;
-
+
- create elt1:E and elt2:F :SELF <-
( + result:SELF;
-
+
result := clone;
result.make elt1 and elt2;
result
);
-
+
- make elt1:E and elt2:F <-
(
first := elt1;
second := elt2;
- );
+ );
diff --git a/src/tools/coupled.li b/src/tools/coupled.li
index 5eefb49..095ad1c 100644
--- a/src/tools/coupled.li
+++ b/src/tools/coupled.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := COUPLED(E);
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Couple object";
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
+ first :E;
+ second:E;
-
+
- create elt1:E and elt2:E :SELF <-
( + result:SELF;
-
+
result := clone;
result.make elt1 and elt2;
result
);
-
+
- make elt1:E and elt2:E <-
(
first := elt1;
second := elt2;
- );
+ );
diff --git a/src/tools/position.li b/src/tools/position.li
index ff9bb07..42a2240 100644
--- a/src/tools/position.li
+++ b/src/tools/position.li
@@ -19,35 +19,35 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := Expanded POSITION;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Coding position : \
\ 9 bits : Index prototype [1..511]. \
\ 8 bits : Column [0..255]. \
\ 15 bits : Line [1..32767].";
-
+
- type := `unsigned long`;
- default := ( CONVERT(INTEGER,POSITION).on 0 );
-
-Section Insert
-
+
+Section Insert
+
- parent_any:ANY := ANY;
-
+
Section Public
-
+
- object_size:INTEGER <- POINTER.object_size;
-
+
- code:UINTEGER_32 <- CONVERT(POSITION,UINTEGER_32).on Self;
-
+
//
// Creation.
//
-
+
- create proto:PROTOTYPE line l:INTEGER column c:INTEGER :POSITION <-
( + cod:UINTEGER_32;
? {l .in_range 0 to 131071};
@@ -56,7 +56,7 @@ Section Public
cod := proto.index.to_uinteger_32 | (c << 9) | (l << 17);
CONVERT(UINTEGER_32,POSITION).on cod
);
-
+
//
// Localization.
//
@@ -64,13 +64,13 @@ Section Public
- prototype:PROTOTYPE <- PROTOTYPE.prototype_list.item (code.to_integer & 01FFh);
- line:UINTEGER_32 <- code >> 17;
-
+
- column:UINTEGER_32 <- (code >> 9) & 0FFh;
//
// Information Generation.
//
-
+
- nb_warning:INTEGER;
- send_error <-
@@ -79,7 +79,7 @@ Section Public
is_verbose.if {
msg_err.print;
};
- (type_error = warning).if {
+ (type_error = warning).if {
nb_warning := nb_warning + 1;
} else {
die_with_code exit_failure_code;
@@ -102,20 +102,20 @@ Section Public
};
msg_err.append txt;
);
-
+
- put_position <-
( + pos:INTEGER;
+ c,cols:UINTEGER_32;
+ src:STRING;
+ char:CHARACTER;
? {code != 0};
-
+
msg_err.append "\nLine ";
- line.append_in msg_err;
+ line.append_in msg_err;
msg_err.append " column ";
column.append_in msg_err;
msg_err.append " in ";
- msg_err.append (prototype.name);
+ msg_err.append (prototype.name);
msg_err.add_last '(';
prototype.append_filename msg_err;
msg_err.append "):\n";
@@ -131,7 +131,7 @@ Section Public
// copy line :
string_tmp.clear;
cols := column;
- {(pos > src.upper) ||
+ {(pos > src.upper) ||
{src.item pos='\n'}}.until_do {
char := src.item pos;
msg_err.add_last char;
@@ -149,7 +149,7 @@ Section Public
msg_err.append string_tmp;
msg_err.append "^\n";
);
-
+
- extract_line:STRING <-
( + pos:INTEGER;
+ src:STRING;
@@ -165,32 +165,32 @@ Section Public
pos := pos + 1;
};
// copy line :
- string_tmp.clear;
+ string_tmp.clear;
{
- (pos > src.upper) ||
+ (pos > src.upper) ||
{src.item pos='\n'}
}.until_do {
char := src.item pos;
(char)
.when '\\' then { string_tmp.add_last '\\'; }
.when '\"' then { string_tmp.add_last '\\'; };
- string_tmp.add_last char;
+ string_tmp.add_last char;
pos := pos + 1;
- };
+ };
(string_tmp.last.code = 0Dh).if {
string_tmp.remove_last 1;
};
STRING.create_from_string string_tmp
);
-
-Section Private
-
+
+Section Private
+
//
// Service manager
//
-
+
- type_error:INTEGER;
-
+
- msg_err:STRING := STRING.create 256;
diff --git a/src/tools/slim_array.li b/src/tools/slim_array.li
index fe97746..086c5b1 100644
--- a/src/tools/slim_array.li
+++ b/src/tools/slim_array.li
@@ -19,7 +19,7 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SLIM_ARRAY(E); // BSBS: A mettre en Expanded.
- copyright := "2003-2008 Sonntag Benoit";
@@ -30,15 +30,15 @@ Section Header
Section Insert
- parent_object:OBJECT := OBJECT;
-
+
Section Private
-
+
+ list:FAST_ARRAY(E);
-
+
Section Public
-
+
+ first:E;
-
+
- last:E <-
( + result:E;
(list != NULL).if {
@@ -48,10 +48,10 @@ Section Public
};
result
);
-
+
- lower:INTEGER <- 0;
-
- - upper:INTEGER <-
+
+ - upper:INTEGER <-
( + result:INTEGER;
(first = NULL).if {
result := -1;
@@ -60,14 +60,14 @@ Section Public
};
result
);
-
+
- count:INTEGER <- upper + 1;
-
+
- is_empty:BOOLEAN <- first = NULL;
-
+
- item i:INTEGER :E <-
( + result:E;
-
+
(i = 0).if {
result := first;
} else {
@@ -75,7 +75,7 @@ Section Public
};
result
);
-
+
- put e:E to i:INTEGER <-
(
(i = 0).if {
@@ -83,8 +83,8 @@ Section Public
} else {
list.put e to (i-1);
};
- );
-
+ );
+
- add_last e:E <-
(
(first = NULL).if {
@@ -96,7 +96,7 @@ Section Public
list.add_last e;
};
);
-
+
- make_with_capacity n:INTEGER <-
(
first := NULL;
@@ -104,4 +104,4 @@ Section Public
list := FAST_ARRAY(E).create_with_capacity (n-1);
};
);
-
+
diff --git a/src/tools/table.li b/src/tools/table.li
index aad188b..a9325a3 100644
--- a/src/tools/table.li
+++ b/src/tools/table.li
@@ -19,53 +19,53 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
- name := TABLE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Display array manager.";
-
-Section Inherit
-
+
+Section Inherit
+
- parent_object:OBJECT := OBJECT;
-
+
Section Private
-
+
- table:FAST_ARRAY2(ABSTRACT_STRING) := FAST_ARRAY2(ABSTRACT_STRING).create (10,10);
-
+
- size:FAST_ARRAY(INTEGER) := FAST_ARRAY(INTEGER).create_with_capacity 10;
-
+
- line:INTEGER;
- column:INTEGER;
-
+
Section Public
-
+
- new_table (l,c:INTEGER) <-
(
table.make (l,c);
- line := column := 0;
+ line := column := 0;
);
-
+
- add n:ABSTRACT_STRING <-
(
? {n != NULL};
-
+
table.put n to (line,column);
(column = table.upper2).if {
column := 0;
line := line + 1;
} else {
column := column + 1;
- };
+ };
);
-
+
- append_in buffer:STRING <-
( + siz:INTEGER;
+ append_line,append_bar:BLOCK;
-
+
// Size column.
size.make (table.count2);
0.to (table.upper1) do { l:INTEGER;
@@ -76,15 +76,15 @@ Section Public
};
};
};
-
+
// Sub-code for one line.
- append_line :=
+ append_line :=
{ l:INTEGER;
+ n:ABSTRACT_STRING;
buffer.append "// ";
0.to (table.upper2) do { c:INTEGER;
n := table.item (l,c);
- buffer.append "| ";
+ buffer.append "| ";
buffer.append n;
buffer.extend_multiple ' ' by (size.item c - n.count + 1);
};
diff --git a/src/tools/types.li b/src/tools/types.li
index 7607882..fb09162 100644
--- a/src/tools/types.li
+++ b/src/tools/types.li
@@ -19,56 +19,56 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPES;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Aliser TYPE collection.";
-
-Section Inherit
-
+
+Section Inherit
+
- parent_any:ANY := ANY;
-
+
Section TYPES
-
+
+ storage:NATIVE_ARRAY(TYPE);
// Internal access to storage location.
-
+
Section LISAAC
-
+
- size:INTEGER;
-
+
Section Public
-
+
- lower:INTEGER := 0;
-
+
+ upper:INTEGER := -1; // Upper index bound.
-
+
- count:INTEGER <- upper + 1;
-
+
- is_empty:BOOLEAN <- upper = -1;
-
- - first:TYPE <-
+
+ - first:TYPE <-
[ -? {! is_empty}; ]
(
storage.item 0
);
- - second:TYPE <-
+ - second:TYPE <-
[ -? {upper >= 1}; ]
(
storage.item 1
);
-
- - last:TYPE <-
+
+ - last:TYPE <-
[ -? {! is_empty}; ]
(
storage.item upper
);
-
+
- item i:INTEGER :TYPE <-
[ -? {i.in_range lower to upper}; ]
(
@@ -77,10 +77,10 @@ Section Public
[ +? {Result != NULL}; ];
- Self:SELF '~=' Right 60 other:TYPES :BOOLEAN <-
- (
- (Self = other) ||
+ (
+ (Self = other) ||
{
- (upper = other.upper) &&
+ (upper = other.upper) &&
{(is_empty) || {storage.fast_memcmp (other.storage) until (upper + 1)}}
}
);
@@ -90,7 +90,7 @@ Section Public
( + result:BOOLEAN;
+ j1,j2:INTEGER;
+ t:TYPE;
-
+
(upper <= other.upper).if {
j1 := j2 := lower;
result := TRUE;
@@ -101,24 +101,24 @@ Section Public
};
result := (j2 <= other.upper);
j1 := j1 + 1;
- };
+ };
};
- result
+ result
);
-
+
- hash_code:INTEGER <-
( + result:INTEGER;
-
+
(! is_empty).if {
result := (upper << 8) + last.index;
};
result
);
-
+
//
// Display.
//
-
+
- append_in buf:STRING <-
(
(! is_empty).if {
@@ -130,36 +130,36 @@ Section Public
};
last.append_name_in buf;
buf.add_last '(';
- last.index.append_in buf;
+ last.index.append_in buf;
buf.add_last ')';
} else {
buf.append "<Vide>";
};
);
-
+
- print <-
(
string_tmp.clear;
append_in string_tmp;
string_tmp.print;
);
-
+
Section TYPES_TMP
-
+
- create tab:TYPES_TMP :TYPES <-
( + result:TYPES;
-
+
result := clone;
result.make tab;
result
);
-
+
- make tab:TYPES_TMP <-
( + up:INTEGER;
-
+
up := tab.upper;
storage := NATIVE_ARRAY(TYPE).calloc_intern (up + 1);
storage.copy_from (tab.storage) until up;
- upper := up;
- size := size + count * 4;
+ upper := up;
+ size := size + count * 4;
);
\ No newline at end of file
diff --git a/src/tools/types_tmp.li b/src/tools/types_tmp.li
index 9cc1db3..f21fc69 100644
--- a/src/tools/types_tmp.li
+++ b/src/tools/types_tmp.li
@@ -19,77 +19,77 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPES_TMP;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Aliser TYPE collection.";
-
+
Section Inherit
-
+
+ parent_types:Expanded TYPES;
-
+
Section Private
-
+
- bucket:HASHED_SET(TYPES) := HASHED_SET(TYPES).create;
-
+
- free_list:FAST_ARRAY(TYPES_TMP) := FAST_ARRAY(TYPES_TMP).create_with_capacity 5;
-
+
+ capacity:INTEGER;
-
+
- create_types_tmp:TYPES_TMP <-
( + result:TYPES_TMP;
-
+
result := clone;
result.make_types_tmp;
result
);
-
+
- make_types_tmp <-
(
capacity := 256;
storage := NATIVE_ARRAY(TYPE).calloc_intern capacity;
)
[ +? {is_empty}; ];
-
+
Section LISAAC
-
+
- print_types <-
(
(bucket.lower).to (bucket.upper) do { j:INTEGER;
bucket.item j.print; '\n'.print;
};
);
-
+
Section Public
-
+
- types_empty:TYPES := TYPES;
-
+
//
// Creation.
//
-
+
- new:TYPES_TMP <-
( + result:TYPES_TMP;
-
+
(free_list.is_empty).if {
result := create_types_tmp;
} else {
result := free_list.last;
free_list.remove_last;
- };
+ };
result
);
-
+
- update t:TYPES :TYPES <-
[
-? { + tmp:TYPES_TMP; tmp ?= t; tmp = NULL};
]
( + result:TYPES;
-
+
((t != NULL) && {t.count = count}).if {
result := t;
free;
@@ -98,12 +98,12 @@ Section Public
};
result
);
-
+
- to_types:TYPES <-
( + result:TYPES;
-
+
(is_empty).if {
- result := types_empty;
+ result := types_empty;
} else {
result := bucket.reference_at Self with { (e1,e2:TYPES); e1 ~= e2};
(result = NULL).if {
@@ -112,40 +112,40 @@ Section Public
};
};
20 ? {result ~= Self};
-
+
free;
result
);
-
+
- clear <-
(
upper := -1;
);
-
+
- free <-
(
clear;
free_list.add_last Self;
);
-
+
//
// Update list.
//
-
+
- remove_first <-
(
(lower + 1).to upper do { i:INTEGER;
storage.put (item i) to (i - 1);
- };
+ };
upper := upper - 1;
);
-
+
- add t:TYPE <-
( + idx:INTEGER;
-
+
(is_empty).if {
add_last t;
- } else {
+ } else {
idx := search t from 0 to count;
(idx > upper).if {
add_last t;
@@ -154,45 +154,45 @@ Section Public
};
};
)
- [
- 20 ? {order_test};
+ [
+ 20 ? {order_test};
];
- union other:TYPES <-
( + idx1,idx2,t2idx:INTEGER;
+ t2:TYPE;
-
+
{idx2 > other.upper}.until_do {
t2 := other.item idx2;
t2idx := t2.index;
{(idx1 <= upper) && {item idx1.index < t2idx}}.while_do {
idx1 := idx1 + 1;
};
- ((idx1 > upper) || {item idx1 != t2}).if {
- add t2 to idx1;
- };
+ ((idx1 > upper) || {item idx1 != t2}).if {
+ add t2 to idx1;
+ };
idx1 := idx1 + 1;
idx2 := idx2 + 1;
- };
+ };
)
- [
- 20 ? {order_test};
+ [
+ 20 ? {order_test};
];
-
+
Section Private
-
+
- add_last t:TYPE <-
( + new_capacity:INTEGER;
-
+
(upper + 1 > capacity - 1 ).if {
new_capacity := capacity * 2;
storage := storage.realloc capacity with new_capacity;
- capacity := new_capacity;
- };
+ capacity := new_capacity;
+ };
upper := upper + 1;
storage.put t to upper;
);
-
+
- add t:TYPE to index:INTEGER <-
( + new_capacity:INTEGER;
(index = upper + 1).if {
@@ -201,30 +201,30 @@ Section Private
(upper + 1 > capacity - 1 ).if {
new_capacity := capacity * 2;
storage := storage.realloc capacity with new_capacity;
- capacity := new_capacity;
- };
+ capacity := new_capacity;
+ };
upper := upper + 1;
(upper - 1).downto index do { i:INTEGER;
storage.put (item i) to (i + 1);
- };
+ };
storage.put t to index;
};
);
-
+
- search t:TYPE from beg:INTEGER to end:INTEGER :INTEGER <-
// Dichotomic research.
( + middle,result:INTEGER;
-
+
((end - beg) < 2).if {
(t.index > item beg.index).if {
result := end;
} else {
result := beg;
};
- } else {
+ } else {
middle := (beg + end) >> 1;
(t.index > item middle.index).if {
- result := search t from middle to end;
+ result := search t from middle to end;
} else {
result := search t from beg to middle;
};
@@ -236,7 +236,7 @@ Section Private
( + j:INTEGER;
{(j < upper) && {item j.index < item (j+1).index}}.while_do {
- j := j + 1;
+ j := j + 1;
};
j >= upper
);
diff --git a/src/type/prototype.li b/src/type/prototype.li
index 9c96f0f..c153d38 100644
--- a/src/type/prototype.li
+++ b/src/type/prototype.li
@@ -19,46 +19,46 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := PROTOTYPE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Prototype source code.";
-
+
Section Inherit
+ parent_named:Expanded NAMED;
-
+
Section Public
-
+
- prototype_list:FAST_ARRAY(PROTOTYPE) :=
FAST_ARRAY(PROTOTYPE).create_with_capacity 512;
// BSBS: Voir si il faut le conserver !
-
- - prototype_dico:HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT) :=
+
+ - prototype_dico:HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT) :=
HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT).create;
-
+
Section Public
-
+
+ index:INTEGER; // in `prototype_list', for POSITION.
-
+
+ shortname:STRING_CONSTANT;
-
+
//
// Slots
//
-
+
+ slot_list:HASHED_DICTIONARY(ITM_SLOT,STRING_CONSTANT);
-
+
+ first_slot:ITM_SLOT;
-
+
+ last_slot:ITM_SLOT;
-
+
- add_slot s:ITM_SLOT <-
- (
+ (
slot_list.fast_put s to (s.name);
(first_slot = NULL).if {
first_slot := s;
@@ -66,36 +66,36 @@ Section Public
last_slot.set_next s;
};
last_slot := s;
- );
-
+ );
+
- search_parent n:STRING_CONSTANT :BOOLEAN <-
( + slot:ITM_SLOT;
+ result:BOOLEAN;
-
+
slot := first_slot;
{
- (result := (slot != NULL) && {slot.id_section.is_inherit_or_insert})
+ (result := (slot != NULL) && {slot.id_section.is_inherit_or_insert})
&& {slot.name != n}
}.while_do {
slot := slot.next;
};
result
);
-
+
//
// Run Slot.
//
-
+
- init_slot_for typ:TYPE <-
( + cur:ITM_SLOT;
+ slot:SLOT;
+ slot_code:SLOT_CODE;
+ old_profil_current:PROFIL;
-
+
// Parent.
//last_position := position;
cur := first_slot;
- {(cur != NULL) && {cur.id_section.is_inherit_or_insert}}.while_do {
+ {(cur != NULL) && {cur.id_section.is_inherit_or_insert}}.while_do {
typ.slot_run.add_last (SLOT.create cur type typ);
typ.verify_cyclic_inheritance typ;
typ.verify_itm_slot_parent cur;
@@ -104,7 +104,7 @@ Section Public
// Mapping.
((is_mapping) || {is_external}).if {
{cur != NULL}.while_do {
- ((cur.id_section.is_mapping) || {cur.id_section.is_external}).if {
+ ((cur.id_section.is_mapping) || {cur.id_section.is_external}).if {
typ.verify_itm_slot_parent cur;
slot := SLOT.create cur type typ;
typ.slot_run.add_last slot;
@@ -119,19 +119,19 @@ Section Public
};
cur := cur.next;
};
- };
+ };
);
-
+
//
// Mapping / Late binding / Expanded
//
-
+
+ type_style:STRING_CONSTANT; // Reference / Expanded / Strict.
-
+
+ is_mapping:BOOLEAN;
-
+
+ is_external:BOOLEAN;
-
+
- set_mapping <-
(
is_mapping := TRUE;
@@ -141,12 +141,12 @@ Section Public
(
is_external := TRUE;
);
-
- - set_type_style s:STRING_CONSTANT <-
- (
+
+ - set_type_style s:STRING_CONSTANT <-
+ (
type_style := s;
);
-
+
//
// Cast information.
//
@@ -171,11 +171,11 @@ Section Public
+ filename:STRING_CONSTANT; // Pathname of prototype.
+ source : STRING; // Text source code.
-
+
+ generic_count:INTEGER;
-
+
+ idf_generic_list:FAST_ARRAY(ITM_TYPE_PARAMETER);
-
+
- append_filename buffer:STRING <-
(
(path_begin != 1).if {
@@ -183,9 +183,9 @@ Section Public
};
path_begin.to (filename.upper) do { j:INTEGER;
buffer.add_last (filename.item j);
- };
+ };
);
-
+
//
// Default value.
//
@@ -193,21 +193,21 @@ Section Public
+ default_value:ITM_CODE;
- set_default_value v:ITM_CODE <-
- (
+ (
default_value := v; //default_value v to_slot name in Self;
);
-
+
//
// Creation.
//
-
+
- create f:STRING_CONSTANT name n:STRING_CONSTANT generic_count c:INTEGER :SELF <-
( + result:SELF;
result := clone;
result.make f name n generic_count c;
result
);
-
+
- make f:STRING_CONSTANT name n:STRING_CONSTANT generic_count c:INTEGER <-
( //+ file:FILE;
//+ entry:ENTRY;
@@ -215,9 +215,9 @@ Section Public
+ sz,idx:INTEGER;
? {! prototype_dico.fast_has n};
? {n != NULL};
-
+
filename := f;
- name := n;
+ name := n;
idx := n.fast_last_index_of '.';
(idx != 0).if {
string_tmp.copy n;
@@ -228,27 +228,27 @@ Section Public
};
generic_count := c;
idf_generic_list := FAST_ARRAY(ITM_TYPE_PARAMETER).create_with_capacity c;
-
- // Collection.
+
+ // Collection.
index := prototype_list.count;
prototype_list.add_last Self;
- prototype_dico.fast_put Self to f;
-
- // Read file.
- //entry := FILE_SYSTEM.get f;
+ prototype_dico.fast_put Self to f;
+
+ // Read file.
+ //entry := FILE_SYSTEM.get f;
//file ?= entry.open_read_only;
//source := STRING.create (file.size);
//file.read source size (file.size);
//file.close;
-
+
file := FS_MIN.open_read f;
sz := FS_MIN.file_size file;
source := STRING.create (sz+1);
FS_MIN.read file in source size sz;
FS_MIN.close file;
-
- // Init.
- slot_list := HASHED_DICTIONARY(ITM_SLOT,STRING_CONSTANT).create;
+
+ // Init.
+ slot_list := HASHED_DICTIONARY(ITM_SLOT,STRING_CONSTANT).create;
position := POSITION.create Self line 1 column 0;
//
);
@@ -256,7 +256,7 @@ Section Public
//
// Execute.
//
-
+
- depend <-
( + slot_main:SLOT;
+ self_main:EXPR;
@@ -266,23 +266,23 @@ Section Public
+ i:INSTR;
+ cmd:STRING_CONSTANT;
+ exec:{};
-
+
+ buf:STRING;
//
// Creation list execution.
- //
+ //
list_main := list_current := LIST.create position;
(debug_level_option != 0).if {
// Debug mode : Add context local.
- context_main := TYPE_CONTEXT.default.new_local position
+ context_main := TYPE_CONTEXT.default.new_local position
name (ALIAS_STR.variable_context) style '+';
- context_main.set_ensure_count 1;
+ context_main.set_ensure_count 1;
list_current.add_last (PUSH.create position context context_main first TRUE);
};
-
+
// Command argument.
- (is_ansi).if {
+ (is_ansi).if {
(is_java).if {
cmd := "arg = parg";
} else {
@@ -297,7 +297,7 @@ Section Public
\ pthread_key_create(¤t_thread, NULL);\n\
\ pthread_attr_init(&thread_attr);\n\
\ /*pthread_attr_setdetachstate(&thread_attr,PTHREAD_CREATE_DETACHED);*/\n\
- \#endif\n ";
+ \#endif\n ";
cmd := ALIAS_STR.get string_tmp;
};
i := EXTERNAL_C.create position text cmd
@@ -307,19 +307,19 @@ Section Public
// Main Call.
slot_main := get_slot_main;
self_main := PROTOTYPE_CST.create position type (type_input.default);
- base := NODE.new_read (slot_main.position) slot slot_main
- receiver self_main self self_main intern TRUE;
+ base := NODE.new_read (slot_main.position) slot slot_main
+ receiver self_main self self_main intern TRUE;
list_current.add_last base;
-
- // Result.
- list_current.add_last (INTEGER_CST.create position value 0 type (type_integer.default));
-
+
+ // Result.
+ list_current.add_last (INTEGER_CST.create position value 0 type (type_integer.default));
+
//
// Detect life code.
- //
+ //
pass_count := 1;
(is_quiet).if_false {
- STD_ERROR.put_string "Depending pass: .";
+ STD_ERROR.put_string "Depending pass: .";
};
{modify_count != 0}.while_do {
modify_count := 0;
@@ -329,93 +329,93 @@ Section Public
pass_count := pass_count + 1;
NODE.extend_pass;
};
-
+
(is_quiet).if_false {
STD_ERROR.put_string " (";
STD_ERROR.put_integer pass_count;
STD_ERROR.put_string ")\n";
};
-
+
buf := STRING.create 2000;
-
+
(is_verbose).if {
PROFIL_LIST.display;
};
-
+
//
// Evaluation.
//
- VARIABLE.check_variable_block;
+ VARIABLE.check_variable_block;
(is_quiet).if_false {
STD_ERROR.put_string "Executing pass: ";
};
pass_count_depend := pass_count;
exec := {
- {
+ {
modify_count := 0;
null_counter := 0;
(is_quiet).if_false {
- STD_ERROR.put_string ".";
+ STD_ERROR.put_string ".";
};
- pass_count := pass_count + 1;
-
+ pass_count := pass_count + 1;
+
SWITCH.reset_switch_new_pass;
-
- PROFIL_LIST.execute_pass;
-
+
+ PROFIL_LIST.execute_pass;
+
(SWITCH.switch_new_pass).if {
- new_execute_pass;
- };
- (modify_count != 0).if {
- pass_recur := TRUE;
+ new_execute_pass;
+ };
+ (modify_count != 0).if {
+ pass_recur := TRUE;
};
- }.do_while {modify_count != 0};
+ }.do_while {modify_count != 0};
};
- // First pass (recursive)
- is_executing_pass := TRUE;
+ // First pass (recursive)
+ is_executing_pass := TRUE;
{
(is_quiet).if_false {
STD_ERROR.put_string "*";
- };
+ };
pass_count := pass_count + 1;
- PROFIL_LIST.execute_pass_recursive;
+ PROFIL_LIST.execute_pass_recursive;
pass_recur := FALSE;
- // End first pass.
- exec.value;
- (pass_recur).if_false {
+ // End first pass.
+ exec.value;
+ (pass_recur).if_false {
exec.value;
- };
+ };
}.do_while {pass_recur};
(is_quiet).if_false {
STD_ERROR.put_string " (";
STD_ERROR.put_integer (pass_count - pass_count_depend);
- STD_ERROR.put_string ")\n";
+ STD_ERROR.put_string ")\n";
};
- //
+ //
(is_verbose).if {
list_main.debug_display;
PROFIL_LIST.display;
- };
+ };
);
-
+
//
// Type C
//
-
+
+ type_c :STRING_CONSTANT;
- set_c_type n:STRING_CONSTANT <-
(
- type_c := n;
+ type_c := n;
);
-
+
//
// Shorter.
//
-
+
+ comment_slot:STRING_CONSTANT;
+ comment_header:STRING_CONSTANT;
-
+
- set_comment_slot t:STRING_CONSTANT <-
(
comment_slot := t;
@@ -425,97 +425,97 @@ Section Public
(
comment_header := t;
);
-
+
- shorter_out buf:STRING <-
( + title:STRING_CONSTANT;
+ s:ITM_SLOT;
put name to buf like (ALIAS_STR.short_title);
-
+
(comment_slot != NULL).if {
put comment_slot to buf like (ALIAS_STR.short_prototype_comment_light);
};
(comment_header != NULL).if {
put comment_header to buf like (ALIAS_STR.short_prototype_comment);
};
-
+
list_tmp.clear;
shorter_get_all_slot_in list_tmp;
-
+
// Table.
- shorter_table list_tmp select { sl:ITM_SLOT;
+ shorter_table list_tmp select { sl:ITM_SLOT;
sl.id_section.is_inherit_or_insert
} title "Inherit/Insert Summary" in buf;
-
- shorter_table list_tmp select { sl:ITM_SLOT;
+
+ shorter_table list_tmp select { sl:ITM_SLOT;
sl.name.has_prefix "create"
- } title "Constructor Summary" in buf;
-
+ } title "Constructor Summary" in buf;
+
(list_tmp.lower).to (list_tmp.upper) do { j:INTEGER;
s := list_tmp.item j;
(s.stat_shorter = 0).if {
- title := s.comment_chapter;
- shorter_table list_tmp select { sl:ITM_SLOT;
+ title := s.comment_chapter;
+ shorter_table list_tmp select { sl:ITM_SLOT;
sl.comment_chapter = title
- } title title in buf;
+ } title title in buf;
};
};
-
+
// Detail.
- shorter_detail list_tmp select { sl:ITM_SLOT;
+ shorter_detail list_tmp select { sl:ITM_SLOT;
sl.id_section.is_inherit_or_insert
- } title "Inherit/Insert Detail" in buf;
-
- shorter_detail list_tmp select { sl:ITM_SLOT;
+ } title "Inherit/Insert Detail" in buf;
+
+ shorter_detail list_tmp select { sl:ITM_SLOT;
sl.name.has_prefix "create"
- } title "Constructor Detail" in buf;
-
+ } title "Constructor Detail" in buf;
+
(list_tmp.lower).to (list_tmp.upper) do { j:INTEGER;
s := list_tmp.item j;
(s.stat_shorter = 1).if {
- title := s.comment_chapter;
- shorter_detail list_tmp select { sl:ITM_SLOT;
+ title := s.comment_chapter;
+ shorter_detail list_tmp select { sl:ITM_SLOT;
sl.comment_chapter = title
- } title title in buf;
+ } title title in buf;
};
};
-
+
(list_tmp.lower).to (list_tmp.upper) do { j:INTEGER;
list_tmp.item j.set_stat_shorter 0;
};
);
-
+
Section PROTOTYPE
-
+
- get_slot_main:SLOT <-
- ( + result:SLOT;
- + s:ITM_SLOT;
-
- s := first_slot;
- {
- ((s.id_section.is_public) && {s.name = ALIAS_STR.slot_main}).if {
+ ( + result:SLOT;
+ + s:ITM_SLOT;
+
+ s := first_slot;
+ {
+ ((s.id_section.is_public) && {s.name = ALIAS_STR.slot_main}).if {
(s.result_type != ITM_TYPE_SIMPLE.type_void).if {
semantic_error (s.position,"Unix mode: Not value return.");
};
(s.argument_count != 1).if {
semantic_error (s.position,"Unix mode: Not argument list.");
- };
+ };
result := type_input.get_slot (s.name);
};
s := s.next;
}.do_while {(s != NULL) && {result = NULL}};
-
+
(result = NULL).if {
semantic_error (position,"Entry point not found (slot `main' in `Section Public').");
- };
- result
+ };
+ result
);
-
+
- shorter_get_all_slot_in lst:FAST_ARRAY(ITM_SLOT) <-
- ( + s:ITM_SLOT;
+ ( + s:ITM_SLOT;
+ ps:ITM_TYPE_SIMPLE;
+ p:PROTOTYPE;
+ i:INTEGER;
-
+
s := first_slot;
{s != NULL}.while_do {
(is_short_private || {! s.id_section.is_private}).if {
@@ -529,10 +529,10 @@ Section PROTOTYPE
};
s := s.next;
};
-
+
// Parent.
s := first_slot;
- {(s != NULL) && {s.id_section.is_inherit_or_insert}}.while_do {
+ {(s != NULL) && {s.id_section.is_inherit_or_insert}}.while_do {
ps ?= s.result_type;
((ps != NULL) && {
({s.style = '+'} && {ps.style = ALIAS_STR.keyword_expanded}) ||
@@ -546,20 +546,20 @@ Section PROTOTYPE
};
i := i + 1;
};
- (p != NULL).if {
+ (p != NULL).if {
p.shorter_get_all_slot_in lst;
};
- };
+ };
s := s.next;
- };
+ };
);
-
+
- shorter_table lst:FAST_ARRAY(ITM_SLOT) select sel:{ITM_SLOT; BOOLEAN}
title t:STRING_CONSTANT in buf:STRING <-
( + is_first_cur:BOOLEAN;
- + s:ITM_SLOT;
-
- is_first_cur := TRUE;
+ + s:ITM_SLOT;
+
+ is_first_cur := TRUE;
(lst.lower).to (lst.upper) do { i:INTEGER;
s := lst.item i;
((sel.value s) && {s.stat_shorter = 0}).if {
@@ -577,7 +577,7 @@ Section PROTOTYPE
s.pretty_name_in string_tmp2;
put string_tmp2 to string_tmp like (ALIAS_STR.short_table_slot_name);
(
- (s.id_section.is_inherit_or_insert) &&
+ (s.id_section.is_inherit_or_insert) &&
{
(
(s.style != '+') || {
@@ -585,31 +585,31 @@ Section PROTOTYPE
ts ?= s.result_type;
(ts = NULL) || {ts.style != ALIAS_STR.keyword_expanded}
}
- ) &&
- {! s.name.has_prefix "inherit"} &&
+ ) &&
+ {! s.name.has_prefix "inherit"} &&
{! s.name.has_prefix "insert"}
}
).if {
put " No developed." to string_tmp like (ALIAS_STR.short_warning);
};
- string_tmp2.clear;
+ string_tmp2.clear;
get_all_comment_slot (s.name) in string_tmp2;
string_tmp3.clear;
- shorter_comment string_tmp2 in string_tmp3 light TRUE;
+ shorter_comment string_tmp2 in string_tmp3 light TRUE;
put string_tmp3 to string_tmp like (ALIAS_STR.short_table_slot_comment);
put string_tmp to buf like (ALIAS_STR.short_table_item);
- };
- };
+ };
+ };
(is_first_cur).if_false {
put NULL to buf like (ALIAS_STR.short_table_end);
- };
+ };
);
-
+
- shorter_detail lst:FAST_ARRAY(ITM_SLOT) select sel:{ITM_SLOT; BOOLEAN}
title t:STRING_CONSTANT in buf:STRING <-
( + is_first:BOOLEAN;
+ s:ITM_SLOT;
-
+
is_first := TRUE;
(lst.lower).to (lst.upper) do { i:INTEGER;
s := lst.item i;
@@ -628,10 +628,10 @@ Section PROTOTYPE
s.pretty_name_in string_tmp2;
put string_tmp2 to buf like (ALIAS_STR.short_slot_title);
string_tmp.clear;
- s.position.prototype.append_filename string_tmp;
+ s.position.prototype.append_filename string_tmp;
string_tmp.append " line #";
s.position.line.append_in string_tmp;
- put string_tmp to buf like (ALIAS_STR.short_prototype_path);
+ put string_tmp to buf like (ALIAS_STR.short_prototype_path);
//
put "Section:" to buf like (ALIAS_STR.short_subsub_title);
string_tmp.clear;
@@ -640,51 +640,51 @@ Section PROTOTYPE
//
put "Profile:" to buf like (ALIAS_STR.short_subsub_title);
s.shorter_profile_in buf;
- //
+ //
string_tmp.clear;
- get_all_comment_slot (s.name) in string_tmp;
- shorter_comment string_tmp in buf light FALSE;
- };
+ get_all_comment_slot (s.name) in string_tmp;
+ shorter_comment string_tmp in buf light FALSE;
+ };
};
);
-
+
- get_all_comment_slot n:STRING_CONSTANT in buf:STRING <-
- ( + s:ITM_SLOT;
+ ( + s:ITM_SLOT;
+ ps:ITM_TYPE_SIMPLE;
+ p:PROTOTYPE;
+ i:INTEGER;
-
+
s := slot_list.fast_reference_at n;
((s != NULL) && {s.comment != NULL}).if {
buf.append (s.comment);
};
// Parent.
s := first_slot;
- {(s != NULL) && {s.id_section.is_inherit_or_insert}}.while_do {
+ {(s != NULL) && {s.id_section.is_inherit_or_insert}}.while_do {
ps ?= s.result_type;
- (ps != NULL).if {
+ (ps != NULL).if {
p := NULL;
i := prototype_list.lower;
- {(i <= prototype_list.upper) && {p = NULL}}.while_do {
+ {(i <= prototype_list.upper) && {p = NULL}}.while_do {
(prototype_list.item i.name = ps.name).if {
p := prototype_list.item i;
};
i := i + 1;
};
- (p != NULL).if {
+ (p != NULL).if {
p.get_all_comment_slot n in buf;
};
- };
+ };
s := s.next;
};
);
-
+
- list_tmp:FAST_ARRAY(ITM_SLOT) := FAST_ARRAY(ITM_SLOT).create_with_capacity 256;
-
+
- str_tmp:STRING := STRING.create 512;
- str_tmp2:STRING := STRING.create 64;
- str_tmp3:STRING := STRING.create 64;
-
+
- shorter_comment str:STRING in buf:STRING light is_light:BOOLEAN <-
( + cur:INTEGER;
+ stat,old_stat:INTEGER;
@@ -692,21 +692,21 @@ Section PROTOTYPE
+ i:INTEGER;
+ lst:LINKED_LIST(STRING_CONSTANT);
+ code_balise:STRING_CONSTANT;
-
+
cur := str.lower;
str_tmp.clear;
code_balise := ALIAS_STR.short_comment_slot_line;
- {cur <= str.upper}.while_do {
+ {cur <= str.upper}.while_do {
car := str.item cur;
(stat)
- .when 0 then {
+ .when 0 then {
// Begin.
- (car = '*').if {
+ (car = '*').if {
(str_tmp.count > 1).if {
(is_light).if {
buf.append str_tmp;
cur := str.upper + 1;
- } else {
+ } else {
put "Description:" to buf like (ALIAS_STR.short_subsub_title);
put str_tmp to buf like code_balise;
};
@@ -715,7 +715,7 @@ Section PROTOTYPE
stat := 1;
}.elseif {car = '`'} then {
old_stat := stat;
- stat := 2;
+ stat := 2;
str_tmp2.clear;
} else {
str_tmp.add_last car;
@@ -723,15 +723,15 @@ Section PROTOTYPE
}
.when 1 then {
// Begin slot.
- (car.to_lower.in_range 'a' to 'z').if {
+ (car.to_lower.in_range 'a' to 'z').if {
str_tmp.add_last (car.to_lower);
}.elseif {(car = ' ') && {!str_tmp.is_empty}} then {
- str_tmp.add_last '_';
+ str_tmp.add_last '_';
}.elseif {car = ':'} then {
- (str_tmp.count != 0).if {
- code_balise := ALIAS_STR.get str_tmp;
+ (str_tmp.count != 0).if {
+ code_balise := ALIAS_STR.get str_tmp;
lst := PARSER.short_dico.fast_reference_at code_balise;
- (lst = NULL).if {
+ (lst = NULL).if {
code_balise := NULL;
} else {
str_tmp.replace_all '_' with ' ';
@@ -763,7 +763,7 @@ Section PROTOTYPE
} else {
put str_tmp2 to str_tmp like (ALIAS_STR.short_identifier);
};
- };
+ };
stat := old_stat;
} else {
str_tmp2.add_last car;
@@ -772,22 +772,22 @@ Section PROTOTYPE
.when 3 then {
// Read slot.
(car = '*').if {
- (str_tmp.count > 1).if {
+ (str_tmp.count > 1).if {
put str_tmp to buf like code_balise;
};
str_tmp.clear;
- stat := 1;
+ stat := 1;
}.elseif {car = '`'} then {
old_stat := stat;
- stat := 2;
+ stat := 2;
str_tmp2.clear;
} else {
str_tmp.add_last car;
- };
+ };
};
cur := cur + 1;
};
- (str_tmp.count > 1).if {
+ (str_tmp.count > 1).if {
(is_light).if {
buf.append str_tmp;
} else {
diff --git a/src/type/type.li b/src/type/type.li
index 986a830..6a6e268 100644
--- a/src/type/type.li
+++ b/src/type/type.li
@@ -128,9 +128,9 @@ Section Public
(styl = NULL).if {
result := base.default;
} else {
- (styl = ALIAS_STR.keyword_expanded).if {
- result := base.default + TYPE_FULL.expanded_bit;
- } else {
+ (styl = ALIAS_STR.keyword_expanded).if {
+ result := base.default + TYPE_FULL.expanded_bit;
+ } else {
result := base.default + TYPE_FULL.strict_bit;
};
};
@@ -155,7 +155,7 @@ Section Public
{
(j <= slot_run.upper) &&
{slot_run.item j.id_section.is_inherit_or_insert} &&
- {result = NULL}
+ {result = NULL}
}.while_do {
ts ?= slot_run.item j.result_type;
typ := ts.to_run_for Self.raw;
@@ -189,7 +189,7 @@ Section Public
{
(j <= slot_run.upper) &&
{slot_run.item j.id_section.is_inherit_or_insert} &&
- {result = NULL}
+ {result = NULL}
}.while_do {
ts ?= slot_run.item j.result_type;
typ := ts.to_run_for Self.raw;
@@ -240,7 +240,7 @@ Section Public
{
(j <= slot_run.upper) &&
{slot_run.item j.id_section.is_inherit_or_insert} &&
- {result = NULL}
+ {result = NULL}
}.while_do {
it ?= slot_run.item j.result_type;
result := it.to_run_for Self.get_slot n;
@@ -270,10 +270,10 @@ Section Public
};
*/
itm_slot := prototype.slot_list.fast_reference_at n;
- (itm_slot != NULL).if {
+ (itm_slot != NULL).if {
verify_itm_slot_parent itm_slot;
result := SLOT.create itm_slot type Self;
- slot_run.add_last result;
+ slot_run.add_last result;
};
};
result
@@ -335,11 +335,11 @@ Section Private
j := lst.lower;
{(j <= lst.upper) && {lst.item j.to_run_for profil_slot != t}}.while_do {
j := j + 1;
- };
+ };
(j <= lst.upper).if {
result := TRUE;
last_cast_name.copy msg;
- lst.item j.append_cast_name_in last_cast_name;
+ lst.item j.append_cast_name_in last_cast_name;
};
};
result
@@ -499,7 +499,7 @@ Section Public
(s.type.raw.is_block) ||
{is_far_expanded (s.type)}
}
- ).if {
+ ).if {
s.type.raw.genere_struct;
};
};
@@ -513,7 +513,7 @@ Section Public
};
// Sort slot.
(slot_run.lower).to (slot_run.upper) do { j:INTEGER;
- slot := slot_run.item j;
+ slot := slot_run.item j;
(slot.style = '+').if {
// In struct.
(slot.lower_style = 0).if {
@@ -552,7 +552,7 @@ Section Public
// BSBS: A tester sont utilité !
(! tab.is_empty).if {
semantic_error (tab.first.position,"Slot is not possible with a type C");
- };
+ };
};
(is_java).if_false {
@@ -565,12 +565,12 @@ Section Public
output_decl.add_last '\n';
} else {
genere_typedef_type_c;
- (is_late_binding).if {
+ (is_late_binding).if {
semantic_error (tab.first.position,"Late binding is not possible with a type C");
};
};
};
- } else {
+ } else {
output_decl.append "/* ";
output_decl.append intern_name;
output_decl.append " */\n";
@@ -584,24 +584,24 @@ Section Public
output_decl.append "__ ";
};
string_tmp.clear;
- (is_late_binding).if {
- id_counter_with_type.append_in output_decl;
+ (is_late_binding).if {
+ id_counter_with_type.append_in output_decl;
id_counter_with_type := id_counter_with_type + 1;
(prototype.style != '-').if {
string_tmp.append " unsigned int __id;\n";
};
- (prototype.is_mapping).if {
- semantic_error (prototype.position,
+ (prototype.is_mapping).if {
+ semantic_error (prototype.position,
"Late binding is not possible with `mapping' object.");
};
- } else {
- id_counter_without_type.append_in output_decl;
- id_counter_without_type := id_counter_without_type + 1;
+ } else {
+ id_counter_without_type.append_in output_decl;
+ id_counter_without_type := id_counter_without_type + 1;
};
(is_java).if {
output_decl.add_last ';';
};
- output_decl.add_last '\n';
+ output_decl.add_last '\n';
(prototype.style = '-').if {
string_tmp.append " lith_object thread;\n";
(param_count != 0).if {
@@ -615,21 +615,21 @@ Section Public
4.downto 0 do { j:INTEGER;
tab := slot_size.item j;
(tab.lower).to (tab.upper) do { i:INTEGER;
- slot_data := tab.item i;
+ slot_data := tab.item i;
((prototype.is_mapping) && {slot_data.type.is_expanded_c}).if {
string_tmp.append " volatile ";
} else {
- string_tmp.append " ";
+ string_tmp.append " ";
};
slot_data.genere string_tmp;
};
tab.clear;
};
-
+
(Self = type_block).if {
string_tmp.append " void *self;\n";
};
-
+
(string_tmp.is_empty).if {
string_tmp.append " void *Nothing;\n";
};
@@ -700,7 +700,7 @@ Section Public
} else {
output_decl.append "};\n";
};
- };
+ };
// Prototype declaration.
(is_java).if {
output_glob.append "private static __";
@@ -727,12 +727,12 @@ Section Public
output_glob.append intern_name;
output_glob.append "__}";
};
- output_glob.append ";\n";
+ output_glob.append ";\n";
output_glob.append "#define ";
output_glob.append intern_name;
output_glob.append "__ (&";
output_glob.append intern_name;
- output_glob.append "_)\n\n";
+ output_glob.append "_)\n\n";
};
};
};
@@ -754,7 +754,7 @@ Section Public
output_decl.append "typedef ";
output_decl.append type_c;
output_decl.append " __";
- output_decl.append intern_name;
+ output_decl.append intern_name;
output_decl.add_last ';';
output_decl.add_last '\n';
};
@@ -780,7 +780,7 @@ Section Public
output_decl.append (t.intern_name);
output_decl.append "_struct";
output_decl.append " __";
- output_decl.append intern_name;
+ output_decl.append intern_name;
output_decl.add_last ';';
(alias_slot != NULL).if {
output_decl.append " /* ALIAS with ";
@@ -948,7 +948,7 @@ Section Public
}.while_do {
(slot_run.item idx.id_section.is_inherit).if {
ts ?= slot_run.item idx.result_type;
- type_parent := ts.to_run_for Self.raw;
+ type_parent := ts.to_run_for Self.raw;
result := type_parent.is_sub_type_with_name n;
};
idx := idx + 1;
@@ -1220,7 +1220,7 @@ Section TYPE,PROTOTYPE
{slot_run.item idx.id_section.is_inherit_or_insert}
}.while_do {
ts ?= slot_run.item idx.result_type;
- type_parent := ts.to_run_for Self.raw;
+ type_parent := ts.to_run_for Self.raw;
other := type_parent.prototype.slot_list.fast_reference_at (ref.name);
(other != NULL).if {
ref.is_equal_profil other;
@@ -1243,7 +1243,7 @@ Section TYPE,PROTOTYPE
}.while_do {
s := slot_run.item idx;
ts ?= s.result_type;
- type_parent := ts.to_run_for Self.raw;
+ type_parent := ts.to_run_for Self.raw;
(type_parent = ref).if {
semantic_error (s.position,"Static cyclic inheritance.");
};
diff --git a/src/type/type_block.li b/src/type/type_block.li
index 17b707e..93e4c20 100644
--- a/src/type/type_block.li
+++ b/src/type/type_block.li
@@ -19,25 +19,25 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_BLOCK;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Virtual type for BLOCK manager";
-
+
Section Inherit
-
+
+ parent_type:Expanded TYPE;
-
-Section Private
-
+
+Section Private
+
- dico:FAST_ARRAY(TYPE_BLOCK) := FAST_ARRAY(TYPE_BLOCK).create_with_capacity 2048;
-
+
Section TYPE_BLOCK //,PROFIL_BLOCK
-
+
//
// Creation.
//
@@ -48,51 +48,51 @@ Section TYPE_BLOCK //,PROFIL_BLOCK
result.make a_list and_result r_list;
result
);
-
+
- make a_list:FAST_ARRAY(TYPE_FULL) and_result r_list:FAST_ARRAY(TYPE_FULL) <-
- (
+ (
argument_list := a_list;
result_list := r_list;
- default := TYPE_FULL.create Self with 0;
+ default := TYPE_FULL.create Self with 0;
);
-
+
Section Public
- set_late_binding <-
- (
+ (
type_block.set_late_binding;
);
-
+
- intern_name:STRING_CONSTANT <- type_block.intern_name;
-
+
- is_block:BOOLEAN := TRUE;
+ argument_list:FAST_ARRAY(TYPE_FULL);
- + result_list:FAST_ARRAY(TYPE_FULL);
-
- - get_expr_for p:POSITION :EXPR <-
+ + result_list:FAST_ARRAY(TYPE_FULL);
+
+ - get_expr_for p:POSITION :EXPR <-
( + result:EXPR;
+ lst:FAST_ARRAY(EXPR);
-
+
(result_list.count > 1).if {
lst := FAST_ARRAY(EXPR).create_with_capacity (result_list.count);
(result_list.lower).to (result_list.upper) do { j:INTEGER;
lst.add_last (result_list.item j.get_temporary_expr p);
};
result := EXPR_MULTIPLE.create lst;
- }.elseif {result_list.count = 1} then {
+ }.elseif {result_list.count = 1} then {
result := result_list.first.get_temporary_expr p;
} else {
result := PROTOTYPE_CST.create p type (TYPE_VOID.default);
};
result
- );
-
+ );
+
- get t:ITM_TYPE_BLOCK with p:PARAMETER_TO_TYPE :TYPE_FULL <-
( + a_list:FAST_ARRAY(TYPE_FULL);
+ r_list:FAST_ARRAY(TYPE_FULL);
-
- // Argument.
+
+ // Argument.
a_list := ALIAS_ARRAY(TYPE_FULL).new;
(t.type_argument != NULL).if {
t.type_argument.to_run_in a_list for p;
@@ -100,18 +100,18 @@ Section Public
a_list := ALIAS_ARRAY(TYPE_FULL).alias a_list;
// Result.
r_list := ALIAS_ARRAY(TYPE_FULL).new;
- (t.type_result != NULL).if {
+ (t.type_result != NULL).if {
t.type_result.to_run_in r_list for p;
- };
+ };
r_list := ALIAS_ARRAY(TYPE_FULL).alias r_list;
- //
+ //
get_direct a_list and_result r_list.default
);
-
+
- get_direct a_list:FAST_ARRAY(TYPE_FULL) and_result r_list:FAST_ARRAY(TYPE_FULL) :TYPE_BLOCK <-
( + idx:INTEGER;
+ result:TYPE_BLOCK;
-
+
idx := dico.lower;
{
(idx <= dico.upper) && {
@@ -120,7 +120,7 @@ Section Public
}
}.while_do {
idx := idx + 1;
- };
+ };
(idx <= dico.upper).if {
result := dico.item idx;
} else {
@@ -129,61 +129,61 @@ Section Public
};
result
);
-
+
- prototype:PROTOTYPE <- type_block.prototype;
-
+
- get_slot n:STRING_CONSTANT :SLOT <-
(
type_block.get_slot n
);
-
+
- get_local_slot n:STRING_CONSTANT :SLOT <-
(
type_block.get_local_slot n
);
-
+
- get_path_slot n:STRING_CONSTANT :SLOT <-
(
type_block.get_path_slot n
);
-
+
- genere_struct <- type_block.genere_struct;
-
+
//
// Code source generation.
//
-
+
- put_id buffer:STRING <- index.append_in buffer;
-
- - put_access_id e:EXPR in buffer:STRING <-
+
+ - put_access_id e:EXPR in buffer:STRING <-
(
buffer.append "(int)";
e.genere buffer;
);
-
- - put_value buffer:STRING <-
+
+ - put_value buffer:STRING <-
(
buffer.append "(void *)";
index.append_in buffer;
);
-
+
- is_sub_type other:TYPE :BOOLEAN <-
( + me:TYPE_BLOCK;
-
+
me ?= other;
- (me != NULL) &&
- {me.argument_list = argument_list} &&
+ (me != NULL) &&
+ {me.argument_list = argument_list} &&
{me.result_list = result_list}
);
-
+
- is_sub_type_result other:TYPE_BLOCK :BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
(result_list = other.result_list) ||
{
- (result_list != NULL) &&
- {other.result_list != NULL} &&
- {result_list.count = other.result_list.count} &&
+ (result_list != NULL) &&
+ {other.result_list != NULL} &&
+ {result_list.count = other.result_list.count} &&
{
result := TRUE;
j := result_list.lower;
@@ -195,21 +195,21 @@ Section Public
}
}
);
-
+
//
// Display.
//
-
+
- append_name_in buf:STRING <-
(
- buf.add_last '{';
+ buf.add_last '{';
(argument_list.is_empty).if_false {
(argument_list.count > 1).if {
buf.add_last '(';
(argument_list.lower).to (argument_list.upper-1) do { j:INTEGER;
argument_list.item j.display buf;
buf.add_last ',';
- };
+ };
argument_list.last.display buf;
buf.add_last ')';
} else {
@@ -217,15 +217,15 @@ Section Public
};
buf.add_last ';';
buf.add_last ' ';
- };
+ };
(result_list.is_empty).if_false {
(result_list.lower).to (result_list.upper-1) do { j:INTEGER;
result_list.item j.display buf;
buf.add_last ',';
- };
- result_list.last.display buf;
+ };
+ result_list.last.display buf;
};
- buf.add_last '}';
+ buf.add_last '}';
// Debug
buf.append "(TYPE_BLOCK)";
);
diff --git a/src/type/type_context.li b/src/type/type_context.li
index e09bcc1..67ce839 100644
--- a/src/type/type_context.li
+++ b/src/type/type_context.li
@@ -19,34 +19,34 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_CONTEXT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type Context for debug mode";
-
+
Section Inherit
-
+
+ parent_type:Expanded TYPE;
-
+
Section Public
-
+
- name:STRING_CONSTANT <- ALIAS_STR.prototype_context;
-
+
- intern_name:STRING_CONSTANT <- name;
-
+
- type_c:STRING_CONSTANT <- "_____CONTEXT";
-
+
//
// Creation.
//
-
+
- make_context <-
- (
- dico_type.fast_put Self to name;
+ (
+ dico_type.fast_put Self to name;
//slot_run := FAST_ARRAY(SLOT).create_with_capacity 1; // BSBS: Plus utile !
default := TYPE_FULL.create Self with (TYPE_FULL.expanded_bit);
);
@@ -55,10 +55,10 @@ Section Public
(
// Nothing.
);
-
+
- genere_struct <-
- (
- output_decl.append
+ (
+ output_decl.append
"/* ___CONTEXT */\n\
\typedef struct ___CONTEXT_struct _____CONTEXT; \n\
\struct ___CONTEXT_struct {\n\
@@ -67,4 +67,3 @@ Section Public
\};\n\
\_____CONTEXT *top_context; \n\n";
);
-
\ No newline at end of file
diff --git a/src/type/type_full.li b/src/type/type_full.li
index 24d0c04..8a64f61 100644
--- a/src/type/type_full.li
+++ b/src/type/type_full.li
@@ -19,44 +19,44 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_FULL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type with attribute flags.";
-
-Section Inherit
-
+
+Section Inherit
+
- parent_any:ANY := ANY;
-
-Section TYPE, TYPE_FULL // Private after fuck bug
-
+
+Section TYPE, TYPE_FULL // Private after fuck bug
+
+ the_parent_type:TYPE; // BSBS: Passer en héritage + Insert mode.
-
+
Section TYPE, TYPE_FULL
-
+
- get_with flg:UINTEGER_8 :TYPE_FULL <- the_parent_type.get_with flg;
-
-Section Public
-
+
+Section Public
+
- get_slot n:STRING_CONSTANT :SLOT <- the_parent_type.get_slot n;
-
+
- hash_code:INTEGER <- raw.name.hash_code;
-
+
- size:INTEGER <- the_parent_type.size;
-
+
- prototype:PROTOTYPE <- the_parent_type.prototype;
-
+
- is_sub_type other:TYPE_FULL :BOOLEAN <- the_parent_type.is_sub_type (other.raw);
-
+
- slot_run:FAST_ARRAY(SLOT) <- the_parent_type.slot_run;
-
+
- is_late_binding:BOOLEAN <- the_parent_type.is_late_binding;
Section TYPE
-
+
+ flag:UINTEGER_8;
// 7 6 5 4 3 2 1 0
// | | | | | +- 0:Reference / 1:Expanded
@@ -69,63 +69,63 @@ Section TYPE
//
// Creation.
//
-
+
- create typ:TYPE with code:UINTEGER_8 :SELF <-
- [
- -? {typ != NULL};
+ [
+ -? {typ != NULL};
]
( + result:SELF;
-
+
result := clone;
result.make typ with code;
- result
+ result
);
-
+
- make typ:TYPE with code:UINTEGER_8 <-
(
the_parent_type := typ;
- flag := code;
+ flag := code;
? {is_expanded -> (! is_strict)};
);
-
+
Section Public
-
+
- is_parameter_type:BOOLEAN <- FALSE;
-
+
- raw:TYPE <- the_parent_type;
-
+
//
// Set.
//
-
- - expanded_bit :UINTEGER_8 := 000001b;
- - default_expanded_bit:UINTEGER_8 := 000010b;
+
+ - expanded_bit :UINTEGER_8 := 000001b;
+ - default_expanded_bit:UINTEGER_8 := 000010b;
- strict_bit :UINTEGER_8 := 000100b;
- default_strict_bit :UINTEGER_8 := 001000b;
- expanded_ref_bit :UINTEGER_8 := 010000b;
- generic_bit :UINTEGER_8 := 100000b;
-
+
//
// Access.
//
-
+
- is_expanded :BOOLEAN <- (flag & expanded_bit ) != 0;
- is_default_expanded :BOOLEAN <- (flag & default_expanded_bit) != 0;
- is_strict :BOOLEAN <- (flag & strict_bit ) != 0;
- is_default_strict :BOOLEAN <- (flag & default_strict_bit ) != 0;
- is_expanded_ref :BOOLEAN <- (flag & expanded_ref_bit ) != 0;
- is_generic :BOOLEAN <- (flag & generic_bit ) != 0;
-
+
- is_expanded_c:BOOLEAN <- (is_expanded) && {raw.type_c != NULL};
-
- - Self:SELF '==' Right 60 other:E :BOOLEAN <-
+
+ - Self:SELF '==' Right 60 other:E :BOOLEAN <-
( + same:SELF;
- same ?= other;
+ same ?= other;
(same != NULL) && {
(Self = same) || {(raw = same.raw) && {(flag & 01111b) = (same.flag & 01111b)}}
}
);
-
+
- append_name_in buffer:STRING <-
(
(is_strict).if {
@@ -133,41 +133,41 @@ Section Public
};
(is_expanded).if {
buffer.append "Expanded ";
- };
+ };
raw.append_name_in buffer;
// buffer.append (raw.name);
);
-
+
//
// Operation.
//
-
+
- Self:SELF '+' other:UINTEGER_8 :TYPE_FULL <- get_with (flag | other);
-
+
- Self:SELF '-' other:UINTEGER_8 :TYPE_FULL <- get_with (flag & ~other);
-
+
- to_strict:TYPE_FULL <-
( + result:TYPE_FULL;
-
+
(is_expanded).if {
result := Self;
- } else {
- result := get_with (flag | strict_bit);
+ } else {
+ result := get_with (flag | strict_bit);
};
result
);
- to_no_strict:TYPE_FULL <-
( + result:TYPE_FULL;
-
+
(is_expanded).if {
result := Self;
- } else {
- result := get_with (flag & ~strict_bit);
+ } else {
+ result := get_with (flag & ~strict_bit);
};
result
);
-
+
//
// Variable product.
//
@@ -184,10 +184,10 @@ Section Public
(
LOCAL.create p name n style s type Self
);
-
+
- get_temporary_expr p:POSITION :EXPR <-
- ( + result:EXPR;
-
+ ( + result:EXPR;
+
(raw = TYPE_VOID).if {
result := PROTOTYPE_CST.create p type (TYPE_VOID.default); //BSBS: Alias.
} else {
@@ -195,11 +195,11 @@ Section Public
};
result
);
-
+
- get_temporary p:POSITION :LOCAL <-
- (
+ (
new_local p name (ALIAS_STR.variable_tmp) style '+'
- );
+ );
- get p:POSITION result n:INTEGER :LOCAL <-
( + intern:STRING_CONSTANT;
@@ -208,14 +208,14 @@ Section Public
string_tmp.add_last '_';
n.append_in string_tmp;
};
- intern := ALIAS_STR.get string_tmp;
+ intern := ALIAS_STR.get string_tmp;
new_local p name intern style '+'
- );
-
+ );
+
//
// Type Control.
//
-
+
//+----------+----------+----------+----------+
//| A := B-->| Reference| Expanded | Strict |
//| V | TYPE | TYPE | TYPE |
@@ -231,120 +231,120 @@ Section Public
//+----------+----------+----------+----------+
- affect_with other:TYPE_FULL :BOOLEAN <-
( + result:BOOLEAN;
-
+
(other == Self).if {
result := TRUE;
- } else {
+ } else {
(is_strict).if {
// A: Strict.
result := other.raw = TYPE_NULL;
}.elseif {is_expanded} then {
// A: Expanded.
- result :=
+ result :=
((other.is_strict) && {raw ~= other.raw }) ||
{(raw = type_boolean) && {other.is_sub_type Self}} ||
- {(raw = type_pointer) && {other.raw = TYPE_NULL }};
+ {(raw = type_pointer) && {other.raw = TYPE_NULL }};
} else {
// A: Reference.
- result :=
+ result :=
(
- (! other.is_expanded) ||
+ (! other.is_expanded) ||
{ + tb:TYPE_BLOCK;
- tb ?= raw;
+ tb ?= raw;
(tb != NULL)
}
- ) && {other.is_sub_type Self};
- };
+ ) && {other.is_sub_type Self};
+ };
};
result
);
-
+
//
// Import / Export manager.
//
-
+
- is_export_to t:TYPE_FULL :BOOLEAN <- raw.is_export_to t;
-
+
- is_import_to t:TYPE_FULL :BOOLEAN <- raw.is_import_to t;
-
+
//
// Default value.
//
+ recursivity_test:BOOLEAN;
- - default_value p:POSITION :EXPR <-
+ - default_value p:POSITION :EXPR <-
( + result:EXPR;
-
+
((prototype != NULL) && {prototype.default_value != NULL}).if {
- // Prototype User definition.
+ // Prototype User definition.
(recursivity_test).if {
crash;
- POSITION.put_error semantic text
+ POSITION.put_error semantic text
"Recursivity without end (default used default, ...).";
list_current.position.put_position;
prototype.default_value.position.put_position;
- POSITION.send_error;
+ POSITION.send_error;
} else {
recursivity_test := TRUE;
result := prototype.default_value.to_run_expr;
recursivity_test := FALSE;
};
} else {
- (is_expanded).if {
+ (is_expanded).if {
// Copy of model prototype.
result := PROTOTYPE_CST.create p type Self;
} else {
result := PROTOTYPE_CST.create p type (TYPE_NULL.default);
- };
+ };
};
-
+
result
);
-
+
//
// Declaration generation.
//
-
+
- genere_declaration buffer:STRING <-
- (
- (is_expanded).if {
+ (
+ (is_expanded).if {
raw.put_expanded_declaration buffer;
}.elseif {is_strict} then {
raw.put_reference_declaration buffer;
- } else {
- raw.put_generic_declaration buffer;
+ } else {
+ raw.put_generic_declaration buffer;
};
);
-
+
- genere_star_declaration buffer:STRING <-
- (
- ((! is_expanded) || {is_expanded_ref}).if {
- raw.put_reference_star_declaration buffer;
+ (
+ ((! is_expanded) || {is_expanded_ref}).if {
+ raw.put_reference_star_declaration buffer;
};
);
-
+
//
// Generation code.
//
-
+
- genere_value buffer:STRING <-
( + tb:PROFIL_BLOCK;
(
- (is_expanded) && {! is_expanded_ref} &&
+ (is_expanded) && {! is_expanded_ref} &&
{raw != type_true} && {raw != type_false} &&
{tb ?= raw; tb = NULL}
).if {
buffer.append "(*";
raw.put_value buffer;
- buffer.add_last ')';
+ buffer.add_last ')';
} else {
raw.put_value buffer;
};
);
-
+
//
// Display.
//
-
+
- display buf:STRING <-
(
(is_generic).if {
@@ -352,14 +352,14 @@ Section Public
};
append_name_in buf;
);
-
+
- print <-
(
string_tmp.clear;
display string_tmp;
string_tmp.print;
);
-
+
- print_full <-
(
string_tmp.clear;
@@ -388,4 +388,4 @@ Section Public
//
string_tmp.print;
);
-
+
diff --git a/src/type/type_generic.li b/src/type/type_generic.li
index 41d503c..3ae0508 100644
--- a/src/type/type_generic.li
+++ b/src/type/type_generic.li
@@ -19,40 +19,40 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_GENERIC;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Type generic";
-
+
Section Inherit
-
+
+ parent_type:Expanded TYPE;
-
-Section Private
-
+
+Section Private
+
// BSBS: Vu que les ITM_TYPE sont aliaser, il n'est pas necessary d'aliaser les TYPE !
// Mais attention au pb des TYPE_GENERIC et de leur alias de slot_run...
-
- - dicog_type:HASHED_DICTIONARY(TYPE_GENERIC,STRING_CONSTANT) :=
+
+ - dicog_type:HASHED_DICTIONARY(TYPE_GENERIC,STRING_CONSTANT) :=
HASHED_DICTIONARY(TYPE_GENERIC,STRING_CONSTANT).create;
-
+
Section Public
-
+
+ name:STRING_CONSTANT;
-
+
+ key:STRING_CONSTANT;
-
- + generic_list:FAST_ARRAY(TYPE_FULL);
-
+
+ + generic_list:FAST_ARRAY(TYPE_FULL);
+
- parameter_to_type p:ITM_TYPE_PARAMETER :TYPE_FULL <-
( + idx:INTEGER;
+ tab:FAST_ARRAY(ITM_TYPE_PARAMETER);
+ result:TYPE_FULL;
-
+
tab := prototype.idf_generic_list;
idx := tab.fast_first_index_of p;
(idx <= tab.upper).if {
@@ -60,75 +60,75 @@ Section Public
};
result
);
-
+
//
// Detect Alias.
- //
-
+ //
+
- detect_alias <-
(
(dicog_type.lower).to (dicog_type.upper) do { j:INTEGER;
dicog_type.item j.detect_alias_struct;
- };
+ };
);
-
+
//
// Import / Export
//
-
+
- is_export_to t:TYPE_FULL :BOOLEAN <-
- (
+ (
is_cast t with (ALIAS_STR.slot_to) on export_list and (prototype.import_list)
);
- is_import_to t:TYPE_FULL :BOOLEAN <-
- (
+ (
is_cast t with (ALIAS_STR.slot_from) on import_list and (prototype.import_list)
);
-
+
Section Private
-
+
+ export_list:FAST_ARRAY(TYPE_FULL);
+ import_list:FAST_ARRAY(TYPE_FULL);
-
- - is_cast t:TYPE_FULL with msg:STRING_CONSTANT
- on lst:FAST_ARRAY(TYPE_FULL)
+
+ - is_cast t:TYPE_FULL with msg:STRING_CONSTANT
+ on lst:FAST_ARRAY(TYPE_FULL)
and lstp:FAST_ARRAY(ITM_TYPE_MONO) :BOOLEAN <-
- ( + result:BOOLEAN;
+ ( + result:BOOLEAN;
+ j:INTEGER;
-
+
(lst != NULL).if {
- j := lst.fast_first_index_of t;
+ j := lst.fast_first_index_of t;
(j <= lst.upper).if {
result := TRUE;
last_cast_name.copy msg;
- lstp.item j.append_cast_name_in last_cast_name;
- };
+ lstp.item j.append_cast_name_in last_cast_name;
+ };
};
- result
+ result
);
-
+
Section Public
-
+
//
// Get
//
-
- - get itm_typ:ITM_TYPE_SIMPLE :TYPE_FULL <-
+
+ - get itm_typ:ITM_TYPE_SIMPLE :TYPE_FULL <-
(
crash_with_message "`get' in TYPE_GENERIC !";
NULL
);
-
+
- get (path:STRING_CONSTANT,itm_typ:ITM_TYPE_SIMPLE) with gen:FAST_ARRAY(TYPE_FULL) :TYPE_FULL <-
- ( + base:TYPE_GENERIC;
+ ( + base:TYPE_GENERIC;
+ result,t:TYPE_FULL;
+ styl,k:STRING_CONSTANT;
+ proto:PROTOTYPE;
-
- proto := load_prototype (path,itm_typ.name) generic_count (gen.count);
- string_tmp.copy (proto.filename);
+
+ proto := load_prototype (path,itm_typ.name) generic_count (gen.count);
+ string_tmp.copy (proto.filename);
(gen.lower).to (gen.upper) do { j:INTEGER;
string_tmp.add_last ' ';
t := gen.item j;
@@ -139,22 +139,22 @@ Section Public
k := ALIAS_STR.get string_tmp;
//
base := dicog_type.fast_reference_at k;
- (base = NULL).if {
+ (base = NULL).if {
base := TYPE_GENERIC.clone;
dicog_type.fast_put base to k;
base.make itm_typ with proto generic gen key k;
};
- //
+ //
styl := itm_typ.style;
- (styl = NULL).if {
+ (styl = NULL).if {
result := base.default;
} else {
- (styl = ALIAS_STR.keyword_expanded).if {
- result := base.default + TYPE_FULL.expanded_bit;
- } else {
+ (styl = ALIAS_STR.keyword_expanded).if {
+ result := base.default + TYPE_FULL.expanded_bit;
+ } else {
result := base.default + TYPE_FULL.strict_bit;
};
- };
+ };
result
);
@@ -163,44 +163,44 @@ Section Public
// BSBS: A revoir : il n'y a que NATIVE_ARRAY qui a besoin de ca,
// il faudrai plutot stocker ca ailleurs... ou? chépa!
//
-
+
+ put_to_list:FAST_ARRAY(PUT_TO);
-
+
- add_put_to n:PUT_TO <-
- (
+ (
(put_to_list = NULL).if {
put_to_list := FAST_ARRAY(PUT_TO).create_with_capacity 16;
};
put_to_list.add_last n;
);
-
+
- remove_put_to n:PUT_TO <-
( + idx:INTEGER;
-
- idx := put_to_list.fast_first_index_of n;
+
+ idx := put_to_list.fast_first_index_of n;
put_to_list.swap idx with (put_to_list.upper);
put_to_list.remove_last;
);
-
+
+ recursive_test:BOOLEAN;
-
+
+ old_type:TYPES;
-
+
- get_type t:TYPES_TMP <-
( + typ:TYPE_FULL;
+ tmp_type:TYPES_TMP;
-
+
typ := generic_list.first;
- (typ.is_expanded && {typ.raw != type_boolean}).if {
+ (typ.is_expanded && {typ.raw != type_boolean}).if {
t.add (typ.raw);
- } else {
+ } else {
(put_to_list != NULL).if {
- (! recursive_test).if {
+ (! recursive_test).if {
recursive_test := TRUE;
tmp_type := TYPES_TMP.new;
(put_to_list.lower).to (put_to_list.upper) do { j:INTEGER;
put_to_list.item j.value.get_type tmp_type;
- };
+ };
old_type := tmp_type.update old_type;
recursive_test := FALSE;
};
@@ -208,14 +208,14 @@ Section Public
};
};
);
-
+
//
// Declaration generation.
//
-
+
- put_reference_declaration buffer:STRING <-
- (
- (prototype.name = ALIAS_STR.prototype_native_array).if {
+ (
+ (prototype.name = ALIAS_STR.prototype_native_array).if {
generic_list.first.genere_declaration buffer;
}.elseif {prototype.name = ALIAS_STR.prototype_native_array_volatile} then {
buffer.append "volatile ";
@@ -224,13 +224,13 @@ Section Public
parent_type.put_reference_declaration buffer;
};
);
-
+
- put_reference_star_declaration buffer:STRING <-
- (
+ (
(
(prototype.name = ALIAS_STR.prototype_native_array) ||
{prototype.name = ALIAS_STR.prototype_native_array_volatile}
- ).if {
+ ).if {
(is_java).if {
buffer.append "[]";
} else {
@@ -241,29 +241,29 @@ Section Public
parent_type.put_reference_star_declaration buffer;
};
);
-
-Section Public
-
+
+Section Public
+
- make itm_typ:ITM_TYPE_SIMPLE <-
(
crash_with_message "TYPE_GENERIC.make";
);
- - make itm_typ:ITM_TYPE_SIMPLE with proto:PROTOTYPE
+ - make itm_typ:ITM_TYPE_SIMPLE with proto:PROTOTYPE
generic gen:FAST_ARRAY(TYPE_FULL) key k:STRING_CONSTANT <-
- ( + mask_bit:UINTEGER_8;
-
+ ( + mask_bit:UINTEGER_8;
+
index := index_count;
index_count := index_count + 1;
//
string_tmp.copy (itm_typ.name);
- string_tmp.add_last '(';
- (gen.lower).to (gen.upper - 1) do { j:INTEGER;
+ string_tmp.add_last '(';
+ (gen.lower).to (gen.upper - 1) do { j:INTEGER;
gen.item j.append_name_in string_tmp;
string_tmp.add_last ',';
- };
+ };
gen.last.append_name_in string_tmp;
- string_tmp.add_last ')';
+ string_tmp.add_last ')';
name := ALIAS_STR.get string_tmp;
key := k;
generic_list := gen;
@@ -276,8 +276,8 @@ Section Public
intern_name := ALIAS_STR.get_intern string_tmp;
//
prototype := proto;
- itm_type := itm_typ;
- slot_run := FAST_ARRAY(SLOT).create_with_capacity 10; // BSBS: A voir.
+ itm_type := itm_typ;
+ slot_run := FAST_ARRAY(SLOT).create_with_capacity 10; // BSBS: A voir.
(prototype.type_style = ALIAS_STR.keyword_expanded).if {
// Expanded.
mask_bit := TYPE_FULL.expanded_bit | TYPE_FULL.default_expanded_bit;
@@ -286,13 +286,13 @@ Section Public
mask_bit := TYPE_FULL.strict_bit | TYPE_FULL.default_strict_bit;
};
default := TYPE_FULL.create Self with mask_bit;
- prototype.init_slot_for Self;
+ prototype.init_slot_for Self;
//
subtype_list := HASHED_SET(TYPE).create;
subtype_list.fast_add TYPE_NULL;
add_subtype Self;
// BSBS: Size ???
-
+
// Import / Export.
(prototype.export_list != NULL).if {
export_list := FAST_ARRAY(TYPE_FULL).create_with_capacity (prototype.export_list.count);
@@ -308,4 +308,3 @@ Section Public
};
);
-
\ No newline at end of file
diff --git a/src/type/type_id.li b/src/type/type_id.li
index ef7835b..11ebede 100644
--- a/src/type/type_id.li
+++ b/src/type/type_id.li
@@ -19,86 +19,86 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_ID;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Virtual type style slot segregation";
-
+
Section Inherit
-
+
+ parent_type:Expanded TYPE;
-
-Section Private
-
+
+Section Private
+
- list_id:FAST_ARRAY(TYPE_ID);
-
+
- create i:INTEGER :SELF <-
( + result:SELF;
-
+
result := clone;
result.make i;
result
);
-
+
- make i:INTEGER <-
(
index := i;
default := TYPE_FULL.create Self with 0;
);
-
-Section Public
-
+
+Section Public
+
- name:STRING_CONSTANT <- ALIAS_STR.prototype_type_id;
-
+
- intern_name:STRING_CONSTANT <- name;
-
+
- get_index idx:INTEGER :TYPE_ID <-
( + result:TYPE_ID;
-
+
(idx > list_id.upper).if {
result := TYPE_ID.create idx;
list_id.add_last result;
? {list_id.upper = idx};
} else {
result := list_id.item idx;
- };
+ };
result
);
- - make_type_id <-
- (
+ - make_type_id <-
+ (
list_id := FAST_ARRAY(TYPE_ID).create_with_capacity 3;
list_id.add_last (create 0);
list_id.add_last (create 1);
);
-
+
- add_genere_list; // Nothing.
-
+
- genere_struct; // Nothing.
- - is_sub_type other:TYPE :BOOLEAN <-
- (
+ - is_sub_type other:TYPE :BOOLEAN <-
+ (
other.name = name
);
-
+
//
// Declaration generation.
//
-
+
- put_generic_declaration buffer:STRING <- buffer.append "int";
-
+
- put_reference_star_declaration buffer:STRING; // Nothing.
-
+
//
// Code source generation.
//
-
+
- put_id buffer:STRING <- index.append_in buffer;
-
+
- put_access_id e:EXPR in buffer:STRING <- e.genere buffer;
-
+
- put_value buffer:STRING <- index.append_in buffer;
\ No newline at end of file
diff --git a/src/type/type_null.li b/src/type/type_null.li
index 4a511ab..f290378 100644
--- a/src/type/type_null.li
+++ b/src/type/type_null.li
@@ -19,106 +19,105 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_NULL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Special type NULL";
-
+
Section Inherit
-
+
+ parent_type:Expanded TYPE;
-
+
Section Public
-
+
- name:STRING_CONSTANT <- ALIAS_STR.variable_null;
-
+
- intern_name:STRING_CONSTANT <- name;
-
+
//
// Creation.
//
- make_null <-
- (
+ (
index := index_count;
index_count := index_count + 1;
- dico_type.fast_put Self to name;
+ dico_type.fast_put Self to name;
slot_run := FAST_ARRAY(SLOT).create_with_capacity 1; // BSBS: Plus utile !
default := TYPE_FULL.create Self with 0;
);
-
- - get_local_slot n:STRING_CONSTANT :SLOT <- NULL;
-
+
+ - get_local_slot n:STRING_CONSTANT :SLOT <- NULL;
+
- get_path_slot n:STRING_CONSTANT :SLOT <- NULL;
-
+
//
// Error.
//
-
+
//- bug:INTEGER;
-
+
- product_error p:POSITION in lst:LIST with ctext:LOCAL <-
- (
- (debug_level_option != 0).if {
+ (
+ (debug_level_option != 0).if {
lst.add_last (
PUSH.create p context ctext first FALSE
- );
- };
- lst.add_last CALL_NULL;
+ );
+ };
+ lst.add_last CALL_NULL;
);
-
+
Section Public
-
+
//
// Import / Export
//
-
+
- is_export_to t:TYPE_FULL :BOOLEAN <- FALSE;
- is_import_to t:TYPE_FULL :BOOLEAN <- FALSE;
-
+
//
//
//
-
- - is_sub_type other:TYPE :BOOLEAN <- TRUE;
-
+
+ - is_sub_type other:TYPE :BOOLEAN <- TRUE;
+
- genere_typedef <-
(
);
-
+
- genere_struct <-
(
(is_java).if_false {
- output_decl.append
+ output_decl.append
"/* NULL */\n\
\#ifndef NULL\n\
\#define NULL ((void *)0)\n\
\#endif\n\n";
};
);
-
+
//
// Code source generation.
//
-
- - put_id buffer:STRING <-
+
+ - put_id buffer:STRING <-
(
put_value buffer;
);
-
- - put_access_id e:EXPR in buffer:STRING <- e.genere buffer;
-
- - put_value buffer:STRING <-
- (
+
+ - put_access_id e:EXPR in buffer:STRING <- e.genere buffer;
+
+ - put_value buffer:STRING <-
+ (
(is_java).if {
buffer.append "null";
} else {
buffer.append name;
};
);
-
\ No newline at end of file
diff --git a/src/type/type_void.li b/src/type/type_void.li
index 556a828..1202e3f 100644
--- a/src/type/type_void.li
+++ b/src/type/type_void.li
@@ -19,43 +19,43 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := TYPE_VOID;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Special virtual Void type";
-
+
Section Inherit
-
+
+ parent_type:Expanded TYPE;
-
+
Section Public
-
+
- name:STRING_CONSTANT <- ALIAS_STR.variable_void;
-
- - intern_name:STRING_CONSTANT <- name;
-
+
+ - intern_name:STRING_CONSTANT <- name;
+
//
// Creation.
//
-
+
- make_void <-
- (
- dico_type.fast_put Self to name;
+ (
+ dico_type.fast_put Self to name;
default := TYPE_FULL.create Self with 0;
);
-
+
//
// Import / Export
//
-
+
- is_export_to t:TYPE_FULL :BOOLEAN <- FALSE;
- is_import_to t:TYPE_FULL :BOOLEAN <- FALSE;
-
+
//
// Genere.
//
@@ -64,13 +64,13 @@ Section Public
(
// Nothing.
);
-
+
- genere_struct <-
(
// Nothing.
);
-
+
Section Public
-
- - is_sub_type other:TYPE :BOOLEAN <- FALSE;
+
+ - is_sub_type other:TYPE :BOOLEAN <- FALSE;
diff --git a/src/variable/argument.li b/src/variable/argument.li
index e054ab3..08af734 100644
--- a/src/variable/argument.li
+++ b/src/variable/argument.li
@@ -19,64 +19,63 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := ARGUMENT;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Argument runnable";
-
+
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
-
+
Section Public
-
+
+ name:STRING_CONSTANT;
-
+
+ type:TYPE_FULL;
-
+
//
// Creation.
//
-
+
- create p:POSITION name n:STRING_CONSTANT type t:TYPE_FULL :SELF <-
( + result:SELF;
-
+
result := clone;
result.make p name n type t;
result
);
-
+
- make p:POSITION name n:STRING_CONSTANT type t:TYPE_FULL <-
(
position := p;
name := n;
type := t;
);
-
+
//
// To profil
//
-
+
- to_local:LOCAL <-
(
LOCAL.create position name name style ' ' type (type.fix)
);
-
+
//
// Display.
//
-
+
- print <-
- (
+ (
string_tmp.clear;
string_tmp.append name;
string_tmp.add_last ':';
type.append_name_in string_tmp;
string_tmp.print;
);
-
-
\ No newline at end of file
+
diff --git a/src/variable/local.li b/src/variable/local.li
index c45b623..ae088f4 100644
--- a/src/variable/local.li
+++ b/src/variable/local.li
@@ -19,41 +19,41 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LOCAL;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Local slot";
-
+
Section Inherit
-
+
+ parent_variable:Expanded VARIABLE;
-
-Section Public
-
+
+Section Public
+
// BSBS: Doit pas etre utile.
-
+
+ is_result :BOOLEAN := FALSE;
- - set_result r:BOOLEAN <-
+ - set_result r:BOOLEAN <-
(
is_result := r;
);
-
+
//
// Copy alias manager.
//
-
+
- is_alias:BOOLEAN;
-
- - alias_on <-
+
+ - alias_on <-
(
is_alias := TRUE;
);
-
+
- alias_off <-
(
(list_alias.lower).to (list_alias.upper) do { j:INTEGER;
@@ -62,37 +62,37 @@ Section Public
list_alias.clear;
is_alias := FALSE;
);
-
+
- list_alias:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create_with_capacity 64;
-
+
- get_alias:LOCAL <-
(
(my_alias = NULL).if {
my_alias := my_copy;
my_alias.set_type_list type_list;
- list_alias.add_last Self;
+ list_alias.add_last Self;
};
my_alias
);
-
+
+ my_alias:LOCAL;
-
+
- set_my_alias new_loc:LOCAL <-
(
my_alias := new_loc;
);
-
+
+ list_level:INTEGER;
-
+
- set_list_level lev:INTEGER <-
(
list_level := lev;
);
-
+
- write p:POSITION with r:EXPR value val:EXPR :WRITE <-
( + result:WRITE;
-
- (my_alias != NULL).if {
+
+ (my_alias != NULL).if {
result := my_alias.write_direct p with NULL value val;
}.elseif {is_alias} then {
result := get_alias.write_direct p with NULL value val;
@@ -101,42 +101,42 @@ Section Public
};
result
);
-
+
- read p:POSITION with r:EXPR :READ <-
( + result:READ;
-
- (my_alias != NULL).if {
+
+ (my_alias != NULL).if {
result := my_alias.read_direct p with NULL;
- }.elseif {is_alias} then {
+ }.elseif {is_alias} then {
// Case : Argument function (see CALL_SLOT)
- result := get_alias.read_direct p with NULL;
+ result := get_alias.read_direct p with NULL;
} else {
//? {! is_alias};
result := read_direct p with NULL;
- };
+ };
result
);
-
+
//
// Sequence optimizer
//
-
+
+ last_seq:LOCAL_SEQ;
-
+
- reset_last_write w:WRITE <-
- (
+ (
((last_seq != NULL) && {last_seq.last_write = w}).if {
last_seq.set_last_write NULL;
};
);
-
+
- set_last_seq s:LOCAL_SEQ <-
(
last_seq := s;
);
-
+
- set_write w:WRITE <-
- (
+ (
(last_seq = NULL).if {
LOCAL_SEQ.new Self;
//"LOCAL:".print;
@@ -145,30 +145,30 @@ Section Public
(
(! PROFIL.mode_recursive) &&
{loop_invariant = NULL} &&
- {last_seq.last_write != NULL} &&
+ {last_seq.last_write != NULL} &&
{last_seq.last_index != -1} &&
{last_seq.last_list_current = list_current} &&
{last_seq.last_index < list_current.index} &&
{last_seq.last_seq_call_local_and_loop = seq_call_local_and_loop} &&
{list_current.item (last_seq.last_index) = last_seq.last_write} // BSBS: Voir pourquoi pas tjrs le cas
- ).if {
+ ).if {
list_current.put (last_seq.last_write.value) to (last_seq.last_index);
- unwrite (last_seq.last_write);
+ unwrite (last_seq.last_write);
new_execute_pass;
- };
+ };
// Save context
last_seq.set_seq w;
);
-
+
- set_read <-
(
(last_seq != NULL).if {
last_seq.set_last_index (-1);
};
);
-
+
- get_last_index:INTEGER <- last_seq.last_index;
-
+
- is_invariant:BOOLEAN <-
(
(loop_seq_call_local_and_loop = seq_call_local_and_loop) &&
@@ -179,7 +179,7 @@ Section Public
) || {style = ' '}
}
);
-
+
- get_last_value rec:EXPR :EXPR <-
[
? {rec = NULL};
@@ -191,7 +191,7 @@ Section Public
+ g:SLOT_DATA;
/*
+ bug:BOOLEAN;
-
+
(intern_name == "__tmp__TC").if {
bug:=TRUE;
"0\n".print;
@@ -204,13 +204,13 @@ Section Public
};
};
};
- */
-
-
+ */
+
+
(
- (! PROFIL.mode_recursive) && {loop_invariant = NULL} &&
+ (! PROFIL.mode_recursive) && {loop_invariant = NULL} &&
{last_seq != NULL} && {last_seq.last_write != NULL}
- ).if {
+ ).if {
/*
(bug).if {
"1\n".print;
@@ -231,77 +231,77 @@ Section Public
};
(
( // Constant propagation.
- val.is_constant
- ) ||
+ val.is_constant
+ ) ||
{ // Local propagation.
(l != NULL) && {
(
- (l.last_seq != NULL) && {l.last_seq.last_write != NULL} &&
- {l.last_seq.last_seq_index < last_seq.last_seq_index} &&
- {last_seq.last_seq_call_local_and_loop = seq_call_local_and_loop}
+ (l.last_seq != NULL) && {l.last_seq.last_write != NULL} &&
+ {l.last_seq.last_seq_index < last_seq.last_seq_index} &&
+ {last_seq.last_seq_call_local_and_loop = seq_call_local_and_loop}
) || {l.require_count <= 1} || {l.style = ' '}
}
} ||
{ // Global propagation.
(g != NULL) && {g.style = '-'} && {
- (
- (g.last_write != NULL) && {g.last_seq_index < last_seq.last_seq_index} &&
- {last_seq.last_seq_call_and_loop = seq_call_and_loop} &&
+ (
+ (g.last_write != NULL) && {g.last_seq_index < last_seq.last_seq_index} &&
+ {last_seq.last_seq_call_and_loop = seq_call_and_loop} &&
{is_seq_list (g.last_list_current)}
) || {g.require_count = 1}
}
}
- ).if {
+ ).if {
result := val.my_copy;
}.elseif {
// Propagation step by step.
(last_seq.last_seq_or_and = seq_or_and) &&
{ensure_count = 1} &&
- {list_current.index > list_current.lower} &&
- {list_current.item (list_current.index - 1) = last_seq.last_write}
- } then {
+ {list_current.index > list_current.lower} &&
+ {list_current.item (list_current.index - 1) = last_seq.last_write}
+ } then {
unwrite (last_seq.last_write);
last_seq.set_last_write NULL;
- list_current.put NOP to (list_current.index - 1);
+ list_current.put NOP to (list_current.index - 1);
result := val;
};
- };
+ };
};
result
);
-
+
- set_type_list t:TYPES <-
(
type_list := t;
);
-
+
//
//
//
-
+
- is_local:BOOLEAN <- TRUE;
-
+
//
// Creation.
//
-
- - create p:POSITION name n:STRING_CONSTANT
+
+ - create p:POSITION name n:STRING_CONSTANT
style c:CHARACTER type t:TYPE_FULL result r:BOOLEAN :SELF<-
( + result:SELF;
- result := clone;
+ result := clone;
result.make p name n style c type t result r;
result
);
-
- - create p:POSITION name n:STRING_CONSTANT
+
+ - create p:POSITION name n:STRING_CONSTANT
style c:CHARACTER type t:TYPE_FULL :SELF<-
( + result:SELF;
- result := clone;
+ result := clone;
result.make p name n style c type t result FALSE;
result
);
-
- - make p:POSITION name n:STRING_CONSTANT
+
+ - make p:POSITION name n:STRING_CONSTANT
style c:CHARACTER type t:TYPE_FULL result r:BOOLEAN <-
( + tmp:TYPES_TMP;
? {p.code != 0};
@@ -310,75 +310,75 @@ Section Public
position := p;
name := n;
is_result := r;
- intern_name := ALIAS_STR.get_intern n;
-
+ intern_name := ALIAS_STR.get_intern n;
+
((t.is_expanded) && {! t.is_expanded_c}).if {
type := t + TYPE_FULL.expanded_ref_bit;
} else {
type := t;
};
style := c;
-
- (is_static).if {
- tmp := TYPES_TMP.new;
- tmp.add (t.raw);
- type_list := tmp.to_types;
+
+ (is_static).if {
+ tmp := TYPES_TMP.new;
+ tmp.add (t.raw);
+ type_list := tmp.to_types;
} else {
type_list := TYPES_TMP.types_empty;
- };
+ };
);
-
+
- my_copy:LOCAL <-
( + result:LOCAL;
-
+
result := LOCAL.create position name name style style type type;
result
);
-
+
//
// Value.
//
- init <-
( + val:EXPR;
- + i:INSTR;
- + int:INTEGER_CST;
-
- val := type.default_value position;
- (ALIAS_STR.is_integer (type.raw.name)).if {
+ + i:INSTR;
+ + int:INTEGER_CST;
+
+ val := type.default_value position;
+ (ALIAS_STR.is_integer (type.raw.name)).if {
int ?= val;
- (int != NULL).if {
+ (int != NULL).if {
int.cast_type type;
- };
+ };
} else {
val := val.check_type type with position;
};
i := write position value val;
- list_current.add_last i;
+ list_current.add_last i;
);
-
+
- set_intern_name n:STRING_CONSTANT <-
(
intern_name := n;
);
-
+
Section VARIABLE
-
- - new_read p:POSITION with r:EXPR :READ <-
+
+ - new_read p:POSITION with r:EXPR :READ <-
[ -? {r = NULL}; ]
- (
+ (
READ_LOCAL.create p with Self
);
-
+
- new_write p:POSITION with r:EXPR value v:EXPR :WRITE <-
[ -? {r = NULL}; ]
( + result:WRITE;
- result := WRITE_LOCAL.create p with v in Self;
- result
+ result := WRITE_LOCAL.create p with v in Self;
+ result
);
-
+
/*
- - new_access r:EXPR :ACCESS <-
+ - new_access r:EXPR :ACCESS <-
(
ACCESS_LOCAL.create Self
);
diff --git a/src/variable/local_seq.li b/src/variable/local_seq.li
index 5901e36..2f0cfa1 100644
--- a/src/variable/local_seq.li
+++ b/src/variable/local_seq.li
@@ -19,54 +19,54 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := LOCAL_SEQ;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Local slot";
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Private
-
+
- list_busy:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create_with_capacity 512;
-
+
- list_free:FAST_ARRAY(LOCAL_SEQ) := FAST_ARRAY(LOCAL_SEQ).create_with_capacity 512;
-
+
- clean <-
(
last_write := NULL;
);
-
-Section Public
-
+
+Section Public
+
+ last_write:WRITE;
+ last_seq_index:UINTEGER_32;
+ last_seq_or_and:UINTEGER_32;
- + last_seq_call_and_loop:UINTEGER_32;
+ + last_seq_call_and_loop:UINTEGER_32;
+ last_seq_call_local_and_loop:UINTEGER_32;
-
+
+ last_list_current:LIST;
+ last_index:INTEGER;
-
+
- set_last_write w:WRITE <-
(
last_write := w;
);
-
+
- set_last_index i:INTEGER <-
(
last_index := i;
);
-
+
- new l:LOCAL <-
( + result:LOCAL_SEQ;
-
+
(list_free.is_empty).if {
result := clone;
} else {
@@ -77,7 +77,7 @@ Section Public
list_busy.add_last l;
l.set_last_seq result;
);
-
+
- set_seq w:WRITE <-
(
// Save context
@@ -85,18 +85,18 @@ Section Public
last_seq_index := seq_index;
last_seq_or_and := seq_or_and;
last_seq_call_and_loop := seq_call_and_loop;
- last_seq_call_local_and_loop:= seq_call_local_and_loop;
+ last_seq_call_local_and_loop:= seq_call_local_and_loop;
//
last_list_current := list_current;
- last_index := list_current.index;
+ last_index := list_current.index;
);
-
+
- clear <-
( + l:LOCAL;
-
+
(list_busy.upper).downto (list_busy.lower) do { j:INTEGER;
l := list_busy.item j;
- list_free.add_last (l.last_seq);
+ list_free.add_last (l.last_seq);
l.set_last_seq NULL;
};
list_busy.clear;
diff --git a/src/variable/named.li b/src/variable/named.li
index b6653a4..b7d2127 100644
--- a/src/variable/named.li
+++ b/src/variable/named.li
@@ -19,42 +19,42 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := NAMED;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Parent for all slot";
-
+
Section Inherit
-
+
+ parent_itm_object:Expanded ITM_OBJECT;
-
+
Section Public
//
// Data.
//
- + style:CHARACTER; // '+': Clonable,
+ + style:CHARACTER; // '+': Clonable,
// '-': Shared.
// ' ': Argument
// 'T': Temporary
// 'C': Cast
-
+
+ name:STRING_CONSTANT;
- set_style s:CHARACTER <-
(
style := s;
);
-
+
//
// Hashable.
//
-
+
- hash_code: INTEGER <- name.hash_code;
diff --git a/src/variable/section_.li b/src/variable/section_.li
index 4d79f5d..53158f4 100644
--- a/src/variable/section_.li
+++ b/src/variable/section_.li
@@ -19,32 +19,32 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SECTION_;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Test Section protection";
-
+
Section Inherit
-
+
- parent_any:ANY := ANY;
-
+
Section Public
+ name:STRING_CONSTANT;
-
+
+ type_list:FAST_ARRAY(ITM_TYPE_MONO);
-
+
//
// Creation.
- //
+ //
- get_name n:STRING_CONSTANT :SECTION_ <-
( + result:SECTION_;
-
+
result := bucket_name.fast_reference_at n;
(result = NULL).if {
result := clone;
@@ -53,101 +53,101 @@ Section Public
};
result
);
-
+
- get_type_list l:FAST_ARRAY(ITM_TYPE_MONO) :SECTION_ <-
( + result:SECTION_;
-
+
result := bucket_list.fast_reference_at l;
(result = NULL).if {
result := clone;
result.make NULL list l;
bucket_list.fast_put result to l;
};
- result
+ result
);
-
+
//
// Consultation
//
-
+
- is_mapping:BOOLEAN <- name = ALIAS_STR.section_mapping;
-
+
- is_private:BOOLEAN <- name = ALIAS_STR.section_private;
-
+
- is_public:BOOLEAN <- name = ALIAS_STR.section_public;
-
+
- is_header:BOOLEAN <- name = ALIAS_STR.section_header;
-
+
- is_inherit:BOOLEAN <- name = ALIAS_STR.section_inherit;
-
+
- is_insert:BOOLEAN <- name = ALIAS_STR.section_insert;
-
+
- is_inherit_or_insert:BOOLEAN <- (is_inherit) || {is_insert};
-
+
- is_interrupt:BOOLEAN <- name = ALIAS_STR.section_interrupt;
- is_directory:BOOLEAN <- name = ALIAS_STR.section_directory;
-
+
- is_external:BOOLEAN <- name = ALIAS_STR.section_external;
-
+
- is_private_style:BOOLEAN <-
(
? {! is_header};
(! is_public) && {type_list = NULL}
);
-
+
//
// Display.
//
-
+
- append_in buf:STRING <-
- (
+ (
(name != NULL).if {
buf.append name;
} else {
(type_list.lower).to (type_list.upper - 1) do { j:INTEGER;
type_list.item j.append_in buf;
buf.add_last ',';
- buf.add_last ' ';
- };
+ buf.add_last ' ';
+ };
type_list.last.append_in buf;
};
);
-
+
//
// Access test.
//
-
+
- access me:TYPE with client:TYPE :BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
+ ts:ITM_TYPE_SIMPLE;
? {! is_header};
-
+
((me = client) || {is_public} || {is_external}).if {
result := TRUE;
}.elseif {is_directory} then {
string_tmp.copy (me.prototype.filename);
j := string_tmp.last_index_of '/';
- string_tmp.keep_head j;
+ string_tmp.keep_head j;
result := client.prototype.filename.has_prefix string_tmp;
}.elseif {type_list != NULL} then {
j := type_list.lower;
{(j <= type_list.upper) && {! result}}.while_do {
ts ?= type_list.item j;
- result := client.is_sub_type_with_name (ts.name);
+ result := client.is_sub_type_with_name (ts.name);
j := j + 1;
};
};
result
);
-
+
Section Public
-
+
- hash_code:INTEGER <-
( + result:INTEGER;
-
- (name != NULL).if {
+
+ (name != NULL).if {
result := name.hash_code;
} else {
result := type_list.hash_code;
@@ -156,18 +156,17 @@ Section Public
);
Section SECTION_
-
+
// BSBS: Tu devrais créer deux sous-proto section_name, section_list.
-
- - bucket_name:HASHED_DICTIONARY(SECTION_,STRING_CONSTANT) :=
+
+ - bucket_name:HASHED_DICTIONARY(SECTION_,STRING_CONSTANT) :=
HASHED_DICTIONARY(SECTION_,STRING_CONSTANT).create;
-
- - bucket_list:HASHED_DICTIONARY(SECTION_,FAST_ARRAY(ITM_TYPE_MONO)) :=
+
+ - bucket_list:HASHED_DICTIONARY(SECTION_,FAST_ARRAY(ITM_TYPE_MONO)) :=
HASHED_DICTIONARY(SECTION_,FAST_ARRAY(ITM_TYPE_MONO)).create;
-
+
- make n:STRING_CONSTANT list t:FAST_ARRAY(ITM_TYPE_MONO) <-
(
name := n;
type_list := t;
);
-
\ No newline at end of file
diff --git a/src/variable/slot.li b/src/variable/slot.li
index cdcb201..5421852 100644
--- a/src/variable/slot.li
+++ b/src/variable/slot.li
@@ -167,7 +167,7 @@ Section Public
tm ?= result_type;
(tm != NULL).if {
slot_data_list := FAST_ARRAY(SLOT_DATA).create_with_capacity (tm.count-1);
- (tm.lower).to (tm.upper-1) do { k:INTEGER;
+ (tm.lower).to (tm.upper-1) do { k:INTEGER;
typ := tm.item k.to_run_for receiver_type;
slot_data_list.add_last (
SLOT_DATA.create common_slot type_full typ
diff --git a/src/variable/slot_code.li b/src/variable/slot_code.li
index adaee60..9c5b9be 100644
--- a/src/variable/slot_code.li
+++ b/src/variable/slot_code.li
@@ -19,42 +19,42 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SLOT_CODE;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Slot with method";
-
+
Section Inherit
-
+
+ parent_slot:SLOT := SLOT;
-
+
Section Public
-
+
- common_slot:SLOT <- parent_slot;
+ index:INTEGER;
-
+
//
// Static and Dynamic profil.
//
-
+
+ value:ITM_CODE;
-
+
//
// Dynamic profil.
//
+ profil:FAST_ARRAY(PROFIL_SLOT);
-
+
- get_profil args:FAST_ARRAY(EXPR) self type_self:TYPE_FULL :(PROFIL, FAST_ARRAY(WRITE)) <-
[
-? {type_self != NULL};
]
- ( + result:PROFIL_SLOT;
+ ( + result:PROFIL_SLOT;
+ res_lst:FAST_ARRAY(WRITE);
+ pro:PROFIL_SLOT;
+ j,i:INTEGER;
@@ -64,10 +64,10 @@ Section Public
+ typ_list:TYPES_TMP;
+ pro_list:FAST_ARRAY(PROFIL_SLOT);
+ is_new:BOOLEAN;
-
+
(args = NULL).if {
// For auto-load external section.
- result := PROFIL_SLOT.clone;
+ result := PROFIL_SLOT.clone;
profil.add_last result;
is_new := TRUE;
} else {
@@ -91,7 +91,7 @@ Section Public
};
j := j + 1;
};
-
+
(typ_block != NULL).if {
pro_list := typ_block.profil_list;
i := pro_list.lower;
@@ -106,41 +106,41 @@ Section Public
};
i := i + 1;
};
-
+
(result = NULL).if {
- result := PROFIL_SLOT.clone;
+ result := PROFIL_SLOT.clone;
result.set_context_sensitive;
typ_block.profil_list.add_last result;
- is_new := TRUE;
+ is_new := TRUE;
};
- } else {
+ } else {
// Select classic Profil (no block).
(id_section.is_external).if {
result := profil.first;
} else {
- j := profil.lower;
+ j := profil.lower;
{(j <= profil.upper) && {result = NULL}}.while_do {
- pro := profil.item j;
+ pro := profil.item j;
((pro.type_self = NULL) || {pro.type_self == type_self}).if {
- result := pro;
- i := args.lower + 1;
+ result := pro;
+ i := args.lower + 1;
{(i <= args.upper) && {result != NULL}}.while_do {
- loc := pro.argument_list.item i;
+ loc := pro.argument_list.item i;
(
- (loc != NULL) && {loc.require_first != NULL} &&
+ (loc != NULL) && {loc.require_first != NULL} &&
{args.item i.static_type != loc.require_first.value.static_type} &&
{loc.type.raw != type_boolean}
- ).if {
- result := NULL;
+ ).if {
+ result := NULL;
};
- i := i + 1;
- };
+ i := i + 1;
+ };
};
j := j + 1;
};
};
- (result = NULL).if {
- result := PROFIL_SLOT.clone;
+ (result = NULL).if {
+ result := PROFIL_SLOT.clone;
profil.add_last result;
((id_section.is_external) && {profil.count > 1}).if {
semantic_error (position,"Polymorphic External slot is not possible.");
@@ -149,8 +149,8 @@ Section Public
};
};
};
- (is_new).if {
- res_lst := result.make Self with (type_self, args) verify (profil.count = 1);
+ (is_new).if {
+ res_lst := result.make Self with (type_self, args) verify (profil.count = 1);
} else {
res_lst := result.write_argument args;
};
@@ -160,32 +160,32 @@ Section Public
//
// Constructeur.
//
-
+
- create base:SLOT with val:ITM_CODE :SLOT_CODE <-
( + result:SELF;
result := clone;
result.make base with val;
result
);
-
+
- make base:SLOT with val:ITM_CODE <-
- (
+ (
parent_slot := base;
value := val;
- profil := FAST_ARRAY(PROFIL_SLOT).create_with_capacity 1;
+ profil := FAST_ARRAY(PROFIL_SLOT).create_with_capacity 1;
);
-
+
//
// Execute.
//
-
- + last_type_contract:TYPE;
+
+ + last_type_contract:TYPE;
+ is_require:BOOLEAN;
-
+
- previous_contract:ITM_LIST <-
( + slot:ITM_SLOT;
+ contract:ITM_LIST;
-
+
(is_require).if {
slot := last_type_contract.search_require name;
} else {
@@ -198,17 +198,17 @@ Section Public
contract := slot.ensure;
};
last_type_contract := last_type_contract.last_type_contract;
- };
+ };
contract
);
-
+
- create_code is_first:BOOLEAN <-
( + contract:ITM_LIST;
- + slot:ITM_SLOT;
+ + slot:ITM_SLOT;
+ result:EXPR;
+ mul:EXPR_MULTIPLE;
+ nb_result_list:INTEGER;
-
+
verify := is_first;
// Require
is_require := TRUE;
@@ -222,15 +222,15 @@ Section Public
};
contract := slot.require;
last_type_contract := receiver_type.last_type_contract;
- };
+ };
};
- (contract != NULL).if {
+ (contract != NULL).if {
contract.to_run_expr;
};
-
+
// Body.
result := value.to_run_expr;
- (result.static_type.raw != TYPE_VOID).if {
+ (result.static_type.raw != TYPE_VOID).if {
mul ?= result;
(mul != NULL).if {
nb_result_list := mul.count;
@@ -253,9 +253,9 @@ Section Public
}.elseif {nb_result_list > 1} then {
(mul.lower).to (mul.upper) do { j:INTEGER;
put_result (mul.item j) in (profil_slot.result_list.item j);
- };
+ };
};
-
+
// Ensure
is_require := FALSE;
contract := ensure;
@@ -268,9 +268,9 @@ Section Public
};
contract := slot.ensure;
last_type_contract := receiver_type.last_type_contract;
- };
+ };
};
- (contract != NULL).if {
+ (contract != NULL).if {
contract.to_run_expr;
};
// Result.
@@ -283,38 +283,38 @@ Section Public
EXTERNAL_C.create position text "__END_INTERRUPT__" access NULL
persistant TRUE type (TYPE_VOID.default)
);
- };
+ };
);
-
+
- remove_profil prof:PROFIL_SLOT <-
( + idx:INTEGER;
-
+
idx := profil.fast_first_index_of prof;
- (idx <= profil.upper).if { // Else, This profil is in BLOCK
+ (idx <= profil.upper).if { // Else, This profil is in BLOCK
profil.remove idx;
};
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
buffer.append name;
- (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
+ (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
buffer.add_last ' ';
argument_list.item j.display buffer;
- };
+ };
buffer.add_last ' ';
buffer.add_last ':';
- type.display buffer;
- );
-
+ type.display buffer;
+ );
+
- display_all <-
( + prof:PROFIL;
-
- string_tmp.clear;
+
+ string_tmp.clear;
(profil != NULL).if {
(profil.upper).downto (profil.lower) do { k:INTEGER;
prof := profil.item k;
@@ -323,14 +323,13 @@ Section Public
};
string_tmp.print;
);
-
+
Section Private
-
+
- put_result e:EXPR in v:LOCAL <-
( + val:EXPR;
+ wrt:WRITE;
val := e.check_type (v.type) with (v.position);
wrt := v.write position value val;
- list_current.add_last wrt;
+ list_current.add_last wrt;
);
-
\ No newline at end of file
diff --git a/src/variable/slot_data.li b/src/variable/slot_data.li
index 9416d66..14ee2c4 100644
--- a/src/variable/slot_data.li
+++ b/src/variable/slot_data.li
@@ -19,28 +19,28 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := SLOT_DATA;
- copyright := "2003-2007 Benoit Sonntag";
-
+
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Slot with data style";
-
+
Section Inherit
-
+
+ parent_variable:Expanded VARIABLE;
- + parent_slot:SLOT := SLOT;
-
+ + parent_slot:SLOT := SLOT;
+
Section Public
-
+
// BUG COMPILO 0.11
-
- - id_section:SECTION_ <-
+
+ - id_section:SECTION_ <-
( + result:SECTION_;
-
+
(parent_slot != NULL).if {
result := parent_slot.id_section;
} else {
@@ -51,7 +51,7 @@ Section Public
- receiver_type:TYPE <-
( + result:TYPE;
-
+
(parent_slot != NULL).if {
result := parent_slot.receiver_type;
} else {
@@ -59,21 +59,21 @@ Section Public
};
result
);
-
+
//
-
+
- common_slot:SLOT <- parent_slot;
-
+
//
// Sequence optimizer
//
-
+
+ last_write:WRITE;
+ last_seq_index:UINTEGER_32;
- + last_seq_or_and:UINTEGER_32;
+ + last_seq_or_and:UINTEGER_32;
+ last_seq_call_and_loop:UINTEGER_32;
+ last_seq_call_local_and_loop:UINTEGER_32;
-
+
+ last_list_current:LIST;
+ last_index:INTEGER;
@@ -84,47 +84,47 @@ Section Public
{loop_seq_call_and_loop = seq_call_and_loop} &&
{last_seq_index <= loop_seq_index}
);
-
+
- reset_last_write w:WRITE <-
- (
+ (
(last_write = w).if {
last_write := NULL;
};
);
-
+
- set_read <-
(
last_index := -1;
);
-
+
- get_last_index:INTEGER <- last_index;
-
+
- set_write w:WRITE <-
- (
+ (
/* A FAIRE
(
(! PROFIL.mode_recursive) &&
{style = '-'} &&
- {last_write != NULL} &&
+ {last_write != NULL} &&
{last_index < list_current.index} &&
- {last_sequence = sequence_global}
- ).if {
+ {last_sequence = sequence_global}
+ ).if {
? {list_current.item last_index = last_write};
list_current.put (last_write.value) to last_index;
- unwrite last_write;
+ unwrite last_write;
new_execute_pass;
- };
+ };
*/
last_write := w;
last_seq_index := seq_index;
- last_seq_or_and := seq_or_and;
+ last_seq_or_and := seq_or_and;
last_seq_call_and_loop := seq_call_and_loop;
last_seq_call_local_and_loop:= seq_call_local_and_loop;
//
last_list_current := list_current;
last_index := list_current.index;
);
-
+
- get_last_value rec:EXPR :EXPR <-
( + result:EXPR;
+ val:EXPR;
@@ -137,9 +137,9 @@ Section Public
+ my_require_count:INTEGER;
+ pb:PROFIL_BLOCK;
+ i:INSTR;
-
+
((! PROFIL.mode_recursive) && {loop_invariant = NULL} && {last_write != NULL}).if {
-
+
my_require_count := require_count;
(rec != NULL).if {
// Block exception.
@@ -149,7 +149,7 @@ Section Public
l := rd_loc.local;
wrt_slot ?= require_first;
rd_loc ?= wrt_slot.receiver;
- (rd_loc.local = l).if {
+ (rd_loc.local = l).if {
my_require_count := 1;
} else {
my_require_count := 0;
@@ -157,23 +157,23 @@ Section Public
(require_list.lower).to (require_list.upper) do { j:INTEGER;
wrt_slot ?= require_list.item j;
rd_loc ?= wrt_slot.receiver;
- (rd_loc.local = l).if {
+ (rd_loc.local = l).if {
my_require_count := my_require_count + 1;
};
};
};
};
-
+
(
(
- (last_seq_call_and_loop = seq_call_and_loop) &&
+ (last_seq_call_and_loop = seq_call_and_loop) &&
{is_seq_list last_list_current}
) || {my_require_count = 1}
).if {
// Receiver test.
(rec = NULL).if {
- is_rec_ok := TRUE;
- }.elseif {rec.is_constant} then {
+ is_rec_ok := TRUE;
+ }.elseif {rec.is_constant} then {
wrt_slot ?= last_write;
is_rec_ok := rec ~= wrt_slot.receiver;
} else {
@@ -184,25 +184,25 @@ Section Public
wrt_slot ?= last_write;
rd ?= wrt_slot.receiver;
is_rec_ok := (rd != NULL) && {
- (
+ (
{l = rd.variable} && {is_seq_list last_list_current} && {
(
- (l.last_seq != NULL) && {l.last_seq.last_write != NULL} &&
+ (l.last_seq != NULL) && {l.last_seq.last_write != NULL} &&
{l.last_seq.last_seq_index < last_seq_index} &&
{last_seq_call_local_and_loop = seq_call_local_and_loop}
) || {l.require_count <= 1} || {l.style = ' '}
}
- ) ||
+ ) ||
{
{g = rd.variable} && {g.style = '-'} && {
(
(g.last_write != NULL) && {g.last_seq_index < last_seq_index} &&
- {last_seq_call_and_loop = seq_call_and_loop} &&
+ {last_seq_call_and_loop = seq_call_and_loop} &&
{is_seq_list (g.last_list_current)}
) || {g.require_count = 1}
}
}
- };
+ };
};
};
(is_rec_ok).if {
@@ -210,7 +210,7 @@ Section Public
rd ?= val;
(rd = NULL).if {
l := NULL;
- g := NULL;
+ g := NULL;
} else {
l ?= rd.variable;
g ?= rd.variable;
@@ -218,11 +218,11 @@ Section Public
(
( // Constant propagation.
val.is_constant
- ) ||
- { // Local propagation.
- (l != NULL) && {is_seq_list last_list_current} && {
+ ) ||
+ { // Local propagation.
+ (l != NULL) && {is_seq_list last_list_current} && {
(
- (l.last_seq != NULL) && {l.last_seq.last_write != NULL} &&
+ (l.last_seq != NULL) && {l.last_seq.last_write != NULL} &&
{l.last_seq.last_seq_index < last_seq_index} &&
{last_seq_call_local_and_loop = seq_call_local_and_loop}
) || {l.require_count <= 1} || {l.style = ' '}
@@ -231,24 +231,24 @@ Section Public
{ // Global propagation.
(g != NULL) && {g.style = '-'} && {
(
- (g.last_write != NULL) && {g.last_seq_index < last_seq_index} &&
+ (g.last_write != NULL) && {g.last_seq_index < last_seq_index} &&
{last_seq_call_and_loop = seq_call_and_loop} &&
{is_seq_list (g.last_list_current)}
) || {g.require_count = 1}
}
}
- ).if {
+ ).if {
(rec != NULL).if {
rec.remove;
- };
+ };
result := val.my_copy;
}.elseif {
// Propagation step by step.
(last_seq_or_and = seq_or_and) &&
{ensure_count = 1} &&
- {list_current.index > list_current.lower} &&
- {list_current.item (list_current.index - 1) = last_write}
- } then {
+ {list_current.index > list_current.lower} &&
+ {list_current.item (list_current.index - 1) = last_write}
+ } then {
(rec != NULL).if {
rec.remove;
wrt_slot ?= last_write;
@@ -258,38 +258,38 @@ Section Public
list_current.put NOP to (list_current.index - 1);
result := val;
}.elseif {
- (rec != NULL) && {is_seq_list last_list_current} &&
+ (rec != NULL) && {is_seq_list last_list_current} &&
{my_require_count = 1} && {ensure_count = 1} &&
{last_index.in_range (last_list_current.lower) to (last_list_current.upper)} &&
- {last_list_current.item last_index = last_write}
+ {last_list_current.item last_index = last_write}
} then {
- // Local conversion.
+ // Local conversion.
l := type.get_temporary position;
i := l.write (last_write.position) value val;
last_list_current.put i to last_index;
result := l.read (rec.position);
- //
+ //
rec.remove;
wrt_slot ?= last_write;
wrt_slot.receiver.remove;
- unwrite last_write;
+ unwrite last_write;
};
};
- };
+ };
};
result
);
-
+
//
// Constructeur.
//
-
+
- create b:SLOT type_full t:TYPE_FULL :SELF <-
- (
+ (
create (b.position) name (b.name) style (b.style) base b type t
);
-
- - create pos:POSITION name n:STRING_CONSTANT
+
+ - create pos:POSITION name n:STRING_CONSTANT
style s:CHARACTER base b:SLOT type t:TYPE_FULL :SELF <-
// BSBS: N'est plus utilise' !!!
( + result:SELF;
@@ -305,52 +305,52 @@ Section Public
position := pos;
name := n;
style := s;
- intern_name := ALIAS_STR.get_intern name;
- //
- type := t;
+ intern_name := ALIAS_STR.get_intern name;
+ //
+ type := t;
(is_static).if {
- tmp := TYPES_TMP.new;
+ tmp := TYPES_TMP.new;
tmp.add (type.raw);
type_list := tmp.to_types;
} else {
type_list := TYPES_TMP.types_empty;
};
- ((type.raw.is_block) && {name != ALIAS_STR.slot_id} && {name != ALIAS_STR.slot_self}).if {
+ ((type.raw.is_block) && {name != ALIAS_STR.slot_id} && {name != ALIAS_STR.slot_self}).if {
list_variable_block.add_last Self;
};
- ? {type != NULL};
+ ? {type != NULL};
);
-
+
//
// Context
- //
-
+ //
+
+ value_init:LIST;
-
+
- init <-
( + val,rec:EXPR;
- + wrt:WRITE;
+ + wrt:WRITE;
+ old_list:LIST;
+ rd:ITM_READ_ARG1;
+ old_profil_current:PROFIL;
+ old_profil_slot:PROFIL_SLOT;
- /*
+ /*
string_tmp.copy "init : ";
- string_tmp.append name;
+ string_tmp.append name;
warning_error (position,string_tmp);
- */
+ */
((value_init = NULL) && {(affect != '<') || {Self = slot_id}}).if {
- // Context.
+ // Context.
old_list := list_current;
old_profil_current := profil_current;
old_profil_slot := profil_slot;
profil_current := profil_slot := NULL;
- value_init := list_current := LIST.create position;
-
+ value_init := list_current := LIST.create position;
+
(Self = slot_id).if {
val := PROTOTYPE_CST.create position type type;
- } else {
- // Code.
+ } else {
+ // Code.
(value != NULL).if {
rd ?= value;
((rd != NULL) && {rd.arg = NULL}).if {
@@ -362,37 +362,37 @@ Section Public
} else {
val := type.default_value position;
};
- val := val.check_type type with position;
- };
+ val := val.check_type type with position;
+ };
(style = '+').if {
rec := PROTOTYPE_CST.create position type (receiver_type.default);
} else {
rec := NULL;
};
-
+
(debug_level_option != 0).if {
list_current.add_last (
- PUSH.create position context context_main first FALSE
+ PUSH.create position context context_main first FALSE
);
};
-
+
wrt := write position with rec value val;
(is_zero val).if {
wrt.set_quiet_generation;
- };
- list_current.add_last wrt;
+ };
+ list_current.add_last wrt;
list_current.add_last (PROTOTYPE_CST.create position type (TYPE_VOID.default)); // BSBS:Alias
-
+
list_current := old_list;
profil_current := old_profil_current;
profil_slot := old_profil_slot;
};
);
-
+
//
// Execute.
//
-
+
- execute <-
( + lst:FAST_ARRAY(SLOT);
+ slot:SLOT_DATA;
@@ -401,20 +401,20 @@ Section Public
+ old_list_current:LIST;
//+ old_profil_current:PROFIL_SLOT;
+ insert_index:INTEGER;
-
+
(value_init != NULL).if {
val := value_init;
- value_init := NULL;
+ value_init := NULL;
insert_index := list_main.index;
list_main.add val to insert_index;
-
- (type.is_expanded).if {
+
+ (type.is_expanded).if {
lst := type.slot_run;
(lst != NULL).if {
(lst.lower).to (lst.upper) do { j:INTEGER;
s := lst.item j;
(s.style = '+').if {
- slot := s.slot_data_intern;
+ slot := s.slot_data_intern;
(slot != NULL).if {
slot.execute;
};
@@ -424,57 +424,57 @@ Section Public
};
};
};
- };
+ };
};
-
+
old_list_current := list_current;
//old_profil_current := profil_current;
list_current := NULL;
//profil_current := NULL;
-
+
val.execute;
list_main.inc_index;
-
+
list_current := old_list_current;
- //profil_current := old_profil_current;
+ //profil_current := old_profil_current;
};
- );
+ );
//
// Genere
//
-
+
- genere buffer:STRING <-
- (
+ (
type.genere_declaration buffer;
buffer.add_last ' ';
type.genere_star_declaration buffer;
- buffer.append intern_name;
+ buffer.append intern_name;
buffer.append ";\n";
);
-
+
//
// Display.
//
-
+
- display buffer:STRING <-
(
- buffer.append intern_name;
+ buffer.append intern_name;
buffer.add_last ' ';
buffer.add_last ':';
- type.display buffer;
- );
-
+ type.display buffer;
+ );
+
- display_all <-
- (
+ (
string_tmp.clear;
display string_tmp;
string_tmp.print;
);
-
+
Section VARIABLE
-
- - new_read p:POSITION with r:EXPR :READ <-
+
+ - new_read p:POSITION with r:EXPR :READ <-
( + result:READ;
(style = '-').if {
? {r = NULL};
@@ -485,7 +485,7 @@ Section VARIABLE
};
result
);
-
+
- new_write p:POSITION with r:EXPR value v:EXPR :WRITE <-
( + result:WRITE;
(style = '-').if {
@@ -497,11 +497,11 @@ Section VARIABLE
};
result
);
-
+
/*
- - new_access r:EXPR :ACCESS <-
+ - new_access r:EXPR :ACCESS <-
( + result:ACCESS;
-
+
(style = '-').if {
result := ACCESS_GLOBAL.create Self;
} else {
diff --git a/src/variable/variable.li b/src/variable/variable.li
index 41f05d4..3acc94b 100644
--- a/src/variable/variable.li
+++ b/src/variable/variable.li
@@ -124,18 +124,18 @@ Section Public
((typ.subtype_list = NULL) || {typ.subtype_list.count > type_list.count}) ||
{typ = type_block}
}*/
- }).if {
+ }).if {
level_type := level_pass;
tmp_type := TYPES_TMP.new;
- (require_first != NULL).if {
+ (require_first != NULL).if {
- require_first.get_type tmp_type;
+ require_first.get_type tmp_type;
(require_list != NULL).if {
- (require_list.lower).to (require_list.upper) do { j:INTEGER;
+ (require_list.lower).to (require_list.upper) do { j:INTEGER;
require_list.item j.get_type tmp_type;
};
};
- };
+ };
type_list := tmp_type.update type_list;
};
};
@@ -204,9 +204,9 @@ Section Public
tmp_type := TYPES_TMP.new;
(type_list != NULL).if {
tmp_type.union type_list;
- };
+ };
e.value.get_type tmp_type;
- type_list := tmp_type.update type_list;
+ type_list := tmp_type.update type_list;
};
e.set_create;
@@ -253,7 +253,7 @@ Section Public
intern_name.print; '\n'.print;
/*
e.to_pointer.print; ' '.print;
-
+
e.debug_display;
"\n--------\n".print;
require_first.debug_display;
--
Lisaac compiler
More information about the Lisaac-commits
mailing list