Skip to content

Commit

Permalink
API: added field declaration nodes. Fixed #86.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmikecreations committed Oct 29, 2021
1 parent a657c63 commit 193000c
Show file tree
Hide file tree
Showing 21 changed files with 145 additions and 180 deletions.
32 changes: 0 additions & 32 deletions src/Crosslight.API/Nodes/Implementations/Access/ConstantNode.cs

This file was deleted.

38 changes: 0 additions & 38 deletions src/Crosslight.API/Nodes/Implementations/Access/FieldNode.cs

This file was deleted.

33 changes: 0 additions & 33 deletions src/Crosslight.API/Nodes/Implementations/Access/LiteralNode.cs

This file was deleted.

28 changes: 0 additions & 28 deletions src/Crosslight.API/Nodes/Implementations/Access/ValueNode.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Crosslight.API.Nodes.Implementations.Expressions;
using Crosslight.API.Nodes.Interfaces;
using Crosslight.API.Util;
using System;
using System.Collections.Generic;
using System.Text;

namespace Crosslight.API.Nodes.Implementations.Access
{
public class VariableDeclarationNode : Node, IIdentifierProvider
{
public override string Type => nameof(VariableDeclarationNode);

public string Identifier { get; }
public SyncedProperty<ExpressionNode, Node> Initializer { get; protected set; }
// TODO: c# also has bracketed argument list
// public unsafe fixed byte bs[7];
public VariableDeclarationNode(string identifier)
{
Identifier = identifier;
Initializer = new SyncedProperty<ExpressionNode, Node>(Children);
}

public override string ToString()
{
return Type;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Crosslight.API.Nodes.Implementations.Expressions.Types;
using Crosslight.API.Nodes.Interfaces;
using Crosslight.API.Util;

namespace Crosslight.API.Nodes.Implementations.Access
{
/// <summary>
/// <see cref="VariableListDeclarationNode"/> represents the variable abstraction in the language.
/// It can declare one or more actual variables of a common type.
/// </summary>
public class VariableListDeclarationNode : Node
{
public override string Type => nameof(VariableListDeclarationNode);

public SyncedProperty<TypeReferenceNode, Node> DeclarationType { get; protected set; }
public SyncedList<VariableDeclarationNode, Node> Variables { get; protected set; }
public VariableListDeclarationNode()
{
DeclarationType = new SyncedProperty<TypeReferenceNode, Node>(Children);
Variables = new SyncedList<VariableDeclarationNode, Node>(Children);
}
public override string ToString()
{
return Type;
}
}
}
36 changes: 0 additions & 36 deletions src/Crosslight.API/Nodes/Implementations/Access/VariableNode.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Crosslight.API.Nodes.Implementations.Access;
using Crosslight.API.Nodes.Implementations.Access.Modifiers;
using Crosslight.API.Nodes.Implementations.Entities;
using Crosslight.API.Nodes.Interfaces;
using Crosslight.API.Nodes.Interfaces.Access;
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Util;
using System;

namespace Crosslight.API.Nodes.Implementations.Entities.Fields
{
/// <summary>
/// <see cref="BaseFieldDeclarationNode"/> represents the field abstraction in the language.
/// </summary>
public abstract class BaseFieldDeclarationNode : MemberDeclarationNode, IAttributesProvider, IModifiersProvider
{
public override string Type => nameof(BaseFieldDeclarationNode);

public SyncedProperty<VariableListDeclarationNode, Node> Declaration { get; protected set; }
public BaseFieldDeclarationNode()
{
Declaration = new SyncedProperty<VariableListDeclarationNode, Node>(Children);
}

public override string ToString()
{
return Type;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Crosslight.API.Nodes.Interfaces.Access;
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;

namespace Crosslight.API.Nodes.Implementations.Entities.Fields
{
/// <summary>
/// <see cref="EventFieldDeclarationNode"/> represents an event field declaration.
/// </summary>
public class EventFieldDeclarationNode : BaseFieldDeclarationNode, IAttributesProvider, IModifiersProvider
{
public override string Type => nameof(EventFieldDeclarationNode);

public override string ToString()
{
return Type;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Crosslight.API.Nodes.Interfaces.Access;
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;

namespace Crosslight.API.Nodes.Implementations.Entities.Fields
{
/// <summary>
/// <see cref="FieldDeclarationNode"/> represents a field declaration.
/// </summary>
public class FieldDeclarationNode : BaseFieldDeclarationNode, IAttributesProvider, IModifiersProvider
{
public override string Type => nameof(FieldDeclarationNode);

public override string ToString()
{
return Type;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Util;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="BaseTypeDeclarationNode"/> abstract node represents a type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Nodes.Interfaces.Entities;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="ClassDeclarationNode"/> represents the class abstraction in the language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Crosslight.API.Nodes.Interfaces.Entities;
using Crosslight.API.Util;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="CompoundTypeDeclarationNode"/> abstract node represents types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Nodes.Interfaces.Entities;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="CustomCompoundTypeDeclarationNode"/> is reserved for custom type declarations from other languages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Util;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="EnumDeclarationNode"/> represents the enum abstraction in the language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Crosslight.API.Nodes.Interfaces.Entities;
using Crosslight.API.Util;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="FunctionalTypeDeclarationNode"/> is reserved for the functional type abstraction in the language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Nodes.Interfaces.Entities;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="InterfaceDeclarationNode"/> represents the interface abstraction in the language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Crosslight.API.Nodes.Interfaces.Access.Modifiers;
using Crosslight.API.Nodes.Interfaces.Entities;

namespace Crosslight.API.Nodes.Implementations.Entities
namespace Crosslight.API.Nodes.Implementations.Entities.Types
{
/// <summary>
/// <see cref="StructDeclarationNode"/> represents the struct abstraction in the language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Crosslight.API.Nodes.Implementations
public class ExpressionValueNode : ExpressionNode
{
public override string Type => nameof(ExpressionValueNode);
public ValueNode Value { get; set; }
// TODO: fix this
//public ValueNode Value { get; set; }
public ExpressionValueNode()
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Crosslight.API.Nodes.Implementations.Expressions.Types
{
public abstract class TypeReferenceNode : Node // TODO: inheritance
{
public override string Type => nameof(TypeReferenceNode);
public override string ToString()
{
return Type;
}
}
}
Loading

0 comments on commit 193000c

Please sign in to comment.