fbc plugins

General FreeBASIC programming questions.
Post Reply
RockTheSchock
Posts: 252
Joined: Mar 12, 2006 16:25

fbc plugins

Post by RockTheSchock »

I am trying to implement a plugin extension for fbc. I am successfully loading plugins and call init and visitor functions. But where should i put the callback visitor functions in the compiler? I am absolutly lost.

I tried in ast-node-proc at the end of:

function astAdd( byval n as ASTNODE ptr ) as ASTNODE ptr
and
function astAddAfter ...

Maybe i should put the callbacks somewhere else eg

parser-toplevel.bas -> sub cProgram()
or before in the lexer?
or at the end when the ast is completly built?
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbc plugins

Post by dkl »

Hi,

if you want to look at AST right before it's emitted, I recommend putting the callback above the main astLoad() call (ast-node-proc.bas(150)). That's where I like to put astDumpSmall() calls when debugging...

Putting it into astAdd[After]() behind the astUpdate() calls would probably also work though, because I don't think the AST nodes will be modified later once they were astAdd'ed. Putting callbacks in the lexer only makes sense if you want to see the chars read from file (hReadChar()) or tokens produced by it (lexNextToken()).

fbc doesn't keep the complete AST/symbol table for the whole input file, only for one procedure at a time. The exceptions to that are the implicit main() (because its statements can be mixed with normal procedures) and Private procedures (to allow omitting them if unused), and the global namespace w.r.t. symbol tables.
Post Reply