Project

General

Profile

3353a_20171024a.patch

Greg Shah, 10/24/2017 05:09 PM

Download (6.51 KB)

View differences:

new/src/com/goldencode/p2j/uast/progress.g 2017-10-24 21:01:44 +0000
6641 6641
      sym.addBuiltinFunction("dynamic-current-value", FUNC_INT64      , false);
6642 6642
      sym.addBuiltinFunction("dynamic-function"     , FUNC_POLY       , true ); // like called func, uses for annotations only
6643 6643
      sym.addBuiltinFunction("dynamic-invoke"       , FUNC_POLY       , true );
6644
      sym.addBuiltinFunction("dynamic-new"          , FUNC_CLASS      , true , "Progress.Lang.Object");  // used for annotations only
6644 6645
      sym.addBuiltinFunction("dynamic-next-value"   , FUNC_INT64      , false);
6645 6646
      sym.addBuiltinFunction("encode"               , FUNC_CHAR       , true );
6646 6647
      sym.addBuiltinFunction("encrypt"              , FUNC_MEMPTR     , false);
......
8613 8614
   }              
8614 8615
   
8615 8616
   /**
8616
    * Returns <code>true</code> if the given type is <code>VAR_CLASS</code>,
8617
    * <code>FIELD_CLASS</code>, <code>FUNC_CLASS</code>, 
8618
    * <code>METH_CLASS</code>, <code>CLASS_NAME</code> or if this is a built-in 
8619
    * attribute or non-user defined method call <code>COLON</code> that has a
8620
    * <code>ATTR_CLASS</code> or <code>METH_CLASS</code> in the index
8621
    * position 1.
8617
    * Returns <code>true</code> if the given subtree resolves to a <code>VAR_CLASS</code>,
8618
    * <code>FIELD_CLASS</code>, <code>FUNC_CLASS</code>, <code>METH_CLASS</code>,
8619
    * <code>CLASS_NAME</code> or if this is a built-in attribute or non-user defined method call
8620
    * <code>COLON</code> that has a <code>ATTR_CLASS</code> or <code>METH_CLASS</code> in the
8621
    * index position 1.
8622
    * <p>
8623
    * Parenthesis will be ignored and the contained sub-expression will be checked.
8622 8624
    *
8623 8625
    * @param    node
8624 8626
    *           AST node to test.
8625 8627
    *
8626 8628
    * @return   <code>true</code> if the type represents an object reference.
8627 8629
    */
8628
   private boolean isObjectType(Aast node)
8630
   private boolean isObjectSubtree(Aast node)
8629 8631
   {
8630
      return isObjectType(node.getType());
8632
      int  type = node.getType();
8633
      Aast ref  = node;
8634
   
8635
      while (ref != null && type == LPARENS)
8636
      {
8637
         ref = ref.getChildAt(0);
8638
         
8639
         if (ref == null)
8640
         {
8641
            break;
8642
         }
8643
         
8644
         type = ref.getType();
8645
      }
8646
   
8647
      return isObjectType(type);
8631 8648
   }
8632 8649
   
8633 8650
   /**
8634 8651
    * Returns <code>true</code> if the given type is <code>VAR_CLASS</code>,
8635
    * <code>FIELD_CLASS</code>, <code>FUNC_CLASS</code>, 
8636
    * <code>METH_CLASS</code>, <code>CLASS_NAME</code> or
8637
    * <code>ATTR_CLASS</code>.
8652
    * <code>FIELD_CLASS</code>, <code>FUNC_CLASS</code>, <code>METH_CLASS</code>,  
8653
    * <code>CLASS_NAME</code> or <code>ATTR_CLASS</code>.
8638 8654
    *
8639 8655
    * @param    type
8640 8656
    *           The type to test.
......
8652 8668
   }
8653 8669
   
8654 8670
   /**
8671
    * Returns <code>true</code> if the given subtree resolves to a <code>CLASS_NAME</code>.
8672
    * Parenthesis will be ignored and the contained sub-expression will be checked.
8673
    *
8674
    * @param    node
8675
    *           AST node to test.
8676
    *
8677
    * @return   <code>true</code> if the type represents an class reference.
8678
    */
8679
   private boolean isStaticObject(Aast node)
8680
   {
8681
      int  type = node.getType();
8682
      Aast ref  = node;
8683
   
8684
      while (ref != null && type == LPARENS)
8685
      {
8686
         ref = ref.getChildAt(0);
8687
         
8688
         if (ref == null)
8689
         {
8690
            break;
8691
         }
8692
         
8693
         type = ref.getType();
8694
      }
8695
   
8696
      return (type == CLASS_NAME);
8697
   }
8698
   
8699
   /**
8655 8700
    * Find the class name referenced by the given object reference.
8656 8701
    *
8657 8702
    * @param    node
......
8663 8708
    */
8664 8709
   private String getObjectClassName(Aast node)
8665 8710
   {
8666
      return (String) node.getAnnotation("qualified");
8711
      int  type = node.getType();
8712
      Aast ref  = node;
8713
      
8714
      while (ref != null && type == LPARENS)
8715
      {
8716
         ref = ref.getChildAt(0);
8717
         
8718
         if (ref == null)
8719
         {
8720
            break;
8721
         }
8722
         
8723
         type = ref.getType();
8724
      }
8725
   
8726
      return (String) ref.getAnnotation("qualified");
8667 8727
   }
8668 8728
   
8669 8729
   /**
......
25651 25711
           
25652 25712
              // COM-HANDLE reference (or possible reference)
25653 25713
              active_x = isComHandleType(refnode);
25654
           
25714
              
25655 25715
              // determine if the primary expression is an object or class reference
25656
              object = isObjectType(refnode);
25716
              object = isObjectSubtree(refnode);
25657 25717
              
25658 25718
              if (object)
25659 25719
              {
25660
                 isStatic = (refnode.getType() == CLASS_NAME);
25720
                 isStatic = isStaticObject(refnode);
25661 25721
              
25662 25722
                 // determine to what specific class that reference refers
25663 25723
                 cls = getObjectClassName(refnode);
......
26932 26992
         // write our function-specific annotations
26933 26993
         sym.annotateFunction(#c.getText(), ##, false);
26934 26994
         
26935
         // the above probably did not set the class name so we force it
26936
         // here
26995
         // the above probably did not set the class name so we force it here
26937 26996
         String qname = (String) #udt.getAnnotation("qualified");
26938 26997
         sym.annotateClassRef(qname, ##);
26939 26998
      }
......
28783 28842
 */
28784 28843
new_phrase
28785 28844
   :
28786
      KW_NEW^ user_defined_type_name param_passing_list[false]
28845
      KW_NEW^ udt:user_defined_type_name param_passing_list[false]
28846
      {
28847
         // save the original token type, then rewrite the type
28848
         ##.putAnnotation("oldtype", new Long(##.getType()));
28849
         ##.setType(FUNC_CLASS);
28850
            
28851
         // write our function-specific annotations
28852
         sym.annotateFunction(##.getText(), ##, false);
28853
         
28854
         // the above probably did not set the class name so we force it here
28855
         String qname = (String) #udt.getAnnotation("qualified");
28856
         sym.annotateClassRef(qname, ##);
28857
      }
28787 28858
   ;
28788 28859
   
28789 28860
/**
......
28801 28872
         :
28802 28873
         KW_NO_ERROR
28803 28874
      )?
28875
      {
28876
         // save the original token type, then rewrite the type
28877
         ##.putAnnotation("oldtype", new Long(##.getType()));
28878
         ##.setType(FUNC_CLASS);
28879
            
28880
         // write our function-specific annotations
28881
         sym.annotateFunction(##.getText(), ##, false);
28882
         
28883
         // the above probably did not set the class name so we force it here
28884
         sym.annotateClassRef("Progress.Lang.Object", ##);
28885
      }
28804 28886
   ;
28805 28887
   
28806 28888
/**