[nem-en] How field initializers are parsed?

Kamil Skalski kamil.skalski at gmail.com
Sat Dec 16 19:35:10 CET 2006


This is caused by some fake code generated in
macros/Internals.n

    when (Nemerle.Macros.ImplicitCTX().Manager.IsIntelliSenseMode)
    { // Add fake method whith body of field initialiser.
      def n = "_N_field_initialiser__" + f.Name;
      //Fixme: VladD2: I not understand how add
NemerleAttributes.SpecialName to this method.
      Util.locate(val.Location,
        t.Define (<[ decl: private $(n : usesite) () : void { _ = $val; } ]>));
    }


No idea why Vlad added this stuff...

2006/12/15, Andrey Khropov <andrey.khropov at gmail.com>:
>
> Hello,
>
> I've a question. How field initializers are dealt with in the compiler.
> Because I have a problem. I see that some hidden methods are created in
> TypeBuilder, e.g. :
>
> for field declaration
> -------------------------------------------
> private  mutable  components : System.ComponentModel.IContainer = null;
> -------------------------------------------
>
> I get the method
>
> -------------------------------------------------
> Form1._N_field_initialiser__components() : void
> -------------------------------------------------
>
> The typed body of this method is just {()} and when I use
> MethodBuilder.BodyTyped on it assertion fails because its Location's FileIndex
> is 0.
>
> So what's this strange method is about (doesn't FieldBuilder.const_value
> contain enough information) ?
>
> This question may be vs-integration specific because I encountered this during
> parsing Project declarations.
>
> --
> AKhropov
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list