mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
Assert that non-file definitions must have a parent.
This commit is contained in:
parent
e2cfb8aaf1
commit
c296c0f63a
@ -1,4 +1,5 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace CapnpC.Model
|
namespace CapnpC.Model
|
||||||
{
|
{
|
||||||
class Annotation : IDefinition
|
class Annotation : IDefinition
|
||||||
@ -11,6 +12,7 @@ namespace CapnpC.Model
|
|||||||
|
|
||||||
public Annotation(ulong id, IHasNestedDefinitions parent)
|
public Annotation(ulong id, IHasNestedDefinitions parent)
|
||||||
{
|
{
|
||||||
|
Trace.Assert(parent != null);
|
||||||
Id = id;
|
Id = id;
|
||||||
DeclaringElement = parent;
|
DeclaringElement = parent;
|
||||||
parent.NestedDefinitions.Add(this);
|
parent.NestedDefinitions.Add(this);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace CapnpC.Model
|
namespace CapnpC.Model
|
||||||
{
|
{
|
||||||
class Constant : IDefinition
|
class Constant : IDefinition
|
||||||
@ -11,6 +12,7 @@ namespace CapnpC.Model
|
|||||||
|
|
||||||
public Constant(ulong id, IHasNestedDefinitions parent)
|
public Constant(ulong id, IHasNestedDefinitions parent)
|
||||||
{
|
{
|
||||||
|
Trace.Assert(parent != null);
|
||||||
Id = id;
|
Id = id;
|
||||||
DeclaringElement = parent;
|
DeclaringElement = parent;
|
||||||
parent.NestedDefinitions.Add(this);
|
parent.NestedDefinitions.Add(this);
|
||||||
|
@ -6,7 +6,7 @@ namespace CapnpC.Model
|
|||||||
{
|
{
|
||||||
public ulong Id { get; }
|
public ulong Id { get; }
|
||||||
public TypeTag Tag { get => TypeTag.File; }
|
public TypeTag Tag { get => TypeTag.File; }
|
||||||
public IHasNestedDefinitions DeclaringElement { get; }
|
public IHasNestedDefinitions DeclaringElement { get => null; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string[] Namespace { get; set; }
|
public string[] Namespace { get; set; }
|
||||||
|
@ -137,6 +137,7 @@ namespace CapnpC.Model
|
|||||||
|
|
||||||
if (def == null)
|
if (def == null)
|
||||||
{
|
{
|
||||||
|
Trace.Assert(state.parent != null, $"The {node.GetTypeTag().ToString()} node {node.StrId()} was expected to have a parent.");
|
||||||
var typeDef = _typeDefMgr.CreateTypeDef(id, node.GetTypeTag(), state.parent);
|
var typeDef = _typeDefMgr.CreateTypeDef(id, node.GetTypeTag(), state.parent);
|
||||||
typeDef.Name = name;
|
typeDef.Name = name;
|
||||||
def = typeDef;
|
def = typeDef;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
namespace CapnpC.Model
|
namespace CapnpC.Model
|
||||||
{
|
{
|
||||||
@ -18,6 +19,7 @@ namespace CapnpC.Model
|
|||||||
|
|
||||||
public TypeDefinition(TypeTag tag, ulong id, IHasNestedDefinitions parent)
|
public TypeDefinition(TypeTag tag, ulong id, IHasNestedDefinitions parent)
|
||||||
{
|
{
|
||||||
|
Trace.Assert(parent != null);
|
||||||
Tag = tag;
|
Tag = tag;
|
||||||
Id = id;
|
Id = id;
|
||||||
DeclaringElement = parent;
|
DeclaringElement = parent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user