I am working on my PhD at the School of Computing, University of
Utah. My research is on adding aspect-oriented programming (AOP) to
nesC. The AOP grammar is similar to AspectJ with several component-
and embedded-system-related tools. I have been successful in
getting the extended grammar and rulebases working for AOP pointcuts
and weaving. The aspect components merely augment the existing nesC
grammar, meaning that nesC and AOP syntax coexist in the same
"aspect module" or "aspect configuration."
The AOP rules are stored in a pattern-matching rulebase and all
abstract syntax tree (AST) parsing is postponed until the rulebase
is properly loaded and initialized. The normal nesC AST is passed
through the rulebase, and a state machine tracks the token/semantic
state. When an AOP rule (advice) fires, a procedure call is created
to the advice. Also, the new compiler generates nesC-style modules
and configurations (AST/environment form) from the aspect modules
and configurations. This helps simplify weaving and code generation.
During code generation the standard nesC compiler creates inline
stubs that link methods defined by a configuration-module
component. In turn, the method found in the module is generated,
along with all the dependent (used by the method) methods and data
members. The methods and members from the newly generated
components from the AOP rules do not get generated. The
configuration stub is there in app.c but the module methods and data
members are omitted.
I have been able to hack a intermediate solution, because I found
that one test in 'prt_nesc_function()' keeps things from working
properly. The test for "fn->definition != NULL &&
fn->suppress_definition" fails, because "fn->definition" is NULL
("fn->suppress_definition" is set to TRUE is "fn->definition" is
NULL). When this test fails, I hacked a search for any method
defined in the Aspect nesC code with a matching name; if found,
"fn->definition" is set to the correct reference. The module method
is then successfully generated. But, any dependent methods and
members do not get pulled in.
I believe that the problem is rooted in 'cgraph' ("call graph"). I
have been unable to figure out how the abstract data type works
(beyond the rudimentary 'graph.c'/'graph.h').
What I need to learn:
Where does 'fn->definition' (in 'prt_nesc_function()') get populated?
How do I read a cgraph? (I.e., it looks like a set of methods, but I
can't figure out what data type it is -- nesc_declaration?)
How do I modify a cgraph? For example, how do I take the rulebase
rule, generate a nesC AST (done), generate a nesC Environment
(done?), AND manipulate a cgraph with the new internal
Can the cgraph populate the "fn->definition" for me?
Thanks to anyone who can help me with this.
PhD student, U of U.