diff --git a/Upsilon/BaseTypes/Boolean.cs b/Upsilon/BaseTypes/LuaBoolean.cs similarity index 52% rename from Upsilon/BaseTypes/Boolean.cs rename to Upsilon/BaseTypes/LuaBoolean.cs index 11fdd60..d9bd3a6 100644 --- a/Upsilon/BaseTypes/Boolean.cs +++ b/Upsilon/BaseTypes/LuaBoolean.cs @@ -1,8 +1,8 @@ namespace Upsilon.BaseTypes { - public class Boolean : LuaType + public class LuaBoolean : LuaType { - public Boolean(bool value) + public LuaBoolean(bool value) { Value = value; } @@ -10,19 +10,19 @@ namespace Upsilon.BaseTypes public override Type Type => Type.Boolean; public bool Value { get; } - public static implicit operator bool(Boolean b) + public static implicit operator bool(LuaBoolean b) { return b.Value; } - public static implicit operator Boolean(bool b) + public static implicit operator LuaBoolean(bool b) { - return new Boolean(b); + return new LuaBoolean(b); } - public static Boolean operator ! (Boolean n) + public static LuaBoolean operator ! (LuaBoolean n) { - return new Boolean(!n.Value); + return new LuaBoolean(!n.Value); } public override string ToString() diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index 36d72ef..27dcc97 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -3,7 +3,6 @@ using System.Collections.Immutable; using Upsilon.BaseTypes; using Upsilon.BaseTypes.Number; using Upsilon.Parser; -using Boolean = Upsilon.BaseTypes.Boolean; using Type = Upsilon.BaseTypes.Type; namespace Upsilon.Binder @@ -109,7 +108,7 @@ namespace Upsilon.Binder break; case bool b: type = Type.Boolean; - outValue = new Boolean(b); + outValue = new LuaBoolean(b); break; default: _diagnostics.LogUnknownType(e.Span); diff --git a/Upsilon/Evaluator/Evaluator.cs b/Upsilon/Evaluator/Evaluator.cs index d55fe2d..8b44294 100644 --- a/Upsilon/Evaluator/Evaluator.cs +++ b/Upsilon/Evaluator/Evaluator.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Upsilon.BaseTypes; using Upsilon.BaseTypes.Number; using Upsilon.Binder; -using Boolean = Upsilon.BaseTypes.Boolean; namespace Upsilon.Evaluator { @@ -84,7 +83,7 @@ namespace Upsilon.Evaluator case BoundUnaryOperator.OperatorKind.Negation: return -((Number)operand); case BoundUnaryOperator.OperatorKind.LogicalNegation: - return !(Boolean) operand; + return !(LuaBoolean) operand; default: throw new Exception("Invalid Unary Operator: " + e.Operator.Kind); } @@ -105,9 +104,9 @@ namespace Upsilon.Evaluator case BoundBinaryOperator.OperatorKind.Division: return ((Number)left) / ((Number)right); case BoundBinaryOperator.OperatorKind.Equality: - return new Boolean(Equals(left, right)); + return new LuaBoolean(Equals(left, right)); case BoundBinaryOperator.OperatorKind.Inequality: - return new Boolean(!Equals(left, right)); + return new LuaBoolean(!Equals(left, right)); default: throw new Exception("Invalid Binary Operator: " + e.Operator); } @@ -136,7 +135,7 @@ namespace Upsilon.Evaluator private void EvaluateBoundIfStatement(BoundIfStatement boundBlockStatement) { var condition = EvaluateExpression(boundBlockStatement.Condition.Expression); - if ((Boolean) condition) + if ((LuaBoolean) condition) { EvaluateBoundBlockStatement(boundBlockStatement.Block); } diff --git a/UpsilonCompiler/Compiler.cs b/UpsilonCompiler/Compiler.cs index b6f32fb..73f2b5f 100644 --- a/UpsilonCompiler/Compiler.cs +++ b/UpsilonCompiler/Compiler.cs @@ -1,8 +1,8 @@ using System; using System.Text; +using Upsilon.BaseTypes; using Upsilon.BaseTypes.Number; using Upsilon.Binder; -using Boolean = Upsilon.BaseTypes.Boolean; using Type = Upsilon.BaseTypes.Type; namespace UpsilonCompiler @@ -60,7 +60,7 @@ namespace UpsilonCompiler case Type.Nil: return "null"; case Type.Boolean: - return ((Boolean)e.Value) ? "true" : "false"; + return ((LuaBoolean)e.Value) ? "true" : "false"; case Type.Number: return ((Number) e.Value).ToString(); case Type.String: diff --git a/UpsilonTests/IfTests.cs b/UpsilonTests/IfTests.cs index a5b9f93..c093a66 100644 --- a/UpsilonTests/IfTests.cs +++ b/UpsilonTests/IfTests.cs @@ -13,7 +13,7 @@ namespace UpsilonTests var input = "if true then val = true end"; var script = new Script(input); Assert.Empty(script.Diagnostics.Messages); - var actual = script.Evaluate(); + var actual = script.Evaluate(); Assert.True(actual); }