Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
clean-compiler-and-rts
compiler
Commits
97af71b3
Commit
97af71b3
authored
Jul 09, 2019
by
johnvg@science.ru.nl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove inlining abc code from .abc files in the backend (use :== code in system modules instead)
parent
4a22c31f
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
4 additions
and
487 deletions
+4
-487
backendC/CleanCompilerSources/backend.c
backendC/CleanCompilerSources/backend.c
+0
-7
backendC/CleanCompilerSources/buildtree.c
backendC/CleanCompilerSources/buildtree.c
+0
-1
backendC/CleanCompilerSources/checker_2.c
backendC/CleanCompilerSources/checker_2.c
+0
-32
backendC/CleanCompilerSources/checksupport.c
backendC/CleanCompilerSources/checksupport.c
+0
-1
backendC/CleanCompilerSources/codegen.c
backendC/CleanCompilerSources/codegen.c
+0
-2
backendC/CleanCompilerSources/codegen1.c
backendC/CleanCompilerSources/codegen1.c
+0
-1
backendC/CleanCompilerSources/codegen2.c
backendC/CleanCompilerSources/codegen2.c
+4
-12
backendC/CleanCompilerSources/comparser_2.c
backendC/CleanCompilerSources/comparser_2.c
+0
-3
backendC/CleanCompilerSources/comsupport.c
backendC/CleanCompilerSources/comsupport.c
+0
-2
backendC/CleanCompilerSources/instructions.c
backendC/CleanCompilerSources/instructions.c
+0
-43
backendC/CleanCompilerSources/optimisations.c
backendC/CleanCompilerSources/optimisations.c
+0
-1
backendC/CleanCompilerSources/scanner.h
backendC/CleanCompilerSources/scanner.h
+0
-10
backendC/CleanCompilerSources/scanner_2.c
backendC/CleanCompilerSources/scanner_2.c
+0
-370
backendC/CleanCompilerSources/syntaxtr.t
backendC/CleanCompilerSources/syntaxtr.t
+0
-2
No files found.
backendC/CleanCompilerSources/backend.c
View file @
97af71b3
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
# include "sizes.h"
# include "sizes.h"
# include "set_scope_numbers.h"
# include "set_scope_numbers.h"
# include "scanner.h"
/* InitScanner, ScanInitIdentStringTable */
# include "checker.h"
/* scc_dependency_list, ClearOpenDefinitionModules, AddOpenDefinitionModule */
# include "checker.h"
/* scc_dependency_list, ClearOpenDefinitionModules, AddOpenDefinitionModule */
# include "comsupport.h"
/* CurrentModule */
# include "comsupport.h"
/* CurrentModule */
# include "buildtree.h"
/* TupleSymbol, ApplySymbol */
# include "buildtree.h"
/* TupleSymbol, ApplySymbol */
...
@@ -2353,9 +2352,6 @@ BEDeclareRuleType (int functionIndex, int moduleIndex, CleanString name)
...
@@ -2353,9 +2352,6 @@ BEDeclareRuleType (int functionIndex, int moduleIndex, CleanString name)
Assert
(
functions
[
functionIndex
].
symb_kind
==
erroneous_symb
);
Assert
(
functions
[
functionIndex
].
symb_kind
==
erroneous_symb
);
newSymbDef
=
ConvertAllocType
(
SymbDefS
);
newSymbDef
=
ConvertAllocType
(
SymbDefS
);
if
(
module
->
bem_isSystemModule
)
/* for inline code */
PutStringInHashTable
(
ConvertCleanString
(
name
),
FirstSystemModuleTable
+
moduleIndex
,
newSymbDef
);
newSymbDef
->
sdef_kind
=
NEWDEFINITION
;
newSymbDef
->
sdef_kind
=
NEWDEFINITION
;
newSymbDef
->
sdef_exported
=
False
;
newSymbDef
->
sdef_exported
=
False
;
newSymbDef
->
sdef_module
=
module
->
bem_name
;
newSymbDef
->
sdef_module
=
module
->
bem_name
;
...
@@ -3296,9 +3292,6 @@ BEInit (int argc)
...
@@ -3296,9 +3292,6 @@ BEInit (int argc)
CurrentExt
=
""
;
CurrentExt
=
""
;
InitStorage
();
InitStorage
();
/* +++ remove symbol table from backend */
ScanInitIdentStringTable
();
InitScanner
();
/* for inlining */
#if SA_RECOGNIZES_ABORT_AND_UNDEF
#if SA_RECOGNIZES_ABORT_AND_UNDEF
StdMiscId
=
NULL
;
StdMiscId
=
NULL
;
...
...
backendC/CleanCompilerSources/buildtree.c
View file @
97af71b3
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
# include "sizes.h"
# include "sizes.h"
# include "buildtree.h"
# include "buildtree.h"
# include "checker.h"
# include "checker.h"
# include "scanner.h"
SymbolP
TrueSymbol
,
FalseSymbol
,
TupleSymbol
,
SymbolP
TrueSymbol
,
FalseSymbol
,
TupleSymbol
,
SelectSymbols
[
MaxNodeArity
],
ApplySymbol
,
IfSymbol
,
SelectSymbols
[
MaxNodeArity
],
ApplySymbol
,
IfSymbol
,
...
...
backendC/CleanCompilerSources/checker_2.c
View file @
97af71b3
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
#include "syntaxtr.t"
#include "syntaxtr.t"
#include "comsupport.h"
#include "comsupport.h"
#include "sizes.h"
#include "sizes.h"
#include "scanner.h"
#include "buildtree.h"
#include "buildtree.h"
#include "comparser.h"
#include "comparser.h"
#include "statesgen.h"
#include "statesgen.h"
...
@@ -42,37 +41,6 @@ void GenDependencyList (void)
...
@@ -42,37 +41,6 @@ void GenDependencyList (void)
);
);
}
}
void
ReadInlineCode
(
void
)
{
DefModList
d_mod
;
for_l
(
d_mod
,
OpenDefinitionModules
,
mod_next
){
DefMod
def_mod
;
def_mod
=
d_mod
->
mod_body
;
if
(
def_mod
->
dm_system_module
){
int
i
,
n_function_symbols
;
Symbol
function_symbol_a
;
n_function_symbols
=
def_mod
->
dm_n_function_symbols
;
function_symbol_a
=
def_mod
->
dm_function_symbol_a
;
for
(
i
=
0
;
i
<
n_function_symbols
;
++
i
)
if
(
function_symbol_a
[
i
].
symb_kind
==
definition
){
SymbDef
sdef
;
sdef
=
function_symbol_a
[
i
].
symb_def
;
if
(
sdef
->
sdef_kind
==
SYSRULE
&&
(
sdef
->
sdef_mark
&
(
SDEF_USED_STRICTLY_MASK
|
SDEF_DEFRULE_ABC_CODE
))
==
SDEF_USED_STRICTLY_MASK
)
break
;
}
if
(
i
<
n_function_symbols
&&
d_mod
->
mod_body
->
dm_name
!=
CurrentModule
)
/* Get the inline instructions of all the rules that are defined in this module */
ScanInlineFile
(
d_mod
->
mod_body
->
dm_name
,
FirstSystemModuleTable
+
def_mod
->
dm_module_n
);
}
}
}
char
*
StdBoolId
;
char
*
StdBoolId
;
SymbDef
AndSymbDef
,
OrSymbDef
;
SymbDef
AndSymbDef
,
OrSymbDef
;
...
...
backendC/CleanCompilerSources/checksupport.c
View file @
97af71b3
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#include "types.t"
#include "types.t"
#include "syntaxtr.t"
#include "syntaxtr.t"
#include "comsupport.h"
#include "comsupport.h"
#include "scanner.h"
#include "checksupport.h"
#include "checksupport.h"
#include "settings.h"
#include "settings.h"
#include "buildtree.h"
#include "buildtree.h"
...
...
backendC/CleanCompilerSources/codegen.c
View file @
97af71b3
...
@@ -1223,8 +1223,6 @@ void CodeGeneration (ImpMod imod, char *fname)
...
@@ -1223,8 +1223,6 @@ void CodeGeneration (ImpMod imod, char *fname)
GenSystemImports
();
GenSystemImports
();
FileComment
();
FileComment
();
ReadInlineCode
();
CreateStackFrames
();
CreateStackFrames
();
ImportSymbols
(
imod
->
im_size_dcl_mfts_a
,
imod
->
im_dcl_mfts_a
);
ImportSymbols
(
imod
->
im_size_dcl_mfts_a
,
imod
->
im_dcl_mfts_a
);
...
...
backendC/CleanCompilerSources/codegen1.c
View file @
97af71b3
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include "codegen2.h"
#include "codegen2.h"
#include "codegen3.h"
#include "codegen3.h"
#include "instructions.h"
#include "instructions.h"
#include "scanner.h"
#include "buildtree.h"
#include "buildtree.h"
#include "pattern_match.h"
#include "pattern_match.h"
#if SHARE_UPDATE_CODE
#if SHARE_UPDATE_CODE
...
...
backendC/CleanCompilerSources/codegen2.c
View file @
97af71b3
...
@@ -2616,9 +2616,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
...
@@ -2616,9 +2616,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
*
bsp_p
-=
b_size
;
*
bsp_p
-=
b_size
;
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
(
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_INSTRUCTIONS
)
!=
0
&&
sdef
->
sdef_instructions
!=
NULL
&&
*
sdef
->
sdef_instructions
!=
'\0'
&&
*
sdef
->
sdef_instructions
!=
'.'
)
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
))
||
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
)
)
{
{
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
...
@@ -2643,9 +2641,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
...
@@ -2643,9 +2641,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
*
bsp_p
-=
b_size
;
*
bsp_p
-=
b_size
;
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
(
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_INSTRUCTIONS
)
!=
0
&&
sdef
->
sdef_instructions
!=
NULL
&&
*
sdef
->
sdef_instructions
!=
'\0'
&&
*
sdef
->
sdef_instructions
!=
'.'
)
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
))
||
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
)
)
{
{
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
+
1
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
+
1
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
...
@@ -2668,9 +2664,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
...
@@ -2668,9 +2664,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
*
bsp_p
-=
b_size
;
*
bsp_p
-=
b_size
;
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
(
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_INSTRUCTIONS
)
!=
0
&&
sdef
->
sdef_instructions
!=
NULL
&&
*
sdef
->
sdef_instructions
!=
'\0'
&&
*
sdef
->
sdef_instructions
!=
'.'
)
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
))
||
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
)
)
{
{
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
...
@@ -4998,9 +4992,7 @@ static void FillUniqueNodeWithNode (NodeP update_node,int *asp_p,int *bsp_p,Code
...
@@ -4998,9 +4992,7 @@ static void FillUniqueNodeWithNode (NodeP update_node,int *asp_p,int *bsp_p,Code
*
bsp_p
-=
b_size
;
*
bsp_p
-=
b_size
;
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
if
(
!
(
sdef
->
sdef_kind
==
SYSRULE
&&
(
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_INSTRUCTIONS
)
!=
0
&&
sdef
->
sdef_instructions
!=
NULL
&&
*
sdef
->
sdef_instructions
!=
'\0'
&&
*
sdef
->
sdef_instructions
!=
'.'
)
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
))
||
(
sdef
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
)
!=
0
&&
sdef
->
sdef_abc_code
!=
NULL
&&
sdef
->
sdef_abc_code
->
instr_this
[
0
]
!=
'.'
)
)
{
{
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
cleanup_stack
(
asp_p
,
bsp_p
,
a_size
,
b_size
,
&
code_gen_node_ids_p
->
a_node_ids
,
&
code_gen_node_ids_p
->
b_node_ids
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
&
code_gen_node_ids_p
->
free_node_ids
,
code_gen_node_ids_p
->
moved_node_ids_l
,
...
...
backendC/CleanCompilerSources/comparser_2.c
View file @
97af71b3
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
# include "syntaxtr.t"
# include "syntaxtr.t"
# include "comsupport.h"
# include "comsupport.h"
# include "scanner.h"
# include "sizes.h"
# include "sizes.h"
# include "checker.h"
# include "checker.h"
# include "statesgen.h"
# include "statesgen.h"
...
@@ -20,8 +19,6 @@ InitParser (void)
...
@@ -20,8 +19,6 @@ InitParser (void)
{
{
int
i
;
int
i
;
ScanInitialise
();
for
(
i
=
0
;
i
<
MaxNodeArity
;
i
++
)
for
(
i
=
0
;
i
<
MaxNodeArity
;
i
++
)
{
SelectSymbols
[
i
]
=
NULL
;
{
SelectSymbols
[
i
]
=
NULL
;
TupleTypeSymbols
[
i
]
=
NULL
;
TupleTypeSymbols
[
i
]
=
NULL
;
...
...
backendC/CleanCompilerSources/comsupport.c
View file @
97af71b3
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "settings.h"
#include "settings.h"
#include "syntaxtr.t"
#include "syntaxtr.t"
#include "comsupport.h"
#include "comsupport.h"
#include "scanner.h"
#include "buildtree.h"
#include "buildtree.h"
#include "comparser.h"
#include "comparser.h"
#include "checker.h"
#include "checker.h"
...
@@ -454,7 +453,6 @@ void InitCompiler (void)
...
@@ -454,7 +453,6 @@ void InitCompiler (void)
CurrentExt
=
""
;
CurrentExt
=
""
;
InitStorage
();
InitStorage
();
InitScanner
();
InitParser
();
InitParser
();
InitChecker
();
InitChecker
();
InitStatesGen
();
InitStatesGen
();
...
...
backendC/CleanCompilerSources/instructions.c
View file @
97af71b3
...
@@ -1332,55 +1332,12 @@ static void CallFunction2 (Label label, SymbDef def, Bool isjsr, StateS root_sta
...
@@ -1332,55 +1332,12 @@ static void CallFunction2 (Label label, SymbDef def, Bool isjsr, StateS root_sta
label
->
lab_pref
=
s_pref
;
label
->
lab_pref
=
s_pref
;
if
(
def
->
sdef_kind
==
SYSRULE
){
if
(
def
->
sdef_kind
==
SYSRULE
){
char
*
instr
;
if
(
def
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
){
if
(
def
->
sdef_mark
&
SDEF_DEFRULE_ABC_CODE
){
GenABCInstructions
(
def
->
sdef_abc_code
);
GenABCInstructions
(
def
->
sdef_abc_code
);
if
(
!
isjsr
)
if
(
!
isjsr
)
GenRtn
(
aout
,
bout
,
root_state
);
GenRtn
(
aout
,
bout
,
root_state
);
return
;
return
;
}
}
if
(
def
->
sdef_mark
&
SDEF_DEFRULE_INSTRUCTIONS
)
instr
=
def
->
sdef_instructions
;
else
instr
=
NULL
;
if
(
instr
&&
*
instr
!=
'\0'
){
char
*
tail
;
for
(;
*
instr
!=
'\0'
;
instr
=
tail
){
for
(
tail
=
instr
;
*
tail
!=
'\n'
;
tail
++
)
;
*
tail
=
'\0'
;
FPrintF
(
OutFile
,
"
\n
%s"
,
instr
);
*
tail
++
=
'\n'
;
}
if
(
!
isjsr
)
GenRtn
(
aout
,
bout
,
root_state
);
}
else
{
if
((
def
->
sdef_mark
&
SDEF_WARNED_NO_INLINE_CODE
)
==
0
&&
instr
==
NULL
){
char
*
previous_module
=
CurrentModule
;
char
*
previous_ext
=
CurrentExt
;
CurrentModule
=
def
->
sdef_module
;
CurrentExt
=
GetFileExtension
(
abcFile
);
StaticMessage
(
False
,
"%D"
,
"no inline code for this function"
,
def
);
CurrentModule
=
previous_module
;
CurrentExt
=
previous_ext
;
def
->
sdef_mark
|=
SDEF_WARNED_NO_INLINE_CODE
;
}
GenDStackLayout
(
ain
,
bin
,
fun_args
);
if
(
isjsr
){
GenJsr
(
label
);
GenOStackLayoutOfState
(
aout
,
bout
,
root_state
);
}
else
GenJmp
(
label
);
}
return
;
}
}
if
(
def
->
sdef_kind
==
IMPRULE
){
if
(
def
->
sdef_kind
==
IMPRULE
){
if
((
def
->
sdef_mark
&
SDEF_INLINE_IS_CONSTRUCTOR
)
!=
0
){
if
((
def
->
sdef_mark
&
SDEF_INLINE_IS_CONSTRUCTOR
)
!=
0
){
...
...
backendC/CleanCompilerSources/optimisations.c
View file @
97af71b3
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
#include "comsupport.h"
#include "comsupport.h"
#include "statesgen.h"
#include "statesgen.h"
#include "checker.h"
#include "checker.h"
#include "scanner.h"
#include "buildtree.h"
#include "buildtree.h"
#include "codegen_types.h"
#include "codegen_types.h"
#include "optimisations.h"
#include "optimisations.h"
...
...
backendC/CleanCompilerSources/scanner.h
View file @
97af71b3
extern
void
PutStringInHashTable
(
char
*
string
,
TableKind
tabkind
,
SymbDefP
sys_rule_def
);
extern
void
InitScanner
(
void
);
extern
void
ScanInitialise
(
void
);
extern
void
ScanInitIdentStringTable
(
void
);
extern
void
ScanInlineFile
(
char
*
fname
,
TableKind
table_kind
);
backendC/CleanCompilerSources/scanner_2.c
View file @
97af71b3
/*
Ronny Wichers Schreur
University of Nijmegen
*/
# include <stdio.h>
# include <string.h>
# include <ctype.h>
# include <limits.h>
# undef H
# include "compiledefines.h"
# include "types.t"
#if defined (applec) || (defined (__MWERKS__) && !defined (_WINDOWS_)) || defined (__MRC__)
# define __ppc__
#endif
# include "system.h"
# include "syntaxtr.t"
# include "comsupport.h"
# include "scanner.h"
# include "sizes.h"
STRUCT
(
ident
,
Ident
){
char
*
ident_name
;
struct
symbol_def
*
ident_sys_rule_def
;
struct
ident
*
ident_next
;
unsigned
char
ident_table
;
/* TableKind */
unsigned
char
ident_mark
;
};
#define INLINE_MASK 8
typedef
struct
ident_string
*
IdentStringP
;
struct
ident_string
{
IdentStringP
left
;
IdentStringP
right
;
Ident
ident
;
char
*
string
;
};
static
IdentP
NewIdentInTable
(
TableKind
tableKind
,
char
*
name
)
{
IdentP
ident
;
ident
=
CompAllocType
(
struct
ident
);
ident
->
ident_table
=
tableKind
;
ident
->
ident_name
=
name
;
ident
->
ident_next
=
NULL
;
ident
->
ident_sys_rule_def
=
NULL
;
ident
->
ident_mark
=
0
;
return
(
ident
);
}
#define CompAllocString(size) ((char*)CompAlloc(size))
static
char
*
AllocString
(
char
*
string
,
short
length
)
{
int
i
;
char
*
s
,
*
newString
;
s
=
newString
=
CompAllocString
(
length
+
1
);
for
(
i
=
0
;
i
<
length
;
i
++
)
*
s
++
=
*
string
++
;
*
s
=
'\0'
;
return
(
newString
);
}
/* AllocString */
# define kIdentStringTableSizeBits 10
# define kIdentStringTableSize ((1 << kIdentStringTableSizeBits) - 1)
static
IdentStringP
*
gIdentStringTable
;
static
IdentStringP
StringInTable
(
char
*
string
,
short
length
)
{
int
i
;
unsigned
long
hash
;
IdentStringP
identString
,
*
identStringPtr
;
char
*
s
;
hash
=
0
;
s
=
string
;
for
(
i
=
0
;
i
<
length
;
i
++
)
{
hash
<<=
2
;
hash
+=
*
s
++
;
}
/* Compute (hash % kIdentStringTableSize) */
while
(
hash
>=
(
kIdentStringTableSize
<<
1
))
hash
=
(
hash
&
kIdentStringTableSize
)
+
(
hash
>>
kIdentStringTableSizeBits
);
if
(
hash
>=
kIdentStringTableSize
)
hash
-=
kIdentStringTableSize
;
identStringPtr
=
&
gIdentStringTable
[
hash
];
while
((
identString
=
*
identStringPtr
)
!=
NIL
)
{
int
compare
;
compare
=
strncmp
(
identString
->
string
,
string
,
length
);
if
(
compare
==
0
&&
(
compare
=
((
unsigned
char
*
)
identString
->
string
)
[
length
])
==
0
)
/* found it */
break
;
else
if
(
compare
>
0
)
identStringPtr
=
&
identString
->
left
;
else
/* if (compare < 0) */
identStringPtr
=
&
identString
->
right
;
}
if
(
identString
==
NIL
)
{
identString
=
CompAllocType
(
struct
ident_string
);
identString
->
left
=
NIL
;
identString
->
right
=
NIL
;
identString
->
ident
=
NIL
;
identString
->
string
=
AllocString
(
string
,
length
);
*
identStringPtr
=
identString
;
}
return
(
identString
);
}
/* StringInTable */
static
IdentP
PutIdentStringInTable
(
IdentStringP
identString
,
TableKind
tableKind
)
{
IdentP
ident
;
for
(
ident
=
identString
->
ident
;
ident
!=
NIL
;
ident
=
ident
->
ident_next
)
if
(
ident
->
ident_table
==
tableKind
)
break
;
if
(
ident
==
NIL
)
{
ident
=
NewIdentInTable
(
tableKind
,
identString
->
string
);
ident
->
ident_next
=
identString
->
ident
;
identString
->
ident
=
ident
;
}
return
(
ident
);
}
/* PutIdentStringInTable */
void
PutStringInHashTable
(
char
*
string
,
TableKind
tableKind
,
SymbDefP
sys_rule_def
)
{
IdentStringP
identString
;
IdentP
newIdent
;
identString
=
StringInTable
(
string
,
strlen
(
string
));
newIdent
=
PutIdentStringInTable
(
identString
,
tableKind
);
newIdent
->
ident_sys_rule_def
=
sys_rule_def
;
}
/* PutStringInHashTable */
static
IdentP
RetrieveFromSymbolTable
(
char
*
string
,
TableKind
table_kind
)
{
char
*
s
;
unsigned
long
hash
;
IdentStringP
identString
;
IdentP
ident
;
hash
=
0
;
for
(
s
=
string
;
*
s
!=
'\0'
;
s
++
){
hash
<<=
2
;
hash
+=
*
s
;
}
/* Compute (hash % 1023) */
while
(
hash
>=
2046
)
hash
=
(
hash
&
1023
)
+
(
hash
>>
10
);
if
(
hash
>=
1023
)
hash
-=
1023
;
identString
=
gIdentStringTable
[
hash
];
while
(
identString
!=
NIL
){
int
compare
;
compare
=
strcmp
(
identString
->
string
,
string
);
if
(
compare
==
0
)
/* found it */
break
;
else
if
(
compare
>
0
)
identString
=
identString
->
left
;
else
/* if (compare < 0) */
identString
=
identString
->
right
;
}
if
(
identString
!=
NIL
){
for
(
ident
=
identString
->
ident
;
ident
!=
NIL
;
ident
=
ident
->
ident_next
)
if
(
ident
->
ident_table
==
table_kind
)
break
;
}
else
ident
=
NIL
;
return
ident
;
}
/*
+-----------------------------------------------------------------------+
| ReadInlineCode scans all the imported SYSTEM modules and stores the |
| the encountered inline instructions in the symbol table. |
+-----------------------------------------------------------------------+
*/
char
NextLine
[
LineLength
];
/* has a command been read? */
static
char
*
IsCommand
(
char
*
com
,
char
*
p
)
{
while
(
*
com
++
==
*
p
++
)
if
(
*
com
==
'\0'
)
return
(
p
);
return
((
char
*
)
NIL
);
}
/* scan a file for .inline-.end command pairs */
char
*
InlineCodeBuffer
;
unsigned
InlineBufferIndex
,
InlineBufferStart
;
void
ScanInlineFile
(
char
*
fname
,
TableKind
system_module_table_kind
)
{
register
char
*
tail
,
*
instr
,
*
importingModule
,
*
importingExtension
;
IdentP
instrid
;
int
nrinstr
;
File
f
;
importingModule
=
CurrentModule
;