-
Notifications
You must be signed in to change notification settings - Fork 2
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
308 changed files
with
18,169 additions
and
18,446 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,18 +1,17 @@ | ||
namespace EVIL.CommonTypes.TypeSystem | ||
namespace EVIL.CommonTypes.TypeSystem; | ||
|
||
public enum DynamicValueType | ||
{ | ||
public enum DynamicValueType | ||
{ | ||
Nil, | ||
Number, | ||
String, | ||
Boolean, | ||
Table, | ||
Array, | ||
Fiber, | ||
Chunk, | ||
Error, | ||
TypeCode, | ||
NativeFunction, | ||
NativeObject | ||
} | ||
Nil, | ||
Number, | ||
String, | ||
Boolean, | ||
Table, | ||
Array, | ||
Fiber, | ||
Chunk, | ||
Error, | ||
TypeCode, | ||
NativeFunction, | ||
NativeObject | ||
} |
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,38 +1,37 @@ | ||
using System.Collections.Generic; | ||
namespace EVIL.Grammar.AST.Base; | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace EVIL.Grammar.AST.Base | ||
public abstract class AstNode | ||
{ | ||
public abstract class AstNode | ||
{ | ||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
|
||
public AstNode? Parent { get; set; } | ||
public AstNode? Parent { get; set; } | ||
|
||
public bool IsConstant => this is ConstantExpression; | ||
public bool IsConstant => this is ConstantExpression; | ||
|
||
internal T CopyMetadata<T>(AstNode from) where T : AstNode | ||
{ | ||
Line = from.Line; | ||
Column = from.Column; | ||
Parent = from.Parent; | ||
internal T CopyMetadata<T>(AstNode from) where T : AstNode | ||
{ | ||
Line = from.Line; | ||
Column = from.Column; | ||
Parent = from.Parent; | ||
|
||
return (this as T)!; | ||
} | ||
return (this as T)!; | ||
} | ||
|
||
protected void Reparent(params AstNode?[] nodes) | ||
protected void Reparent(params AstNode?[] nodes) | ||
{ | ||
for (var i = 0; i < nodes.Length; i++) | ||
{ | ||
for (var i = 0; i < nodes.Length; i++) | ||
if (nodes[i] != null) | ||
{ | ||
if (nodes[i] != null) | ||
{ | ||
nodes[i]!.Parent = this; | ||
} | ||
nodes[i]!.Parent = this; | ||
} | ||
} | ||
|
||
protected void Reparent(IEnumerable<AstNode?> nodes) | ||
=> Reparent(nodes.ToArray()); | ||
} | ||
|
||
protected void Reparent(IEnumerable<AstNode?> nodes) | ||
=> Reparent(nodes.ToArray()); | ||
} |
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,6 +1,5 @@ | ||
namespace EVIL.Grammar.AST.Base | ||
namespace EVIL.Grammar.AST.Base; | ||
|
||
public abstract class ConstantExpression : Expression | ||
{ | ||
public abstract class ConstantExpression : Expression | ||
{ | ||
} | ||
} |
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,17 +1,16 @@ | ||
namespace EVIL.Grammar.AST.Base; | ||
|
||
using EVIL.Grammar.AST.Expressions; | ||
|
||
namespace EVIL.Grammar.AST.Base | ||
public abstract class Expression : AstNode | ||
{ | ||
public abstract class Expression : AstNode | ||
{ | ||
public bool IsValidExpressionStatement | ||
=> this is AssignmentExpression | ||
or InvocationExpression | ||
or SelfInvocationExpression | ||
or IncrementationExpression | ||
or DecrementationExpression | ||
or YieldExpression; | ||
public bool IsValidExpressionStatement | ||
=> this is AssignmentExpression | ||
or InvocationExpression | ||
or SelfInvocationExpression | ||
or IncrementationExpression | ||
or DecrementationExpression | ||
or YieldExpression; | ||
|
||
public virtual Expression Reduce() => this; | ||
} | ||
public virtual Expression Reduce() => this; | ||
} |
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,6 +1,5 @@ | ||
namespace EVIL.Grammar.AST.Base | ||
namespace EVIL.Grammar.AST.Base; | ||
|
||
public abstract class Statement : AstNode | ||
{ | ||
public abstract class Statement : AstNode | ||
{ | ||
} | ||
} |
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,14 +1,13 @@ | ||
namespace EVIL.Grammar.AST.Constants; | ||
|
||
using EVIL.Grammar.AST.Base; | ||
|
||
namespace EVIL.Grammar.AST.Constants | ||
public sealed class BooleanConstant : ConstantExpression | ||
{ | ||
public sealed class BooleanConstant : ConstantExpression | ||
{ | ||
public bool Value { get; } | ||
public bool Value { get; } | ||
|
||
public BooleanConstant(bool value) | ||
{ | ||
Value = value; | ||
} | ||
public BooleanConstant(bool value) | ||
{ | ||
Value = value; | ||
} | ||
} |
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,8 +1,7 @@ | ||
namespace EVIL.Grammar.AST.Constants; | ||
|
||
using EVIL.Grammar.AST.Base; | ||
|
||
namespace EVIL.Grammar.AST.Constants | ||
public sealed class NilConstant : ConstantExpression | ||
{ | ||
public sealed class NilConstant : ConstantExpression | ||
{ | ||
} | ||
} |
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,14 +1,13 @@ | ||
using EVIL.Grammar.AST.Base; | ||
namespace EVIL.Grammar.AST.Constants; | ||
|
||
namespace EVIL.Grammar.AST.Constants | ||
using EVIL.Grammar.AST.Base; | ||
|
||
public sealed class NumberConstant : ConstantExpression | ||
{ | ||
public sealed class NumberConstant : ConstantExpression | ||
{ | ||
public double Value { get; } | ||
public double Value { get; } | ||
|
||
public NumberConstant(double value) | ||
{ | ||
Value = value; | ||
} | ||
public NumberConstant(double value) | ||
{ | ||
Value = value; | ||
} | ||
} |
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,16 +1,15 @@ | ||
using EVIL.Grammar.AST.Base; | ||
namespace EVIL.Grammar.AST.Constants; | ||
|
||
namespace EVIL.Grammar.AST.Constants | ||
using EVIL.Grammar.AST.Base; | ||
|
||
public sealed class StringConstant : ConstantExpression | ||
{ | ||
public sealed class StringConstant : ConstantExpression | ||
{ | ||
public string Value { get; } | ||
public bool IsInterpolated { get; } | ||
public string Value { get; } | ||
public bool IsInterpolated { get; } | ||
|
||
public StringConstant(string value, bool isInterpolated) | ||
{ | ||
Value = value; | ||
IsInterpolated = isInterpolated; | ||
} | ||
public StringConstant(string value, bool isInterpolated) | ||
{ | ||
Value = value; | ||
IsInterpolated = isInterpolated; | ||
} | ||
} |
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,15 +1,14 @@ | ||
namespace EVIL.Grammar.AST.Constants; | ||
|
||
using EVIL.CommonTypes.TypeSystem; | ||
using EVIL.Grammar.AST.Base; | ||
|
||
namespace EVIL.Grammar.AST.Constants | ||
public class TypeCodeConstant : ConstantExpression | ||
{ | ||
public class TypeCodeConstant : ConstantExpression | ||
{ | ||
public DynamicValueType Value { get; } | ||
public DynamicValueType Value { get; } | ||
|
||
public TypeCodeConstant(DynamicValueType value) | ||
{ | ||
Value = value; | ||
} | ||
public TypeCodeConstant(DynamicValueType value) | ||
{ | ||
Value = value; | ||
} | ||
} |
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,20 +1,19 @@ | ||
namespace EVIL.Grammar.AST.Expressions; | ||
|
||
using System.Collections.Generic; | ||
using EVIL.Grammar.AST.Base; | ||
|
||
namespace EVIL.Grammar.AST.Expressions | ||
public sealed class ArrayExpression : Expression | ||
{ | ||
public class ArrayExpression : Expression | ||
{ | ||
public Expression? SizeExpression { get; } | ||
public List<Expression> Initializers { get; } | ||
public Expression? SizeExpression { get; } | ||
public List<Expression> Initializers { get; } | ||
|
||
public ArrayExpression(Expression? sizeExpression, List<Expression> initializers) | ||
{ | ||
SizeExpression = sizeExpression; | ||
Initializers = initializers; | ||
public ArrayExpression(Expression? sizeExpression, List<Expression> initializers) | ||
{ | ||
SizeExpression = sizeExpression; | ||
Initializers = initializers; | ||
|
||
Reparent(SizeExpression); | ||
Reparent(Initializers); | ||
} | ||
Reparent(SizeExpression); | ||
Reparent(Initializers); | ||
} | ||
} |
27 changes: 13 additions & 14 deletions
27
Core/EVIL.Grammar/AST/Expressions/AssignmentExpression.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 |
---|---|---|
@@ -1,22 +1,21 @@ | ||
using EVIL.Grammar.AST.Base; | ||
namespace EVIL.Grammar.AST.Expressions; | ||
|
||
namespace EVIL.Grammar.AST.Expressions | ||
using EVIL.Grammar.AST.Base; | ||
|
||
public sealed class AssignmentExpression : Expression | ||
{ | ||
public sealed class AssignmentExpression : Expression | ||
{ | ||
public Expression Left { get; } | ||
public Expression Right { get; } | ||
public Expression Left { get; } | ||
public Expression Right { get; } | ||
|
||
public AssignmentOperationType OperationType { get; } | ||
public AssignmentOperationType OperationType { get; } | ||
|
||
public AssignmentExpression(Expression left, Expression right, AssignmentOperationType operationType) | ||
{ | ||
Left = left; | ||
Right = right; | ||
public AssignmentExpression(Expression left, Expression right, AssignmentOperationType operationType) | ||
{ | ||
Left = left; | ||
Right = right; | ||
|
||
OperationType = operationType; | ||
OperationType = operationType; | ||
|
||
Reparent(Left, Right); | ||
} | ||
Reparent(Left, Right); | ||
} | ||
} |
Oops, something went wrong.