[SCM] Lisaac compiler branch, mildred-projects, updated. lisaac-0.12-421-g00631ef
Mildred Ki'Lya
silkensedai at online.fr
Wed Aug 5 21:05:56 UTC 2009
The following commit has been merged in the mildred-projects branch:
commit 206e1357bddccf3aacc87d7e09ad211043c4f711
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Wed Aug 5 22:10:09 2009 +0200
Changed the way to create sub-projects. The initialization is still not OK
diff --git a/make.lip b/make.lip
index dc42cb7..ad4e966 100644
--- a/make.lip
+++ b/make.lip
@@ -58,6 +58,18 @@ Section Private
+ target:STRING := "unix";
+ lib_std :PROJECT;
+
+ //
+ // Code
+ //
+
+ - init prj:PROJECT <-
+ // Initialize the library
+ (
+ "Initialize project ".print; Self.print;
+ prj.if { " from ".print; prj.print; };
+ "\n".print;
+ );
//
// Directory.
@@ -66,9 +78,13 @@ Section Private
- standard_path <-
// Standard library.
(
- "Load: lib.lip\n".print;
- lib_std := project ("STD");
- lib_std.load("lib.lip");
+ "STD A: ".print; lib_std.print; "\n".print;
+ lib_std := lib_std.create("STD");
+ "STD B: ".print; lib_std.print; "\n".print;
+ lib_std := lib_std.private;
+ "STD C: ".print; lib_std.print; "\n".print;
+ lib_std := lib_std.load("lib.lip");
+ "STD D: ".print; lib_std.print; "\n".print;
);
//
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index 4051e1f..57dc49b 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -135,58 +135,17 @@ Section Public
// Call with a receiver
//
(self.name = ALIAS_STR.prototype_project).if {
- + prj_v:LIP_VALUEPROJECT;
- + prj :LIP_PROJECT;
- prj_v ?= self;
- (prj_v != NULL).if { prj := prj_v.value; };
+ + prj :LIP_VALUEPROJECT;
+ + result:LIP_CONSTANT;
+ prj ?= self;
(prj = NULL).if {
semantic_error(position, "Call on project NULL");
- }.elseif {! prj.initialized} then {
- (name = ALIAS_STR.slot_load).if {
- str ?= val;
- ((str = NULL) || {str.value.is_empty}).if {
- semantic_error (position,"Non empty string argument needed.");
- };
- string_tmp.clear;
- (str.value.first == '/').if_false {
- string_tmp.append (stack_base_directory.last);
- ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
- string_tmp.add_last '/';
- };
- };
- string_tmp.append (str.value);
- prj.load_lip (ALIAS_STR.get string_tmp).if_false {
- string_tmp2.copy "Cannot load lip file `";
- string_tmp2.append string_tmp;
- string_tmp2.append "': file not found";
- semantic_error (position,string_tmp2);
- };
- slot := prj.get_method (ALIAS_STR.slot_init);
- (slot != NULL).if {
- (slot.run_with prj_v).if_false {
- semantic_error (position,"Invalid argument.");
- };
- } else {
- error_slot_not_found "Code slot" name name project (prj.name) send FALSE;
-// (prj.list_method.lower).to (prj.list_method.upper) do { i:INTEGER;
-// slot := prj.list_method.item i;
-// string_tmp2.append "\n - ";
-// string_tmp2.append (slot.name);
-// };
- warning_error (position, string_tmp);
- };
- } else {
- error_slot_not_found "Code slot" name name project (prj.name) send TRUE;
- };
} else {
- slot := project.get_method name;
- (slot = NULL).if {
+ result := prj.call name arg val from project position position;
+ (result = NULL).if {
error_slot_not_found "Code slot" name name project (prj.name) send TRUE;
- };
- (slot.run_with val).if_false {
- semantic_error (position,"Invalid argument.");
- };
- };
+ }
+ }
}.elseif {name = ALIAS_STR.slot_print} then {
self.print;
} else {
@@ -232,20 +191,6 @@ Section Public
result := LIP_INTEGER.get res;
}.elseif { name = ALIAS_STR.slot_info_project} then {
result := LIP_STRING.get (project.info_project);
- }.elseif {(name = ALIAS_STR.slot_project) ||
- {name = ALIAS_STR.slot_public_project} ||
- {name = ALIAS_STR.slot_private_project}
- } then {
- + prj :LIP_PROJECT;
- str ?= val;
- (str = NULL).if {
- semantic_error (position,"String argument needed.");
- };
- prj := LIP_PROJECT.clone.make;
- prj.set_protoname (str.value);
- prj.set_public (name = ALIAS_STR.slot_public_project);
- project.list_prj.add_last prj;
- result := LIP_VALUEPROJECT.get prj;
}.elseif {name = ALIAS_STR.variable_lisaac} then {
result := LIP_STRING.get (LISAAC.path_lisaac);
}.elseif {name = ALIAS_STR.slot_get_integer} then {
@@ -272,27 +217,16 @@ Section Public
// Call with a receiver
//
(self.name = ALIAS_STR.prototype_project).if {
- + prj_v:LIP_VALUEPROJECT;
- + prj :LIP_PROJECT;
- prj_v ?= self;
- (prj_v != NULL).if { prj := prj_v.value; };
+ + prj :LIP_VALUEPROJECT;
+ prj ?= self;
(prj = NULL).if {
semantic_error(position, "Call on project NULL");
- }.elseif {! prj.initialized} then {
- error_slot_not_found "Data slot" name name project (prj.name) send TRUE;
} else {
- slot := project.get_data name;
- ((slot = NULL) && {!stack.is_empty}).if {
- slot := stack.last;
- (slot.name != name).if {
- slot := NULL;
- };
- };
- (slot = NULL).if {
+ result := prj.call name arg val from project position position;
+ (result = NULL).if {
error_slot_not_found "Data slot" name name project (prj.name) send TRUE;
- };
- result := slot.get_value;
- };
+ }
+ }
} else {
error_slot_not_found "Slot" name name;
};
@@ -316,7 +250,7 @@ Section Public
string_tmp.append name;
string_tmp.append "' not found";
(prj != NULL).if {
- string_tmp.append "in project `";
+ string_tmp.append " in project `";
string_tmp.append prj;
string_tmp.append "'";
};
diff --git a/src/lip/lip_project.li b/src/lip/lip_project.li
index 40a6575..5949ea4 100644
--- a/src/lip/lip_project.li
+++ b/src/lip/lip_project.li
@@ -34,6 +34,51 @@ Section Inherit
Section Public
+ - create :SELF <- clone.make;
+
+ - make :SELF <-
+ (
+ items := FAST_ARRAY[PRJ_ITEM].create_with_capacity 128;
+ list_parent := FAST_ARRAY[STRING_CONSTANT].create_with_capacity 1;
+ list_method := FAST_ARRAY[LIP_SLOT_CODE].create_with_capacity 32;
+ list_data := HASHED_DICTIONARY[LIP_SLOT_DATA,STRING_CONSTANT].create;
+ list_prj := FAST_ARRAY[LIP_PROJECT].create_with_capacity 8;
+ Self
+ );
+
+ - init lip_path:STRING_CONSTANT from origin:LIP_PROJECT :SELF <-
+ (
+ // Load lip
+ load_lip lip_path.if_false {
+ string_tmp2.copy "Cannot load lip file `";
+ string_tmp2.append lip_path;
+ string_tmp2.append "': file not found";
+ semantic_error (position,string_tmp2);
+ };
+ call_init origin;
+ Self
+ );
+
+ - call_init origin:LIP_PROJECT <-
+ (
+ + slot:LIP_SLOT_CODE;
+ slot := get_method (ALIAS_STR.slot_init);
+ (slot != NULL).if {
+ (slot.run_with (LIP_VALUEPROJECT.get origin)).if_false {
+ semantic_error (position,"Invalid argument.");
+ };
+ } else {
+ string_tmp.append "Code slot `";
+ string_tmp.append (ALIAS_STR.slot_init);
+ string_tmp.append "' not found";
+ string_tmp.append "in project `";
+ string_tmp.append (name);
+ string_tmp.append "'";
+ string_tmp.append ".";
+ warning_error (position, string_tmp);
+ };
+ );
+
+ list_parent:FAST_ARRAY[STRING_CONSTANT];
// List the parent .lip files (Section Inherit in .lip)
@@ -102,18 +147,6 @@ Section Public
ALIAS_STR.get string_tmp3
);
- - create :SELF <- clone.make;
-
- - make :SELF <-
- (
- items := FAST_ARRAY[PRJ_ITEM].create_with_capacity 128;
- list_parent := FAST_ARRAY[STRING_CONSTANT].create_with_capacity 1;
- list_method := FAST_ARRAY[LIP_SLOT_CODE].create_with_capacity 32;
- list_data := HASHED_DICTIONARY[LIP_SLOT_DATA,STRING_CONSTANT].create;
- list_prj := FAST_ARRAY[LIP_PROJECT].create_with_capacity 8;
- Self
- );
-
- info_project :STRING_CONSTANT <-
(
string_tmp4.clear;
@@ -236,7 +269,13 @@ Section Public
} else {
buffer.append " (private) ";
};
- buffer.append (prj.protoname);
+ (prj.protoname = NULL).if {
+ buffer.append "(unnamed)";
+ } else {
+ buffer.add_last '"';
+ buffer.append (prj.protoname);
+ buffer.add_last '"';
+ };
buffer.append ": ";
buffer.append (prj.name);
buffer.append "\n";
diff --git a/src/lip/lip_valueproject.li b/src/lip/lip_valueproject.li
index 2d2bf8f..becedbe 100644
--- a/src/lip/lip_valueproject.li
+++ b/src/lip/lip_valueproject.li
@@ -37,13 +37,30 @@ Section Private
- set_value p:LIP_PROJECT <-
(
- value := p;
+ value := p;
+ prj_name := NULL;
+ prj_pub := FALSE;
+ (p != NULL).if {
+ prj_pub := p.is_public;
+ prj_name := p.protoname;
+ };
+ );
+
+ - make other:LIP_VALUEPROJECT :SELF <-
+ (
+ value := other.value;
+ prj_name := other.prj_name;
+ prj_pub := other.prj_pub;
+ Self
);
Section Public
+ value :LIP_PROJECT;
+ + prj_name :STRING_CONSTANT;
+ + prj_pub :BOOLEAN;
+
//
// Creation.
//
@@ -73,27 +90,164 @@ Section Public
- copy:LIP_CONSTANT <-
(
- get value
+ get value.make Self
);
- print <-
(
- value.name.print;
+ string_tmp.clear;
+ append_in string_tmp;
+ string_tmp.print;
);
- append_in str:STRING <-
(
(value = NULL).if {
- str.append "NULL";
+ str.append "NULL ";
+ append_status_in str;
}.elseif { ! value.initialized } then {
- str.append "*.lip";
+ str.append "*.lip ";
+ append_status_in str;
} else {
str.append (value.name);
};
);
+ - append_status_in str:STRING <-
+ (
+ str.append "[";
+ (prj_name != NULL).if {
+ str.append "name:";
+ str.append prj_name;
+ str.append ",";
+ };
+ prj_pub.if {
+ str.append "public";
+ } else {
+ str.append "private";
+ };
+ str.append "]";
+ );
+
- to_boolean :BOOLEAN <- value != NULL;
+ - call name:STRING_CONSTANT arg val:LIP_CONSTANT from origin:LIP_PROJECT
+ position position:POSITION :LIP_CONSTANT <-
+ ( + result :LIP_CONSTANT;
+ + slot_data:LIP_SLOT_DATA;
+ + slot_code:LIP_SLOT_CODE;
+ + str :LIP_STRING;
+ + lip_path :STRING_CONSTANT;
+
+ result := Self;
+
+ //
+ // Forward messages
+ //
+ ((value != NULL) && {value.initialized}).if {
+ (val = NULL).if {
+ slot_data := value.get_data name;
+ ((slot_data = NULL) && {!LIP_CODE.stack.is_empty}).if {
+ slot_data := LIP_CODE.stack.last;
+ ((slot_data != NULL) && {slot_data.name != name}).if {
+ slot_data := NULL;
+ };
+ };
+ (slot_data != NULL).if {
+ result := slot_data.get_value;
+ } else {
+ result := NULL;
+ };
+ } else {
+ slot_code := value.get_method name;
+ (slot_code = NULL).if {
+ result := NULL;
+ } else {
+ (slot_code.run_with val).if_false {
+ semantic_error (position,"Invalid argument.");
+ };
+ };
+ };
+
+ //
+ // PROJECT.public
+ //
+ }.elseif {(name = ALIAS_STR.slot_public) && {val = NULL}} then {
+ prj_pub := TRUE;
+ (value != NULL).if { value.set_public TRUE; };
+
+ //
+ // PROJECT.private
+ //
+ }.elseif {(name = ALIAS_STR.slot_private) && {val = NULL}} then {
+ prj_pub := FALSE;
+ (value != NULL).if { value.set_public FALSE; };
+
+ //
+ // PROJECT.create "NAME"
+ //
+ }.elseif {name = ALIAS_STR.slot_create} then {
+ str ?= val;
+ (str = NULL).if {
+ semantic_error (position,"String argument needed.");
+ };
+ prj_name := str.value;
+
+ //
+ // PROJECT.load "file.lip"
+ //
+ }.elseif {name = ALIAS_STR.slot_load} then {
+ str ?= val;
+ ((str = NULL) || {str.value.is_empty}).if {
+ semantic_error (position,"Non empty string argument needed.");
+ };
+ string_tmp.clear;
+ (str.value.first == '/').if_false {
+ string_tmp.append (LIP_CODE.stack_base_directory.last);
+ ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
+ string_tmp.add_last '/';
+ };
+ };
+ string_tmp.append (str.value);
+ lip_path := (ALIAS_STR.get string_tmp);
+ value := LIP_PROJECT.create.init lip_path from origin;
+ value.set_public prj_pub;
+ (prj_name != NULL).if { value.set_protoname prj_name; };
+ origin.list_prj.add_last value;
+
+ } else {
+ result := NULL;
+ };
+
+ (result = NULL).if {
+ result := Self;
+
+ //
+ // PROJECT.print
+ //
+ (name = ALIAS_STR.slot_print).if {
+ print;
+
+ //
+ // PROJECT.to_string
+ //
+ }.elseif {name = ALIAS_STR.slot_to_string} then {
+ string_tmp.clear;
+ append_in string_tmp;
+ result := LIP_STRING.get (ALIAS_STR.get string_tmp);
+
+ } else {
+ result := NULL
+ };
+ };
+
+ (result = Self).if {
+ result := copy;
+ };
+
+ result
+ );
+
Section LIP_CONSTANT
- my_copy other:SELF :LIP_CONSTANT <-
diff --git a/src/lisaac.li b/src/lisaac.li
index 0f2f763..0437fd2 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -305,6 +305,7 @@ Section Private
);
- load_lip file_lip:ABSTRACT_STRING fuzzy fuzzy:BOOLEAN <-
+ // Replace LIP_PROJECT.init
[
-? { file_lip != NULL };
]
@@ -360,8 +361,9 @@ Section Private
};
// Auto-load 'lisaac' variable.
-
+
project.put_string path_lisaac to (ALIAS_STR.variable_lisaac);
+ project.call_init NULL;
);
- put_trace_code buf:STRING <-
diff --git a/src/tools/alias_str.li b/src/tools/alias_str.li
index 0f7c95c..b770e09 100644
--- a/src/tools/alias_str.li
+++ b/src/tools/alias_str.li
@@ -174,11 +174,12 @@ Section Public
- slot_get_string :STRING_CONSTANT := "get_string";
- slot_is_cop :STRING_CONSTANT := "is_cop";
- slot_load :STRING_CONSTANT := "load";
- - slot_project :STRING_CONSTANT := "project";
- - slot_public_project :STRING_CONSTANT := "public_project";
- - slot_private_project:STRING_CONSTANT := "private_project";
- slot_init :STRING_CONSTANT := "init";
-
+ - slot_create :STRING_CONSTANT := "create";
+ - slot_public :STRING_CONSTANT := "public";
+ - slot_private :STRING_CONSTANT := "private";
+ - slot_to_string :STRING_CONSTANT := "to_string";
+
- c_void :STRING_CONSTANT := "void";
- c_struct :STRING_CONSTANT := "struct __";
- code_empty :STRING_CONSTANT := "/* NOTHING */";
@@ -472,10 +473,11 @@ Section Public
list.add slot_get_string;
list.add slot_is_cop;
list.add slot_load;
- list.add slot_project;
- list.add slot_public_project;
- list.add slot_private_project;
list.add slot_init;
+ list.add slot_create;
+ list.add slot_public;
+ list.add slot_private;
+ list.add slot_to_string;
// Type C :
list.add c_void;
--
Lisaac compiler
More information about the Lisaac-commits
mailing list