Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
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
pub
frama-c
Commits
0e799e95
Commit
0e799e95
authored
4 years ago
by
David Bühler
Committed by
Michele Alberti
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[ivette] New component displaying some information about the selected AST marker.
parent
36ebd0a2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/renderer/ASTinfo.tsx
+127
-0
127 additions, 0 deletions
ivette/src/renderer/ASTinfo.tsx
ivette/src/renderer/Application.tsx
+2
-0
2 additions, 0 deletions
ivette/src/renderer/Application.tsx
with
129 additions
and
0 deletions
ivette/src/renderer/ASTinfo.tsx
0 → 100644
+
127
−
0
View file @
0e799e95
// --------------------------------------------------------------------------
// --- AST Information
// --------------------------------------------------------------------------
import
React
from
'
react
'
;
import
*
as
States
from
'
frama-c/states
'
;
import
{
Vfill
}
from
'
dome/layout/boxes
'
;
import
{
RichTextBuffer
}
from
'
dome/text/buffers
'
;
import
{
Text
}
from
'
dome/text/editors
'
;
import
{
Component
}
from
'
frama-c/LabViews
'
;
// --------------------------------------------------------------------------
// --- Parsing information from the server
// --------------------------------------------------------------------------
function
addMarker
(
buffer
:
any
,
fct
:
string
)
{
buffer
.
openTextMarker
({
id
:
fct
,
css
:
'
color: blue
'
});
buffer
.
append
(
fct
);
buffer
.
closeTextMarker
();
}
function
parseVarinfo
(
buffer
:
any
,
data
:
any
)
{
buffer
.
append
(
`Variable
${
data
.
name
}
has type '
${
data
.
type
.
name
}
'.`
);
buffer
.
flushline
();
if
(
data
.
global
)
{
buffer
.
append
(
'
It is a global variable.
'
);
}
else
{
const
kind
=
data
.
formal
?
'
formal
'
:
'
local
'
;
buffer
.
append
(
`It is a
${
kind
}
variable of function `
);
addMarker
(
buffer
,
data
.
defining_function
);
}
buffer
.
flushline
();
if
(
data
.
temp
)
{
const
descr
=
data
.
descr
?
` for
${
data
.
descr
}
`
:
''
;
buffer
.
append
(
`This is a temporary variable
${
descr
}
.`
);
buffer
.
flushline
();
}
const
ref
=
data
.
referenced
?
''
:
'
not
'
;
const
taken
=
data
.
addrof
?
''
:
'
not
'
;
buffer
.
append
(
`It is
${
ref
}
referenced and its address is
${
taken
}
taken.`
);
}
function
parseInfo
(
buffer
:
any
,
data
:
any
)
{
switch
(
data
.
kind
)
{
case
'
expression
'
:
buffer
.
append
(
`This is a pure C expression of type '
${
data
.
type
.
name
}
'.`
);
break
;
case
'
function
'
:
addMarker
(
buffer
,
data
.
varinfo
.
name
);
buffer
.
append
(
` is a C function of type '
${
data
.
type
.
name
}
'.`
);
break
;
case
'
variable
'
:
parseVarinfo
(
buffer
,
data
.
varinfo
);
break
;
case
'
lvalue
'
:
buffer
.
append
(
`This is an lvalue of type '
${
data
.
type
.
name
}
'.`
);
break
;
case
'
declaration
'
:
buffer
.
append
(
'
This is the declaration of variable
'
+
`
${
data
.
varinfo
.
name
}
.`
);
buffer
.
flushline
();
buffer
.
append
(
'
'
);
buffer
.
flushline
();
parseVarinfo
(
buffer
,
data
.
varinfo
);
break
;
case
'
statement
'
:
buffer
.
append
(
`This is a statement of function
${
data
.
function
}
.`
);
break
;
default
:
break
;
}
}
// --------------------------------------------------------------------------
// --- Information Panel
// --------------------------------------------------------------------------
const
ASTinfo
=
()
=>
{
const
buffer
=
React
.
useMemo
(()
=>
new
RichTextBuffer
(),
[]);
const
[
select
,
setSelect
]
=
States
.
useSelection
();
const
marker
=
select
&&
select
.
marker
;
const
data
=
States
.
useRequest
(
'
kernel.ast.info
'
,
marker
||
''
);
React
.
useEffect
(()
=>
{
if
(
data
)
{
buffer
.
clear
();
parseInfo
(
buffer
,
data
);
}
},
[
buffer
,
data
]);
// Callbacks
function
onSelection
(
mark
:
any
)
{
// For now, the only markers are functions.
setSelect
({
function
:
mark
});
}
// Component
return
(
<>
<
Vfill
>
<
Text
buffer
=
{
buffer
}
mode
=
"text"
theme
=
"default"
onSelection
=
{
onSelection
}
readOnly
/>
</
Vfill
>
</>
);
};
// --------------------------------------------------------------------------
// --- Export Component
// --------------------------------------------------------------------------
export
default
()
=>
(
<
Component
id
=
"frama-c.astinfo"
label
=
"Information"
title
=
"AST Information"
>
<
ASTinfo
/>
</
Component
>
);
// --------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
ivette/src/renderer/Application.tsx
+
2
−
0
View file @
0e799e95
...
...
@@ -16,6 +16,7 @@ import { GridItem } from 'dome/layout/grids';
import
*
as
Controller
from
'
./Controller
'
;
import
Properties
from
'
./Properties
'
;
import
ASTview
from
'
./ASTview
'
;
import
ASTinfo
from
'
./ASTinfo
'
;
// --------------------------------------------------------------------------
// --- Main View
...
...
@@ -64,6 +65,7 @@ export default (() => {
<
Controller
.
Console
/>
<
Properties
/>
<
ASTview
/>
<
ASTinfo
/>
</
Group
>
</
LabView
>
</
Splitter
>
...
...
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