Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
teaching
nswi098
Cecko
skeleton
Commits
e23100b0
Commit
e23100b0
authored
Nov 08, 2020
by
Bednárek David RNDr. Ph.D.
Browse files
framework partially doxymented
parent
b0f5c77b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
fmwk/ckcontext.hpp
View file @
e23100b0
/*
/*
* @file
context.hpp
ck
context.hpp
context for the compiler
State-aware upper layer of lexer/parser context.
*/
...
...
@@ -151,23 +151,42 @@ namespace cecko {
class
context
:
public
CKContext
{
public:
/// @cond INTERNAL
context
(
CKTablesObs
tables
,
std
::
ostream
*
outp
,
coverage
::
coverage_data
*
cd
)
:
CKContext
(
tables
),
line_
(
1
),
outp_
(
outp
),
cd_
(
cd
)
{}
std
::
ostream
&
out
()
{
return
*
outp_
;
}
/// @endcond
/// @name Generating error messages
/// @{
/// <param name="err">Error descriptor</param>
/// <param name="loc">Line number</param>
/// <param name="msg">A string argument</param>
void
message
(
errors
::
err_s
err
,
loc_t
loc
,
std
::
string_view
msg
);
void
message
(
errors
::
err_n
err
,
loc_t
loc
);
/// <param name="err">Error descriptor</param>
/// <param name="loc">Line number</param>
void
message
(
errors
::
err_n
err
,
loc_t
loc
);
/// @}
/// @cond INTERNAL
static
std
::
string
escape
(
std
::
string_view
s
);
loc_t
line
()
const
{
return
line_
;
}
loc_t
incline
()
{
return
line_
++
;
}
// returns line value before increment
/// @endcond
/// @name Lexer source-line counting
/// @{
loc_t
line
()
const
{
return
line_
;
}
///< Get current line
loc_t
incline
()
{
return
line_
++
;
}
///< Increment current line
/// @}
/// @cond COVERAGE
void
cov
(
std
::
string
n
)
{
cd_
->
inc
(
line
(),
std
::
move
(
n
));
}
/// @endcond
private:
loc_t
line_
;
...
...
fmwk/ckgrptokens.hpp
View file @
e23100b0
/*
/*
* @file
grptokens.hpp
g
roup tokens
G
roup tokens
.
*/
...
...
fmwk/ckir.hpp
View file @
e23100b0
/** @file
ckir.hpp
A wrapper over LLVM IR.
*/
#ifndef ckir_hpp_
#define ckir_hpp_
...
...
@@ -28,37 +36,39 @@
namespace
cecko
{
// numbers
using
CKIRAPInt
=
llvm
::
APInt
;
using
CKIRAPInt
=
llvm
::
APInt
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1APInt.html">llvm::APInt</a>
// context
using
CKIRContextRef
=
llvm
::
LLVMContext
&
;
using
CKIRContextRef
=
llvm
::
LLVMContext
&
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1LLVMContext.html">llvm::LLVMContext</a>
// types
using
CKIRTypeObs
=
llvm
::
Type
*
;
using
CKIRStructTypeObs
=
llvm
::
StructType
*
;
using
CKIRFunctionTypeObs
=
llvm
::
FunctionType
*
;
using
CKIRTypeObsArray
=
std
::
vector
<
llvm
::
Type
*>
;
using
CKIRTypeObsArrayRef
=
llvm
::
ArrayRef
<
llvm
::
Type
*>
;
using
CKIRTypeObs
=
llvm
::
Type
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Type.html">llvm::Type</a>
using
CKIRStructTypeObs
=
llvm
::
StructType
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1StructType.html">llvm::StructType</a>
using
CKIRFunctionTypeObs
=
llvm
::
FunctionType
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1FunctionType.html">llvm::FunctionType</a>
using
CKIRTypeObsArray
=
std
::
vector
<
llvm
::
Type
*>
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Type.html">llvm::Type</a>
using
CKIRTypeObsArrayRef
=
llvm
::
ArrayRef
<
llvm
::
Type
*>
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1ArrayRef.html">llvm::ArrayRef</a> @sa <a href="http://llvm.org/doxygen/classllvm_1_1Type.html">llvm::Type</a>
// values
using
CKIRValueObs
=
llvm
::
Value
*
;
using
CKIRValueObsArray
=
std
::
vector
<
llvm
::
Value
*>
;
using
CKIRValueObsArrayRef
=
llvm
::
ArrayRef
<
llvm
::
Value
*>
;
using
CKIRValueObs
=
llvm
::
Value
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Value.html">llvm::Value</a>
using
CKIRValueObsArray
=
std
::
vector
<
llvm
::
Value
*>
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Value.html">llvm::Value</a>
using
CKIRValueObsArrayRef
=
llvm
::
ArrayRef
<
llvm
::
Value
*>
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1ArrayRef.html">llvm::ArrayRef</a> @sa <a href="http://llvm.org/doxygen/classllvm_1_1Value.html">llvm::Value</a>
// constant values
using
CKIRConstantObs
=
llvm
::
Constant
*
;
using
CKIRConstantIntObs
=
llvm
::
ConstantInt
*
;
using
CKIRConstantObs
=
llvm
::
Constant
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Constant.html">llvm::Constant</a>
using
CKIRConstantIntObs
=
llvm
::
ConstantInt
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1ConstantInt.html">llvm::ConstantInt</a>
// module
using
CKIRModuleObs
=
llvm
::
Module
*
;
using
CKIRModuleObs
=
llvm
::
Module
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Module.html">llvm::Module</a>
// function
using
CKIRFunctionObs
=
llvm
::
Function
*
;
using
CKIRFunctionObs
=
llvm
::
Function
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Function.html">llvm::Function</a>
// basic block
using
CKIRBasicBlockObs
=
llvm
::
BasicBlock
*
;
using
CKIRBasicBlockObs
=
llvm
::
BasicBlock
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1BasicBlock.html">llvm::BasicBlock</a>
// instructions
using
CKIRAllocaInstObs
=
llvm
::
AllocaInst
*
;
using
CKIRAllocaInstObs
=
llvm
::
AllocaInst
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1AllocaInst.html">llvm::AllocaInst</a>
// builder
using
CKIRBuilder
=
llvm
::
IRBuilder
<>
;
using
CKIRBuilderRef
=
CKIRBuilder
&
;
using
CKIRBuilderObs
=
CKIRBuilder
*
;
using
CKIRBuilder
=
llvm
::
IRBuilder
<>
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1IRBuilder.html">llvm::IRBuilder</a>
using
CKIRBuilderRef
=
CKIRBuilder
&
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1IRBuilder.html">llvm::IRBuilder</a>
using
CKIRBuilderObs
=
CKIRBuilder
*
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1IRBuilder.html">llvm::IRBuilder</a>
// string
using
CKIRName
=
llvm
::
Twine
;
using
CKIRName
=
llvm
::
Twine
;
///< @sa <a href="http://llvm.org/doxygen/classllvm_1_1Twine.html">llvm::Twine</a>
/// @cond INTERNAL
inline
std
::
size_t
CKHashValue
(
const
CKIRAPInt
&
Arg
)
{
...
...
@@ -108,7 +118,7 @@ namespace cecko {
{
return
llvm
::
ConstantInt
::
get
(
llvm
::
Type
::
getInt1Ty
(
Context
),
V
);
}
inline
CKIRConstantIntObs
CKGetInt8Constant
(
CKIRContextRef
Context
,
std
::
int_fast8_t
V
)
{
return
llvm
::
ConstantInt
::
get
(
llvm
::
Type
::
getInt8Ty
(
Context
),
V
);
...
...
@@ -123,6 +133,7 @@ namespace cecko {
{
return
llvm
::
Function
::
Create
(
FT
,
llvm
::
Function
::
ExternalLinkage
,
name
,
M
);
}
/// @endcond
inline
CKIRBasicBlockObs
CKCreateBasicBlock
(
const
std
::
string
&
name
,
CKIRFunctionObs
F
)
{
...
...
@@ -134,6 +145,7 @@ namespace cecko {
return
llvm
::
cast
<
llvm
::
ConstantInt
>
(
v
);
}
/// @cond INTERNAL
CKIRConstantObs
CKCreateGlobalVariable
(
CKIRTypeObs
irtp
,
const
std
::
string
&
name
,
CKIRModuleObs
M
);
CKIRConstantObs
CKCreateExternVariable
(
CKIRTypeObs
irtp
,
const
std
::
string
&
name
,
CKIRModuleObs
M
);
...
...
@@ -179,6 +191,7 @@ namespace cecko {
};
using
CKIREnvironmentObs
=
CKIREnvironment
*
;
/// @endcond
};
#endif
fmwk/cktables.cpp
View file @
e23100b0
...
...
@@ -318,7 +318,7 @@ namespace cecko {
a
->
dump
(
os
,
indent
);
});
auto
typedeflambda
=
[
&
os
,
&
indent
](
auto
&&
a
)
{
os
<<
indent
<<
"typedef "
<<
a
->
get_type
()
->
declaration
(
false
,
a
->
get_name
())
<<
";"
<<
CIEndl
;
os
<<
indent
<<
"typedef "
<<
a
->
get_type
_pack
().
type
->
declaration
(
a
->
get_type_pack
().
is_const
,
a
->
get_name
())
<<
";"
<<
CIEndl
;
};
typedefs_
.
for_each
(
typedeflambda
);
}
...
...
@@ -382,7 +382,7 @@ namespace cecko {
void
CKVar
::
dump
(
CIOStream
&
os
,
const
std
::
string
&
indent
)
const
{
os
<<
indent
<<
get_type
_pack
().
type
->
declaration
(
get_type_pack
().
is_const
,
get_name
())
<<
";"
<<
CIEndl
;
os
<<
indent
<<
get_type
()
->
declaration
(
is_const
()
,
get_name
())
<<
";"
<<
CIEndl
;
}
// CONTEXT
...
...
fmwk/cktables.hpp
View file @
e23100b0
This diff is collapsed.
Click to expand it.
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