コード例 #1
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
        public void TestSpecializationArguments()
        {
            var classTemplate = AstContext.FindDecl <ClassTemplate>("TestSpecializationArguments").FirstOrDefault();

            Assert.IsTrue(classTemplate.Specializations[0].Arguments[0].Type.Type.IsPrimitiveType(PrimitiveType.Int));
        }
コード例 #2
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
        public void TestFindFunctionInNamespace()
        {
            var function = AstContext.FindFunction("Math::function").FirstOrDefault();

            Assert.That(function, Is.Not.Null);
        }
コード例 #3
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
 public void TestLineNumber()
 {
     Assert.AreEqual(70, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
 }
コード例 #4
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
 public void TestMacroLineNumber()
 {
     Assert.AreEqual(103, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
 }
コード例 #5
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     Name = (ItemNameNode)AddChild("name", treeNode.ChildNodes[0]);
 }
コード例 #6
0
ファイル: NotSupportedNode.cs プロジェクト: yangbodevp/irony
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     Name     = treeNode.Term.ToString();
     AsString = Name + " (not supported)";
 }
コード例 #7
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     statement = AddChild("statement", treeNode.GetMappedChildNodes()[1]);
 }
コード例 #8
0
 public void TestIgnoringMethod()
 {
     AstContext.IgnoreClassMethodWithName("Foo", "toIgnore");
     Assert.IsFalse(AstContext.FindClass("Foo").First().Methods.Find(
                        m => m.Name == "toIgnore").IsGenerated);
 }
コード例 #9
0
ファイル: DeclAstNode.cs プロジェクト: kvasnyk/CILantro
        public override void Init(AstContext context, ParseTreeNode parseNode)
        {
            // classHead + _("{") + classDecls + _("}")
            var classChildren = AstChildren.Empty()
                                .Add <ClassHeadAstNode>()
                                .Add("{")
                                .Add <ClassDeclsAstNode>()
                                .Add("}");

            if (classChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.Class;

                ClassDecl = new CilClass
                {
                    Name = new CilClassName
                    {
                        ClassName = classChildren.Child1.ClassName
                    },
                    Methods     = classChildren.Child3.ClassDecls.Methods,
                    Fields      = classChildren.Child3.ClassDecls.Fields,
                    Classes     = classChildren.Child3.ClassDecls.Classes,
                    ExtendsName = classChildren.Child1.ExtendsClassName,
                    Attributes  = classChildren.Child1.ClassAttributes
                };

                return;
            }

            // assemblyHead + _("{") + assemblyDecls + _("}")
            var assemblyChildren = AstChildren.Empty()
                                   .Add <AssemblyHeadAstNode>()
                                   .Add("{")
                                   .Add <AssemblyDeclsAstNode>()
                                   .Add("}");

            if (assemblyChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.Assembly;

                AssemblyDecl = new CilAssembly
                {
                    Name = assemblyChildren.Child1.AssemblyName
                };

                return;
            }

            // assemblyRefHead + _("{") + assemblyRefDecls + _("}")
            var assemblyRefChildren = AstChildren.Empty()
                                      .Add <AssemblyRefHeadAstNode>()
                                      .Add("{")
                                      .Add <AssemblyRefDeclsAstNode>()
                                      .Add("}");

            if (assemblyRefChildren.PopulateWith(parseNode))
            {
                DeclType        = Other.DeclType.AssemblyRef;
                AssemblyRefDecl = new CilAssemblyRef
                {
                    Name            = assemblyRefChildren.Child1.AssemblyName,
                    PublicKeyTokens = assemblyRefChildren.Child3.AssemblyRefDecls.PublicKeyTokens,
                    Versions        = assemblyRefChildren.Child3.AssemblyRefDecls.Versions
                };

                return;
            }

            // moduleHead
            var moduleChildren = AstChildren.Empty()
                                 .Add <ModuleHeadAstNode>();

            if (moduleChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.Module;

                return;
            }

            // _(".file") + _("alignment") + int32
            var fileAlignmentChildren = AstChildren.Empty()
                                        .Add(".file")
                                        .Add("alignment")
                                        .Add <Int32AstNode>();

            if (fileAlignmentChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.FileAlignment;

                return;
            }

            // _(".subsystem") + int32
            var subsystemChildren = AstChildren.Empty()
                                    .Add(".subsystem")
                                    .Add <Int32AstNode>();

            if (subsystemChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.Subsystem;

                return;
            }

            // _(".corflags") + int32
            var corFlagsChildren = AstChildren.Empty()
                                   .Add(".corflags")
                                   .Add <Int32AstNode>();

            if (corFlagsChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.CorFlags;

                return;
            }

            // _(".imagebase") + int64
            var imageBaseChildren = AstChildren.Empty()
                                    .Add(".imagebase")
                                    .Add <Int64AstNode>();

            if (imageBaseChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.ImageBase;

                return;
            }

            // _(".stackreserve") + int64
            var stackReserveChildren = AstChildren.Empty()
                                       .Add(".stackreserve")
                                       .Add <Int64AstNode>();

            if (stackReserveChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.StackReserve;

                return;
            }

            // manifestResHead + _("{") + manifestResDecls + _("}")
            var manifestResChildren = AstChildren.Empty()
                                      .Add <ManifestResHeadAstNode>()
                                      .Add("{")
                                      .Add <ManifestResDeclsAstNode>()
                                      .Add("}");

            if (manifestResChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.ManifestRes;

                return;
            }

            // methodHead + methodDecls + _("}")
            var methodChildren = AstChildren.Empty()
                                 .Add <MethodHeadAstNode>()
                                 .Add <MethodDeclsAstNode>()
                                 .Add("}");

            if (methodChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.Method;

                MethodDecl = new CilMethod
                {
                    Name         = methodChildren.Child1.MethodName,
                    IsEntryPoint = methodChildren.Child2.MethodDecls.IsEntryPoint,
                    Instructions = methodChildren.Child2.MethodDecls.Instructions,
                    Locals       = methodChildren.Child2.MethodDecls.Locals
                };

                return;
            }

            // customAttrDecl
            var customAttrDeclChildren = AstChildren.Empty()
                                         .Add <CustomAttrDeclAstNode>();

            if (customAttrDeclChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.CustomAttribute;

                return;
            }

            // dataDecl
            var dataDeclChildren = AstChildren.Empty()
                                   .Add <DataDeclAstNode>();

            if (dataDeclChildren.PopulateWith(parseNode))
            {
                DeclType = Other.DeclType.Data;
                DataDecl = dataDeclChildren.Child1.Data;
                DataId   = dataDeclChildren.Child1.DataId;

                return;
            }

            throw new NotImplementedException();
        }
コード例 #10
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     Value = Convert.ToInt32(treeNode.Token.Value);
 }
コード例 #11
0
 internal static bool HasError(AstContext context)
 {
     return(context.Messages.Any(message => message.Level.EqualToAny(ErrorLevel.Error, ErrorLevel.Warning)));
 }
コード例 #12
0
 public static object ValueToAstNode(object astValue, AstContext context, ParseTreeNode parseTreeNode)
 {
     return(((Grammar)context.Language.Grammar).AstCreation == AstCreation.CreateAstWithAutoBrowsableAstNodes && !(astValue is IBrowsableAstNode)
         ? new AstNodeWrapper(astValue, context, parseTreeNode)
         : astValue);
 }
コード例 #13
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            child = AddChild("expression", treeNode.GetMappedChildNodes()[0]);
        }
コード例 #14
0
ファイル: AstNodeViewModel.cs プロジェクト: rsdn/nitra
 public PropertyAstNodeViewModel(AstContext context, PropertyDescriptor propertyDescriptor)
   : base(context, propertyDescriptor.Object)
 {
   _propertyDescriptor = propertyDescriptor;
 }
コード例 #15
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     Expression = (VisualizerBinaryExpressionNode)AddChild("Inner", treeNode.ChildNodes[0]);
     Statement  = AddChild("statement", treeNode.ChildNodes[1]);
 }
コード例 #16
0
 public void TestSkippedPrivateMethod()
 {
     AstContext.IgnoreClassMethodWithName("Foo", "toIgnore");
     Assert.That(AstContext.FindClass("Foo").First().Methods.Find(
                     m => m.Name == "toIgnore"), Is.Null);
 }
コード例 #17
0
 void DoNothing(AstContext ctx, ParseTreeNode node)
 {
     ProcessChildren(ctx, node);
     // do nothing except for processing children.
 }
コード例 #18
0
 void DoNothing(AstContext ctx, ParseTreeNode node)
 {
     // do nothing.
 }
コード例 #19
0
 public override void Init(AstContext context, Irony.Parsing.ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     Characters = treeNode.ChildNodes.Select(cn => cn.AstNode as CharacterDeclarationNode).ToList();
 }
コード例 #20
0
 public override void Init(AstContext context, ParseTreeNode parseNode)
 {
     throw new NotImplementedException();
 }
コード例 #21
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     scenenumber = String1.str2varname();
 }
コード例 #22
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
 public void TestFindClassInNamespace()
 {
     Assert.IsNotNull(AstContext.FindClass("HiddenInNamespace").FirstOrDefault());
 }
コード例 #23
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     Start = (ScopeLimitSatementNode)AddChild("start", treeNode.ChildNodes[0]);
     End   = (ScopeLimitSatementNode)AddChild("end", treeNode.ChildNodes[1]);
 }
コード例 #24
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
 public void TestLineNumberOfFriend()
 {
     Assert.AreEqual(93, AstContext.FindFunction("operator+").First().LineNumberStart);
 }
コード例 #25
0
 protected override void Initialize(AstContext context, ParseTreeNode parseNode)
 {
     TagPairs = GetChildren <TagPairAstNode>(parseNode);
     _tagMap  = TagPairs.ToDictionary(node => node.Name.Text, node => node.Value.Text);
 }
コード例 #26
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
 public void TestImplicitDeclaration()
 {
     Assert.IsTrue(AstContext.FindClass("ImplicitCtor").First().Constructors.First(
                       c => c.Parameters.Count == 0).IsImplicit);
 }
コード例 #27
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     InnerExpression = AddChild("cell expression", treeNode.ChildNodes[0]);
 }
コード例 #28
0
ファイル: TestAST.cs プロジェクト: richardlalancette/CppSharp
        public void TestLayoutBase()
        {
            var @class = AstContext.FindCompleteClass("TestComments");

            Assert.That(@class.Layout.Bases.Count, Is.EqualTo(0));
        }
コード例 #29
0
ファイル: TestAST.cs プロジェクト: rjmporter/CppSharp
        public void TestComments()
        {
            var @class       = AstContext.FindCompleteClass("TestComments");
            var commentClass = @class.Comment.FullComment.CommentToString(CommentKind.BCPLSlash);

            Assert.AreEqual(@"/// <summary>
/// <para>Hash set/map base class.</para>
/// <para>Note that to prevent extra memory use due to vtable pointer, %HashBase intentionally does not declare a virtual destructor</para>
/// <para>and therefore %HashBase pointers should never be used.</para>
/// </summary>".Replace("\r", string.Empty), commentClass.Replace("\r", string.Empty));

            var method        = @class.Methods.First(m => m.Name == "GetIOHandlerControlSequence");
            var commentMethod = method.Comment.FullComment.CommentToString(CommentKind.BCPL);

            Assert.AreEqual(@"// <summary>
// <para>Get the string that needs to be written to the debugger stdin file</para>
// <para>handle when a control character is typed.</para>
// </summary>
// <param name=""ch"">The character that was typed along with the control key</param>
// <returns>
// <para>The string that should be written into the file handle that is</para>
// <para>feeding the input stream for the debugger, or NULL if there is</para>
// <para>no string for this control key.</para>
// </returns>
// <remarks>
// <para>Some GUI programs will intercept &quot;control + char&quot; sequences and want</para>
// <para>to have them do what normally would happen when using a real</para>
// <para>terminal, so this function allows GUI programs to emulate this</para>
// <para>functionality.</para>
// </remarks>".Replace("\r", string.Empty), commentMethod.Replace("\r", string.Empty));

            var methodTestDoxygen    = @class.Methods.First(m => m.Name == "SBAttachInfo");
            var commentMethodDoxygen = methodTestDoxygen.Comment.FullComment.CommentToString(CommentKind.BCPLSlash);

            Assert.AreEqual(@"/// <summary>Attach to a process by name.</summary>
/// <param name=""path"">A full or partial name for the process to attach to.</param>
/// <param name=""wait_for"">
/// <para>If <c>false,</c> attach to an existing process whose name matches.</para>
/// <para>If <c>true,</c> then wait for the next process whose name matches.</para>
/// </param>
/// <remarks>
/// <para>This function implies that a future call to SBTarget::Attach(...)</para>
/// <para>will be synchronous.</para>
/// </remarks>".Replace("\r", string.Empty), commentMethodDoxygen.Replace("\r", string.Empty));

            var methodDoxygenCustomTags = @class.Methods.First(m => m.Name == "glfwDestroyWindow");

            new CleanCommentsPass {
            }.VisitFull(methodDoxygenCustomTags.Comment.FullComment);
            var commentMethodDoxygenCustomTag = methodDoxygenCustomTags.Comment.FullComment.CommentToString(CommentKind.BCPLSlash);

            Assert.AreEqual(@"/// <summary>Destroys the specified window and its context.</summary>
/// <param name=""window"">The window to destroy.</param>
/// <remarks>
/// <para>This function destroys the specified window and its context.  On calling</para>
/// <para>this function, no further callbacks will be called for that window.</para>
/// <para>If the context of the specified window is current on the main thread, it is</para>
/// <para>detached before being destroyed.</para>
/// <para>The context of the specified window must not be current on any other</para>
/// <para>thread when this function is called.</para>
/// <para>This function must not be called from a callback.</para>
/// <para>This function must only be called from the main thread.</para>
/// <para>Added in version 3.0.  Replaces `glfwCloseWindow`.</para>
/// </remarks>".Replace("\r", string.Empty), commentMethodDoxygenCustomTag.Replace("\r", string.Empty));
        }
コード例 #30
0
ファイル: AstNodeViewModel.cs プロジェクト: rsdn/nitra
    public AstNodeViewModel(AstContext context, ObjectDescriptor objectDescriptor)
    {
      Context           = context;
      _objectDescriptor = objectDescriptor;
      Items = new ReactiveList<AstNodeViewModel>();
      if (objectDescriptor.IsObject || objectDescriptor.IsSeq && objectDescriptor.Count > 0)
      {
        NeedLoadContent = true;
        Items.Add(null);
      }

      this.WhenAnyValue(vm => vm.IsExpanded)
          .Where(isExpanded => isExpanded && NeedLoadContent)
          .Subscribe(_ => LoadItems());
    }
コード例 #31
0
ファイル: AstBuilder.cs プロジェクト: kevlyons/Sarcasm
 public AstBuilder(AstContext context)
     : base(context)
 {
 }
コード例 #32
0
ファイル: AstNodeViewModel.cs プロジェクト: rsdn/nitra
 public ItemAstNodeViewModel(AstContext context, ObjectDescriptor objectDescriptor, int index) : base(context, objectDescriptor)
 {
   Index = index;
 }
コード例 #33
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     From = (TableCellReferenceNode)AddChild("table cell reference", treeNode.ChildNodes[0]);
     To   = (TableCellReferenceNode)AddChild("table cell reference", treeNode.ChildNodes[1]);
 }