Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
5f1bd21b
Commit
5f1bd21b
authored
Apr 29, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require fixed struct data section size to be in bytes, not words, for clarity.
parent
d63388ce
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
14 deletions
+10
-14
test.capnp
c++/src/capnproto/test.capnp
+4
-4
Compiler.hs
compiler/src/Compiler.hs
+2
-2
Parser.hs
compiler/src/Parser.hs
+2
-6
Semantics.hs
compiler/src/Semantics.hs
+2
-2
No files found.
c++/src/capnproto/test.capnp
View file @
5f1bd21b
...
...
@@ -283,16 +283,16 @@ struct TestInline8 fixed(1 bytes) { f0 @0: Bool; f1 @1: Bool; f2 @2: Bool; }
struct TestInline16 fixed(2 bytes) { f0 @0: UInt8; f1 @1: UInt8; }
struct TestInline32 fixed(4 bytes) { f0 @0: UInt8; f1 @1: UInt16; }
struct TestInline64 fixed(8 bytes) { f0 @0: UInt8; f1 @1: UInt32; }
struct TestInline128 fixed(
2 word
s) { f0 @0: UInt64; f1 @1: UInt64; }
struct TestInline192 fixed(
3 word
s) { f0 @0: UInt64; f1 @1: UInt64; f2 @2: UInt64; }
struct TestInline128 fixed(
16 byte
s) { f0 @0: UInt64; f1 @1: UInt64; }
struct TestInline192 fixed(
24 byte
s) { f0 @0: UInt64; f1 @1: UInt64; f2 @2: UInt64; }
struct TestInline0p fixed(1 pointers) { f @0 :Inline(TestInline0); p0 @1 :Text; }
struct TestInline8p fixed(1 bytes, 1 pointers) { f @0 :Inline(TestInline8); p0 @1 :Text; }
struct TestInline16p fixed(2 bytes, 2 pointers) { f @0 :Inline(TestInline16); p0 @1 :Text; p1 @2 :Text; }
struct TestInline32p fixed(4 bytes, 2 pointers) { f @0 :Inline(TestInline32); p0 @1 :Text; p1 @2 :Text; }
struct TestInline64p fixed(8 bytes, 2 pointers) { f @0 :Inline(TestInline64); p0 @1 :Text; p1 @2 :Text; }
struct TestInline128p fixed(
2 word
s, 3 pointers) { f @0 :Inline(TestInline128); p0 @1 :Text; p1 @2 :Text; p2 @3 :Text; }
struct TestInline192p fixed(
3 word
s, 3 pointers) { f @0 :Inline(TestInline192); p0 @1 :Text; p1 @2 :Text; p2 @3 :Text; }
struct TestInline128p fixed(
16 byte
s, 3 pointers) { f @0 :Inline(TestInline128); p0 @1 :Text; p1 @2 :Text; p2 @3 :Text; }
struct TestInline192p fixed(
24 byte
s, 3 pointers) { f @0 :Inline(TestInline192); p0 @1 :Text; p1 @2 :Text; p2 @3 :Text; }
struct TestInlineLayout {
f0 @0 :Inline(TestInline0);
...
...
compiler/src/Compiler.hs
View file @
5f1bd21b
...
...
@@ -738,8 +738,8 @@ enforceFixed (Just (Located pos (requestedDataSize, requestedPointerCount)))
16
->
return
DataSection16
32
->
return
DataSection32
s
|
mod
s
64
==
0
->
return
$
DataSectionWords
$
div
s
64
_
->
makeError
pos
$
printf
"Struct data section size must be
a whole number of words
\
\
or 0, 1, 2, 4, or
8 bytes."
_
->
makeError
pos
$
printf
"Struct data section size must be
0, 1, 2, 4, or a multiple of
\
\
8 bytes."
recover
()
$
when
(
dataSectionBits
actualDataSize
>
dataSectionBits
validatedRequestedDataSize
)
$
makeError
pos
$
printf
"Struct data section size is %s which exceeds specified maximum of
\
...
...
compiler/src/Parser.hs
View file @
5f1bd21b
...
...
@@ -255,13 +255,9 @@ combineFixedSizes (_, Just _) (FixedPointers _) =
fixedSize
=
do
size
<-
literalInt
-- We do not allow single-bit structs because most CPUs cannot address bits.
(
exactIdentifier
"byte"
>>
return
(
FixedData
(
8
*
size
)))
<|>
(
exactIdentifier
"bytes"
>>
return
(
FixedData
(
8
*
size
)))
<|>
(
exactIdentifier
"word"
>>
return
(
FixedData
(
64
*
size
)))
<|>
(
exactIdentifier
"words"
>>
return
(
FixedData
(
64
*
size
)))
<|>
(
exactIdentifier
"pointer"
>>
return
(
FixedPointers
size
))
(
exactIdentifier
"bytes"
>>
return
(
FixedData
(
8
*
size
)))
<|>
(
exactIdentifier
"pointers"
>>
return
(
FixedPointers
size
))
<?>
"
\"
bytes
\"
,
\"
words
\"
,
or
\"
pointers
\"
"
<?>
"
\"
bytes
\"
or
\"
pointers
\"
"
structLine
::
Maybe
[
Located
Statement
]
->
TokenParser
Declaration
structLine
Nothing
=
usingDecl
<|>
constantDecl
<|>
fieldDecl
<|>
annotationDecl
...
...
compiler/src/Semantics.hs
View file @
5f1bd21b
...
...
@@ -278,11 +278,11 @@ dataSizeToSectionSize Size16 = DataSection16
dataSizeToSectionSize
Size32
=
DataSection32
dataSizeToSectionSize
Size64
=
DataSectionWords
1
dataSectionSizeString
DataSection1
=
"1 bits
"
dataSectionSizeString
DataSection1
=
error
"Data section for display can't be 1 bit.
"
dataSectionSizeString
DataSection8
=
"1 bytes"
dataSectionSizeString
DataSection16
=
"2 bytes"
dataSectionSizeString
DataSection32
=
"4 bytes"
dataSectionSizeString
(
DataSectionWords
n
)
=
show
n
++
" word
s"
dataSectionSizeString
(
DataSectionWords
n
)
=
show
(
n
*
8
)
++
" byte
s"
data
DataSize
=
Size1
|
Size8
|
Size16
|
Size32
|
Size64
deriving
(
Eq
,
Ord
,
Enum
)
...
...
Write
Preview
Markdown
is supported
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