You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3021930 on 2016/06/21 by Ben.Marsh BuildGraph: Better diagnostic message if the source directory for copies does not exist. Change 3022391 on 2016/06/21 by Ben.Marsh Rework copy task slightly so that all code paths result in files being tagged. Change 3026592 on 2016/06/24 by Ben.Marsh BuildGraph: Add a ForEach element, which will assign a local property to each of a semicolon separated list of values, and expand the elements within it. Added an example in Properties.xml. Change 3028708 on 2016/06/27 by Matthew.Griffin Converting Engine build process to BuildGraph script Added Tag Receipts task to retrieve list of build products/dependencies from *.target files. Changed Pak File task so that you can specify an existing response file, rather than creating one from the file list. Changed base task so that you can resolve filespec from a list of file patterns if you already have them separated, which was the case with wildcards in runtime dependencies. Added EngineMajorVersion, EngineMinorVersion and EnginePatchVersion as default properties available to BuildGraph Added FinalizeInstalledBuild command to write out InstalledBuild.txt file and config entries for installed platforms Included .exe.config and exe.mdb files to build products of CsCompile task if they exist Added TagReferences option to CsCompile so that you can get any external references projects have that need to be included when staging Added RunOptions parameter to SpawnTask, so that you can specify these for the exe you want to run Added missing Runtime Dependency for ICU on Mac Change 3030209 on 2016/06/28 by Matthew.Griffin Renamed EngineBuild.xml to InstalledEngineBuild.xml to make its purpose more clear. Removed reference to xcodeunlock.sh from Mac Installed build dependencies as the file itself has been deleted. Added myself to list of notifiers for failures in the UE4 Binary build. Change 3034068 on 2016/06/30 by Ben.Marsh BuildGraph: Change scoping rules for properties. Local properties can no longer shadow global properties with the same name (or vice versa), and local properties are always modified in the scope that they were first declared, rather than being re-declared in a narrower scope. Change 3034070 on 2016/06/30 by Ben.Marsh BuildGraph: Warn when referencing a property which is not defined, and add new attributes to the <Property> element to set the default value for a property if it's not already set, and validating that it's one of a list of valid values if it is (eg. <Property Name="WithWin64" Restrict="true;false" Default="false"/>). Change 3034110 on 2016/06/30 by Matthew.Griffin Updated Installed Build so that properties are consistently named Exceptions and that the right versions are used Added Filter and Exception properties for each target platform to add any files that can't be figured out via dependencies Added Default values for various properties used across Engine build scripts - IsReleaseBranch, IsPreflight, OutputDir, BuildLabel, WithWin64 etc. Tagged Generated Includes from each target so that they can be included in Installed Build Added additional Android architectures to Shipping build Changed SwarmCoordinator to build for Any CPU Removed Local HostPlatform property from DDC nodes Changed Installed Build target platforms to use Do blocks so that we only have to check With... property once Reordered stripping and signing process so that we use the Exception check in less places Change 3035499 on 2016/07/01 by Ben.Marsh BuildGraph: Remove the <Local> element, and just make all <Property> declarations scoped. Also add an error if a property is later declared in a parent scope, since the earlier assignment won't be visible to the later one. Change 3035520 on 2016/07/01 by Ben.Marsh BuildGraph: Add support for <, <=, >, >= operators in condition expressions. Change 3035666 on 2016/07/01 by Matthew.Griffin Added more parameters to Chunk and Label Build tasks Updated all remaining uses of Local to Property in Installed Build script Made sure Feature Packs use paths compatible with Mac and also changed the node to use a ForEach element Change 3037020 on 2016/07/04 by Matthew.Griffin Ensured that TempStorageFileList uses forward slashes as its path separators so that it's easily used on Mac and Windows Was causing the results of the Make Feature Packs node to be tagged using Windows style paths, meaning they would throw an error if you tried to copy them on Mac Change 3037052 on 2016/07/04 by Ben.Marsh Move FJsonValue::ErrorMessage into cpp file, since it depends on the log class defined in Json.h (which includes it). Change 3037283 on 2016/07/05 by Matthew.Griffin Removed EnterScope and LeaveScope from ReadGraphBody so that included files are treated as being in the same scope (allows use of properties across files) Change 3037547 on 2016/07/05 by Ben.Marsh UAT: Allow CommandUtils.Run() to check directories listed in the PATH environment variable for the executable before failing. Change 3037552 on 2016/07/05 by Ben.Marsh BuildGraph: Add an <Unzip> task, which extracts a zip file to an output directory. Change 3039109 on 2016/07/06 by Matthew.Griffin Moved tagging of UAT build products to the Installed Build step as it's the only thing that needs them Moved Strip and Sign filters to the filters file, made sure they're used for all operations and added stripping back to UE4Editor nodes Changed BuildPatchTool to be built in shipping mode Changed all C# projects to be compiled for AnyCPU as they ended up in different output folders otherwise Added all files referenced by C# projects to avoid having to filter them manually Changed filters to get files included for Linux closer to the old pattern Changed Build DDC command to ignore empty entries in FeaturePacks list, don't want to fail the process if a list begins with a ; Changed UE4Game to use shipping PhysX libs for Shipping builds Added glut32.dll as a Runtime Dependency for PhysX Added libsteam_api.so as a Runtime Dependency for Steamworks on Linux Change 3039676 on 2016/07/06 by Ben.Marsh Core: Move definitions for FORCEINLINE'd FMath functions into UnrealMathUtility. Prevents link errors if including one without the other. Change 3039681 on 2016/07/06 by Ben.Marsh Core: Move implementation of GetTypeHash(FTimespan) into CPP file, to remove implicit dependency on the inline implementation of GetTypeHash(int64) being included. Change 3039735 on 2016/07/06 by Ben.Marsh Core: Move USE_DELEGATE_TRYGETBOUNDFUNCTIONNAME into a separate header, so delegate headers can be included separately. Change 3039878 on 2016/07/06 by Ben.Marsh Core: Move FOperatorFunctionID out of TOperatorJumpTable to allow MSVC to compile it and catch errors before the template is instantiated. Change 3040156 on 2016/07/06 by Ben.Marsh Core: Move FDateTime::GetTypeHash() into cpp file to eliminate dependency on TypeHash.h being included before it. Change 3041009 on 2016/07/07 by Matthew.Griffin Changed UE4Game to only use shipping PhysX libraries on Windows Change 3041015 on 2016/07/07 by Leigh.Swift UBT: Support creating C# programs that will be included in the UE4.sln Programs list. To have your program listed, remove the sln file that may have been created for you, and add a file named "UE4CSharp.prog" next to your csproj file. Change 3041234 on 2016/07/07 by Matthew.Griffin Added building of Launcher Samples to BuildGraph system Added Command to Build Sample projects, which distills to temp directory, builds DDC if needed and then chunks/posts to MCP Change 3041244 on 2016/07/07 by Ben.Marsh Core: Change PlatformIncludes.h to include all the individual PlatformMemory.h, PlatformTime.h, etc... headers rather than including separate per-platform headers which include them all. Makes it much easier to optimize header file usage, and eliminates redundant typedefs in the individual Platform*.h files. Also fixes some headers that previously didn't compile. Change 3042518 on 2016/07/08 by Matthew.Griffin Added content modifiers to those notified about Sample failures Throw exception if RocketPromoteBuild tries to promote all samples Throw exceptions for missing parameters in BuildLauncherSample command, corrected EngineDir parameter name. Change 3042545 on 2016/07/08 by Ben.Marsh Core: Push/Pop defines for MAX_uint8, MAX_uint16, MAX_uint32, MAX_int32 around Windows.h includes, so we don't need to be careful about the order in which we include NumericLimits.h. Change 3042546 on 2016/07/08 by Ben.Marsh Core: Put standard CRT includes into their own header, so we can include it without taking all of PlatformIncludes.h (and make any platform-specific additions as needed) Change 3042548 on 2016/07/08 by Ben.Marsh Core: Include PlatformCompilerSetup headers from Platform.h, as well as all the defaults for non-platform overriden defines. Allows including Platform.h to get all the basic types, defines and compile environment set up without having to include a large number of system headers or unnecessary functionality. Change 3044424 on 2016/07/11 by Ben.Marsh Merge fixes for QFE installer (CL 3044412) from 4.11 branch. Change 3044584 on 2016/07/11 by Ben.Marsh Core: Move FMath::FormatIntToHumanReadable() to UnrealMath.cpp, since it's a very large/expensive function to try to inline (and introduce a FString dependency for) Change 3044603 on 2016/07/11 by Matthew.Griffin Added PS4 and XboxOne to installed build as options that will always be disabled by default Standardised some of the agent names Removed logging from the Installed Build nodes as it takes a huge amount of time to write out the list for little reward Change 3044608 on 2016/07/11 by Ben.Marsh Core: Split out definition of SIMD VectorRegister class into its own header, so it's not forcibly included with UnrealMathUtility. Change 3044638 on 2016/07/11 by Matthew.Griffin Added internal build jobs for all games with compile, cook and package nodes. Added Documentation, Localization and NonUnity steps. Change 3045959 on 2016/07/12 by Matthew.Griffin Removed Aggregates from Installed Build script as they weren't used/necessary. Change 3045961 on 2016/07/12 by Matthew.Griffin Fixed various issues with Full Build Switch to build non-client/server configurations for some games Included PS4 and Xbox game targets in our internal monolithics aggregate Added Requirements for steps that need UHT, SCW etc. Added list of Packaged Game Nodes that we can build up as they're defined Added targets that were previously in the Internal Tools nodes Changed APIDocTool to build Release as that's what the solution uses and made use of the path created for it Removed -clean from the NonUnity targets as that doesn't actually build anything Changed mail notifications so that individual nodes are used for content modifiers, not every preceeding node too Change 3047068 on 2016/07/12 by Ben.Marsh BuildGraph: Reduce the amount of log output when compiling a C# project; use /verbosity:minimal and /nolog, as Visual Studio does. Change 3047298 on 2016/07/12 by Ben.Marsh EC: Add a workspace setting specifying that it should be synced incrementally. Change 3047626 on 2016/07/13 by Matthew.Griffin Added PackageToNetwork property, which will default to false, which determines whether to put staged builds on the P: drive or within the LocalBuilds folder of the root dir Also changed WorldExplorers to use P:/Builds/Friday instead of WEX, as no one is now clearing up the WEX folder regularly Change 3047762 on 2016/07/13 by Matthew.Griffin Added -nodebuginfo to all compile tasks with -precompile to reduce the size of libs produced Added plugin intermediates to list of files excluded from installed build [CL 3047809 by Ben Marsh in Main branch]
386 lines
12 KiB
C#
386 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AutomationTool
|
|
{
|
|
/// <summary>
|
|
/// Exception class thrown due to type and syntax errors in condition expressions
|
|
/// </summary>
|
|
class ConditionException : Exception
|
|
{
|
|
/// <summary>
|
|
/// Constructor; formats the exception message with the given String.Format() style parameters.
|
|
/// </summary>
|
|
/// <param name="Format">Formatting string, in String.Format syntax</param>
|
|
/// <param name="Args">Optional arguments for the string</param>
|
|
public ConditionException(string Format, params object[] Args) : base(String.Format(Format, Args))
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Class to evaluate condition expressions in build scripts, following this grammar:
|
|
///
|
|
/// or-expression ::= and-expression
|
|
/// | or-expression "Or" and-expression;
|
|
///
|
|
/// and-expression ::= comparison
|
|
/// | and-expression "And" comparison;
|
|
///
|
|
/// comparison ::= scalar
|
|
/// | scalar "==" scalar
|
|
/// | scalar "!=" scalar
|
|
/// | scalar "<" scalar
|
|
/// | scalar "<=" scalar;
|
|
/// | scalar ">" scalar
|
|
/// | scalar ">=" scalar;
|
|
///
|
|
/// scalar ::= "(" or-expression ")"
|
|
/// | "!" scalar
|
|
/// | "Exists" "(" scalar ")"
|
|
/// | "HasTrailingSlash" "(" scalar ")"
|
|
/// | string
|
|
/// | identifier;
|
|
///
|
|
/// string ::= any sequence of characters terminated by single quotes (') or double quotes ("). Not escaped.
|
|
/// identifier ::= any sequence of letters, digits, or underscore characters.
|
|
///
|
|
/// The type of each subexpression is always a scalar, which are converted to expression-specific types (eg. booleans, integers) as required.
|
|
/// Scalar values are case-insensitive strings. The identifier 'true' and the strings "true" and "True" are all identical scalars.
|
|
/// </summary>
|
|
static class Condition
|
|
{
|
|
/// <summary>
|
|
/// Sentinel added to the end of a sequence of tokens.
|
|
/// </summary>
|
|
const string EndToken = "<EOF>";
|
|
|
|
/// <summary>
|
|
/// Evaluates the given string as a condition. Throws a ConditionException on a type or syntax error.
|
|
/// </summary>
|
|
/// <param name="Text">The condition text</param>
|
|
/// <returns>The result of evaluating the condition</returns>
|
|
public static bool Evaluate(string Text)
|
|
{
|
|
List<string> Tokens = new List<string>();
|
|
Tokenize(Text, Tokens);
|
|
|
|
bool bResult = true;
|
|
if(Tokens.Count > 1)
|
|
{
|
|
int Idx = 0;
|
|
string Result = EvaluateOr(Tokens, ref Idx);
|
|
if(Tokens[Idx] != EndToken)
|
|
{
|
|
throw new ConditionException("Garbage after expression: {0}", String.Join("", Tokens.Skip(Idx)));
|
|
}
|
|
bResult = CoerceToBool(Result);
|
|
}
|
|
return bResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Evaluates an "or-expression" production.
|
|
/// </summary>
|
|
/// <param name="Tokens">List of tokens in the expression</param>
|
|
/// <param name="Idx">Current position in the token stream. Will be incremented as tokens are consumed.</param>
|
|
/// <returns>A scalar representing the result of evaluating the expression.</returns>
|
|
static string EvaluateOr(List<string> Tokens, ref int Idx)
|
|
{
|
|
// <Condition> Or <Condition> Or...
|
|
string Result = EvaluateAnd(Tokens, ref Idx);
|
|
while(String.Compare(Tokens[Idx], "Or", true) == 0)
|
|
{
|
|
// Evaluate this condition. We use a binary OR here, because we want to parse everything rather than short-circuit it.
|
|
Idx++;
|
|
string Lhs = Result;
|
|
string Rhs = EvaluateAnd(Tokens, ref Idx);
|
|
Result = (CoerceToBool(Lhs) | CoerceToBool(Rhs))? "true" : "false";
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Evaluates an "and-expression" production.
|
|
/// </summary>
|
|
/// <param name="Tokens">List of tokens in the expression</param>
|
|
/// <param name="Idx">Current position in the token stream. Will be incremented as tokens are consumed.</param>
|
|
/// <returns>A scalar representing the result of evaluating the expression.</returns>
|
|
static string EvaluateAnd(List<string> Tokens, ref int Idx)
|
|
{
|
|
// <Condition> And <Condition> And...
|
|
string Result = EvaluateComparison(Tokens, ref Idx);
|
|
while(String.Compare(Tokens[Idx], "And", true) == 0)
|
|
{
|
|
// Evaluate this condition. We use a binary AND here, because we want to parse everything rather than short-circuit it.
|
|
Idx++;
|
|
string Lhs = Result;
|
|
string Rhs = EvaluateComparison(Tokens, ref Idx);
|
|
Result = (CoerceToBool(Lhs) & CoerceToBool(Rhs))? "true" : "false";
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Evaluates a "comparison" production.
|
|
/// </summary>
|
|
/// <param name="Tokens">List of tokens in the expression</param>
|
|
/// <param name="Idx">Current position in the token stream. Will be incremented as tokens are consumed.</param>
|
|
/// <returns>The result of evaluating the expression</returns>
|
|
static string EvaluateComparison(List<string> Tokens, ref int Idx)
|
|
{
|
|
// scalar
|
|
// scalar == scalar
|
|
// scalar != scalar
|
|
// scalar < scalar
|
|
// scalar <= scalar
|
|
// scalar > scalar
|
|
// scalar >= scalar
|
|
|
|
string Result = EvaluateScalar(Tokens, ref Idx);
|
|
if(Tokens[Idx] == "==")
|
|
{
|
|
// Compare two scalars for equality
|
|
Idx++;
|
|
string Lhs = Result;
|
|
string Rhs = EvaluateScalar(Tokens, ref Idx);
|
|
Result = (String.Compare(Lhs, Rhs, true) == 0)? "true" : "false";
|
|
}
|
|
else if(Tokens[Idx] == "!=")
|
|
{
|
|
// Compare two scalars for inequality
|
|
Idx++;
|
|
string Lhs = Result;
|
|
string Rhs = EvaluateScalar(Tokens, ref Idx);
|
|
Result = (String.Compare(Lhs, Rhs, true) != 0)? "true" : "false";
|
|
}
|
|
else if(Tokens[Idx] == "<")
|
|
{
|
|
// Compares whether the first integer is less than the second
|
|
Idx++;
|
|
int Lhs = CoerceToInteger(Result);
|
|
int Rhs = CoerceToInteger(EvaluateScalar(Tokens, ref Idx));
|
|
Result = (Lhs < Rhs)? "true" : "false";
|
|
}
|
|
else if(Tokens[Idx] == "<=")
|
|
{
|
|
// Compares whether the first integer is less than the second
|
|
Idx++;
|
|
int Lhs = CoerceToInteger(Result);
|
|
int Rhs = CoerceToInteger(EvaluateScalar(Tokens, ref Idx));
|
|
Result = (Lhs <= Rhs)? "true" : "false";
|
|
}
|
|
else if(Tokens[Idx] == ">")
|
|
{
|
|
// Compares whether the first integer is less than the second
|
|
Idx++;
|
|
int Lhs = CoerceToInteger(Result);
|
|
int Rhs = CoerceToInteger(EvaluateScalar(Tokens, ref Idx));
|
|
Result = (Lhs > Rhs)? "true" : "false";
|
|
}
|
|
else if(Tokens[Idx] == ">=")
|
|
{
|
|
// Compares whether the first integer is less than the second
|
|
Idx++;
|
|
int Lhs = CoerceToInteger(Result);
|
|
int Rhs = CoerceToInteger(EvaluateScalar(Tokens, ref Idx));
|
|
Result = (Lhs >= Rhs)? "true" : "false";
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Evaluates a "scalar" production.
|
|
/// </summary>
|
|
/// <param name="Tokens">List of tokens in the expression</param>
|
|
/// <param name="Idx">Current position in the token stream. Will be incremented as tokens are consumed.</param>
|
|
/// <returns>The result of evaluating the expression</returns>
|
|
static string EvaluateScalar(List<string> Tokens, ref int Idx)
|
|
{
|
|
string Result;
|
|
if(Tokens[Idx] == "(")
|
|
{
|
|
// Subexpression
|
|
Idx++;
|
|
Result = EvaluateOr(Tokens, ref Idx);
|
|
if(Tokens[Idx] != ")")
|
|
{
|
|
throw new ConditionException("Expected ')'");
|
|
}
|
|
Idx++;
|
|
}
|
|
else if(Tokens[Idx] == "!")
|
|
{
|
|
// Logical not
|
|
Idx++;
|
|
string Rhs = EvaluateScalar(Tokens, ref Idx);
|
|
Result = CoerceToBool(Rhs)? "false" : "true";
|
|
}
|
|
else if(String.Compare(Tokens[Idx], "Exists", true) == 0 && Tokens[Idx + 1] == "(")
|
|
{
|
|
// Check whether file or directory exists. Evaluate the argument as a subexpression.
|
|
Idx++;
|
|
string Argument = EvaluateScalar(Tokens, ref Idx);
|
|
Result = (File.Exists(Argument) || Directory.Exists(Argument))? "true" : "false";
|
|
}
|
|
else if(String.Compare(Tokens[Idx], "HasTrailingSlash", true) == 0 && Tokens[Idx + 1] == "(")
|
|
{
|
|
// Check whether the given string ends with a slash
|
|
Idx++;
|
|
string Argument = EvaluateScalar(Tokens, ref Idx);
|
|
Result = (Argument.Length > 0 && (Argument[Argument.Length - 1] == Path.DirectorySeparatorChar || Argument[Argument.Length - 1] == Path.AltDirectorySeparatorChar))? "true" : "false";
|
|
}
|
|
else
|
|
{
|
|
// Raw scalar. Remove quotes from strings, and allow literals and simple identifiers to pass through directly.
|
|
string Token = Tokens[Idx];
|
|
if(Token.Length >= 2 && (Token[0] == '\'' || Token[0] == '\"') && Token[Token.Length - 1] == Token[0])
|
|
{
|
|
Result = Token.Substring(1, Token.Length - 2);
|
|
Idx++;
|
|
}
|
|
else if(Char.IsLetterOrDigit(Token[0]) || Token[0] == '_')
|
|
{
|
|
Result = Token;
|
|
Idx++;
|
|
}
|
|
else
|
|
{
|
|
throw new ConditionException("Token '{0}' is not a valid scalar", Token);
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a scalar to a boolean value.
|
|
/// </summary>
|
|
/// <param name="Scalar">The scalar to convert</param>
|
|
/// <returns>The scalar converted to a boolean value.</returns>
|
|
static bool CoerceToBool(string Scalar)
|
|
{
|
|
bool Result;
|
|
if(String.Compare(Scalar, "true", true) == 0)
|
|
{
|
|
Result = true;
|
|
}
|
|
else if(String.Compare(Scalar, "false", true) == 0)
|
|
{
|
|
Result = false;
|
|
}
|
|
else
|
|
{
|
|
throw new ConditionException("Token '{0}' cannot be coerced to a bool", Scalar);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a scalar to a boolean value.
|
|
/// </summary>
|
|
/// <param name="Scalar">The scalar to convert</param>
|
|
/// <returns>The scalar converted to an integer value.</returns>
|
|
static int CoerceToInteger(string Scalar)
|
|
{
|
|
int Value;
|
|
if(!Int32.TryParse(Scalar, out Value))
|
|
{
|
|
throw new ConditionException("Token '{0}' cannot be coerced to an integer", Scalar);
|
|
}
|
|
return Value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Splits an input string up into expression tokens.
|
|
/// </summary>
|
|
/// <param name="Text">Text to be converted into tokens</param>
|
|
/// <param name="Tokens">List to receive a list of tokens</param>
|
|
static void Tokenize(string Text, List<string> Tokens)
|
|
{
|
|
int Idx = 0;
|
|
while(Idx < Text.Length)
|
|
{
|
|
int EndIdx = Idx + 1;
|
|
if(!Char.IsWhiteSpace(Text[Idx]))
|
|
{
|
|
// Scan to the end of the current token
|
|
if(Char.IsNumber(Text[Idx]))
|
|
{
|
|
// Number
|
|
while(EndIdx < Text.Length && Char.IsNumber(Text[EndIdx]))
|
|
{
|
|
EndIdx++;
|
|
}
|
|
}
|
|
else if(Char.IsLetter(Text[Idx]) || Text[Idx] == '_')
|
|
{
|
|
// Identifier
|
|
while(EndIdx < Text.Length && (Char.IsLetterOrDigit(Text[EndIdx]) || Text[EndIdx] == '_'))
|
|
{
|
|
EndIdx++;
|
|
}
|
|
}
|
|
else if(Text[Idx] == '!' || Text[Idx] == '<' || Text[Idx] == '>' || Text[Idx] == '=')
|
|
{
|
|
// Operator that can be followed by an equals character
|
|
if(EndIdx < Text.Length && Text[EndIdx] == '=')
|
|
{
|
|
EndIdx++;
|
|
}
|
|
}
|
|
else if(Text[Idx] == '\'' || Text[Idx] == '\"')
|
|
{
|
|
// String
|
|
if(EndIdx < Text.Length)
|
|
{
|
|
EndIdx++;
|
|
while(EndIdx < Text.Length && Text[EndIdx - 1] != Text[Idx]) EndIdx++;
|
|
}
|
|
}
|
|
Tokens.Add(Text.Substring(Idx, EndIdx - Idx));
|
|
}
|
|
Idx = EndIdx;
|
|
}
|
|
Tokens.Add(EndToken);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Test cases for conditions.
|
|
/// </summary>
|
|
public static void TestConditions()
|
|
{
|
|
TestCondition("1 == 2", false);
|
|
TestCondition("1 == 1", true);
|
|
TestCondition("1 != 2", true);
|
|
TestCondition("1 != 1", false);
|
|
TestCondition("'hello' == 'hello'", true);
|
|
TestCondition("'hello' == ('hello')", true);
|
|
TestCondition("'hello' == 'world'", false);
|
|
TestCondition("'hello' != ('world')", true);
|
|
TestCondition("true == ('true')", true);
|
|
TestCondition("true == ('True')", true);
|
|
TestCondition("true == ('false')", false);
|
|
TestCondition("true == !('False')", true);
|
|
TestCondition("true == 'true' and 'false' == 'False'", true);
|
|
TestCondition("true == 'true' and 'false' == 'true'", false);
|
|
TestCondition("true == 'false' or 'false' == 'false'", true);
|
|
TestCondition("true == 'false' or 'false' == 'true'", true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Helper method to evaluate a condition and check it's the expected result
|
|
/// </summary>
|
|
/// <param name="Condition">Condition to evaluate</param>
|
|
/// <param name="ExpectedResult">The expected result</param>
|
|
static void TestCondition(string Condition, bool ExpectedResult)
|
|
{
|
|
bool Result = Evaluate(Condition);
|
|
Console.WriteLine("{0}: {1} = {2}", (Result == ExpectedResult)? "PASS" : "FAIL", Condition, Result);
|
|
}
|
|
}
|
|
}
|