Download presentation
Presentation is loading. Please wait.
Published byAlvin May Modified over 9 years ago
1
Generating a Generator Jeff Gray University of Alabama at Birmingham Department of Computer and Information Sciences gray (at) cis.uab.edu http://www.gray-area.org GPCE Young Researchers Workshop October 5, 2002 Pittsburgh, PA This work is supported by the DARPA IXO, under the Program Composition for Embedded Systems (PCES) program,
2
Background Aspect-Oriented Domain Modeling
3
Model-Integrated Computing (MIC) with the Generic Modeling Environment (GME) Meta-modeling Environment Domain-specific Modeling Environment
4
Difficulties in Managing Constraints in Models A B cde 12 3 B cde 1''2'' 4 F B cde 1'1'2'2' 3'3' 4 Multiple Levels of Hierarchy Replicated Structures Context Sensitive Change Maintenance???
5
Domain-Specific Strategies Strategies (C++) XML Parser Aspect Parser strategy ApplyConstraint(constraintName : string, expression : string) { addAtom("OCLConstraint", "Constraint", constraintName).addAttribute("Expression", expression); } strategy RemoveConstraint(constraintName : string) { findAtom(constraintName).removeChild(); } strategy ReplaceConstraint(constraintName : string, expression : string) { RemoveConstraint(constraintName); ApplyConstraint(constraintName, expression); } Specification Aspects Models B c d e constraint FOOB2 { // apply a specific constraint to “B2” only in Structural models("ProcessingCompound")-> select(p | p.name() == "B2")->PowerStrategy(1, 100); } constraint FOOBStar { // apply a specific constraint to all nodes beginning with “B” - use wildcard in Structural models("ProcessingCompound")-> select(p | p.name() == "B*")->PowerStrategy(1, 100); } Constrained Models B c d e 1 3 2 Design-Space Exploration and Pruning
6
The Metaweaver Framework Strategy Code Generator Strategies (C++) Strategies Specification Aspects strategy ApplyConstraint(constraintName : string, expression : string) { addAtom("OCLConstraint", "Constraint", constraintName).addAttribute("Expression", expression); } strategy RemoveConstraint(constraintName : string) { findAtom(constraintName).removeChild(); } strategy ReplaceConstraint(constraintName : string, expression : string) { RemoveConstraint(constraintName); ApplyConstraint(constraintName, expression); } XML ( Model Hierarchy ) New Focus: How to generate these… (Generating a Generator)
7
Extending the Framework Previous implementation (strength) Provides variability, through domain-specific strategies, among different modeling domains in the GME (tool specific) Future implementation (address weakness) Provide variability such that new weavers can be instantiated to support other tools (e.g., Rose) Provide variability to support different aspect modeling languages other than ECL (not covered in this talk)
8
Subset of GME DTD
9
Subset of XMLParser Methods nodeType XMLParser::addAtom(nodeType self, CComBSTR kind, CComBSTR role, CComBSTR name) { return addNode(self, "atom", kind, role, name); } nodeType XMLParser::findModel(nodeType aNode, CComBSTR name) { CComBSTR bstrFind(L"./model[name=\""); bstrFind.Append(name); bstrFind.Append("\"]"); return submitXPath(aNode, bstrFind); } CComBSTR XMLParser::id(nodeType aNode) { CComBSTR res; CComPtr attr = XMLParser::findAttribute (aNode, "id"); XMLParser::getStr(attr, res); return res; } Implementation details associated with using underlying MSXML Tool-specific details tied to GME
10
Variability with Respect to Modeling Tools: Generating the XML Parser Strategies (C++) XML Parser Generator Specification Aspects XML Parser Aspect XML DTD (tool-specific)
11
Code Generator for findModel (within StratGen) void Generator::GenerateFindModel() { static findModelCounter = 0; genOut << indentStr << "nodeType aModelFind" << findModelCounter << " = XMLParser::findModel(" << lastVariable << ", "; lastVariable.Format("%s%d", "aModelFind", findModelCounter++); }
12
Variability with Respect to Modeling Tools: Generating Portions of StratGen Meta-Generator Strategy Code Generator XML DTD (tool-specific)
13
Conclusion There are three possible degrees of variability with the metaweaver framework Variability with respect to modeling domains (previous focus) Variability with respect to modeling tools (future focus – topic of this position paper) Variability with respect to aspect modeling languages (future focus – not covered here) Providing variability among modeling tools can be provided by generating a StratGen generator that is specific to a particular modeling tool
14
Process of Using a Weaver GME Domain-Specific Weaver bit1 bit1 Structural ProcessingCompound GatesPerBit 37,153 NomBits 205,76 MaxBits 128,76 Enhanced FOO.XML bit1 bit1 Structural ProcessingCompound GatesPerBit 37,153 NomBits 205,76 MaxBits 128,76 FOO.XML constraint FOOB2 { // apply a specific constraint to “B2” only in Structural models("ProcessingCompound")-> select(p | p.name() == "B2")->PowerStrategy(1, 100); } constraint FOOBStar { // apply a specific constraint to all nodes beginning with “B” - use wildcard in Structural models("ProcessingCompound")-> select(p | p.name() == "B*")->PowerStrategy(1, 100); } Specification Aspects
15
Code Generation Example CComPtr models0 = XMLParser::models(components, ""); nodeTypeVector selectVec1 = XMLParser::ConvertDomList(models0); nodeTypeVector selectVecTrue1 = new std::vector ; vector ::iterator itrSelect1; for(itrSelect1 = selectVec1->begin(); itrSelect1 != selectVec1->end(); itrSelect1++) { nodeType selectNode1 = (*itrSelect1); nodeType c; c = selectNode1; CComBSTR id0 = XMLParser::id(c); ClData varforward1(id0); ClData varforward2(referredID); bool varforward3 = varforward1 == varforward2; if(varforward3) selectVecTrue1->push_back(*itrSelect1); } vector ::iterator itrCollCall1; for(itrCollCall1 = selectVecTrue1->begin(); itrCollCall1 != selectVecTrue1->end(); itrCollCall1++) eagerLazy::apply(…);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.