SlideShare una empresa de Scribd logo
1 de 52
Descargar para leer sin conexión
Generators


            Jun Chen
           March 2003
University of Colorado at Boulder




                                    1
Agenda
Part I: Generator Technology

Part II: GenVoca

Part III: GenVoca vs. AOP




                               2
Part I: Generator Technology
 What are Generators?
 Technologies for Building Generators
 Vertical, Horizontal, Oblique Transformations
 Compositional vs. Transformational Generators
 Kinds of Transformations
  • Compiler Transformations
  • Source-to-Source Transformations
 Transformation Systems


                                          3
What are Generators?
 Generator: A program that takes a higher-
 level specification of a piece of software and
 produces its implementation.

                • Check Specification
  System                                       System
                • Complete Specification
Specification                               Implementation
                • Perform Optimizations
                • Generate Implementation

                         Generator


                                                    4
Three Issues
 Raising the intentionality of system
 descriptions
 • Focus on “what is needed”
 • Avoid implementation details




                                        5
Three Issues
 Raising the intentionality of system
 descriptions
 Computing an efficient implementation
 • Performance Requirements (e.g. response time)
 • Complex computation inside generators




                                            6
Three Issues
 Raising the intentionality of system descriptions
 Computing an efficient implementation
 Avoiding the library scaling problem
 •   Exponential growth
 •   Factoring libraries into components corresponding to
     features + Composing using function calls
      • Avoid “exponential growth”
      • Poor performance
 •   Generators: factoring + eliminating calling overhead

                                                     7
Three Ways to Build Generators
  Developing generators as stand-alone
  programs from scratch
  • Effort-intensive
  Using the built-in metaprogramming
capabilities of a programming lang. (e.g. c++)
  •Advantage: easier to write generators, generators could
  be part of the library
  •Disadvantage: limited by the host lang., debugging

                                                    8
Three Ways to Build Generators
 Using a generator infrastructure
 • The infrastructure provides basic facilities
    • A common format for the internal source representation
    • Operations for encoding transformations
    • Input/output facilities
    • Debugging facilities
 • An example: Intentional Programming


                                                  9
Vertical, Horizontal, Oblique
Transformations

                    Horizontal
                  Transformation



     Vertical
                              Oblique
 Transformation
                           Transformation
    (Forward
  Refinement)




                                            10
Compositional vs.
Transformational Generators
 Compositional Generator:
    vertical transformation


 Transformational Generators:
    vertical transformation + horizontal transformation




                                                    11
Kinds of Transformations




                           12
Automating System Implementation
                                                     System
     System                 System
                                                  Requirements
   Requirements           Requirements
                                                            Manually
          Manually               Manually
                                                            Implement
          Implement              Implement
                                                High-level system
                                                   specification
                                   Source-to-Source         Interactive,
                                   Transformations          automated support
Compiler              System source using      System source using
Transformations       domain-specific lang.    domain-specific lang.
                          abstractions             abstractions
                                 Compile                  Compile
   System source         Could generate           Could generate
    in a general-        code in C++ or           code in C++ or
   purpose lang.         Java if needed           Java if needed
          Compile                Compile                  Compile
                                                     System
     System                 System
                                                  Implementation
  Implementation         Implementation
Compiler Transformations
 Refinements(vertical) – adds implementation details
 • Decomposition
     • An abstract data type(ADT) -> A number of other ADTs
 • Choice of representation
     • Matrix -> Array? Vector? Hash Table?
 • Choice of algorithm
     • Performance



                                                     14
Compiler Transformations
 Optimizations(horizontal) – improve performance
 • Structural changes of the code -> code becomes
   hard to understand
    • Inlining – replace the symbol by its definition
    • Loop fusion – combine two loops into one if two loops
      have a similar structure and can be done in parallel
 • Beyond conventional compilers
    • Domain-specific optimizations (domain knowledge)
    • Global optimizations (cross multiple locations)


                                                        15
Source-to-Source Transformations
 Restructuring transformations
 • Editing transformations
    • Mechanize some simple editing operations
    • Ex. converting a code section into a procedure

 • Refactoring transformations
    • Recognize code
    • Ex. abstraction and generalization


                                                  16
Transformation Systems
 Definition
 • Environments for building transformational
     generators
 •   Transformational generators




                                                17
Elements of transformation
systems
 A common format for the internal program
 representation
 •   Abstract syntax tree, data and control flow graph
 Code analysis facilities
 •   Check the input program and guide transformation
 A transformation engine
 •   Apply transformations
 Input and output facilities for the internal
 representation


                                                     18
An Example
Program text                                           Transformed
                            AST
e.g., (y+1/y+1)+z                                                                 1+z
                                                           AST
                                      Transformation
              Parser                                                  Unparser
                                          Engine

                            +                                 +
                        /         z                               z
                                                          1
                    +        +
                                           /
                    y1y                            1
                                 1
                                       x       x

                                        Rewrite Rule




                                                                             19
Summary: Generator Technology
 What are Generators?
 Technologies for Building Generators
 Vertical, Horizontal, Oblique Transformations
 Compositional vs. Transformational Generators
 Kinds of Transformations
  • Compiler Transformations
  • Source-to-Source Transformations
 Transformation Systems


                                          20
Part II: GenVoca
 GenVoca Approach
 GenVoca Model
 Implementing GenVoca in C++
 Composition Validation




                               21
GenVoca Approach
 Build software system generators based
 on composing object-oriented layers of
 abstraction.
 • Stacked layers
 • Layer above refines the layer below it. Ex.
   add new classes


 OO framework v.s. GenVoca model

                                            22
Transforming a framework into
a GenVoca model (step 1)
 Identify layers of abstractions in a framework

                 C11         C13




                 C21   C22



       Most
                 C31   C32   C33
       Refined


                                          23
Transforming a framework into
a GenVoca model (step 2)
 Turn the hierarchy of layers upside down
      Most
                C31   C32   C33
      Refined




                C21   C22




                C11         C13



                                        24
Transforming a framework into
a GenVoca model (step 3)
 Treat “the layer below” as a parameter of “the
 layer” above
                 C31    C32   C33




                 C21    C22




                 C11          C13

                                         25
Transforming a framework into
a GenVoca model (step 4)
 Provide families of alternative, parameterized
 layers




                                          26
GenVoca Model
 Components and Realms
 • Component (or layer): an implementation of
     abstract data type or feature
 •   Realm: all components that implement the
     same abstract data type or feature
 Example:
   S = { a, b, c }
   T = { d[S], e[S], f[S] }
   W = { n[W], m[W], p, q[T,S] }



                                           27
GenVoca Model
 Parameters & Transformations
 • A component has a realm parameter for every
   realm that it imports.
   Example:
     S = { a, b, c }
     T = { d[S], e[S], f[S] }
     W = { n[W], m[W], p, q[T,S] }

 Vertical v.s. Horizontal Parameters
 • Vertical parameters: layer parameters
 • Horizontal parameters: other parameters
                                             28
GenVoca Model
 Symmetric Components
 • Exports the same interface as it imports
 Example:
     S = { a, b, c }
     T = { d[S], e[S], f[S] }
     W = { n[W], m[W], p, q[T,S] }

     n[W], m[W]



                                              29
GenVoca Model
 Grammar
 Example:
     S = { a, b, c }
     T = { d[S], e[S], f[S] }
     W = { n[W], m[W], p, q[T,S] }

     S := a | b | c
     T := d[S] | e[S] | f[S]
     W:= n[W] | m[W] | p | q[T,S]




                                     30
GenVoca Model
 Type Expressions
 • describing layer composition, used to model
   software system
 Example:
   S := a | b | c
   T := d[S] | e[S] | f[S]
   W:= n[W] | m[W] | p | q[T,S]

   System_1 = d [b]
   System_2 = q [d[a], c]


                                          31
GenVoca Model
 Families of Systems
 •   The set of all component compositions
 Scalability
 •   Few components, large families of systems
 Design Rules and Domain Models
             S = { a, b, c }
             T = { d[S], e[S], f[S] }
             d[a], d[b], d[c], e[a], e[b], e[c], f[a], f[b], f[c]
 •   Type expression, syntax correct, semantics wrong
 •   Domain-specific constrains -> Design rules
 •   Domain model: Realms of components + Design rules

                                                              32
An Example – Booch Data Structure
 Data Structure Families
 •   Bag: unordered collection of objects
 •   Queue: ordered sequence of objects with FIFO semantics

 Data Structure Features for Every Family
 •   Unbounded: No upper bound on total number of objects
 •   Concurrent: A multithread environment, read/write serialized
 •   Managed: Free objects are stored on a list for subsequent
     reuse.


 Data Structure Features only for Queue
 •   Priority: Objects are sorted based on some priority function
                                                           33
An Example – Booch Data Structure
Bag[Concurrent[Size_of[Unbounded[Managed[heap]]]]]
                  Formal
        Bag
                  parameter

     Concurrent                  Multiple Parameters

      Size_of


    Unbounded


     Managed

                  Used as a
       heap
                  parameter of

                                                       34
Implementing GenVoca Layers
in C++
 Implement GenVoca layers as class templates
 containing member classes

 Example: LayerA




                                               35
Template <class LowerLayer>                              Forwarding Implementation
Class LayerA
{   public:
          class ClassA
          {    public:
                      void operationA() //refine operationA()
                      {    …//LayerA-specific work
                           lower.operationA();
                           …//LayerA-specific work
                      };
                      void operationB() { lower.operationB(); }; //forward operationB
               private:
                      typedef typename LowerLayer::ClassA LowerLayerClassA;
                      LowerLayerClassA lower;
          };
          class ClassB {…};
}
Forwarding Static Wrapper
Template <class Component>
Class Wrapper
{   public:
          void operationA() //refine operationA()   Problem:
          {    …//wrapper-specific work
                                                    propagation of operations
               component.operationA();
                                                    Solution: Inheritance
               …//wrapper-specific work
          };
          void operationB() { component.operationB(); }; //forward operationB
    private:
          Component component;
}

                                                                     37
Inheritance-based Static Wrapper
Template <class Component>
Class Wrapper : public Component
{   public:
          void operationA() //refine operationA()
          {    …//wrapper-specific work
               Component :: operationA();
               …//wrapper-specific work
          };
}




                                                    38
Template <class LowerLayer>                         Inheritance-based Implementation
Class LayerA
{   private:
          typedef typename LowerLayer::ClassA LowerLayerClassA;
          typedef typename LowerLayer::ClassB LowerLayerClassB;
    public:
          class ClassA : Public LowerLayerA
          {    public:
                     void operationA() //refine operationA()
                     {    …//LayerA-specific work
                          LowerLayerClassA :: operationA();
                          …//LayerA-specific work
                     };
          };
          class ClassB : Public LowerLayerClassB
           {…};
}
Upward Type Propagation
 Scope operator, ::
 typedef
 Problem: the layer might have to explicitly
 pass types they are not interested for
 themselves.
 Solution: configuration repository
 • an “envelop” containing all the layers, types and
   constants


                                                40
An Example

            Accessing R2
            and R3 Possible   R1:         A

R1:   A                       R2:         B,C
                              Config
R2:   B,C
                                export:
R3:   D,E                       Global1, Global2
                                ConfigA::HorizA
            Accessing R3        ConfigB::HorizB
            Possible




                                                   41
Downward Type Propagation
 Idea: put the whole layer hierarchy into the
 configuration repository.

                                  Access R1
               R1:         A
                                  possible
               R2:         B
               Config
                 export:
                 R1, R2




                                              42
Composition Validation
 Problem: syntactically correct composition
 might be wrong in semantics.
 Example:
    DS_Size: guarded[DS_Size] | concurrent[DS_Size]
             multiple[DS_Size] | size_of[DS] | …
    DS     : bounded | unbounded[Memory] | …

    guarded[guarded[multiple[concurrent[guarded[concurrent[si
    ze_of[bounded]]]]]]]
 Solution: Configuration Rules

                                                      43
A model – Conditions & Restrictions
 Upward and downward propagation of
 attributes that represent constraints on layers or
 properties of layers
 Conditions: constraints propagated downwards
 Restrictions: constraints propagated upwards
       Postrestrictions             Preconditions


                          Layer A

       Prerestrictions              Postconditions


                                                     44
