Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Anders Blomdell
LabComm
Commits
f60d2c16
Commit
f60d2c16
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
more tech_report cleanup
parent
598b1368
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/2014/LabCommTokens.jrag
+2
-2
2 additions, 2 deletions
compiler/2014/LabCommTokens.jrag
doc/tech_report.tex
+141
-33
141 additions, 33 deletions
doc/tech_report.tex
with
143 additions
and
35 deletions
compiler/2014/LabCommTokens.jrag
+
2
−
2
View file @
f60d2c16
...
...
@@ -2,8 +2,8 @@ aspect LabCommTokens {
public static final int ASTNode.LABCOMM_VERSION = 0x01;
public static final int ASTNode.LABCOMM_SAMPLE_DEF = 0x02; // The flat signature
public static final int ASTNode.LABCOMM_
SAMPL
E_
R
EF
=
0x03;
public static final int ASTNode.LABCOMM_TYPE_
DEF = 0x04; // and type declarations, hierarchically
public static final int ASTNode.LABCOMM_
TYP
E_
D
EF
=
0x03;
// and type declarations, hierarchically
public static final int ASTNode.LABCOMM_TYPE_
BINDING=0x04;
public static final int ASTNode.LABCOMM_ARRAY = 0x10;
public static final int ASTNode.LABCOMM_STRUCT = 0x11;
...
...
This diff is collapsed.
Click to expand it.
doc/tech_report.tex
+
141
−
33
View file @
f60d2c16
...
...
@@ -285,9 +285,9 @@ But
With the following `example.lc` file:
\lstinputlisting
[basicstyle=\footnotesize]
{
../examples/wiki
_
example/example.lc
}
\lstinputlisting
[basicstyle=\footnotesize
\ttfamily
]
{
../examples/wiki
_
example/example.lc
}
and this
\verb
+
example_encoder.c
+
file
\lstinputlisting
[basicstyle=\footnotesize,language=C]
{
../examples/wiki
_
example/example
_
encoder.c
}
\lstinputlisting
[basicstyle=\footnotesize
\ttfamily
,language=C]
{
../examples/wiki
_
example/example
_
encoder.c
}
\newpage
...
...
@@ -330,6 +330,95 @@ i.e.,
<sample
_
data> <user
_
id: 40> <length: 14> <packed
_
sample
_
data>
\end{verbatim}
\section
{
Technical details
}
TODO: better section title
\subsection
{
Type and sample declarations
}
LabComm has two constructs for declaring sample types,
\emph
{
sample
declarations
}
and
\emph
{
type declarations
}
. A sample declaration is used
for the concrete sample types that may be transmitted, and is always
encoded as a
\emph
{
flattened
}
signature. That means that a sample
containing user types, like
\begin{verbatim}
typedef struct
{
int x;
int y;
}
point;
sample struct
{
point start;
point end;
}
line;
\end{verbatim}
is flattened to
\begin{verbatim}
sample struct
{
struct
{
int x;
int y;
}
start;
struct
{
int x;
int y;
}
end;
}
line;
\end{verbatim}
Sample declarations are always sent, and is the fundamental identity of
a type in LabComm.
Type declarations is the hierarchical counterpart to sample
declarations: here, fields of user types are encoded as a reference to
the type instead of being flattened. As the flattened sample decl is the
fundamental identity of a type, type declarations can be regarded as
meta-data, describing the internal structure of a sample. They are
intended to be read by higher-level software and human system developers
and integrators.
Sample declarations and type declarations have separate name-spaces in
the sense that the numbers assigned to them by a labcomm encoder
come from two independent number series. To identify which
\verb
+
TYPE_DECL
+
a particular
\verb
+
SAMPLE_DECL
+
corresponds to, the
\verb
+
TYPE_BINDING
+
packet is used.
\subsubsection
{
Example
}
The labcomm declaration
\lstinputlisting
[basicstyle=\footnotesize\ttfamily]
{
../examples/user
_
types/test.lc
}
can be is encoded as
\begin{lstlisting}
[basicstyle=
\footnotesize\ttfamily
]
TYPE
_
DECL 0x40 "coord" <int> val
TYPE
_
DECL 0x41 "point" <struct> <2 fields>
"x" <type: 0x40>
"y" <type: 0x40>
TYPE
_
DECL 0x42 "line" <struct> <2 fields>
"start" <type: 0x41>
"end" <type: 0x41>
TYPE
_
DECL 0x43 "foo" <struct> <3 fields>
"a" <int>
"b" <int>
"c" <boolean>
TYPE
_
DECL 0x44 "twolines" <struct> <3 fields>
"l1" <type:0x42>
"l2" <type:0x42>
"f" <type:0x43>
SAMPLE
_
DECL 0x40 "twolines" <flat signature>
TYPE
_
BINDING 0x40 0x44
\end{lstlisting}
Note that the id 0x40 is used both for the
\verb
+
TYPE_DECL
+
of
\verb
+
coord
+
and the
\verb
+
SAMPLE_DECL
+
of
\verb
+
twoline
+
, and that the
\verb
+
TYPE_BINDING
+
binds the sample id
\verb
+
0x40
+
to the type id
\verb
+
0x44
+
.
\section
{
Ideas/Discussion
}
:
The labcomm language is more expressive than its target languages regarding data types.
...
...
@@ -400,36 +489,43 @@ follow. The sequence of chunks are sent with the least significant chunk
first.
The built-in data types are encoded as follows:
\begin{
verbatim}
||Type
||Encoding/Size
||
||----------
-----||---
---------------------------------------------------||
||boolean
|| 8 bits
||
||byte
|| 8 bits
||
||short
|| 16 bits
||
||integer
|| 32 bits
||
||long
|| 64 bits
||
||float
|| 32 bits
||
||double
|| 64 bits
||
||string
|| length (varint), followed by UTF8 encoded string
||
||array
|| each variable index (varint),
||
||
|| followed by encoded elements
||
||struct
|| concatenation of encoding of each element
||
||
|| in declaration order
||
\end{
verbatim
}
\begin{
lstlisting}
[basicstyle=
\footnotesize\ttfamily
]
||Type ||Encoding/Size ||
||----------
||
---------------------------------------------------||
||boolean || 8 bits ||
||byte || 8 bits ||
||short || 16 bits ||
||integer || 32 bits ||
||long || 64 bits ||
||float || 32 bits ||
||double || 64 bits ||
||string || length (varint), followed by UTF8 encoded string ||
||array || each variable index (varint), ||
|| || followed by encoded elements ||
||struct || concatenation of encoding of each element ||
|| || in declaration order ||
\end{
lstlisting
}
\subsection
{
Protocol grammar
}
\label
{
sec:ConcreteGrammar
}
\begin{verbatim}
<packet> := ( <version> | <type
_
decl> | <sample
_
decl> | <sample
_
data> )*
<version> := 0x01 <length> <string>
<sample
_
def> := 0x02 <length> <user
_
id> <string> <type>
<type
_
def> := 0x03 <length> <user
_
id> <string> <type>
<user
_
id> := 0x40..0xffffffff
<string> := <string
_
length> <char>*
<string
_
length> := 0x00..0xffffffff
<char> := any UTF-8 char
<type> := <length> ( <basic
_
type> | <user
_
id> | <array
_
decl> | <struct
_
decl> )
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
\begin{lstlisting}
[basicstyle=
\footnotesize\ttfamily
]
<packet> := <id> <length> ( <version> |
<type
_
decl> |
<sample
_
decl> |
<type
_
binding> |
<sample
_
data> )
<version> := <string>
<sample
_
def> := <sample
_
id> <string> <type>
<type
_
def> := <type
_
id> <string> <type>
<type
_
binding> := <sample
_
id> <type
_
id>
<user
_
id> := 0x40..0xffffffff
<sample
_
id> : <user
_
id>
<type
_
id> : <user
_
id>
<string> := <string
_
length> <char>*
<string
_
length>:= 0x00..0xffffffff
<char> := any UTF-8 char
<type> := <length> ( <basic
_
type> | <array
_
decl> | <struct
_
decl> | <type
_
id> )
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<integer
_
type> | <long
_
type> | <float
_
type> |
<double
_
type> | <string
_
type> )
<boolean
_
type> := 0x20
...
...
@@ -448,8 +544,20 @@ The built-in data types are encoded as follows:
<struct
_
decl> := 0x11 <number
_
of
_
fields> <field>*
<number
_
of
_
fields> := 0x00..0xffffffff
<field> := <string> <type>
<sample
_
data> := <user
_
id> <packed
_
sample
_
data>
<packed
_
sample
_
data> := is sent in network order, encoded :
\end{verbatim}
<sample
_
data> := packed sample data sent in network order, with
primitive type elements encoded according to
the sizes above
\end{lstlisting}
where the
\verb
+
<id>
+
in
\verb
+
<packet>
+
signals the type of payload,
and may be either a
\verb
+
<sample_id>
+
or a system packet id.
The labcomm sytem packet ids are:
\begin{lstlisting}
[basicstyle=
\footnotesize\ttfamily
]
version: 0x01
sample
_
decl: 0x02
type
_
decl: 0x03
type
_
binding: 0x04
\end{lstlisting}
Note that since the signature transmitted in a
\verb
+
<sample_def>
+
is
flattened, the
\verb
+
<type>
+
transmitted in a
\verb
+
<sample_def>
+
may
not contain any
\verb
+
<type_id>
+
fields.
\end{document}
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