Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rtree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chrg
rtree
Commits
d100697f
Commit
d100697f
authored
3 weeks ago
by
chrg
Browse files
Options
Downloads
Patches
Plain Diff
Acceptable changes
parent
211f5ac9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rtree-c/src/ReduceC.hs
+43
-13
43 additions, 13 deletions
rtree-c/src/ReduceC.hs
with
43 additions
and
13 deletions
rtree-c/src/ReduceC.hs
+
43
−
13
View file @
d100697f
...
...
@@ -142,6 +142,7 @@ reduceCTranslUnit (C.CTranslUnit es ni) ctx = do
let
builtins
=
[
(
"fabsf"
,
FunType
(
NonVoid
TNum
)
(
Params
[
Just
TNum
]
False
))
,
(
"fabs"
,
FunType
(
NonVoid
TNum
)
(
Params
[
Just
TNum
]
False
))
,
(
"__builtin_abort"
,
FunType
Void
(
Params
[]
False
))
]
let
functions'''
=
...
...
@@ -450,9 +451,21 @@ reduceCExternalDeclaration r = case r of
-- Type definitions
C
.
CDeclExt
(
C
.
CDecl
(
C
.
CStorageSpec
(
C
.
CTypedef
nif
)
:
rst
)
[
item
]
ni
)
->
runMaybeT
do
(
ix
,
dd
)
<-
case
item
of
C
.
CDeclarationItem
(
C
.
CDeclr
(
Just
ix
)
dd
Nothing
_
_
)
Nothing
Nothing
->
pure
(
ix
,
dd
)
(
ix
,
dd
,
wrap
)
<-
case
item
of
C
.
CDeclarationItem
(
C
.
CDeclr
(
Just
ix
)
dd
Nothing
extras
_
)
Nothing
Nothing
->
case
extras
of
[]
->
pure
(
ix
,
dd
,
id
)
[
C
.
CAttr
(
C
.
Ident
"__vector_size__"
_
_
)
[
a
]
_
]
->
do
case
a
of
C
.
CBinary
C
.
CMulOp
(
C
.
CConst
(
C
.
CIntConst
(
C
.
CInteger
n
_
_
)
_
))
(
C
.
CSizeofType
_
_
)
_
->
-- todo assuming this is a checked size
pure
(
ix
,
dd
,
NonVoid
.
TVector
(
fromInteger
n
)
)
_
->
notSupportedYet
a
ni
a
->
notSupportedYet
(
map
void
a
)
ni
i
->
notSupportedYet
(
void
i
)
ni
modify'
(
addTypeDef
ix
ITDelete
)
...
...
@@ -463,10 +476,10 @@ reduceCExternalDeclaration r = case r of
(
t
,
_
)
<-
updateCDerivedDeclarators
bt
(
repeat
True
)
dd
unless
keep
do
modify'
(
addTypeDef
ix
(
ITInline
t
rst'
))
modify'
(
addTypeDef
ix
(
ITInline
(
wrap
t
)
rst'
))
exceptIf
(
"inline typedef "
<>
C
.
identToString
ix
,
C
.
posOf
ni
)
modify'
(
addTypeDef
ix
(
ITKeep
t
))
modify'
(
addTypeDef
ix
(
ITKeep
(
wrap
t
)
))
pure
$
C
.
CDeclExt
$
C
.
CDecl
(
C
.
CStorageSpec
(
C
.
CTypedef
nif
)
:
rst'
)
[
item
]
ni
-- The rest.
...
...
@@ -661,14 +674,29 @@ reduceCInitializer ::
m
(
C
.
CInitializer
C
.
NodeInfo
,
Maybe
C
.
CExpr
)
reduceCInitializer
t
einit
ctx
=
case
einit
of
C
.
CInitExpr
e
ni2
->
do
e'
<-
fromMaybe
(
pure
zeroExpr
)
$
reduceCExpr
e
(
exactly
t
)
ctx
pure
(
C
.
CInitExpr
e'
ni2
,
case
e'
of
C
.
CConst
_
->
Just
e'
C
.
CVar
_
_
->
Just
e'
_ow
->
Nothing
)
let
me
=
reduceCExpr
e
(
exactly
t
)
ctx
case
(
me
,
t
)
of
(
Just
es
,
_
)
->
do
e'
<-
es
pure
(
C
.
CInitExpr
e'
ni2
,
case
e'
of
C
.
CConst
_
->
Just
e'
C
.
CVar
_
_
->
Just
e'
_ow
->
Nothing
)
(
Nothing
,
TVector
n
_
)
->
do
let
items'
=
[(
[]
,
C
.
CInitExpr
zeroExpr
ni2
)
|
_
<-
replicate
n
()
]
pure
(
C
.
CInitList
(
C
.
CInitializerList
items'
)
ni2
,
Nothing
)
(
Nothing
,
_
)
->
do
let
e'
=
zeroExpr
pure
(
C
.
CInitExpr
e'
ni2
,
case
e'
of
C
.
CConst
_
->
Just
e'
C
.
CVar
_
_
->
Just
e'
_ow
->
Nothing
)
C
.
CInitList
(
C
.
CInitializerList
items
)
ni2
->
do
items'
<-
case
t
of
TStruct
stct
->
do
...
...
@@ -1040,6 +1068,7 @@ inferType ctx = \case
t2
<-
inferType
ctx
x
case
(
t1
,
t2
)
of
(
NonVoid
(
TPointer
x'
),
NonVoid
TNum
)
->
pure
x'
(
NonVoid
(
TVector
_
x'
),
NonVoid
TNum
)
->
pure
x'
_ow
->
error
(
show
(
"index"
,
t1
,
t2
))
C
.
CMember
a
l
t
_
->
do
t1
<-
inferType
ctx
a
...
...
@@ -1467,6 +1496,7 @@ data Type
=
TNum
|
TStruct
!
(
Either
C
.
Ident
StructType
)
|
TPointer
!
Voidable
|
TVector
!
Int
!
Voidable
|
TFun
!
FunType
deriving
(
Show
,
Eq
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment