Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do this using source-to-source transformations.</p> <p>Our <a href="http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html" rel="nofollow">DMS Software Reengineering Toolkit</a> could be used to implement this. DMS uses explicit language definitions to parse source code to ASTs, prettyprinting of ASTs back to source code, provides various kinds of symbol table, control/data flow capabilities, and provides transformation ability to enable one to build custom source-code transformers. DMS has <a href="http://www.semanticdesigns.com/Products/FrontEnds" rel="nofollow">many front ends for differenct languages</a> including C and C++ with full preprocessors.</p> <p>To accomplish your task with DMS, you'd use the C parser to parse all the code of your system (because you have to inspect all call sites for any partial specializations). You'd need to define a way to specify the partial evaluation you wish; one way, as you've suggested, is to write a function call with arguments bound-to constants, but you could generalize this to arguments bound-to arbitrary expressions. Such a specification can be parsed by DMS's pattern parser, which can process arbitrary lnaguage nonterminals, e.g., a function call :-} You need to park these specifications somewhere; perhaps as an additional external file, or as comments at or near the call sites in question.</p> <p>With a parse of the partial-eval specification, you need to look up the function call name to determine the actual function of interest; it is somewhere in that stack of sources and the symbol table will make this easy to find. Given a call site with a specialization, the AST for the identified function can be replicated and arguments substituted; using probably only a small number of transformations but you have to watch out for capture of an argument by a lexical scope inside the function being specialized. Getting around that might require additional transformations. After gensymming a new name and shortened argument list for the specified function, you'd re-insert its AST near the original function definition site, modify the call site appropriately, and spit out the modified ASTs. Whether you wanted to add additional transforms to unroll loops for special cases, or whatever else interests you, is also practical.</p> <p>DMS has been used carry out massive transformations on C and C++ code; this seems "technically" easy. There is the small matter of becoming familiar with a tool like DMS; there's a fair learning curve there.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload