Skip to content
Snippets Groups Projects
Commit 4c48a2ff authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] load function and display AST

parent 9909e01e
No related branches found
No related tags found
No related merge requests found
...@@ -10,5 +10,6 @@ yarn-error.log ...@@ -10,5 +10,6 @@ yarn-error.log
/bin /bin
/dist /dist
/doc/html /doc/html
/src/dome
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
// Test for Ivette
int main(int x,int y)
{
int k ;
if (0 < x) k = 0;
k += x ;
k += y ;
k += x ;
k += y ;
return k;
}
...@@ -78,7 +78,7 @@ const chainableOrder = ( order ) => { ...@@ -78,7 +78,7 @@ const chainableOrder = ( order ) => {
const compare = (a,b) => { const compare = (a,b) => {
for (var k = 0; k < order.length ; k++) { for (var k = 0; k < order.length ; k++) {
const cmp = (order[k])(a,b); const cmp = (order[k])(a,b);
if (cmp) return cmp; if (cmp !==0 ) return cmp;
} }
return 0; return 0;
}; };
......
...@@ -356,8 +356,10 @@ class SyncArray ...@@ -356,8 +356,10 @@ class SyncArray
updated.forEach((item) => { updated.forEach((item) => {
this.index[item.key] = item; this.index[item.key] = item;
}); });
if (reloaded || removed.length || updated.length) if (reloaded || removed.length || updated.length) {
this.index = Object.assign( {}, this.index );
Dome.emit( this.UPDATE ); Dome.emit( this.UPDATE );
}
if (pending>0) { if (pending>0) {
this.fetch(); this.fetch();
} }
......
...@@ -5,9 +5,34 @@ ...@@ -5,9 +5,34 @@
import _ from 'lodash' ; import _ from 'lodash' ;
import React from 'react' ; import React from 'react' ;
import Dome from 'dome' ; import Dome from 'dome' ;
import Server from 'frama-c/server' ;
import States from 'frama-c/states' ; import States from 'frama-c/states' ;
import { Vfill } from 'dome/layout/boxes' ;
import { Buffer } from 'dome/text/buffers' ;
import { Text } from 'dome/text/editors' ;
import { Component } from 'frama-c/labviews' ; import { Component } from 'frama-c/labviews' ;
import 'codemirror/mode/clike/clike.js';
import 'codemirror/theme/ambiance.css' ;
// --------------------------------------------------------------------------
// --- Rich Text Printer
// --------------------------------------------------------------------------
const print = async (buffer, text) => {
if (Array.isArray(text)) {
const tag = text.shift();
if (tag !== '')
buffer.openTextMarker( { id:tag } );
for (const k in text)
await print(buffer, text[k]);
if (tag !== '')
buffer.closeTextMarker();
} else if (typeof(text)==='string')
buffer.append(text);
};
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- AST Printer // --- AST Printer
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -15,13 +40,31 @@ import { Component } from 'frama-c/labviews' ; ...@@ -15,13 +40,31 @@ import { Component } from 'frama-c/labviews' ;
const ASTview = () => { const ASTview = () => {
// Hooks // Hooks
const buffer = React.useMemo( () => new Buffer(), []);
const [ select, setSelect ] = States.useSelection(); const [ select, setSelect ] = States.useSelection();
const theFunction = select && select.function ;
React.useEffect( () => {
buffer.clear();
if (theFunction) {
buffer.log('Loading',theFunction,'');
Server
.sendGET("kernel.ast.printFunction", theFunction)
.then(data => {
buffer.clear();
return print(buffer,data);
});
}
}, [ theFunction ] );
return ( return (
<div> <Vfill>
<div>Function: {select && select.function}</div> <div>Function: {select && select.function}</div>
<div>Marker: {select && select.marker}</div> <div>Marker: {select && select.marker}</div>
</div> <Text buffer={buffer}
mode='text/x-csrc'
theme='ambiance'
readOnly />
</Vfill>
); );
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment