Fluent interface for AST nodes

#10 Merged at 9153eea
Repository
alexdura
Branch
fluent-interface
Repository
jastadd
Branch
master
Author
  1. Alexandru Dura
Reviewers
Description
  • Add a fluent interface to AST nodes

    Modify the methods that add or update children of an AST node to return a reference to the AST node that is updates (i.e. this).

Comments (5)

  1. Jesper Öqvist

    Some of the templates do not have the Host variable bound:

    Template expansion warning: while expanding template 'Opt.additionalDeclarations': unbound variable 'Host'

  2. Jesper Öqvist

    JModelica r13231 diff to fix the compile problems:

    Index: Compiler/ModelicaFlatTree/src/jastadd/Sizes.jrag
    ===================================================================
    --- Compiler/ModelicaFlatTree/src/jastadd/Sizes.jrag    (revision 13234)
    +++ Compiler/ModelicaFlatTree/src/jastadd/Sizes.jrag    (working copy)
    @@ -266,7 +266,7 @@
     aspect FunctionCallSizes {
    
         public abstract Size FType.getSize();
    -    public abstract void FType.setSize(Size size);
    +    public abstract FType FType.setSize(Size size);
    
         @Override
         public Size FArrayType.getSize() {
    @@ -277,7 +277,7 @@
             return newSize;
         }
         @Override
    -    public void FArrayType.setSize(Size size) {throw new InternalCompilerError("FArrayType does not support setSize()");}
    +    public FArrayType FArrayType.setSize(Size size) {throw new InternalCompilerError("FArrayType does not support setSize()");}
    
         syn Size FAbstractFunctionCall.sizeOfOutput(int i) = (i == 0) ? size() : Size.SCALAR;
         eq CommonFunctionCall.sizeOfOutput(int i)          = typeOfOutput(i).size();
    @@ -683,4 +683,4 @@
             }
         }
    
    -}
    \ No newline at end of file
    +}
    Index: Compiler/ModelicaFrontEnd/src/jastadd/util/Annotations.jrag
    ===================================================================
    --- Compiler/ModelicaFrontEnd/src/jastadd/util/Annotations.jrag (revision 13234)
    +++ Compiler/ModelicaFrontEnd/src/jastadd/util/Annotations.jrag (working copy)
    @@ -1834,7 +1834,7 @@
         public class FAttributeListAnnotationNode extends AnnotationNode {
    
             public interface FAttributeList {
    -            public void addFAttribute(FAttribute attribute);
    +            public FAttributeList addFAttribute(FAttribute attribute);
                 public List<FAttribute> getFAttributeList();
                 public int getNumFAttribute();
             }
    Index: Compiler/ModelicaFrontEnd/src/jastadd/util/SrcAnnotations.jrag
    ===================================================================
    --- Compiler/ModelicaFrontEnd/src/jastadd/util/SrcAnnotations.jrag  (revision 13234)
    +++ Compiler/ModelicaFrontEnd/src/jastadd/util/SrcAnnotations.jrag  (working copy)
    @@ -443,7 +443,7 @@
         public interface ASTNodeWithAnnotation {
             public SrcAnnotation getSrcAnnotation();
             public boolean hasSrcAnnotation();
    -        public void setSrcAnnotation(SrcAnnotation annotation);
    +        public ASTNodeWithAnnotation setSrcAnnotation(SrcAnnotation annotation);
         }
    
         SrcFullClassDecl implements ASTNodeWithAnnotation;
    Index: Compiler/ModelicaMiddleEnd/src/jastadd/transformations/GenerateEventIndicators.jrag
    ===================================================================
    --- Compiler/ModelicaMiddleEnd/src/jastadd/transformations/GenerateEventIndicators.jrag (revision 13234)
    +++ Compiler/ModelicaMiddleEnd/src/jastadd/transformations/GenerateEventIndicators.jrag (working copy)
    @@ -467,7 +467,7 @@
    
         public interface EventGeneratingExp {
             boolean hasIndicator();
    -        void addIndicator(FAccessExp indicator);
    +        EventGeneratingExp addIndicator(FAccessExp indicator);
         }
         FRelExp implements EventGeneratingExp;
         FDelayExp implements EventGeneratingExp;
    @@ -790,12 +790,14 @@
             return myIndicatorVariables().contains(indicator);
         }
    
    -    public void FRelExp.addIndicator(FAccessExp indicator) {
    +    public FRelExp FRelExp.addIndicator(FAccessExp indicator) {
             setIndicator(indicator);
    +        return this;
         }
    
    -    public void FSpatialDistExp.addIndicator(FAccessExp indicator) {
    +    public FSpatialDistExp FSpatialDistExp.addIndicator(FAccessExp indicator) {
             setIndicator(indicator);
    +        return this;
         }
    
         /* ====================== *
    Index: ThirdParty/JastAdd/jastadd2.jar
    ===================================================================
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream