Пример #1
0
        public static ILAssembly ToAssembly(this IDLParserToken t)
        {
            var a = new ILAssembly();

            var q = t;

            #region AssemblyExternList
            {
                var p = q;

                while (p != null)
                {
                    var n = p.ToAssemblyExtern();

                    if (n == null)
                    {
                        p = null;
                    }
                    else
                    {
                        a.AssemblyExternList.Add(n);
                        p = n.Scope.Item2;
                    }
                }
            }
            #endregion



            return(a);
        }
Пример #2
0
        public static ILAssembly ToAssembly(this IDLParserToken t)
        {
            var a = new ILAssembly();

            var q = t;

            #region AssemblyExternList
            {
                var p = q;

                while (p != null)
                {
                    var n = p.ToAssemblyExtern();

                    if (n == null)
                    {
                        p = null;
                    }
                    else
                    {
                        a.AssemblyExternList.Add(n);
                        p = n.Scope.Item2;
                    }
                }
            }
            #endregion



            return a;
        }
Пример #3
0
        public static ILAssembly ToAssemblyWithMethods(this IDLParserToken t)
        {
            // used by?

            var a = new ILAssembly();

            var q = t;

     
            #region manage those quouted literals
            {
                var p = q;
                while (p != null)
                {
                    Action<string> CombineAsPairs =
                        Qoute =>
                        {
                            var ok = p.Text == Qoute;

                            while (ok)
                            {
                                p.IsCommentDiscoveryEnabled = false;

                                // do we allow escaping? :)
                                if (p.Next.Text == Qoute)
                                    ok = false;

                                new[] { p, p.Next }.Combine();

                                //Console.WriteLine("literal: " + p.Text);
                            }

                            p.IsCommentDiscoveryEnabled = true;
                        };

                    CombineAsPairs("\"");
                    CombineAsPairs("'");

                    Action<string> CombineKeyword =
                        k =>
                        {
                            if (p.Text + p.Next.Text == k)
                            {
                                new[] { p, p.Next }.Combine();
                            }
                        };


                    CombineKeyword(".corflags");
                    CombineKeyword(".class");
                    CombineKeyword(".method");
                    CombineKeyword(".ctor");

                    p = p.SkipTo();
                }
            }
            #endregion



            {


                {
                    var p = q;
                    while (p != null)
                    {
                        if (p.Text == ".method")
                        {
                            var NameToken = p.SkipWhile(k => k.SkipTo().Text != "(").First();
                            var Sig = p.TakeWhile(k => k != NameToken).ToArray();

                            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/08-cx/20150518
                            var IsPrivate = Sig.Any(k => k.Text == "private");
                            var IsStatic = Sig.Any(k => k.Text == "static");
                            var IsUnmanagedExport = Sig.Any(k => k.Text == "unmanagedexp");

                            a.Methods.Add(
                                new ILAssemblyMethod
                                {
                                    Token = p,
                                    IsPrivate = IsPrivate,
                                    IsStatic = IsStatic,
                                    IsUnmanagedExport = IsUnmanagedExport,
                                    NameToken = NameToken,
                                    ParameterStartToken = p.SkipWhile(k => k.Text != "(").First(),
                                    BodyStartToken = p.SkipWhile(k => k.Text != "{").First(),
                                }
                            );
                        }
                        p = p.SkipTo();
                    }
                }
            }

            return a;
        }
Пример #4
0
        public static ILAssembly ToAssemblyWithMethods(this IDLParserToken t)
        {
            // used by?

            var a = new ILAssembly();

            var q = t;


            #region manage those quouted literals
            {
                var p = q;
                while (p != null)
                {
                    Action <string> CombineAsPairs =
                        Qoute =>
                    {
                        var ok = p.Text == Qoute;

                        while (ok)
                        {
                            p.IsCommentDiscoveryEnabled = false;

                            // do we allow escaping? :)
                            if (p.Next.Text == Qoute)
                            {
                                ok = false;
                            }

                            new[] { p, p.Next }.Combine();

                            //Console.WriteLine("literal: " + p.Text);
                        }

                        p.IsCommentDiscoveryEnabled = true;
                    };

                    CombineAsPairs("\"");
                    CombineAsPairs("'");

                    Action <string> CombineKeyword =
                        k =>
                    {
                        if (p.Text + p.Next.Text == k)
                        {
                            new[] { p, p.Next }.Combine();
                        }
                    };


                    CombineKeyword(".corflags");
                    CombineKeyword(".class");
                    CombineKeyword(".method");
                    CombineKeyword(".ctor");

                    p = p.SkipTo();
                }
            }
            #endregion



            {
                {
                    var p = q;
                    while (p != null)
                    {
                        if (p.Text == ".method")
                        {
                            var NameToken = p.SkipWhile(k => k.SkipTo().Text != "(").First();
                            var Sig       = p.TakeWhile(k => k != NameToken).ToArray();

                            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/08-cx/20150518
                            var IsPrivate         = Sig.Any(k => k.Text == "private");
                            var IsStatic          = Sig.Any(k => k.Text == "static");
                            var IsUnmanagedExport = Sig.Any(k => k.Text == "unmanagedexp");

                            a.Methods.Add(
                                new ILAssemblyMethod
                            {
                                Token               = p,
                                IsPrivate           = IsPrivate,
                                IsStatic            = IsStatic,
                                IsUnmanagedExport   = IsUnmanagedExport,
                                NameToken           = NameToken,
                                ParameterStartToken = p.SkipWhile(k => k.Text != "(").First(),
                                BodyStartToken      = p.SkipWhile(k => k.Text != "{").First(),
                            }
                                );
                        }
                        p = p.SkipTo();
                    }
                }
            }

            return(a);
        }