完全清除Resource依赖, 目前可以直接使用源码
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Reflection.Emit;
|
||||
using System.Reflection;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
using System;
|
||||
|
||||
namespace Flee.ExpressionElements.Base
|
||||
@@ -114,7 +113,7 @@ namespace Flee.ExpressionElements.Base
|
||||
|
||||
protected void ThrowOperandTypeMismatch(object operation, Type leftType, Type rightType)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.OperationNotDefinedForTypes, CompileExceptionReason.TypeMismatch, operation, leftType.Name, rightType.Name);
|
||||
base.ThrowCompileException("OperationNotDefinedForTypes", CompileExceptionReason.TypeMismatch, operation, leftType.Name, rightType.Name);
|
||||
}
|
||||
|
||||
protected abstract Type GetResultType(Type leftType, Type rightType);
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using System.Diagnostics;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements.Base
|
||||
{
|
||||
@@ -30,15 +29,16 @@ namespace Flee.ExpressionElements.Base
|
||||
|
||||
protected void ThrowCompileException(string messageKey, CompileExceptionReason reason, params object[] arguments)
|
||||
{
|
||||
string messageTemplate = FleeResourceManager.Instance.GetCompileErrorString(messageKey);
|
||||
string message = string.Format(messageTemplate, arguments);
|
||||
//string messageTemplate = FleeResourceManager.Instance.GetCompileErrorString(messageKey);
|
||||
//string message = string.Format(messageTemplate, arguments);
|
||||
string message = $"[{messageKey}]{string.Join(',', arguments)}";
|
||||
message = string.Concat(this.Name, ": ", message);
|
||||
throw new ExpressionCompileException(message, reason);
|
||||
}
|
||||
|
||||
protected void ThrowAmbiguousCallException(Type leftType, Type rightType, object operation)
|
||||
{
|
||||
this.ThrowCompileException(CompileErrorResourceKeys.AmbiguousOverloadedOperator, CompileExceptionReason.AmbiguousMatch, leftType.Name, rightType.Name, operation);
|
||||
this.ThrowCompileException("AmbiguousOverloadedOperator", CompileExceptionReason.AmbiguousMatch, leftType.Name, rightType.Name, operation);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Flee.ExpressionElements.Base
|
||||
get
|
||||
{
|
||||
string key = this.GetType().Name;
|
||||
string value = FleeResourceManager.Instance.GetElementNameString(key);
|
||||
string value = $"{key}";
|
||||
Debug.Assert(value != null, $"Element name for '{key}' not in resource file");
|
||||
return value;
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ using System.Diagnostics;
|
||||
using System.Reflection.Emit;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
|
||||
namespace Flee.ExpressionElements.Base.Literals
|
||||
@@ -12,7 +11,7 @@ namespace Flee.ExpressionElements.Base.Literals
|
||||
{
|
||||
protected void OnParseOverflow(string image)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.ValueNotRepresentableInType, CompileExceptionReason.ConstantOverflow, image, this.ResultType.Name);
|
||||
base.ThrowCompileException("ValueNotRepresentableInType", CompileExceptionReason.ConstantOverflow, image, this.ResultType.Name);
|
||||
}
|
||||
|
||||
public static void EmitLoad(Int32 value, FleeILGenerator ilg)
|
||||
|
@@ -5,7 +5,6 @@ using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements.Base
|
||||
{
|
||||
@@ -62,11 +61,11 @@ namespace Flee.ExpressionElements.Base
|
||||
|
||||
if (this.IsStatic == true && this.SupportsStatic == false && IsExtensionMethod == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.StaticMemberCannotBeAccessedWithInstanceReference, CompileExceptionReason.TypeMismatch, MyName);
|
||||
base.ThrowCompileException("StaticMemberCannotBeAccessedWithInstanceReference", CompileExceptionReason.TypeMismatch, MyName);
|
||||
}
|
||||
else if (this.IsStatic == false && this.SupportsInstance == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.ReferenceToNonSharedMemberRequiresObjectReference, CompileExceptionReason.TypeMismatch, MyName);
|
||||
base.ThrowCompileException("ReferenceToNonSharedMemberRequiresObjectReference", CompileExceptionReason.TypeMismatch, MyName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements.Base
|
||||
{
|
||||
@@ -17,7 +16,7 @@ namespace Flee.ExpressionElements.Base
|
||||
|
||||
if (_myResultType == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.OperationNotDefinedForType, CompileExceptionReason.TypeMismatch, MyChild.ResultType.Name);
|
||||
base.ThrowCompileException("OperationNotDefinedForType", CompileExceptionReason.TypeMismatch, MyChild.ResultType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,6 @@ using System.Reflection;
|
||||
using Flee.ExpressionElements.Base;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
using System;
|
||||
|
||||
namespace Flee.ExpressionElements
|
||||
@@ -21,7 +20,7 @@ namespace Flee.ExpressionElements
|
||||
|
||||
if (_myDestType == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.CouldNotResolveType, CompileExceptionReason.UndefinedName, GetDestTypeString(destTypeParts, isArray));
|
||||
base.ThrowCompileException("CouldNotResolveType", CompileExceptionReason.UndefinedName, GetDestTypeString(destTypeParts, isArray));
|
||||
}
|
||||
|
||||
if (isArray == true)
|
||||
@@ -257,7 +256,7 @@ namespace Flee.ExpressionElements
|
||||
|
||||
private void ThrowInvalidCastException()
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.CannotConvertType, CompileExceptionReason.InvalidExplicitCast, _myCastExpression.ResultType.Name, _myDestType.Name);
|
||||
base.ThrowCompileException("CannotConvertType", CompileExceptionReason.InvalidExplicitCast, _myCastExpression.ResultType.Name, _myDestType.Name);
|
||||
}
|
||||
|
||||
private static bool IsCastableNumericType(Type t)
|
||||
|
@@ -3,7 +3,6 @@ using System.Reflection.Emit;
|
||||
using Flee.ExpressionElements.Base;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements
|
||||
{
|
||||
@@ -21,7 +20,7 @@ namespace Flee.ExpressionElements
|
||||
|
||||
if ((!object.ReferenceEquals(_myCondition.ResultType, typeof(bool))))
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.FirstArgNotBoolean, CompileExceptionReason.TypeMismatch);
|
||||
base.ThrowCompileException("FirstArgNotBoolean", CompileExceptionReason.TypeMismatch);
|
||||
}
|
||||
|
||||
// The result type is the type that is common to the true/false operands
|
||||
@@ -35,7 +34,7 @@ namespace Flee.ExpressionElements
|
||||
}
|
||||
else
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.NeitherArgIsConvertibleToTheOther, CompileExceptionReason.TypeMismatch, _myWhenTrue.ResultType.Name, _myWhenFalse.ResultType.Name);
|
||||
base.ThrowCompileException("NeitherArgIsConvertibleToTheOther", CompileExceptionReason.TypeMismatch, _myWhenTrue.ResultType.Name, _myWhenFalse.ResultType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,6 @@ using Flee.ExpressionElements.Base;
|
||||
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -62,7 +61,7 @@ namespace Flee.ExpressionElements
|
||||
|
||||
if (MyTargetCollectionType == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.SearchArgIsNotKnownCollectionType, CompileExceptionReason.TypeMismatch, MyTargetCollectionElement.ResultType.Name);
|
||||
base.ThrowCompileException("SearchArgIsNotKnownCollectionType", CompileExceptionReason.TypeMismatch, MyTargetCollectionElement.ResultType.Name);
|
||||
}
|
||||
|
||||
// Validate that the operand type is compatible with the collection
|
||||
@@ -71,7 +70,7 @@ namespace Flee.ExpressionElements
|
||||
|
||||
if (ImplicitConverter.EmitImplicitConvert(MyOperand.ResultType, p1.ParameterType, null) == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.OperandNotConvertibleToCollectionType, CompileExceptionReason.TypeMismatch, MyOperand.ResultType.Name, p1.ParameterType.Name);
|
||||
base.ThrowCompileException("OperandNotConvertibleToCollectionType", CompileExceptionReason.TypeMismatch, MyOperand.ResultType.Name, p1.ParameterType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,6 @@ using Flee.ExpressionElements.Base.Literals;
|
||||
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
using System;
|
||||
|
||||
namespace Flee.ExpressionElements.Literals
|
||||
@@ -19,7 +18,7 @@ namespace Flee.ExpressionElements.Literals
|
||||
|
||||
if (DateTime.TryParseExact(image, options.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out _myValue) == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.CannotParseType, CompileExceptionReason.InvalidFormat, typeof(DateTime).Name);
|
||||
base.ThrowCompileException("CannotParseType", CompileExceptionReason.InvalidFormat, typeof(DateTime).Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,6 @@ using System.Reflection.Emit;
|
||||
using Flee.ExpressionElements.Base.Literals;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements.Literals
|
||||
{
|
||||
@@ -15,7 +14,7 @@ namespace Flee.ExpressionElements.Literals
|
||||
{
|
||||
if (TimeSpan.TryParse(image, out _myValue) == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.CannotParseType, CompileExceptionReason.InvalidFormat, typeof(TimeSpan).Name);
|
||||
base.ThrowCompileException("CannotParseType", CompileExceptionReason.InvalidFormat, typeof(TimeSpan).Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ using Flee.ExpressionElements.Base;
|
||||
using Flee.ExpressionElements.Base.Literals;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
@@ -69,11 +68,11 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
if (previous == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.UndefinedFunction, CompileExceptionReason.UndefinedName, MyName, _myArguments);
|
||||
base.ThrowCompileException("UndefinedFunction", CompileExceptionReason.UndefinedName, MyName, _myArguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.UndefinedFunctionOnType, CompileExceptionReason.UndefinedName, MyName, _myArguments, previous.TargetType.Name);
|
||||
base.ThrowCompileException("UndefinedFunctionOnType", CompileExceptionReason.UndefinedName, MyName, _myArguments, previous.TargetType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,17 +80,17 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
if (previous == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.NoAccessibleMatches, CompileExceptionReason.AccessDenied, MyName, _myArguments);
|
||||
base.ThrowCompileException("NoAccessibleMatches", CompileExceptionReason.AccessDenied, MyName, _myArguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.NoAccessibleMatchesOnType, CompileExceptionReason.AccessDenied, MyName, _myArguments, previous.TargetType.Name);
|
||||
base.ThrowCompileException("NoAccessibleMatchesOnType", CompileExceptionReason.AccessDenied, MyName, _myArguments, previous.TargetType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
private void ThrowAmbiguousMethodCallException()
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.AmbiguousCallOfFunction, CompileExceptionReason.AmbiguousMatch, MyName, _myArguments);
|
||||
base.ThrowCompileException("AmbiguousCallOfFunction", CompileExceptionReason.AmbiguousMatch, MyName, _myArguments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -220,7 +219,7 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
// Any function reference in an expression must return a value
|
||||
if (object.ReferenceEquals(this.Method.ReturnType, typeof(void)))
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.FunctionHasNoReturnValue, CompileExceptionReason.FunctionHasNoReturnValue, MyName);
|
||||
base.ThrowCompileException("FunctionHasNoReturnValue", CompileExceptionReason.FunctionHasNoReturnValue, MyName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@ using Flee.ExpressionElements.Literals.Integral;
|
||||
using Flee.ExpressionElements.Literals.Real;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
using System;
|
||||
|
||||
|
||||
@@ -59,11 +58,11 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
|
||||
if (MyPrevious == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.NoIdentifierWithName, CompileExceptionReason.UndefinedName, MyName);
|
||||
base.ThrowCompileException("NoIdentifierWithName", CompileExceptionReason.UndefinedName, MyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.NoIdentifierWithNameOnType, CompileExceptionReason.UndefinedName, MyName, MyPrevious.TargetType.Name);
|
||||
base.ThrowCompileException("NoIdentifierWithNameOnType", CompileExceptionReason.UndefinedName, MyName, MyPrevious.TargetType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +83,11 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
// More than one accessible member
|
||||
if (previous == null)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.IdentifierIsAmbiguous, CompileExceptionReason.AmbiguousMatch, MyName);
|
||||
base.ThrowCompileException("IdentifierIsAmbiguous", CompileExceptionReason.AmbiguousMatch, MyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.IdentifierIsAmbiguousOnType, CompileExceptionReason.AmbiguousMatch, MyName, previous.TargetType.Name);
|
||||
base.ThrowCompileException("IdentifierIsAmbiguousOnType", CompileExceptionReason.AmbiguousMatch, MyName, previous.TargetType.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -5,7 +5,6 @@ using System.Reflection.Emit;
|
||||
using Flee.ExpressionElements.Base;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
@@ -36,7 +35,7 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
// Not an array, so try to find an indexer on the type
|
||||
if (this.FindIndexer(target) == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.TypeNotArrayAndHasNoIndexerOfType, CompileExceptionReason.TypeMismatch, target.Name, _myIndexerElements);
|
||||
base.ThrowCompileException("TypeNotArrayAndHasNoIndexerOfType", CompileExceptionReason.TypeMismatch, target.Name, _myIndexerElements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,11 +45,11 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
|
||||
if (_myIndexerElements.Count > 1)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.MultiArrayIndexNotSupported, CompileExceptionReason.TypeMismatch);
|
||||
base.ThrowCompileException("MultiArrayIndexNotSupported", CompileExceptionReason.TypeMismatch);
|
||||
}
|
||||
else if (ImplicitConverter.EmitImplicitConvert(_myIndexerElement.ResultType, typeof(Int32), null) == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.ArrayIndexersMustBeOfType, CompileExceptionReason.TypeMismatch, typeof(Int32).Name);
|
||||
base.ThrowCompileException("CompileErrorResourceKeys.ArrayIndexersMustBeOfType", CompileExceptionReason.TypeMismatch, typeof(Int32).Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,6 @@ using System.Collections;
|
||||
using Flee.ExpressionElements.Base;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
@@ -86,7 +85,7 @@ namespace Flee.ExpressionElements.MemberElements
|
||||
|
||||
if (elements.Count == 0)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.NamespaceCannotBeUsedAsType, CompileExceptionReason.TypeMismatch, currentImport.Name);
|
||||
base.ThrowCompileException("NamespaceCannotBeUsedAsType", CompileExceptionReason.TypeMismatch, currentImport.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,6 @@ using System.Reflection.Emit;
|
||||
using Flee.ExpressionElements.Base;
|
||||
using Flee.InternalTypes;
|
||||
using Flee.PublicTypes;
|
||||
using Flee.Resources;
|
||||
|
||||
namespace Flee.ExpressionElements
|
||||
{
|
||||
@@ -37,7 +36,7 @@ namespace Flee.ExpressionElements
|
||||
{
|
||||
if (ImplicitConverter.EmitImplicitConvert(_myChild.ResultType, _myResultType, null) == false)
|
||||
{
|
||||
base.ThrowCompileException(CompileErrorResourceKeys.CannotConvertTypeToExpressionResult, CompileExceptionReason.TypeMismatch, _myChild.ResultType.Name, _myResultType.Name);
|
||||
base.ThrowCompileException("CannotConvertTypeToExpressionResult", CompileExceptionReason.TypeMismatch, _myChild.ResultType.Name, _myResultType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user