-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
using Socordia.CodeAnalysis.Parsing.ParsePoints.Declarations; | ||
|
||
namespace Socordia.CodeAnalysis.AST; | ||
|
||
public class RootBlock(IEnumerable<AstNode> body) : Block(body); | ||
public class RootBlock(IEnumerable<AstNode> body) : Block(body) | ||
{ | ||
public Scope Scope { get; set; } = new Scope(null); | ||
} |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
NewSource/Socordia.CodeAnalysis/AST/TypeAliasDeclaration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Socordia.CodeAnalysis.AST; | ||
|
||
// using t as System.Int32; | ||
// using t as i32; | ||
public class TypeAliasDeclaration : AstNode | ||
{ | ||
public TypeAliasDeclaration(AstNode expr) | ||
{ | ||
Children.Add(expr); | ||
} | ||
|
||
public AstNode Name => Children.First.Children[0]; | ||
public AstNode Type => Children.First.Children[1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
NewSource/SocordiaC/Compilation/Listeners/TypeAliasListener.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using MrWatkins.Ast.Listening; | ||
using Socordia.CodeAnalysis.AST; | ||
|
||
namespace SocordiaC.Compilation; | ||
|
||
public class TypeAliasListener : Listener<Driver, AstNode, TypeAliasDeclaration> | ||
{ | ||
protected override void ListenToNode(Driver context, TypeAliasDeclaration node) | ||
{ | ||
var root = (RootBlock)node.Root.Scope; | ||
|
||
root.Scope.TypeAliases.Add(node.Name, node.Type); | ||
} | ||
|
||
protected override bool ShouldListenToChildren(BodyCompilation context, TypeAliasDeclaration node) => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters