public void TestSpecializationArguments() { var classTemplate = AstContext.FindDecl <ClassTemplate>("TestSpecializationArguments").FirstOrDefault(); Assert.IsTrue(classTemplate.Specializations[0].Arguments[0].Type.Type.IsPrimitiveType(PrimitiveType.Int)); }
public void TestFindFunctionInNamespace() { var function = AstContext.FindFunction("Math::function").FirstOrDefault(); Assert.That(function, Is.Not.Null); }
public void TestLineNumber() { Assert.AreEqual(70, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart); }
public void TestMacroLineNumber() { Assert.AreEqual(103, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); Name = (ItemNameNode)AddChild("name", treeNode.ChildNodes[0]); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); Name = treeNode.Term.ToString(); AsString = Name + " (not supported)"; }
public override void Init(AstContext context, ParseTreeNode treeNode) { statement = AddChild("statement", treeNode.GetMappedChildNodes()[1]); }
public void TestIgnoringMethod() { AstContext.IgnoreClassMethodWithName("Foo", "toIgnore"); Assert.IsFalse(AstContext.FindClass("Foo").First().Methods.Find( m => m.Name == "toIgnore").IsGenerated); }
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(); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); Value = Convert.ToInt32(treeNode.Token.Value); }
internal static bool HasError(AstContext context) { return(context.Messages.Any(message => message.Level.EqualToAny(ErrorLevel.Error, ErrorLevel.Warning))); }
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); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); child = AddChild("expression", treeNode.GetMappedChildNodes()[0]); }
public PropertyAstNodeViewModel(AstContext context, PropertyDescriptor propertyDescriptor) : base(context, propertyDescriptor.Object) { _propertyDescriptor = propertyDescriptor; }
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]); }
public void TestSkippedPrivateMethod() { AstContext.IgnoreClassMethodWithName("Foo", "toIgnore"); Assert.That(AstContext.FindClass("Foo").First().Methods.Find( m => m.Name == "toIgnore"), Is.Null); }
void DoNothing(AstContext ctx, ParseTreeNode node) { ProcessChildren(ctx, node); // do nothing except for processing children. }
void DoNothing(AstContext ctx, ParseTreeNode node) { // do nothing. }
public override void Init(AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); Characters = treeNode.ChildNodes.Select(cn => cn.AstNode as CharacterDeclarationNode).ToList(); }
public override void Init(AstContext context, ParseTreeNode parseNode) { throw new NotImplementedException(); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); scenenumber = String1.str2varname(); }
public void TestFindClassInNamespace() { Assert.IsNotNull(AstContext.FindClass("HiddenInNamespace").FirstOrDefault()); }
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]); }
public void TestLineNumberOfFriend() { Assert.AreEqual(93, AstContext.FindFunction("operator+").First().LineNumberStart); }
protected override void Initialize(AstContext context, ParseTreeNode parseNode) { TagPairs = GetChildren <TagPairAstNode>(parseNode); _tagMap = TagPairs.ToDictionary(node => node.Name.Text, node => node.Value.Text); }
public void TestImplicitDeclaration() { Assert.IsTrue(AstContext.FindClass("ImplicitCtor").First().Constructors.First( c => c.Parameters.Count == 0).IsImplicit); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); InnerExpression = AddChild("cell expression", treeNode.ChildNodes[0]); }
public void TestLayoutBase() { var @class = AstContext.FindCompleteClass("TestComments"); Assert.That(@class.Layout.Bases.Count, Is.EqualTo(0)); }
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 "control + char" 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)); }
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()); }
public AstBuilder(AstContext context) : base(context) { }
public ItemAstNodeViewModel(AstContext context, ObjectDescriptor objectDescriptor, int index) : base(context, objectDescriptor) { Index = index; }
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]); }