Summary : GenVoca

 GenVoca Approach
 GenVoca Model
 Implementing GenVoca in C++
 Composition Validation




                               45
Part III: GenVoca vs. AOP
 Richard Cardone

 AOP: a meta-programming model that promotes
 code reuse by localizing the implementation of
 design features that cut across multiple functional
 unit.

 GenVoca: a model of hierarchical software
 construction that enables customized applications to
 be assembled from interchangeable and reusable
 components.

                                                 46
Difference & Similarity
 Difference
  • Starting point
  • Focus
  • Style

 Similarity
  • Basic concepts
  • Effort required for implementation
                                         47
Fundamental Concepts
 AOP
 • Components, Aspects, Joint Points

 GenVoca
 • Components, Realms, Parameters



                                       48
Implementation
 AOP
 • Aspect language
 • Weaver (preprocessor)

 GenVoca
 • Type expression
 • Generator (preprocessor)

                              49
Focus
 AOP
 •   For any existing code base
 •   Support code reuse by applying new features in a
     controlled and localized way


 Genvoca
 •   Require the definition of standardized realm
     interfaces, domain analysis needed
 •   Provide techniques to decompose applications into
     reusable and composable components

                                                   50
Conclusion
 Generators
 •   Automate system implementation
 •   Various levels: compiler, source-to-source
 •   Depending on the needs
 •   Transformation systems
 GenVoca
 •   A systematic approach
 •   Issues:
      • composition validation (distance)
      • how to get effective component composition
      • component changes
                                                     51
Sources
 “Generative Programming” textbook
 Don Batory, http://www.cs.utexas.edu/users/dsb/
 •   “Composition Validation and Subjectivity in GenVoca
     Generators”, 1997
 “On the Relationship of Aspect-Oriented
 Programming and GenVoca”, Richard Cardone




                                                           52

Más contenido relacionado

La actualidad más candente

Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)fefe7270
 
Accelerated test case - Anish bhanu
Accelerated test case - Anish bhanuAccelerated test case - Anish bhanu
Accelerated test case - Anish bhanuRoopa Nadkarni
 
Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)
Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)
Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)Benoit Combemale
 
Systems Navigator - Added value of simulation in the design of terminals
Systems Navigator - Added value of simulation in the design of terminalsSystems Navigator - Added value of simulation in the design of terminals
Systems Navigator - Added value of simulation in the design of terminalsjhjsmits
 
07 140430-ipp-languages used in llvm during compilation
07 140430-ipp-languages used in llvm during compilation07 140430-ipp-languages used in llvm during compilation
07 140430-ipp-languages used in llvm during compilationAdam Husár
 
08.Abap Dialog Programming Overview
08.Abap Dialog Programming Overview08.Abap Dialog Programming Overview
08.Abap Dialog Programming Overviewsapdocs. info
 
Обзор продуктов IBM Rational
Обзор продуктов IBM RationalОбзор продуктов IBM Rational
Обзор продуктов IBM RationalAlexander Novichkov
 

La actualidad más candente (8)

Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)
 
Accelerated test case - Anish bhanu
Accelerated test case - Anish bhanuAccelerated test case - Anish bhanu
Accelerated test case - Anish bhanu
 
Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)
Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)
Efficient and Advanced Omniscient Debugging for xDSMLs (SLE 2015)
 
Systems Navigator - Added value of simulation in the design of terminals
Systems Navigator - Added value of simulation in the design of terminalsSystems Navigator - Added value of simulation in the design of terminals
Systems Navigator - Added value of simulation in the design of terminals
 
Firstenberg q207
Firstenberg q207Firstenberg q207
Firstenberg q207
 
07 140430-ipp-languages used in llvm during compilation
07 140430-ipp-languages used in llvm during compilation07 140430-ipp-languages used in llvm during compilation
07 140430-ipp-languages used in llvm during compilation
 
08.Abap Dialog Programming Overview
08.Abap Dialog Programming Overview08.Abap Dialog Programming Overview
08.Abap Dialog Programming Overview
 
Обзор продуктов IBM Rational
Обзор продуктов IBM RationalОбзор продуктов IBM Rational
Обзор продуктов IBM Rational
 

Similar a Generator

From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!melbats
 
Collaborate12 fce
Collaborate12 fceCollaborate12 fce
Collaborate12 fcerkrivera
 
Collaborate12 Fce
Collaborate12 FceCollaborate12 Fce
Collaborate12 Fcerkrivera
 
10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprogramsMunawar Ahmed
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll buildMark Stoodley
 
Lessons learned using GitOps
Lessons learned using GitOpsLessons learned using GitOps
Lessons learned using GitOpsEdgaras Apšega
 
The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)Stefan Koopmanschap
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testingClarkTony
 
Intro to Kubernetes & GitOps Workshop
Intro to Kubernetes & GitOps WorkshopIntro to Kubernetes & GitOps Workshop
Intro to Kubernetes & GitOps WorkshopWeaveworks
 
Uncover the mysteries of infrastructure as code (iac)!
Uncover the mysteries of infrastructure as code (iac)!Uncover the mysteries of infrastructure as code (iac)!
Uncover the mysteries of infrastructure as code (iac)!Prashant Kalkar
 
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.VitaliyMakogon
 
Mainframe migration
Mainframe migrationMainframe migration
Mainframe migrationGinfo Intl
 
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"LogeekNightUkraine
 
4.9.a apend tuning and performance
4.9.a apend tuning and performance4.9.a apend tuning and performance
4.9.a apend tuning and performanceAcácio Oliveira
 
SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!melbats
 
App Engine overview (Android meetup 06-10)
App Engine overview (Android meetup 06-10)App Engine overview (Android meetup 06-10)
App Engine overview (Android meetup 06-10)jasonacooper
 

Similar a Generator (20)

From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!
 
Collaborate12 fce
Collaborate12 fceCollaborate12 fce
Collaborate12 fce
 
Collaborate12 Fce
Collaborate12 FceCollaborate12 Fce
Collaborate12 Fce
 
10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprograms
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
Simics - Break the Rules of Product Development
Simics - Break the Rules of Product DevelopmentSimics - Break the Rules of Product Development
Simics - Break the Rules of Product Development
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll build
 
Lessons learned using GitOps
Lessons learned using GitOpsLessons learned using GitOps
Lessons learned using GitOps
 
The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testing
 
Intro to Kubernetes & GitOps Workshop
Intro to Kubernetes & GitOps WorkshopIntro to Kubernetes & GitOps Workshop
Intro to Kubernetes & GitOps Workshop
 
Uncover the mysteries of infrastructure as code (iac)!
Uncover the mysteries of infrastructure as code (iac)!Uncover the mysteries of infrastructure as code (iac)!
Uncover the mysteries of infrastructure as code (iac)!
 
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
Vitaliy Makogon: Migration to ivy. Angular component libraries with IVY support.
 
Mainframe migration
Mainframe migrationMainframe migration
Mainframe migration
 
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
 
4.9.a apend tuning and performance
4.9.a apend tuning and performance4.9.a apend tuning and performance
4.9.a apend tuning and performance
 
SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!
 
App Engine overview (Android meetup 06-10)
App Engine overview (Android meetup 06-10)App Engine overview (Android meetup 06-10)
App Engine overview (Android meetup 06-10)
 

Más de Ramasubbu .P (20)

radar
radarradar
radar
 
Press
PressPress
Press
 
Milling 2
Milling 2Milling 2
Milling 2
 
MIlling 1
MIlling 1MIlling 1
MIlling 1
 
Drillings
DrillingsDrillings
Drillings
 
Holding
HoldingHolding
Holding
 
Saftey
SafteySaftey
Saftey
 
Harvesting
HarvestingHarvesting
Harvesting
 
Plough
PloughPlough
Plough
 
Tractor PTO
Tractor PTOTractor PTO
Tractor PTO
 
Tractor Components
Tractor ComponentsTractor Components
Tractor Components
 
MSAT
MSATMSAT
MSAT
 
GPS
GPSGPS
GPS
 
RTOS
RTOSRTOS
RTOS
 
Virus
VirusVirus
Virus
 
Hacker
HackerHacker
Hacker
 
Denail of Service
Denail of ServiceDenail of Service
Denail of Service
 
RAID CONCEPT
RAID CONCEPTRAID CONCEPT
RAID CONCEPT
 
Network Security
Network SecurityNetwork Security
Network Security
 
Timer
TimerTimer
Timer
 

Último

Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Último (20)

Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

Generator

  • 1. Generators Jun Chen March 2003 University of Colorado at Boulder 1
  • 2. Agenda Part I: Generator Technology Part II: GenVoca Part III: GenVoca vs. AOP 2
  • 3. Part I: Generator Technology What are Generators? Technologies for Building Generators Vertical, Horizontal, Oblique Transformations Compositional vs. Transformational Generators Kinds of Transformations • Compiler Transformations • Source-to-Source Transformations Transformation Systems 3
  • 4. What are Generators? Generator: A program that takes a higher- level specification of a piece of software and produces its implementation. • Check Specification System System • Complete Specification Specification Implementation • Perform Optimizations • Generate Implementation Generator 4
  • 5. Three Issues Raising the intentionality of system descriptions • Focus on “what is needed” • Avoid implementation details 5
  • 6. Three Issues Raising the intentionality of system descriptions Computing an efficient implementation • Performance Requirements (e.g. response time) • Complex computation inside generators 6
  • 7. Three Issues Raising the intentionality of system descriptions Computing an efficient implementation Avoiding the library scaling problem • Exponential growth • Factoring libraries into components corresponding to features + Composing using function calls • Avoid “exponential growth” • Poor performance • Generators: factoring + eliminating calling overhead 7
  • 8. Three Ways to Build Generators Developing generators as stand-alone programs from scratch • Effort-intensive Using the built-in metaprogramming capabilities of a programming lang. (e.g. c++) •Advantage: easier to write generators, generators could be part of the library •Disadvantage: limited by the host lang., debugging 8
  • 9. Three Ways to Build Generators Using a generator infrastructure • The infrastructure provides basic facilities • A common format for the internal source representation • Operations for encoding transformations • Input/output facilities • Debugging facilities • An example: Intentional Programming 9
  • 10. Vertical, Horizontal, Oblique Transformations Horizontal Transformation Vertical Oblique Transformation Transformation (Forward Refinement) 10
  • 11. Compositional vs. Transformational Generators Compositional Generator: vertical transformation Transformational Generators: vertical transformation + horizontal transformation 11
  • 13. Automating System Implementation System System System Requirements Requirements Requirements Manually Manually Manually Implement Implement Implement High-level system specification Source-to-Source Interactive, Transformations automated support Compiler System source using System source using Transformations domain-specific lang. domain-specific lang. abstractions abstractions Compile Compile System source Could generate Could generate in a general- code in C++ or code in C++ or purpose lang. Java if needed Java if needed Compile Compile Compile System System System Implementation Implementation Implementation
  • 14. Compiler Transformations Refinements(vertical) – adds implementation details • Decomposition • An abstract data type(ADT) -> A number of other ADTs • Choice of representation • Matrix -> Array? Vector? Hash Table? • Choice of algorithm • Performance 14
  • 15. Compiler Transformations Optimizations(horizontal) – improve performance • Structural changes of the code -> code becomes hard to understand • Inlining – replace the symbol by its definition • Loop fusion – combine two loops into one if two loops have a similar structure and can be done in parallel • Beyond conventional compilers • Domain-specific optimizations (domain knowledge) • Global optimizations (cross multiple locations) 15
  • 16. Source-to-Source Transformations Restructuring transformations • Editing transformations • Mechanize some simple editing operations • Ex. converting a code section into a procedure • Refactoring transformations • Recognize code • Ex. abstraction and generalization 16
  • 17. Transformation Systems Definition • Environments for building transformational generators • Transformational generators 17
  • 18. Elements of transformation systems A common format for the internal program representation • Abstract syntax tree, data and control flow graph Code analysis facilities • Check the input program and guide transformation A transformation engine • Apply transformations Input and output facilities for the internal representation 18
  • 19. An Example Program text Transformed AST e.g., (y+1/y+1)+z 1+z AST Transformation Parser Unparser Engine + + / z z 1 + + / y1y 1 1 x x Rewrite Rule 19
  • 20. Summary: Generator Technology What are Generators? Technologies for Building Generators Vertical, Horizontal, Oblique Transformations Compositional vs. Transformational Generators Kinds of Transformations • Compiler Transformations • Source-to-Source Transformations Transformation Systems 20
  • 21. Part II: GenVoca GenVoca Approach GenVoca Model Implementing GenVoca in C++ Composition Validation 21
  • 22. GenVoca Approach Build software system generators based on composing object-oriented layers of abstraction. • Stacked layers • Layer above refines the layer below it. Ex. add new classes OO framework v.s. GenVoca model 22
  • 23. Transforming a framework into a GenVoca model (step 1) Identify layers of abstractions in a framework C11 C13 C21 C22 Most C31 C32 C33 Refined 23
  • 24. Transforming a framework into a GenVoca model (step 2) Turn the hierarchy of layers upside down Most C31 C32 C33 Refined C21 C22 C11 C13 24
  • 25. Transforming a framework into a GenVoca model (step 3) Treat “the layer below” as a parameter of “the layer” above C31 C32 C33 C21 C22 C11 C13 25
  • 26. Transforming a framework into a GenVoca model (step 4) Provide families of alternative, parameterized layers 26
  • 27. GenVoca Model Components and Realms • Component (or layer): an implementation of abstract data type or feature • Realm: all components that implement the same abstract data type or feature Example: S = { a, b, c } T = { d[S], e[S], f[S] } W = { n[W], m[W], p, q[T,S] } 27
  • 28. GenVoca Model Parameters & Transformations • A component has a realm parameter for every realm that it imports. Example: S = { a, b, c } T = { d[S], e[S], f[S] } W = { n[W], m[W], p, q[T,S] } Vertical v.s. Horizontal Parameters • Vertical parameters: layer parameters • Horizontal parameters: other parameters 28
  • 29. GenVoca Model Symmetric Components • Exports the same interface as it imports Example: S = { a, b, c } T = { d[S], e[S], f[S] } W = { n[W], m[W], p, q[T,S] } n[W], m[W] 29
  • 30. GenVoca Model Grammar Example: S = { a, b, c } T = { d[S], e[S], f[S] } W = { n[W], m[W], p, q[T,S] } S := a | b | c T := d[S] | e[S] | f[S] W:= n[W] | m[W] | p | q[T,S] 30
  • 31. GenVoca Model Type Expressions • describing layer composition, used to model software system Example: S := a | b | c T := d[S] | e[S] | f[S] W:= n[W] | m[W] | p | q[T,S] System_1 = d [b] System_2 = q [d[a], c] 31
  • 32. GenVoca Model Families of Systems • The set of all component compositions Scalability • Few components, large families of systems Design Rules and Domain Models S = { a, b, c } T = { d[S], e[S], f[S] } d[a], d[b], d[c], e[a], e[b], e[c], f[a], f[b], f[c] • Type expression, syntax correct, semantics wrong • Domain-specific constrains -> Design rules • Domain model: Realms of components + Design rules 32
  • 33. An Example – Booch Data Structure Data Structure Families • Bag: unordered collection of objects • Queue: ordered sequence of objects with FIFO semantics Data Structure Features for Every Family • Unbounded: No upper bound on total number of objects • Concurrent: A multithread environment, read/write serialized • Managed: Free objects are stored on a list for subsequent reuse. Data Structure Features only for Queue • Priority: Objects are sorted based on some priority function 33
  • 34. An Example – Booch Data Structure Bag[Concurrent[Size_of[Unbounded[Managed[heap]]]]] Formal Bag parameter Concurrent Multiple Parameters Size_of Unbounded Managed Used as a heap parameter of 34
  • 35. Implementing GenVoca Layers in C++ Implement GenVoca layers as class templates containing member classes Example: LayerA 35
  • 36. Template <class LowerLayer> Forwarding Implementation Class LayerA { public: class ClassA { public: void operationA() //refine operationA() { …//LayerA-specific work lower.operationA(); …//LayerA-specific work }; void operationB() { lower.operationB(); }; //forward operationB private: typedef typename LowerLayer::ClassA LowerLayerClassA; LowerLayerClassA lower; }; class ClassB {…}; }
  • 37. Forwarding Static Wrapper Template <class Component> Class Wrapper { public: void operationA() //refine operationA() Problem: { …//wrapper-specific work propagation of operations component.operationA(); Solution: Inheritance …//wrapper-specific work }; void operationB() { component.operationB(); }; //forward operationB private: Component component; } 37
  • 38. Inheritance-based Static Wrapper Template <class Component> Class Wrapper : public Component { public: void operationA() //refine operationA() { …//wrapper-specific work Component :: operationA(); …//wrapper-specific work }; } 38
  • 39. Template <class LowerLayer> Inheritance-based Implementation Class LayerA { private: typedef typename LowerLayer::ClassA LowerLayerClassA; typedef typename LowerLayer::ClassB LowerLayerClassB; public: class ClassA : Public LowerLayerA { public: void operationA() //refine operationA() { …//LayerA-specific work LowerLayerClassA :: operationA(); …//LayerA-specific work }; }; class ClassB : Public LowerLayerClassB {…}; }
  • 40. Upward Type Propagation Scope operator, :: typedef Problem: the layer might have to explicitly pass types they are not interested for themselves. Solution: configuration repository • an “envelop” containing all the layers, types and constants 40
  • 41. An Example Accessing R2 and R3 Possible R1: A R1: A R2: B,C Config R2: B,C export: R3: D,E Global1, Global2 ConfigA::HorizA Accessing R3 ConfigB::HorizB Possible 41
  • 42. Downward Type Propagation Idea: put the whole layer hierarchy into the configuration repository. Access R1 R1: A possible R2: B Config export: R1, R2 42
  • 43. Composition Validation Problem: syntactically correct composition might be wrong in semantics. Example: DS_Size: guarded[DS_Size] | concurrent[DS_Size] multiple[DS_Size] | size_of[DS] | … DS : bounded | unbounded[Memory] | … guarded[guarded[multiple[concurrent[guarded[concurrent[si ze_of[bounded]]]]]]] Solution: Configuration Rules 43
  • 44. A model – Conditions & Restrictions Upward and downward propagation of attributes that represent constraints on layers or properties of layers Conditions: constraints propagated downwards Restrictions: constraints propagated upwards Postrestrictions Preconditions Layer A Prerestrictions Postconditions 44
  • 45. Summary : GenVoca GenVoca Approach GenVoca Model Implementing GenVoca in C++ Composition Validation 45
  • 46. Part III: GenVoca vs. AOP Richard Cardone AOP: a meta-programming model that promotes code reuse by localizing the implementation of design features that cut across multiple functional unit. GenVoca: a model of hierarchical software construction that enables customized applications to be assembled from interchangeable and reusable components. 46
  • 47. Difference & Similarity Difference • Starting point • Focus • Style Similarity • Basic concepts • Effort required for implementation 47
  • 48. Fundamental Concepts AOP • Components, Aspects, Joint Points GenVoca • Components, Realms, Parameters 48
  • 49. Implementation AOP • Aspect language • Weaver (preprocessor) GenVoca • Type expression • Generator (preprocessor) 49
  • 50. Focus AOP • For any existing code base • Support code reuse by applying new features in a controlled and localized way Genvoca • Require the definition of standardized realm interfaces, domain analysis needed • Provide techniques to decompose applications into reusable and composable components 50
  • 51. Conclusion Generators • Automate system implementation • Various levels: compiler, source-to-source • Depending on the needs • Transformation systems GenVoca • A systematic approach • Issues: • composition validation (distance) • how to get effective component composition • component changes 51
  • 52. Sources “Generative Programming” textbook Don Batory, http://www.cs.utexas.edu/users/dsb/ • “Composition Validation and Subjectivity in GenVoca Generators”, 1997 “On the Relationship of Aspect-Oriented Programming and GenVoca”, Richard Cardone 52