Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bpftrace
Commits
a48fce1c
Commit
a48fce1c
authored
7 years ago
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dereference operator
parent
c198723b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
0 deletions
+14
-0
src/ast.cpp
src/ast.cpp
+1
-0
src/codegen_llvm.cpp
src/codegen_llvm.cpp
+7
-0
src/parser.yy
src/parser.yy
+1
-0
src/semantic_analyser.cpp
src/semantic_analyser.cpp
+5
-0
No files found.
src/ast.cpp
View file @
a48fce1c
...
...
@@ -80,6 +80,7 @@ std::string opstr(Unop &unop)
switch
(
unop
.
op
)
{
case
bpftrace
:
:
Parser
::
token
::
LNOT
:
return
"!"
;
case
bpftrace
:
:
Parser
::
token
::
BNOT
:
return
"~"
;
case
bpftrace
:
:
Parser
::
token
::
MUL
:
return
"dereference"
;
default:
abort
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/codegen_llvm.cpp
View file @
a48fce1c
...
...
@@ -124,6 +124,13 @@ void CodegenLLVM::visit(Unop &unop)
switch
(
unop
.
op
)
{
case
bpftrace
:
:
Parser
::
token
::
LNOT
:
expr_
=
b_
.
CreateNot
(
expr_
);
break
;
case
bpftrace
:
:
Parser
::
token
::
BNOT
:
expr_
=
b_
.
CreateNeg
(
expr_
);
break
;
case
bpftrace
:
:
Parser
::
token
::
MUL
:
{
AllocaInst
*
dst
=
b_
.
CreateAllocaBPF
();
b_
.
CreateProbeRead
(
dst
,
b_
.
getInt64
(
8
),
expr_
);
expr_
=
b_
.
CreateLoad
(
dst
);
break
;
}
default:
abort
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/parser.yy
View file @
a48fce1c
...
...
@@ -148,6 +148,7 @@ expr : INT { $$ = new ast::Integer($1); }
| expr BXOR expr { $$ = new ast::Binop($1, token::BXOR, $3); }
| LNOT expr { $$ = new ast::Unop(token::LNOT, $2); }
| BNOT expr { $$ = new ast::Unop(token::BNOT, $2); }
| MUL expr { $$ = new ast::Unop(token::MUL, $2); }
;
call : IDENT "(" ")" { $$ = new ast::Call($1); }
...
...
This diff is collapsed.
Click to expand it.
src/semantic_analyser.cpp
View file @
a48fce1c
...
...
@@ -142,6 +142,11 @@ void SemanticAnalyser::visit(Binop &binop)
void
SemanticAnalyser
::
visit
(
Unop
&
unop
)
{
unop
.
expr
->
accept
(
*
this
);
if
(
type_
!=
Type
::
integer
)
{
err_
<<
"The "
<<
opstr
(
unop
)
<<
" operator can not be used on expressions of type "
<<
type_
<<
std
::
endl
;
}
type_
=
Type
::
integer
;
}
...
...
This diff is collapsed.
Click to expand it.
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