1 / 15

GPCE Young Researchers Workshop October 5, 2002 Pittsburgh, PA

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.

erna
Download Presentation

GPCE Young Researchers Workshop October 5, 2002 Pittsburgh, PA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generating a GeneratorJeff GrayUniversity of Alabama at BirminghamDepartment of Computer and Information Sciencesgray (at) cis.uab.eduhttp://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 theGeneric Modeling Environment (GME) Meta-modeling Environment Domain-specific Modeling Environment

  4. Difficulties in Managing Constraints in Models Multiple Levels of Hierarchy Change Maintenance??? A 4 Replicated Structures 3 B F 1 2 c d e 3' B B 4 1' 2' 1'' 2'' c d e c d e Context Sensitive

  5. 3 B Models Specification Aspects 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); } B 2 1 c e d c e d Constrained Models Design-Space Exploration and Pruning Aspect XML Strategies (C++) Parser Parser Domain-Specific Strategies 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); }

  6. New Focus: How to generate these… (Generating a Generator) The Metaweaver Framework Specification Aspects XML Parser Strategies (C++) Aspect Parser XML (Model Hierarchy) Strategies Strategy Code Generator 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); }

  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 <!ELEMENT model (name, (constraint|attribute|model|atom|reference|set connection)*)> <!ATTLIST model id ID #IMPLIEDkind NMTOKEN #REQUIRED role NMTOKEN #IMPLIED> <!ELEMENT atom (name, (regnode|constraint|attribute)*)> <!ATTLIST atom id ID #IMPLIED kind NMTOKEN #REQUIRED role NMTOKEN #IMPLIED> <!ELEMENT attribute (value, regnode*)> <!ATTLIST attributekind NMTOKEN #REQUIRED>

  9. Subset of XMLParser Methods Implementation details associated with using underlying MSXML Tool-specific details tied to GME nodeType XMLParser::addAtom(nodeType self, CComBSTRkind, CComBSTRrole, CComBSTRname){ return addNode(self, "atom", kind, role, name);} nodeType XMLParser::findModel(nodeType aNode, CComBSTRname){ CComBSTR bstrFind(L"./model[name=\""); bstrFind.Append(name); bstrFind.Append("\"]"); return submitXPath(aNode, bstrFind);} CComBSTR XMLParser::id(nodeType aNode){ CComBSTR res; CComPtr<IXMLDOMNode> attr = XMLParser::findAttribute (aNode, "id"); XMLParser::getStr(attr, res); return res;}

  10. XML Parser Generator Variability with Respect to Modeling Tools:Generating the XML Parser Aspect XML Strategies (C++) Parser Parser Specification Aspects <!ELEMENT model (name, (constraint|attribute|model|atom|reference|set connection)*)> <!ATTLIST model id ID #IMPLIED kind NMTOKEN #REQUIRED role NMTOKEN #IMPLIED> <!ELEMENT atom (name, (regnode|constraint|attribute)*)> <!ATTLIST atom id ID #IMPLIED kind NMTOKEN #REQUIRED role NMTOKEN #IMPLIED> <!ELEMENT attribute (value, regnode*)> <!ATTLIST attribute kind NMTOKEN #REQUIRED> 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 <!ELEMENT model (name, (constraint|attribute|model|atom|reference|set connection)*)> <!ATTLIST model id ID #IMPLIED kind NMTOKEN #REQUIRED role NMTOKEN #IMPLIED> <!ELEMENT atom (name, (regnode|constraint|attribute)*)> <!ATTLIST atom id ID #IMPLIED kind NMTOKEN #REQUIRED role NMTOKEN #IMPLIED> <!ELEMENT attribute (value, regnode*)> <!ATTLIST attribute kind NMTOKEN #REQUIRED> 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. GME <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE project SYSTEM "mga.dtd"> <project guid="{00000000-0000-0000-0000-000000000000}" cdate="Thu Nov 30 14:15:40 2000" mdate="Thu Nov 30 14:15:40 2000" metaguid="{00000000-0000-0000-0000-000000000000}" metaname="PCES"> <name>bit1</name> <comment></comment> <author></author> <folder id="id-006a-00000001" kind="RootFolder"> <name>bit1</name> <folder id="id-006a-00000002" kind="Structural"> <name>Structural</name> <model id="id-0065-00000001" kind="ProcessingCompound"> <name>ProcessingCompound</name> <attribute kind="Description" status="meta"> <value></value> </attribute> <atom id="id-0066-00000007" kind="Attribute" role="Attrib"> <name>GatesPerBit</name> <regnode name="PartRegs"> <value></value> <regnode name="StructuralAspect"> <value></value> <regnode name="Position" isopaque="yes"> <value>37,153</value> </regnode> </regnode> </regnode> <attribute kind="Value" status="meta"> <value></value> </attribute> </atom> <atom id="id-0066-00000006" kind="Attribute" role="Attrib"> <name>NomBits</name> <regnode name="PartRegs"> <value></value> <regnode name="StructuralAspect"> <value></value> <regnode name="Position" isopaque="yes"> <value>205,76</value> </regnode> </regnode> </regnode> <attribute kind="Value" status="meta"> <value></value> </attribute> </atom> <atom id="id-0066-00000005" kind="Attribute" role="Attrib"> <name>MaxBits</name> <regnode name="PartRegs"> <value></value> <regnode name="StructuralAspect"> <value></value> <regnode name="Position" isopaque="yes"> <value>128,76</value> </regnode> </regnode> </regnode> Enhanced FOO.XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE project SYSTEM "mga.dtd"> <project guid="{00000000-0000-0000-0000-000000000000}" cdate="Thu Nov 30 14:15:40 2000" mdate="Thu Nov 30 14:15:40 2000" metaguid="{00000000-0000-0000-0000-000000000000}" metaname="PCES"> <name>bit1</name> <comment></comment> <author></author> <folder id="id-006a-00000001" kind="RootFolder"> <name>bit1</name> <folder id="id-006a-00000002" kind="Structural"> <name>Structural</name> <model id="id-0065-00000001" kind="ProcessingCompound"> <name>ProcessingCompound</name> <attribute kind="Description" status="meta"> <value></value> </attribute> <atom id="id-0066-00000007" kind="Attribute" role="Attrib"> <name>GatesPerBit</name> <regnode name="PartRegs"> <value></value> <regnode name="StructuralAspect"> <value></value> <regnode name="Position" isopaque="yes"> <value>37,153</value> </regnode> </regnode> </regnode> <attribute kind="Value" status="meta"> <value></value> </attribute> </atom> <atom id="id-0066-00000006" kind="Attribute" role="Attrib"> <name>NomBits</name> <regnode name="PartRegs"> <value></value> <regnode name="StructuralAspect"> <value></value> <regnode name="Position" isopaque="yes"> <value>205,76</value> </regnode> </regnode> </regnode> <attribute kind="Value" status="meta"> <value></value> </attribute> </atom> <atom id="id-0066-00000005" kind="Attribute" role="Attrib"> <name>MaxBits</name> <regnode name="PartRegs"> <value></value> <regnode name="StructuralAspect"> <value></value> <regnode name="Position" isopaque="yes"> <value>128,76</value> </regnode> </regnode> </regnode> FOO.XML Domain-Specific Weaver Specification Aspects 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); } Process of Using a Weaver

  15. Code Generation Example CComPtr<IXMLDOMNodeList> models0 = XMLParser::models(components, ""); nodeTypeVector selectVec1 = XMLParser::ConvertDomList(models0); nodeTypeVector selectVecTrue1 = new std::vector<nodeType>; vector<nodeType>::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<nodeType>::iterator itrCollCall1; for(itrCollCall1 = selectVecTrue1->begin(); itrCollCall1 != selectVecTrue1->end(); itrCollCall1++) eagerLazy::apply(…);

More Related