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
d7a0ac39
Commit
d7a0ac39
authored
May 10, 2019
by
johnvg@science.ru.nl
Browse files
remove tests for BEArraySelectFun or BEArrayUpdateFun in function BESpecialArrayFunctionSymbol
parent
feb4a221
Changes
1
Hide whitespace changes
Inline
Side-by-side
backendC/CleanCompilerSources/backend.c
View file @
d7a0ac39
...
@@ -553,10 +553,8 @@ void BEBindSpecialType (int special_type_n,int type_index,int module_index)
...
@@ -553,10 +553,8 @@ void BEBindSpecialType (int special_type_n,int type_index,int module_index)
BESymbolP
BESymbolP
BESpecialArrayFunctionSymbol
(
BEArrayFunKind
arrayFunKind
,
int
functionIndex
,
int
moduleIndex
)
BESpecialArrayFunctionSymbol
(
BEArrayFunKind
arrayFunKind
,
int
functionIndex
,
int
moduleIndex
)
{
{
Bool
isSpecialArrayFunction
;
BEModuleP
module
;
BEModuleP
module
;
SymbolP
functionSymbol
;
SymbolP
functionSymbol
,
previousFunctionSymbol
;
SymbDefP
sdef
;
SymbDefP
originalsdef
;
SymbDefP
originalsdef
;
TypeAlt
*
typeAlt
;
TypeAlt
*
typeAlt
;
TypeNode
elementType
,
arrayType
;
TypeNode
elementType
,
arrayType
;
...
@@ -572,172 +570,153 @@ BESpecialArrayFunctionSymbol (BEArrayFunKind arrayFunKind, int functionIndex, in
...
@@ -572,172 +570,153 @@ BESpecialArrayFunctionSymbol (BEArrayFunKind arrayFunKind, int functionIndex, in
originalsdef
=
functionSymbol
->
symb_def
;
originalsdef
=
functionSymbol
->
symb_def
;
typeAlt
=
originalsdef
->
sdef_rule_type
->
rule_type_rule
;
typeAlt
=
originalsdef
->
sdef_rule_type
->
rule_type_rule
;
isSpecialArrayFunction
=
False
;
switch
(
arrayFunKind
)
switch
(
arrayFunKind
)
{
{
case
BEArraySelectFun
:
Assert
(
originalsdef
->
sdef_arfun
==
BEArraySelectFun
||
originalsdef
->
sdef_arfun
==
BEUnqArraySelectFun
);
break
;
case
BE_UnqArraySelectFun
:
case
BE_UnqArraySelectFun
:
case
BE_UnqArraySelectLastFun
:
case
BE_UnqArraySelectLastFun
:
Assert
(
typeAlt
->
type_alt_lhs
->
type_node_arity
==
2
);
Assert
(
typeAlt
->
type_alt_lhs
->
type_node_arity
==
2
);
elementType
=
typeAlt
->
type_alt_rhs
;
elementType
=
typeAlt
->
type_alt_rhs
;
arrayType
=
typeAlt
->
type_alt_lhs
->
type_node_arguments
->
type_arg_node
;
arrayType
=
typeAlt
->
type_alt_lhs
->
type_node_arguments
->
type_arg_node
;
isSpecialArrayFunction
=
True
;
Assert
(
originalsdef
->
sdef_arfun
==
BEArraySelectFun
);
Assert
(
originalsdef
->
sdef_arfun
==
BEArraySelectFun
);
break
;
break
;
case
BE_ArrayUpdateFun
:
case
BE_ArrayUpdateFun
:
isSpecialArrayFunction
=
True
;
elementType
=
typeAlt
->
type_alt_lhs
->
type_node_arguments
->
type_arg_next
->
type_arg_next
->
type_arg_node
;
elementType
=
typeAlt
->
type_alt_lhs
->
type_node_arguments
->
type_arg_next
->
type_arg_next
->
type_arg_node
;
arrayType
=
typeAlt
->
type_alt_lhs
->
type_node_arguments
->
type_arg_node
;
arrayType
=
typeAlt
->
type_alt_lhs
->
type_node_arguments
->
type_arg_node
;
/* fall through! */
case
BEArrayUpdateFun
:
Assert
(
originalsdef
->
sdef_arfun
==
BEArrayUpdateFun
);
Assert
(
originalsdef
->
sdef_arfun
==
BEArrayUpdateFun
);
break
;
break
;
default:
default:
Assert
(
False
);
Assert
(
False
);
b
re
ak
;
re
turn
(
functionSymbol
)
;
}
}
if
(
isSpecialArrayFunction
)
previousFunctionSymbol
=
functionSymbol
;
{
functionSymbol
=
functionSymbol
->
symb_next
;
SymbolP
previousFunctionSymbol
;
Bool
allreadyCreated
;
previousFunctionSymbol
=
functionSymbol
;
if
(
functionSymbol
!=
NULL
&&
functionSymbol
->
symb_kind
==
definition
){
functionSymbol
=
functionSymbol
->
symb_next
;
if
(
functionSymbol
->
symb_def
->
sdef_arfun
==
(
ArrayFunKind
)
arrayFunKind
)
return
functionSymbol
;
allreadyCreated
=
False
;
if
(
arrayFunKind
==
BE_UnqArraySelectLastFun
&&
functionSymbol
->
symb_def
->
sdef_arfun
==
BE_UnqArraySelectFun
){
if
(
f
unctionSymbol
!=
NULL
&&
functionSymbol
->
symb_kind
==
definition
)
previousF
unctionSymbol
=
functionSymbol
;
{
functionSymbol
=
functionSymbol
->
symb_next
;
sdef
=
functionSymbol
->
symb_def
;
allreadyCreated
=
sdef
->
sdef_arfun
==
(
ArrayFunKind
)
arrayFunKind
;
if
(
functionSymbol
!=
NULL
&&
functionSymbol
->
symb_kind
==
definition
&&
if
(
!
allreadyCreated
&&
arrayFunKind
==
BE_UnqArraySelectLastFun
&&
sdef
->
sdef_arfun
==
BE_UnqArraySelectFun
)
functionSymbol
->
symb_def
->
sdef_arfun
==
(
ArrayFunKind
)
arrayFunKind
)
{
{
previousFunctionSymbol
=
functionSymbol
;
return
functionSymbol
;
functionSymbol
=
functionSymbol
->
symb_next
;
if
(
functionSymbol
!=
NULL
&&
functionSymbol
->
symb_kind
==
definition
)
{
sdef
=
functionSymbol
->
symb_def
;
allreadyCreated
=
sdef
->
sdef_arfun
==
(
ArrayFunKind
)
arrayFunKind
;
}
}
}
}
}
}
{
char
*
functionName
,
*
functionPrefix
;
TypeAlt
*
newTypeAlt
;
IdentP
newIdent
;
SymbDefP
newsdef
;
SymbolP
newFunctionSymbol
;
RuleTypes
newRuleType
;
TypeArgs
lhsArgs
;
TypeNode
rhs
;
newFunctionSymbol
=
ConvertAllocType
(
SymbolS
);
newsdef
=
ConvertAllocType
(
SymbDefS
);
newIdent
=
ConvertAllocType
(
IdentS
);
newTypeAlt
=
ConvertAllocType
(
TypeAlt
);
Assert
(
!
arrayType
->
type_node_is_var
);
switch
(
arrayType
->
type_node_symbol
->
symb_kind
)
{
case
strict_array_type
:
case
unboxed_array_type
:
elementType
->
type_node_annotation
=
StrictAnnot
;
break
;
case
array_type
:
break
;
default:
Assert
(
False
);
break
;
}
if
(
!
allreadyCreate
d
)
switch
(
arrayFunKin
d
)
{
{
char
*
functionName
,
*
functionPrefix
;
case
BE_UnqArraySelectFun
:
TypeAlt
*
newTypeAlt
;
rhs
=
BESymbolTypeNode
(
NoAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
IdentP
newIdent
;
BETypeArgs
(
elementType
,
BETypeArgs
(
arrayType
,
NULL
)));
SymbDefP
newsdef
;
lhsArgs
=
BETypeArgs
(
arrayType
,
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
int_type
],
NULL
),
NULL
));
SymbolP
newFunctionSymbol
;
functionPrefix
=
"_uselectf"
;
RuleTypes
newRuleType
;
break
;
TypeArgs
lhsArgs
;
case
BE_UnqArraySelectLastFun
:
TypeNode
rhs
;
newFunctionSymbol
=
ConvertAllocType
(
SymbolS
);
newsdef
=
ConvertAllocType
(
SymbDefS
);
newIdent
=
ConvertAllocType
(
IdentS
);
newTypeAlt
=
ConvertAllocType
(
TypeAlt
);
Assert
(
!
arrayType
->
type_node_is_var
);
switch
(
arrayType
->
type_node_symbol
->
symb_kind
)
{
{
case
strict_array_type
:
TypeNode
rType
;
case
unboxed_array_type
:
elementType
->
type_node_annotation
=
StrictAnnot
;
rType
=
BEVar0TypeNode
(
StrictAnnot
,
NoUniAttr
);
break
;
rhs
=
BESymbolTypeNode
(
NoAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
case
array_type
:
BETypeArgs
(
elementType
,
BETypeArgs
(
rType
,
NULL
)));
break
;
lhsArgs
=
BETypeArgs
(
default:
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
Assert
(
False
);
BETypeArgs
(
arrayType
,
BETypeArgs
(
rType
,
NULL
))),
break
;
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
int_type
],
NULL
),
NULL
));
functionPrefix
=
"_uselectl"
;
break
;
}
}
case
BE_ArrayUpdateFun
:
switch
(
arrayFunKind
)
{
{
case
BE_UnqArraySelectFun
:
TypeNode
rType
;
rhs
=
BESymbolTypeNode
(
NoAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
BETypeArgs
(
elementType
,
BETypeArgs
(
arrayType
,
NULL
)));
rType
=
BEVar0TypeNode
(
StrictAnnot
,
NoUniAttr
);
lhsArgs
=
BETypeArgs
(
arrayType
,
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
int_type
],
NULL
),
NULL
));
rhs
=
rType
;
functionPrefix
=
"_uselectf"
;
lhsArgs
=
BETypeArgs
(
break
;
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
case
BE_UnqArraySelectLastFun
:
BETypeArgs
(
arrayType
,
BETypeArgs
(
rType
,
NULL
))),
{
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
int_type
],
NULL
),
TypeNode
rType
;
BETypeArgs
(
elementType
,
NULL
)));
rType
=
BEVar0TypeNode
(
StrictAnnot
,
NoUniAttr
);
functionPrefix
=
"_updatei"
;
rhs
=
BESymbolTypeNode
(
NoAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
break
;
BETypeArgs
(
elementType
,
BETypeArgs
(
rType
,
NULL
)));
lhsArgs
=
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
BETypeArgs
(
arrayType
,
BETypeArgs
(
rType
,
NULL
))),
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
int_type
],
NULL
),
NULL
));
functionPrefix
=
"_uselectl"
;
break
;
}
case
BE_ArrayUpdateFun
:
{
TypeNode
rType
;
rType
=
BEVar0TypeNode
(
StrictAnnot
,
NoUniAttr
);
rhs
=
rType
;
lhsArgs
=
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
tuple_type
],
BETypeArgs
(
arrayType
,
BETypeArgs
(
rType
,
NULL
))),
BETypeArgs
(
BESymbolTypeNode
(
StrictAnnot
,
NoUniAttr
,
gBasicSymbols
[
int_type
],
NULL
),
BETypeArgs
(
elementType
,
NULL
)));
functionPrefix
=
"_updatei"
;
break
;
}
default:
Assert
(
False
);
break
;
}
}
default:
Assert
(
False
);
break
;
}
functionName
=
ConvertAlloc
(
strlen
(
functionPrefix
)
+
1
+
strlen
(
originalsdef
->
sdef_ident
->
ident_name
)
+
1
);
functionName
=
ConvertAlloc
(
strlen
(
functionPrefix
)
+
1
+
strlen
(
originalsdef
->
sdef_ident
->
ident_name
)
+
1
);
strcpy
(
functionName
,
functionPrefix
);
strcpy
(
functionName
,
functionPrefix
);
strcat
(
functionName
,
";"
);
strcat
(
functionName
,
";"
);
strcat
(
functionName
,
originalsdef
->
sdef_ident
->
ident_name
);
strcat
(
functionName
,
originalsdef
->
sdef_ident
->
ident_name
);
newTypeAlt
->
type_alt_lhs
=
BESymbolTypeNode
(
NoAnnot
,
NoUniAttr
,
newFunctionSymbol
,
lhsArgs
);
newTypeAlt
->
type_alt_rhs
=
rhs
;
newTypeAlt
->
type_alt_strict_positions
=
NULL
;
newIdent
->
ident_symbol
=
newFunctionSymbol
;
newTypeAlt
->
type_alt_lhs
=
BESymbolTypeNode
(
NoAnnot
,
NoUniAttr
,
newFunctionSymbol
,
lhsArgs
);
newIdent
->
ident_name
=
functionName
;
newTypeAlt
->
type_alt_rhs
=
rhs
;
newTypeAlt
->
type_alt_strict_positions
=
NULL
;
new
RuleType
=
ConvertAllocType
(
struct
rule_type
)
;
new
Ident
->
ident_symbol
=
newFunctionSymbol
;
new
RuleType
->
rule_type_rule
=
newTypeAlt
;
new
Ident
->
ident_name
=
functionName
;
newsdef
->
sdef_ident
=
newIdent
;
newRuleType
=
ConvertAllocType
(
struct
rule_type
);
newsdef
->
sdef_module
=
gBEState
.
be_icl
.
beicl_module
->
im_name
;
newRuleType
->
rule_type_rule
=
newTypeAlt
;
newsdef
->
sdef_mark
=
0
;
newsdef
->
sdef_isused
=
True
;
newsdef
->
sdef_exported
=
False
;
newsdef
->
sdef_arity
=
newTypeAlt
->
type_alt_lhs
->
type_node_arity
;
newsdef
->
sdef_arfun
=
arrayFunKind
;
newsdef
->
sdef_kind
=
SYSRULE
;
newsdef
->
sdef_rule_type
=
newRuleType
;
newsdef
->
sdef_ident
=
newIdent
;
newsdef
->
sdef_mark
=
0
;
newFunctionSymbol
->
symb_kind
=
definition
;
newsdef
->
sdef_ident
=
newIdent
;
newFunctionSymbol
->
symb_def
=
newsdef
;
newsdef
->
sdef_module
=
gBEState
.
be_icl
.
beicl_module
->
im_name
;
newsdef
->
sdef_mark
=
0
;
newsdef
->
sdef_isused
=
True
;
newsdef
->
sdef_exported
=
False
;
newsdef
->
sdef_arity
=
newTypeAlt
->
type_alt_lhs
->
type_node_arity
;
newsdef
->
sdef_arfun
=
arrayFunKind
;
newsdef
->
sdef_kind
=
SYSRULE
;
newsdef
->
sdef_rule_type
=
newRuleType
;
newsdef
->
sdef_ident
=
newIdent
;
newsdef
->
sdef_mark
=
0
;
functionSymbol
=
previousFunctionSymbol
->
symb_next
;
newFunctionSymbol
->
symb_kind
=
definition
;
previousFunctionSymbol
->
symb_next
=
newFunctionSymbol
;
newFunctionSymbol
->
symb_def
=
newsdef
;
newFunctionSymbol
->
symb_next
=
functionSymbol
;
AddUserDefinedArrayFunction
(
newFunctionSymbol
);
functionSymbol
=
previousFunctionSymbol
->
symb_next
;
previousFunctionSymbol
->
symb_next
=
newFunctionSymbol
;
newFunctionSymbol
->
symb_next
=
functionSymbol
;
functionSymbol
=
newFunctionSymbol
;
AddUserDefinedArrayFunction
(
newFunctionSymbol
);
}
functionSymbol
=
newFunctionSymbol
;
}
}
return
(
functionSymbol
);
return
(
functionSymbol
);
...
...
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