Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tommy Olofsson
LabComm
Commits
f60d2c16
Commit
f60d2c16
authored
Jan 21, 2015
by
Sven Gestegård Robertz
Browse files
more tech_report cleanup
parent
598b1368
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/2014/LabCommTokens.jrag
View file @
f60d2c16
...
@@ -2,8 +2,8 @@ aspect LabCommTokens {
...
@@ -2,8 +2,8 @@ aspect LabCommTokens {
public static final int ASTNode.LABCOMM_VERSION = 0x01;
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_SAMPLE_DEF = 0x02; // The flat signature
public static final int ASTNode.LABCOMM_
SAMPL
E_
R
EF
=
0x03;
public static final int ASTNode.LABCOMM_
TYP
E_
D
EF
=
0x03;
// and type declarations, hierarchically
public static final int ASTNode.LABCOMM_TYPE_
DEF = 0x04; // 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_ARRAY = 0x10;
public static final int ASTNode.LABCOMM_STRUCT = 0x11;
public static final int ASTNode.LABCOMM_STRUCT = 0x11;
...
...
doc/tech_report.tex
View file @
f60d2c16
...
@@ -285,9 +285,9 @@ But
...
@@ -285,9 +285,9 @@ But
With the following `example.lc` file:
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
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
\newpage
...
@@ -330,6 +330,95 @@ i.e.,
...
@@ -330,6 +330,95 @@ i.e.,
<sample
_
data> <user
_
id: 40> <length: 14> <packed
_
sample
_
data>
<sample
_
data> <user
_
id: 40> <length: 14> <packed
_
sample
_
data>
\end{verbatim}
\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
}
:
\section
{
Ideas/Discussion
}
:
The labcomm language is more expressive than its target languages regarding data types.
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
...
@@ -400,36 +489,43 @@ follow. The sequence of chunks are sent with the least significant chunk
first.
first.
The built-in data types are encoded as follows:
The built-in data types are encoded as follows:
\begin{
verbatim}
\begin{
lstlisting}
[basicstyle=
\footnotesize\ttfamily
]
||Type
||Encoding/Size
||
||Type ||Encoding/Size ||
||----------
-----||---
---------------------------------------------------||
||----------
||
---------------------------------------------------||
||boolean
|| 8 bits
||
||boolean || 8 bits ||
||byte
|| 8 bits
||
||byte || 8 bits ||
||short
|| 16 bits
||
||short || 16 bits ||
||integer
|| 32 bits
||
||integer || 32 bits ||
||long
|| 64 bits
||
||long || 64 bits ||
||float
|| 32 bits
||
||float || 32 bits ||
||double
|| 64 bits
||
||double || 64 bits ||
||string
|| length (varint), followed by UTF8 encoded string
||
||string || length (varint), followed by UTF8 encoded string ||
||array
|| each variable index (varint),
||
||array || each variable index (varint), ||
||
|| followed by encoded elements
||
|| || followed by encoded elements ||
||struct
|| concatenation of encoding of each element
||
||struct || concatenation of encoding of each element ||
||
|| in declaration order
||
|| || in declaration order ||
\end{
verbatim
}
\end{
lstlisting
}
\subsection
{
Protocol grammar
}
\subsection
{
Protocol grammar
}
\label
{
sec:ConcreteGrammar
}
\label
{
sec:ConcreteGrammar
}
\begin{verbatim}
\begin{lstlisting}
[basicstyle=
\footnotesize\ttfamily
]
<packet> := ( <version> | <type
_
decl> | <sample
_
decl> | <sample
_
data> )*
<packet> := <id> <length> ( <version> |
<version> := 0x01 <length> <string>
<type
_
decl> |
<sample
_
def> := 0x02 <length> <user
_
id> <string> <type>
<sample
_
decl> |
<type
_
def> := 0x03 <length> <user
_
id> <string> <type>
<type
_
binding> |
<user
_
id> := 0x40..0xffffffff
<sample
_
data> )
<string> := <string
_
length> <char>*
<version> := <string>
<string
_
length> := 0x00..0xffffffff
<sample
_
def> := <sample
_
id> <string> <type>
<char> := any UTF-8 char
<type
_
def> := <type
_
id> <string> <type>
<type> := <length> ( <basic
_
type> | <user
_
id> | <array
_
decl> | <struct
_
decl> )
<type
_
binding> := <sample
_
id> <type
_
id>
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<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> |
<integer
_
type> | <long
_
type> | <float
_
type> |
<double
_
type> | <string
_
type> )
<double
_
type> | <string
_
type> )
<boolean
_
type> := 0x20
<boolean
_
type> := 0x20
...
@@ -448,8 +544,20 @@ The built-in data types are encoded as follows:
...
@@ -448,8 +544,20 @@ The built-in data types are encoded as follows:
<struct
_
decl> := 0x11 <number
_
of
_
fields> <field>*
<struct
_
decl> := 0x11 <number
_
of
_
fields> <field>*
<number
_
of
_
fields> := 0x00..0xffffffff
<number
_
of
_
fields> := 0x00..0xffffffff
<field> := <string> <type>
<field> := <string> <type>
<sample
_
data> := <user
_
id> <packed
_
sample
_
data>
<sample
_
data> := packed sample data sent in network order, with
<packed
_
sample
_
data> := is sent in network order, encoded :
primitive type elements encoded according to
\end{verbatim}
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}
\end{document}
Write
Preview
Supports
Markdown
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