Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-compiler-and-rts
compiler
Commits
bf5f61b6
Commit
bf5f61b6
authored
May 31, 2001
by
Martijn Vervoort
Browse files
added mechanism to generate a module id for each module. Fixed an index
out of range error reported by Peter.
parent
b06be171
Changes
5
Hide whitespace changes
Inline
Side-by-side
frontend/check.icl
View file @
bf5f61b6
...
...
@@ -1718,6 +1718,14 @@ check_module2 mod_name mod_imported_objects mod_imports mod_type icl_global_func
(
dcls_import_list
,
dcl_modules
,
cs
)
=
addImportedSymbolsToSymbolTable
nr_of_modules
(
Yes
dcl_macros
)
modules_in_component_set
imports_ikh
dcl_modules
cs
// MV ...
(
x_main_dcl_module
,
cs
)
=
cs
!
cs_x
.
x_main_dcl_module_n
cs
=
cs
// <=< adjust_predef_symbol PD_ModuleType x_main_dcl_module STE_Type
<=<
adjust_predef_symbol
PD_ModuleConsSymbol
x_main_dcl_module
STE_Constructor
// .. MV
(
dcl_modules
,
icl_functions
,
hp_expression_heap
,
cs
)
=
checkExplicitImportCompleteness
imports
.
si_explicit
...
...
@@ -2677,6 +2685,20 @@ where
=
getClassDef
ins_class
mod_index
com_class_defs
modules
=
(
size
class_members
+
sum
,
com_class_defs
,
modules
)
// MV...
adjust_predef_symbol
predef_index
mod_index
symb_kind
cs
=:{
cs_predef_symbols
,
cs_symbol_table
,
cs_error
}
#
(
pre_symb
,
cs_predef_symbols
)
=
cs_predef_symbols
![
predef_index
]
#
pre_id
=
pre_symb
.
pds_ident
#!
pre_index
=
determine_index_of_symbol
(
sreadPtr
pre_id
.
id_info
cs_symbol_table
)
symb_kind
|
pre_index
<>
NoIndex
=
{
cs
&
cs_predef_symbols
=
{
cs_predef_symbols
&
[
predef_index
]
=
{
pre_symb
&
pds_def
=
pre_index
,
pds_module
=
mod_index
}}}
=
{
cs
&
cs_predef_symbols
=
cs_predef_symbols
,
cs_error
=
checkError
pre_id
" function not defined"
cs_error
}
where
determine_index_of_symbol
{
ste_kind
,
ste_index
}
symb_kind
|
ste_kind
==
symb_kind
=
ste_index
=
NoIndex
// ... MV
NewEntry
symbol_table
symb_ptr
def_kind
def_index
level
previous
:==
symbol_table
<:=
(
symb_ptr
,{
ste_kind
=
def_kind
,
ste_index
=
def_index
,
ste_def_level
=
level
,
ste_previous
=
previous
})
...
...
frontend/parse.icl
View file @
bf5f61b6
...
...
@@ -286,6 +286,9 @@ where
(
mod_ident
,
pState
)
=
stringToIdent
mod_name
IC_Module
pState
pState
=
check_layout_rule
pState
(
defs
,
pState
)
=
want_definitions
(
SetGlobalContext
iclmodule
)
pState
// MV ...
#
(
defs
,
pState
)
=
add_module_id
mod_name
defs
pState
;
// ... MV
{
ps_scanState
,
ps_hash_table
,
ps_error
,
ps_pre_def_symbols
}
=
pState
defs
=
if
(
ParseOnly
&&
id_name
<>
"StdOverloaded"
&&
id_name
<>
"StdArray"
&&
id_name
<>
"StdEnum"
&&
id_name
<>
"StdBool"
&&
id_name
<>
"StdDynamics"
&&
id_name
<>
"StdGeneric"
)
...
...
@@ -303,6 +306,36 @@ where
mod
=
{
mod_name
=
file_id
,
mod_type
=
mod_type
,
mod_imports
=
[],
mod_imported_objects
=
[],
mod_defs
=
[]
}
=
(
False
,
mod
,
hash_table
,
error
<<<
"Error ["
<<<
file_name
<<<
','
<<<
fp_line
<<<
"]: incorrect module header"
,
pre_def_symbols
,
closeScanner
scanState
files
)
where
// MV...
add_module_id
mod_name
defs
pState
|
not
iclmodule
=
(
defs
,
pState
);
// It is essential that the type name denoted by ident is an unique type name within the application. Otherwise
// the static linker will choose one implementation (because the type names are equal) and map the other to the
// chosen implementation.
// The zero arity of the _Module constructor makes the code generator, pre-allocate _Module in .data section of
// the final executable. The module name needed by the dynamic run-time system can then be determined by looking
// at the descriptor. If however all implementations were mapped to a single one, the dynamic rts could not use
// the module name anymore because they are all the same.
#
(
ident
,
pState
)
=
stringToIdent
(
"_"
+++
mod_name
+++
"_Module"
)
IC_Type
pState
#
td
=
MakeTypeDef
ident
[]
(
ConsList
[])
TA_None
[]
NoPos
#
(
pc_cons_name
,
pState
)
=
stringToIdent
"_Module"
IC_Expression
pState
#
cons
=
{
pc_cons_name
=
pc_cons_name
,
pc_arg_types
=
[]
,
pc_cons_arity
=
0
,
pc_cons_prio
=
NoPrio
,
pc_exi_vars
=
[]
,
pc_cons_pos
=
NoPos
}
#
td
=
{
td
&
td_rhs
=
ConsList
[
cons
]
}
=
([
PD_Type
td
:
defs
],
pState
)
// ...MV
try_module_header
::
!
Bool
!
ScanState
->
(!
Bool
,!
ModuleKind
,!
String
,!
ScanState
)
try_module_header
is_icl_mod
scanState
...
...
frontend/predef.dcl
View file @
bf5f61b6
...
...
@@ -14,7 +14,6 @@ import syntax, hashtable
/* identifiers not present the hastable */
PD_PredefinedModule
:==
0
PD_StringType
:==
1
...
...
@@ -69,7 +68,7 @@ PD_UnqArraySizeFun :== 119
/* Enum/Comprehension functions */
PD_SmallerFun
:==
120
PD_LessOrEqualFun
:==
121
PD_LessOrEqualFun
:==
121
PD_SubFun
:==
122
PD_IncFun
:==
123
PD_From
:==
124
...
...
@@ -90,44 +89,49 @@ PD_variablePlaceholder :== 133
PD_StdDynamics
:==
134
PD_undo_indirections
:==
135
// MV ...
//PD_ModuleType :== 136
PD_ModuleConsSymbol
:==
137
// ... MV
/* Generics */
PD_StdGeneric
:==
13
6
PD_TypeISO
:==
13
7
PD_ConsISO
:==
1
38
PD_iso_to
:==
1
39
PD_iso_from
:==
14
0
PD_TypeUNIT
:==
14
1
PD_ConsUNIT
:==
14
2
PD_TypeEITHER
:==
14
3
PD_ConsLEFT
:==
14
4
PD_ConsRIGHT
:==
14
5
PD_TypePAIR
:==
14
6
PD_ConsPAIR
:==
14
7
PD_TypeARROW
:==
1
48
PD_ConsARROW
:==
1
49
PD_TypeConsDefInfo
:==
15
0
PD_ConsConsDefInfo
:==
15
1
PD_TypeTypeDefInfo
:==
15
2
PD_ConsTypeDefInfo
:==
15
3
PD_cons_info
:==
15
4
PD_TypeCONS
:==
15
5
PD_ConsCONS
:==
15
6
PD_isomap_ARROW_
:==
15
7
PD_isomap_ID
:==
1
58
PD_StdGeneric
:==
13
8
PD_TypeISO
:==
13
9
PD_ConsISO
:==
1
40
PD_iso_to
:==
1
41
PD_iso_from
:==
14
2
PD_TypeUNIT
:==
14
3
PD_ConsUNIT
:==
14
4
PD_TypeEITHER
:==
14
5
PD_ConsLEFT
:==
14
6
PD_ConsRIGHT
:==
14
7
PD_TypePAIR
:==
14
8
PD_ConsPAIR
:==
14
9
PD_TypeARROW
:==
1
50
PD_ConsARROW
:==
1
51
PD_TypeConsDefInfo
:==
15
2
PD_ConsConsDefInfo
:==
15
3
PD_TypeTypeDefInfo
:==
15
4
PD_ConsTypeDefInfo
:==
15
5
PD_cons_info
:==
15
6
PD_TypeCONS
:==
15
7
PD_ConsCONS
:==
15
8
PD_isomap_ARROW_
:==
15
9
PD_isomap_ID
:==
1
60
/* StdMisc */
PD_StdMisc
:==
1
59
PD_abort
:==
16
0
PD_undef
:==
16
1
PD_StdMisc
:==
1
61
PD_abort
:==
16
2
PD_undef
:==
16
3
PD_Start
:==
16
2
PD_Start
:==
16
4
PD_DummyForStrictAliasFun
:==
16
3
PD_DummyForStrictAliasFun
:==
16
5
PD_NrOfPredefSymbols
:==
16
4
PD_NrOfPredefSymbols
:==
16
6
GetTupleConsIndex
tup_arity
:==
PD_Arity2TupleSymbol
+
tup_arity
-
2
GetTupleTypeIndex
tup_arity
:==
PD_Arity2TupleType
+
tup_arity
-
2
...
...
frontend/predef.icl
View file @
bf5f61b6
...
...
@@ -88,44 +88,49 @@ PD_variablePlaceholder :== 133
PD_StdDynamics
:==
134
PD_undo_indirections
:==
135
// MV ...
//PD_ModuleType :== 136
PD_ModuleConsSymbol
:==
137
// ... MV
/* Generics */
PD_StdGeneric
:==
13
6
PD_TypeISO
:==
13
7
PD_ConsISO
:==
1
38
PD_iso_to
:==
1
39
PD_iso_from
:==
14
0
PD_TypeUNIT
:==
14
1
PD_ConsUNIT
:==
14
2
PD_TypeEITHER
:==
14
3
PD_ConsLEFT
:==
14
4
PD_ConsRIGHT
:==
14
5
PD_TypePAIR
:==
14
6
PD_ConsPAIR
:==
14
7
PD_TypeARROW
:==
1
48
PD_ConsARROW
:==
1
49
PD_TypeConsDefInfo
:==
15
0
PD_ConsConsDefInfo
:==
15
1
PD_TypeTypeDefInfo
:==
15
2
PD_ConsTypeDefInfo
:==
15
3
PD_cons_info
:==
15
4
PD_TypeCONS
:==
15
5
PD_ConsCONS
:==
15
6
PD_isomap_ARROW_
:==
15
7
PD_isomap_ID
:==
1
58
PD_StdGeneric
:==
13
8
PD_TypeISO
:==
13
9
PD_ConsISO
:==
1
40
PD_iso_to
:==
1
41
PD_iso_from
:==
14
2
PD_TypeUNIT
:==
14
3
PD_ConsUNIT
:==
14
4
PD_TypeEITHER
:==
14
5
PD_ConsLEFT
:==
14
6
PD_ConsRIGHT
:==
14
7
PD_TypePAIR
:==
14
8
PD_ConsPAIR
:==
14
9
PD_TypeARROW
:==
1
50
PD_ConsARROW
:==
1
51
PD_TypeConsDefInfo
:==
15
2
PD_ConsConsDefInfo
:==
15
3
PD_TypeTypeDefInfo
:==
15
4
PD_ConsTypeDefInfo
:==
15
5
PD_cons_info
:==
15
6
PD_TypeCONS
:==
15
7
PD_ConsCONS
:==
15
8
PD_isomap_ARROW_
:==
15
9
PD_isomap_ID
:==
1
60
/* StdMisc */
PD_StdMisc
:==
1
59
PD_abort
:==
16
0
PD_undef
:==
16
1
PD_StdMisc
:==
1
61
PD_abort
:==
16
2
PD_undef
:==
16
3
PD_Start
:==
16
2
PD_Start
:==
16
4
PD_DummyForStrictAliasFun
:==
16
3
PD_DummyForStrictAliasFun
:==
16
5
PD_NrOfPredefSymbols
:==
16
4
PD_NrOfPredefSymbols
:==
16
6
(<<=)
infixl
(<<=)
state
val
...
...
@@ -200,6 +205,8 @@ where
<<-
(
"_undo_indirections"
,
IC_Expression
,
PD_undo_indirections
)
// MV..
<<-
(
"DynamicTemp"
,
IC_Type
,
PD_DynamicTemp
)
// <<- ("Module", IC_Type, PD_ModuleType)
<<-
(
"_Module"
,
IC_Expression
,
PD_ModuleConsSymbol
)
// ..MV
// AA..
...
...
frontend/transform.icl
View file @
bf5f61b6
...
...
@@ -1103,12 +1103,16 @@ where
->
(
fun_defs
,
symbol_table
)
expandMacrosInBody
::
[.
FunCall
]
CheckedBody
PredefinedSymbol
/* MV ... */
!
Int
/* ... MV */
*
ExpandState
->
([
FreeVar
],
Expression
,[
FreeVar
],[
FunCall
],
/* MV ... */
!
FunInfo
,
/* ... MV */
.
ExpandState
);
expandMacrosInBody
fi_calls
{
cb_args
,
cb_rhs
}
alias_dummy
/* MV ... */
es_current_fun_index
/* ... MV */
es
=:{
es_symbol_
table
,
es_fun_defs
}
expandMacrosInBody
fi_calls
{
cb_args
,
cb_rhs
}
alias_dummy
/* MV ... */
es_current_fun_index
/* ... MV */
es
=:{
es_symbol_
heap
,
es_fun_defs
}
// MV ...
#
(
fun_def
=:{
fun_info
},
es_fun_defs
)
=
es_fun_defs
![
es_current_fun_index
]
#
(
max_index
,
es_symbol_heap
)
=
determine_amount_of_dynamics
0
fun_info
.
fi_dynamics
es_symbol_heap
#
(
es
=:{
es_symbol_table
,
es_fun_defs
})
=
{
es
&
es_symbol_heap
=
es_symbol_heap
,
es_fun_defs
=
es_fun_defs
}
#
cos_used_dynamics
=
createArray
(
length
fun_info
.
fi_dynamics
)
False
// means not removed
=
createArray
(
inc
max_index
)
False
// means not removed
// ... MV
#
(
prev_calls
,
fun_defs
,
es_symbol_table
)
...
...
@@ -1144,15 +1148,28 @@ where
#
(
EI_Dynamic
_
id
)
=
expr_info
|
cos_used_dynamics
.[
id
]
// cos_removed_dynamic means cos_used_dynamic
=
(
changed
,[
dyn_expr_ptr
:
accu
],
cos_used_dynamics
,
cos_symbol_heap
)
// unused
=
(
True
,
accu
,
cos_used_dynamics
,
cos_symbol_heap
)
where
isEI_Dynamic
(
EI_Dynamic
_
_)
=
True
isEI_Dynamic
_
=
False
determine_amount_of_dynamics
max_index
[]
es_symbol_table
=
(
max_index
,
es_symbol_table
)
determine_amount_of_dynamics
max_index
[
expr_info_ptr
:
expr_info_ptrs
]
es_symbol_table
#
(
expr_info
,
es_symbol_table
)
=
readPtr
expr_info_ptr
es_symbol_table
#
(
max_index
,
es_symbol_table
)
=
case
expr_info
of
EI_Dynamic
_
id
->
(
max
max_index
id
,
es_symbol_table
)
EI_DynamicTypeWithVars
_
_
expr_info_ptrs2
->
determine_amount_of_dynamics
max_index
expr_info_ptrs2
es_symbol_table
// EI_DynamicType _ expr_info_ptrs2
// -> determine_amount_of_dynamics max_index expr_info_ptrs2 es_symbol_table
=
determine_amount_of_dynamics
max_index
expr_info_ptrs
es_symbol_table
// ... MV
expandCheckedAlternative
{
ca_rhs
,
ca_position
}
ei
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment