[svn] r6803: nemerle/trunk/ncc/hierarchy/ClassMembers.n

VladD2 svnadmin at nemerle.org
Sat Oct 28 12:19:33 CEST 2006


Log:
Add Ast property into all MemberBuilder subtypes.

Author: VladD2
Date: Sat Oct 28 12:19:29 2006
New Revision: 6803

Modified:
   nemerle/trunk/ncc/hierarchy/ClassMembers.n

Modified: nemerle/trunk/ncc/hierarchy/ClassMembers.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/ClassMembers.n	(original)
+++ nemerle/trunk/ncc/hierarchy/ClassMembers.n	Sat Oct 28 12:19:29 2006
@@ -58,6 +58,20 @@
     set { attributes = value }
   }
 
+  _ast : PT.ClassMember;
+
+  public Ast : PT.ClassMember
+  {
+    get
+    {
+      if (Manager.IsInCompletionMode)
+        _ast
+      else
+        throw System.InvalidOperationException (
+        "Ast accessible only if Manager.IsInCompletionMode is true.");
+    }
+  }
+
   protected mutable m_has_been_used : bool;
 
   internal mutable disable_type_attr : bool;
@@ -66,13 +80,14 @@
   public mutable optional_modifiers : list[System.Type] = [];
   public Env : GlobalEnv;
   
-  protected this (par : TypeBuilder, d : PT.ClassMember)
+  protected this (par : TypeBuilder, ast : PT.ClassMember)
   {
-    Env = d.Env;
-    loc = d.loc;
-    modifiers = d.modifiers;
-    name = d.Name; 
     declaring_type = par;
+    _ast = if (Manager.IsInCompletionMode) ast else null;
+    Env = ast.Env;
+    loc = ast.loc;
+    modifiers = ast.modifiers;
+    name = ast.Name; 
     id = Util.next_id ();
 
     attributes = modifiers.mods;
@@ -399,16 +414,22 @@
   public mutable const_value : Literal;
   mutable has_been_assigned = false;
 
-  public this (par : TypeBuilder, f : PT.ClassMember.Field) {
-    base (par, f);
+  /// Parsed representation (AST) of field.
+  /// Note: available only in CompletionMode 
+  /// (if Manager.IsInCompletionMode = true)
+  public new Ast : PT.ClassMember.Field { get { base.Ast :> PT.ClassMember.Field } }
+
+  public this (par : TypeBuilder, fieldAst : PT.ClassMember.Field)
+  {
+    base (par, fieldAst);
     
     // check if field's type is valid
-    match (f.ty) {
+    match (fieldAst.ty) {
       | <[ _ ]> => Message.Error ("type inference for fields is available only when assigning literal value to them") 
       | _ => ()
     }
     
-    ty = par.MonoBindType (f.ty);
+    ty = par.MonoBindType (fieldAst.ty);
         
     kind = MemberKind.Field (this);
     
@@ -519,22 +540,23 @@
   mutable parent_property : IProperty = null;
   
   internal mutable property_builder : SRE.PropertyBuilder;
+
   /// Parsed representation (AST) of property.
   /// Note: available only in CompletionMode 
-  /// (if Managet.IsInCompletionMode = true)
-  [Accessor] _parsedTree : PT.ClassMember.Property;
+  /// (if Manager.IsInCompletionMode = true)
+  public new Ast : PT.ClassMember.Property { get { base.Ast :> PT.ClassMember.Property } }
   
-  public this (par : TypeBuilder, f : PT.ClassMember.Property)
+  public this (par : TypeBuilder, propertyAst : PT.ClassMember.Property)
   {
-    base (par, f);
-    _parsedTree = if (Manager.IsInCompletionMode) f else null;
-    is_mutable = Option.IsSome (f.set);
-    ty = par.MonoBindType (f.prop_ty);
+    base (par, propertyAst);
+
+    is_mutable = Option.IsSome (propertyAst.set);
+    ty = par.MonoBindType (propertyAst.prop_ty);
 
     kind = MemberKind.Property (this);
 
     parms = 
-      List.Map (f.dims, fun (parm : PT.Fun_parm) {
+      List.Map (propertyAst.dims, fun (parm : PT.Fun_parm) {
         par.MonoBindType (parm.ty);
       });
 
@@ -548,8 +570,8 @@
         method
       | None => null
     }
-    getter = process_accessor (f.get);
-    setter = process_accessor (f.set);
+    getter = process_accessor (propertyAst.get);
+    setter = process_accessor (propertyAst.set);
 
     ty.CheckAccessibility (this, accessibility);
 
@@ -652,10 +674,13 @@
   [Accessor (flags = Override)]
   protected mutable body_location : Location;
   
-  [Accessor] _parsedFunction : PT.ClassMember.Function;
-  
   is_var_args : bool;
 
+  /// Parsed representation (AST) of function.
+  /// Note: available only in CompletionMode 
+  /// (if Manager.IsInCompletionMode = true)
+  public new Ast : PT.ClassMember.Function { get { base.Ast :> PT.ClassMember.Function } }
+
   public GetMethodBase () : SR.MethodBase
   {
     def res =
@@ -734,16 +759,16 @@
     get { is_var_args }
   }
 
-  public this (par : TypeBuilder, f : PT.ClassMember.Function)
+  public this (par : TypeBuilder, functionAst : PT.ClassMember.Function)
   {
-    this (par, f, false);
+    this (par, functionAst, false);
   }
   
-  public this (par : TypeBuilder, f : PT.ClassMember.Function, is_property : bool)
+  public this (par : TypeBuilder, functionAst : PT.ClassMember.Function, is_property : bool)
   {
-    base (par, f);
+    base (par, functionAst);
 
-    _parsedFunction = f;
+    def f = functionAst;
 
     when (LexerBase.IsOperator (name))
       unless (IsStatic && IsPublic)
@@ -1162,17 +1187,22 @@
   internal mutable event_builder : SRE.EventBuilder;
   internal storage_field : FieldBuilder;
   
-  public this (par : TypeBuilder, f : PT.ClassMember.Event) {
-    base (par, f);
+  /// Parsed representation (AST) of event.
+  /// Note: available only in CompletionMode 
+  /// (if Manager.IsInCompletionMode = true)
+  public new Ast : PT.ClassMember.Event { get { base.Ast :> PT.ClassMember.Event } }
+  
+  public this (par : TypeBuilder, eventAst : PT.ClassMember.Event) {
+    base (par, eventAst);
     
-    ty = par.MonoBindType (f.ty);
+    ty = par.MonoBindType (eventAst.ty);
 
     kind = MemberKind.Event (this);
 
     // prevent closurising `this' 
     def self = this;
 
-    when (f.field != null) {
+    when (eventAst.field != null) {
       def update_mfunction (meth : PT.ClassMember.Function, which_accessor : string) {
         if (declaring_type.IsInterface)
           meth.body = FunBody.Abstract ()
@@ -1182,7 +1212,7 @@
               typeof ($(declaring_type.ParsedName : name))
             ]>
             else <[ this ]>;
-          def field_name = f.field.ParsedName;
+          def field_name = eventAst.field.ParsedName;
 
           // according to C# spec, we have to add locks
           // http://www.jaggersoft.com/csharp_standard/17.7.1.htm
@@ -1196,12 +1226,12 @@
       };
       
       unless (declaring_type.IsInterface) {
-        when (IsStatic) f.field.modifiers.mods |= NemerleAttributes.Static;
-        storage_field = FieldBuilder (par, f.field);
+        when (IsStatic) eventAst.field.modifiers.mods |= NemerleAttributes.Static;
+        storage_field = FieldBuilder (par, eventAst.field);
         declaring_type.AddMember (storage_field);
       }
-      update_mfunction (f.add, "add");
-      update_mfunction (f.remove, "remove");
+      update_mfunction (eventAst.add, "add");
+      update_mfunction (eventAst.remove, "remove");
     }
       
     def make_method (mfunc : PT.ClassMember.Function) {
@@ -1212,8 +1242,8 @@
       meth'
     };
 
-    adder = make_method (f.add);
-    remover = make_method (f.remove);
+    adder = make_method (eventAst.add);
+    remover = make_method (eventAst.remove);
     ManagerClass.Instance.MarkAsUsed (remover);
 
     ty.CheckAccessibility (this, accessibility);



More information about the svn mailing list