| |
| /pliant/language/compiler/module/module1.pli |
| |
| 1 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 2 |
# | |
| 3 |
# This program is free software; you can redistribute it and/or | |
| 4 |
# modify it under the terms of the GNU General Public License version 2 | |
| 5 |
# as published by the Free Software Foundation. | |
| 6 |
# | |
| 7 |
# This program is distributed in the hope that it will be useful, | |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 |
# GNU General Public License for more details. | |
| 11 |
# | |
| 12 |
# You should have received a copy of the GNU General Public License | |
| 13 |
# version 2 along with this program; if not, write to the Free Software | |
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 |
| |
| 16 |
scope "/pliant/language/""/pliant/install/" | |
| 17 |
module "/pliant/install/ring1.pli" | |
| 18 |
| |
| 19 |
public | |
| 20 |
constant module_flag_absolutepath 1 | |
| 21 |
constant module_flag_external 2 | |
| 22 |
constant module_flag_submodule 4 | |
| 23 |
constant module_flag_public 8 | |
| 24 |
constant module_flag_blackhole 16 | |
| 25 |
constant module_flag_ring 32 | |
| 26 |
| |
| 27 |
| |
| 28 |
gvar Link:Module empty_module :> new Module | |
| 29 |
| |
| 30 |
function the_module name -> module | |
| 31 |
arg Str name ; arg_RW Module module | |
| 32 |
if (name 0 1)="/" | |
| 33 |
module :> (pliant_module_dictionary first name) map Module | |
| 34 |
else | |
| 35 |
module :> null map Module | |
| 36 |
if addressof:module=null | |
| 37 |
error error_id_missing "Failed to find module "+name | |
| 38 |
module :> empty_module | |
| 39 |
| |
| 40 |
meta this_module e | |
| 41 |
if e:size=0 | |
| 42 |
var Link:Argument a :> new Argument | |
| 43 |
a locate Module argument_constant | |
| 44 |
a constant := addressof e:module:external | |
| 45 |
e set_result a access_read+access_write | |
| 46 |
| |
| 47 |
method m include sub | |
| 48 |
arg_rw Module m ; arg Module sub | |
| 49 |
m include sub 0 | |
| 50 |
| |
| 51 |
method m undefine name adr | |
| 52 |
arg Module m ; arg Str name ; arg Address adr | |
| 53 |
pliant_general_dictionary remove name adr | |
| 54 |
| |
| 55 |
export the_module this_module '. include' '. undefine' | |
| 56 |
| |
| 57 |
| |
| 58 |
if false | |
| 59 |
method m move name adr to | |
| 60 |
arg Module m ; arg Str name ; arg Address adr ; arg Module to | |
| 61 |
var Pointer:Arrow c :> pliant_general_dictionary first name | |
| 62 |
while c<>null | |
| 63 |
if (addressof ((addressof:c translate Arrow 1) map Pointer:Module))=addressof:m | |
| 64 |
(addressof:c translate Arrow 1) map Pointer:Module :> to | |
| 65 |
c :> pliant_general_dictionary next name c | |
| 66 |
export '.move' | |
| |