public override void Compile(MoveInfo treeInfo, ScriptInfo scriptInfo, CompilingInfo compilingInfo) { Assign tryAssign = _exp.GetChildren()[0] as Assign; if (tryAssign != null) { ArrayContentDef tryArrayContentDef = tryAssign.Exp.GetChildren()[0] as ArrayContentDef; if (tryArrayContentDef != null) { IElement compiledStatements = tryArrayContentDef.GetCompiledStatements(tryAssign.VarName); treeInfo.ReplaceCurrent(compiledStatements); } } }
public override void Compile(MoveInfo treeInfo, ScriptInfo scriptInfo, CompilingInfo compilingInfo) { if (this._constInfo.SF.SFPath == "compiler") { IElement e = null; switch (this._constInfo.Name) { case "Time": e = new Token(TokenType.String, DateTime.Now.ToShortTimeString()); break; case "Date": e = new Token(TokenType.String, DateTime.Now.ToShortDateString()); break; case "DateTime": e = new Token(TokenType.String, DateTime.Now.ToString()); break; case "FilePath": e = new Token(TokenType.String, scriptInfo.SF.SFPath); break; case "FilePathFull": e = new Token(TokenType.String, scriptInfo.SF.SFFullPath); break; case "Line": e = new Token(TokenType.Number, treeInfo.Current.LineIndex + 1); break; case "FunctionName": var function1 = treeInfo.FindBlockInStack <FuncDef>(true); var function1Name = ""; if (function1 != null) { function1Name = function1.FuncInfo.Name; } e = new Token(TokenType.String, function1Name); break; case "FunctionSignature": var function2 = treeInfo.FindBlockInStack <FuncDef>(true); var function2Signature = ""; if (function2 != null) { function2Signature = function2.FuncInfo.GetHead(); } e = new Token(TokenType.String, function2Signature); break; case "VersionInt": e = new Token(TokenType.Number, scriptInfo.SF.Manager.Settings.VersionInt); break; case "VersionStr": e = new Token(TokenType.String, scriptInfo.SF.Manager.Settings.VersionStr); break; case "TargetPlatform": e = new Token(TokenType.Number, (int)scriptInfo.SF.Manager.Settings.TargetPlatform); break; case "TargetPlatform_Windows": e = new Token(TokenType.Number, (int)TargetPlatform.Windows); break; case "TargetPlatform_Linux": e = new Token(TokenType.Number, (int)TargetPlatform.Linux); break; case "TargetPlatform_LinuxNinja": e = new Token(TokenType.Number, (int)TargetPlatform.LinuxNinja); break; case "TargetConfiguration": e = new Token(TokenType.Number, (int)scriptInfo.SF.Manager.Settings.TargetConfiguration); break; case "TargetConfiguration_Debug": e = new Token(TokenType.Number, (int)TargetConfiguration.Debug); break; case "TargetConfiguration_Release": e = new Token(TokenType.Number, (int)TargetConfiguration.Release); break; case "TargetConfiguration_FinalRelease": e = new Token(TokenType.Number, (int)TargetConfiguration.FinalRelease); break; default: throw new ArgumentException("Unknown compiler constant '" + _constInfo.Name + "', " + scriptInfo.SF.ToString()); } treeInfo.ReplaceCurrent(e); } }