Skip to content
GitLab
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
feb4a221
Commit
feb4a221
authored
May 09, 2019
by
johnvg@science.ru.nl
Browse files
split list of symbols into list of functions and list of types
parent
07a16816
Changes
7
Hide whitespace changes
Inline
Side-by-side
backendC/CleanCompilerSources/backend.c
View file @
feb4a221
...
...
@@ -122,7 +122,8 @@ STRUCT (be_state, BEState)
BEIclS
be_icl
;
unsigned
int
be_nModules
;
SymbolP
be_allSymbols
;
SymbolP
be_function_symbols
;
SymbolP
be_type_symbols
;
SymbolP
be_dontCareSymbol
;
SymbolP
be_dictionarySelectFunSymbol
;
SymbolP
be_dictionaryUpdateFunSymbol
;
...
...
@@ -180,36 +181,48 @@ PredefinedSymbol (SymbKind symbolKind, int arity)
}
/* PredefinedSymbol */
static
SymbolP
AllocateSymbols
(
int
nFunctions
And
Types
,
int
nConstructorsAndFields
,
SymbolP
allSymbols
)
AllocateSymbols
(
int
nFunctions
,
int
n
Types
,
int
nConstructorsAndFields
,
SymbolP
*
function_symbols_h
,
SymbolP
*
type_symbols_h
)
{
int
nSymbols
;
nSymbols
=
nFunctionsAndTypes
+
nConstructorsAndFields
;
int
nFunctionsAndTypes
,
nSymbols
;
if
(
nSymbols
>
0
){
int
i
;
nFunctionsAndTypes
=
nFunctions
+
nTypes
;
nSymbols
=
nFunctionsAndTypes
+
nConstructorsAndFields
;
if
(
nSymbols
!=
0
){
SymbolP
symbols
;
int
i
;
symbols
=
(
SymbolP
)
ConvertAlloc
(
nSymbols
*
sizeof
(
SymbolS
));
i
=
0
;
if
(
nFunctionsAndTypes
>
0
){
if
(
nFunctions
>
0
){
for
(;
i
<
nFunctions
;
++
i
){
symbols
[
i
].
symb_kind
=
erroneous_symb
;
symbols
[
i
].
symb_next
=
&
symbols
[
i
+
1
];
}
symbols
[
nFunctions
-
1
].
symb_next
=
*
function_symbols_h
;
*
function_symbols_h
=
symbols
;
}
if
(
nTypes
>
0
){
for
(;
i
<
nFunctionsAndTypes
;
++
i
){
symbols
[
i
].
symb_kind
=
erroneous_symb
;
symbols
[
i
].
symb_next
=
&
symbols
[
i
+
1
];
}
symbols
[
nFunctionsAndTypes
-
1
].
symb_next
=
allS
ymbols
;
allSymbols
=
symbols
;
symbols
[
nFunctionsAndTypes
-
1
].
symb_next
=
*
type_s
ymbols
_h
;
*
type_symbols_h
=
&
symbols
[
nFunctions
]
;
}
for
(;
i
<
nSymbols
;
i
++
){
symbols
[
i
].
symb_kind
=
erroneous_symb
;
symbols
[
i
].
symb_next
=
NULL
;
}
}
return
(
allSymbols
);
return
symbols
;
}
else
return
NULL
;
}
/* AllocateSymbols */
static
void
...
...
@@ -285,11 +298,9 @@ DeclareModule (int moduleIndex, char *name, Bool isSystemModule, int nFunctions,
int
nTypes
,
int
nConstructors
,
int
nFields
)
{
BEModuleP
module
;
SymbolP
symbols
,
allSymbols
;
SymbolP
symbols
;
allSymbols
=
gBEState
.
be_allSymbols
;
allSymbols
=
AllocateSymbols
(
nFunctions
+
nTypes
,
nConstructors
+
nFields
,
allSymbols
);
symbols
=
AllocateSymbols
(
nFunctions
,
nTypes
,
nConstructors
+
nFields
,
&
gBEState
.
be_function_symbols
,
&
gBEState
.
be_type_symbols
);
Assert
((
unsigned
int
)
moduleIndex
<
gBEState
.
be_nModules
);
module
=
&
gBEState
.
be_modules
[
moduleIndex
];
...
...
@@ -297,8 +308,6 @@ DeclareModule (int moduleIndex, char *name, Bool isSystemModule, int nFunctions,
module
->
bem_name
=
name
;
module
->
bem_isSystemModule
=
isSystemModule
;
symbols
=
allSymbols
;
module
->
bem_nFunctions
=
(
unsigned
int
)
nFunctions
;
module
->
bem_functions
=
symbols
;
symbols
+=
nFunctions
;
...
...
@@ -327,8 +336,6 @@ DeclareModule (int moduleIndex, char *name, Bool isSystemModule, int nFunctions,
module
->
bem_nFields
=
(
unsigned
int
)
nFields
;
module
->
bem_fields
=
symbols
;
symbols
+=
nFields
;
gBEState
.
be_allSymbols
=
allSymbols
;
}
/* DeclareModule */
static
int
main_dcl_module_n
=
0
;
...
...
@@ -377,7 +384,8 @@ BEDeclareIclModule (CleanString name, CleanString modificationTime, int nFunctio
iclModule
->
im_def_module
=
im_def_module
;
iclModule
->
im_rules
=
NULL
;
iclModule
->
im_start
=
NULL
;
iclModule
->
im_symbols
=
gBEState
.
be_allSymbols
;
iclModule
->
im_function_symbols
=
gBEState
.
be_function_symbols
;
iclModule
->
im_type_symbols
=
gBEState
.
be_type_symbols
;
# if IMPORT_OBJ_AND_LIB
iclModule
->
im_imported_objs
=
NULL
;
iclModule
->
im_imported_libs
=
NULL
;
...
...
@@ -408,20 +416,21 @@ BEDeclareDclModule (int moduleIndex, CleanString name, CleanString modificationT
char
*
cName
;
SymbolP
moduleNameSymbol
;
DefMod
dclModule
;
SymbolP
save
S
ymbols
,
previous_all_symbols
;
SymbolP
save
d_function_symbols
,
saved_type_s
ymbols
,
previous_all_symbols
;
cName
=
ConvertCleanString
(
name
);
moduleNameSymbol
=
ConvertAllocType
(
SymbolS
);
moduleNameSymbol
->
symb_ident
=
Identifier
(
cName
);
if
(
moduleIndex
==
main_dcl_module_n
)
{
saveSymbols
=
gBEState
.
be_allSymbols
;
gBEState
.
be_allSymbols
=
NULL
;
if
(
moduleIndex
==
main_dcl_module_n
){
saved_function_symbols
=
gBEState
.
be_function_symbols
;
saved_type_symbols
=
gBEState
.
be_type_symbols
;
gBEState
.
be_function_symbols
=
NULL
;
gBEState
.
be_type_symbols
=
NULL
;
}
previous_all_symbols
=
gBEState
.
be_
allS
ymbols
;
previous_all_symbols
=
gBEState
.
be_
function_s
ymbols
;
DeclareModule
(
moduleIndex
,
cName
,
isSystemModule
,
nFunctions
,
nTypes
,
nConstructors
,
nFields
);
...
...
@@ -429,14 +438,16 @@ BEDeclareDclModule (int moduleIndex, CleanString name, CleanString modificationT
dclModule
->
dm_name
=
cName
;
dclModule
->
dm_modification_time
=
ConvertCleanString
(
modificationTime
);
dclModule
->
dm_system_module
=
isSystemModule
;
dclModule
->
dm_symbols
=
gBEState
.
be_allSymbols
;
dclModule
->
dm_function_symbols
=
gBEState
.
be_function_symbols
;
dclModule
->
dm_type_symbols
=
gBEState
.
be_type_symbols
;
dclModule
->
dm_symbols_end
=
previous_all_symbols
;
dclModule
->
dm_system_module_table_kind
=
FirstSystemModuleTable
+
moduleIndex
;
AddOpenDefinitionModule
(
moduleNameSymbol
,
dclModule
);
if
(
moduleIndex
==
main_dcl_module_n
){
gBEState
.
be_allSymbols
=
saveSymbols
;
gBEState
.
be_function_symbols
=
saved_function_symbols
;
gBEState
.
be_type_symbols
=
saved_type_symbols
;
im_def_module
=
dclModule
;
}
}
/* BEDeclareDclModule */
...
...
@@ -3398,7 +3409,8 @@ BEInit (int argc)
gBEState
.
be_argi
=
0
;
gBEState
.
be_modules
=
NULL
;
gBEState
.
be_allSymbols
=
NULL
;
gBEState
.
be_function_symbols
=
NULL
;
gBEState
.
be_type_symbols
=
NULL
;
gBEState
.
be_dontCareSymbol
=
NULL
;
gBEState
.
be_dictionarySelectFunSymbol
=
NULL
;
gBEState
.
be_dictionaryUpdateFunSymbol
=
NULL
;
...
...
backendC/CleanCompilerSources/checker_2.c
View file @
feb4a221
...
...
@@ -82,7 +82,7 @@ void ReadInlineCode (void)
symbols_end
=
def_mod
->
dm_symbols_end
;
for
(
symbol
=
def_mod
->
dm_symbols
;
symbol
!=
NULL
&&
symbol
!=
symbols_end
;
symbol
=
symbol
->
symb_next
)
for
(
symbol
=
def_mod
->
dm_
function_
symbols
;
symbol
!=
NULL
&&
symbol
!=
symbols_end
;
symbol
=
symbol
->
symb_next
)
if
(
symbol
->
symb_kind
==
definition
){
SymbDef
sdef
;
...
...
backendC/CleanCompilerSources/codegen.c
View file @
feb4a221
...
...
@@ -1136,14 +1136,14 @@ void CodeGeneration (ImpMod imod, char *fname)
#if 0
PrintRules (imod->im_rules);
#endif
DetermineSharedAndAnnotatedNodes
(
imod
->
im_rules
,
&
imod
->
im_symbols
);
DetermineSharedAndAnnotatedNodes
(
imod
->
im_rules
,
&
imod
->
im_
function_
symbols
);
ExitOnInterrupt
();
#if 0
PrintRules (imod->im_rules,rules_file);
#endif
GenerateStatesForRecords
(
imod
->
im_symbols
);
GenerateStatesForRecords
(
imod
->
im_
type_
symbols
);
DoStrictnessAnalysis_and_init_ok
=
DoStrictnessAnalysis
&&
init_strictness_analysis
(
imod
);
...
...
@@ -1152,7 +1152,7 @@ void CodeGeneration (ImpMod imod, char *fname)
ExitOnInterrupt
();
}
ExamineTypesAndLhsOfSymbols
(
imod
->
im_symbols
);
ExamineTypesAndLhsOfSymbols
(
imod
->
im_
function_symbols
,
imod
->
im_type_
symbols
);
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
{
...
...
@@ -1234,9 +1234,9 @@ void CodeGeneration (ImpMod imod, char *fname)
CreateStackFrames
();
ImportSymbols
(
imod
->
im_symbols
);
ImportSymbols
(
imod
->
im_
function_symbols
,
imod
->
im_type_
symbols
);
GenerateCodeForConstructorsAndRecords
(
imod
->
im_symbols
);
GenerateCodeForConstructorsAndRecords
(
imod
->
im_
type_
symbols
);
GenerateForeignExports
(
imod
->
im_foreign_exports
);
...
...
@@ -1285,7 +1285,7 @@ void CodeGeneration (ImpMod imod, char *fname)
GenerateCodeForLazyUnboxedRecordListFunctions
();
#endif
import_not_yet_imported_record_r_labels
(
imod
->
im_symbols
);
import_not_yet_imported_record_r_labels
(
imod
->
im_
type_
symbols
);
import_not_yet_imported_system_labels
();
WriteLastNewlineToABCFile
();
...
...
backendC/CleanCompilerSources/sa.c
View file @
feb4a221
...
...
@@ -5724,7 +5724,7 @@ int init_strictness_analysis (ImpMod imod)
if
(
setjmp
(
SAEnv
)
==
0
){
ConvertSyntaxTree
(
imod
->
im_symbols
);
ConvertSyntaxTree
(
imod
->
im_
type_
symbols
);
/* other values are converted after syntaxconversion (because of cons symbol) */
InitValues
();
...
...
backendC/CleanCompilerSources/statesgen.c
View file @
feb4a221
...
...
@@ -1254,16 +1254,19 @@ void ExamineTypesAndLhsOfSymbolDefinition (SymbDef def)
extern
PolyList
unboxed_record_cons_list
,
unboxed_record_decons_list
;
#endif
void
ExamineTypesAndLhsOfSymbols
(
Symbol
symb
s
)
void
ExamineTypesAndLhsOfSymbols
(
Symbol
P
function_symbols
,
SymbolP
type_symbol
s
)
{
SymbolP
symbs
;
next_def_number
=
1
;
while
(
symbs
!=
NULL
){
for_l
(
symbs
,
function_symbols
,
symb_next
)
if
(
symbs
->
symb_kind
==
definition
)
ExamineTypesAndLhsOfSymbolDefinition
(
symbs
->
symb_def
);
symbs
=
symbs
->
symb_next
;
}
for_l
(
symbs
,
type_symbols
,
symb_next
)
if
(
symbs
->
symb_kind
==
definition
)
ExamineTypesAndLhsOfSymbolDefinition
(
symbs
->
symb_def
);
#if STRICT_LISTS
{
PolyList
unboxed_record_cons_elem
,
unboxed_record_decons_elem
;
...
...
@@ -1280,7 +1283,7 @@ PolyList UserDefinedArrayFunctions;
char
*
current_imported_module
;
/* also used by instructions.c */
void
ImportSymbols
(
Symbol
symbols
)
void
ImportSymbols
(
Symbol
P
function_symbols
,
Symbol
type_
symbols
)
{
Symbol
symbol
;
PolyList
array_fun
;
...
...
@@ -1296,7 +1299,27 @@ void ImportSymbols (Symbol symbols)
fun_def
->
sdef_module
=
CurrentModule
;
}
for_l
(
symbol
,
symbols
,
symb_next
){
for_l
(
symbol
,
function_symbols
,
symb_next
){
SymbDef
sdef
;
if
(
symbol
->
symb_kind
!=
definition
)
continue
;
sdef
=
symbol
->
symb_def
;
if
(
sdef
->
sdef_module
!=
CurrentModule
){
if
(
sdef
->
sdef_isused
&&
sdef
->
sdef_mark
&
(
SDEF_USED_STRICTLY_MASK
|
SDEF_USED_LAZILY_MASK
|
SDEF_USED_CURRIED_MASK
)
){
if
(
sdef
->
sdef_module
!=
current_imported_module
){
current_imported_module
=
sdef
->
sdef_module
;
GenImpMod
(
current_imported_module
);
}
GenImport
(
sdef
);
}
}
}
for_l
(
symbol
,
type_symbols
,
symb_next
){
SymbDef
sdef
;
if
(
symbol
->
symb_kind
!=
definition
)
...
...
@@ -1330,7 +1353,7 @@ void ImportSymbols (Symbol symbols)
}
GenImport
(
constructor_sdef
);
}
}
}
}
else
if
(
sdef
->
sdef_kind
==
RECORDTYPE
){
FieldList
fields
;
...
...
backendC/CleanCompilerSources/statesgen.h
View file @
feb4a221
...
...
@@ -16,8 +16,8 @@ extern void InitStatesGen (void);
extern
void
GenerateStates
(
ImpRules
rules
);
extern
void
DetermineSharedAndAnnotatedNodes
(
ImpRules
rules
,
SymbolP
*
im_symbols_h
);
extern
void
DetermineStateOfArrayElem
(
Symbol
elemtype
,
States
state
);
extern
void
ExamineTypesAndLhsOfSymbols
(
Symbol
symb
s
);
extern
void
ImportSymbols
(
Symbol
symbols
);
extern
void
ExamineTypesAndLhsOfSymbols
(
Symbol
P
function_symbols
,
SymbolP
type_symbol
s
);
extern
void
ImportSymbols
(
Symbol
P
function_symbols
,
Symbol
type_
symbols
);
extern
void
import_not_yet_imported_record_r_labels
(
Symbol
symbols
);
extern
void
DetermineStatesOfRootNodeAndDefs
(
Node
root_node
,
NodeDefs
*
rootdef
,
StateS
demstate
,
int
local_scope
);
...
...
backendC/CleanCompilerSources/syntaxtr.t
View file @
feb4a221
...
...
@@ -668,7 +668,8 @@ typedef FileTime ModuleFileTime;
typedef
struct
{
char
*
im_name
;
Symbol
im_symbols
;
SymbolP
im_function_symbols
;
SymbolP
im_type_symbols
;
ImpRules
im_rules
;
struct
symbol_def
*
im_start
;
DefMod
im_def_module
;
...
...
@@ -684,7 +685,8 @@ typedef struct {
struct
def_repr
{
char
*
dm_name
;
Symbol
dm_symbols
;
SymbolP
dm_function_symbols
;
SymbolP
dm_type_symbols
;
Symbol
dm_symbols_end
;
TableKind
dm_system_module_table_kind
;
Bool
dm_system_module
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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