/**************************************************************** * Subroutine Node ***************************************************************/ public Node Subroutine() { var subroutToken = Expect(TokenCategory.SUBROUTINE); var subroutName = new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }; Expect(TokenCategory.PARENTHESIS_OPEN); var args = new ArgumentList(); if (CurrentToken != TokenCategory.PARENTHESIS_CLOSE) { args.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); while (CurrentToken == TokenCategory.COMMA) { Expect(TokenCategory.COMMA); args.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); } } Expect(TokenCategory.PARENTHESIS_CLOSE); var declList = EvaluateDeclarations(); var stmtList = EvaluateStatements(); var ret = new Return() { AnchorToken = Expect(TokenCategory.RETURN) }; if (this.labelCache != null) { ret.Add(this.labelCache); this.labelCache = null; } var end = new End() { AnchorToken = Expect(TokenCategory.END) }; var subroutResult = new Subroutine() { subroutName, args, declList, stmtList, ret, end }; subroutResult.AnchorToken = subroutToken; return(subroutResult); }
// bans if ban = true, unbans if ban = false public static void ban(String name, String bannedby, bool ban) { Player player = FindPlayer(name); Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(name); if (player != null) { if (player.Name != null) { if (ban) { Commands.Ban(sender, command); server.sendToOneClient(Packet.PLAYER_BANNED(name), bannedby); } } } else { if (ban) server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), bannedby); else { Commands.UnBan(sender, command); server.sendToOneClient(Packet.PLAYER_UNBANNED(name), bannedby); } } }
public void Mux(object sender, DoWorkEventArgs e) { var inputM2TsFlags = _keepM2TsAudio ? null : "--no-audio"; var inputMkvFlags = _keepM2TsAudio ? "--no-audio" : null; var args = new ArgumentList(); // Chapter file args.AddIfAllNonEmpty("--chapters", _inputChaptersPath); // Output file args.AddAll("-o", _outputMkvPath); // Input M2TS file args.AddNonEmpty("--no-video", inputM2TsFlags, _inputM2TsPath); // If an input chapter file is specified, exclude chapters from the input MKV file if (!string.IsNullOrEmpty(_inputChaptersPath)) args.Add("--no-chapters"); // Input MKV file args.AddNonEmpty(inputMkvFlags, _inputMkvPath); Execute(args, sender, e); }
public void Mux(object sender, DoWorkEventArgs e) { var inputM2TsFlags = _keepM2TsAudio ? null : "--no-audio"; var inputMkvFlags = _keepM2TsAudio ? "--no-audio" : null; var args = new ArgumentList(); // Chapter file args.AddIfAllNonEmpty("--chapters", _inputChaptersPath); // Output file args.AddAll("-o", _outputMkvPath); // Input M2TS file args.AddNonEmpty("--no-video", inputM2TsFlags, _inputM2TsPath); // If an input chapter file is specified, exclude chapters from the input MKV file if (!string.IsNullOrEmpty(_inputChaptersPath)) { args.Add("--no-chapters"); } // Input MKV file args.AddNonEmpty(inputMkvFlags, _inputMkvPath); Execute(args, sender, e); }
/// <summary> /// Initializes a new instance of the <see cref="CSharpFeatureCall"/> class. /// </summary> /// <param name="context">The creation context.</param> /// <param name="source">Details of the feature call.</param> public CSharpFeatureCall(ICSharpContext context, IFeatureCall source) { foreach (IParameter Item in source.ParameterList) { ICSharpClass Owner = context.GetClass(Item.ResolvedParameter.Location.EmbeddingClass); ICSharpParameter NewParameter = CSharpParameter.Create(context, Item, Owner); ParameterList.Add(NewParameter); } foreach (IParameter Item in source.ResultList) { ICSharpClass Owner = context.GetClass(Item.ResolvedParameter.Location.EmbeddingClass); ICSharpParameter NewParameter = CSharpParameter.Create(context, Item, Owner); ResultList.Add(NewParameter); } foreach (IArgument Item in source.ArgumentList) { ICSharpArgument NewArgument = CSharpArgument.Create(context, Item); ArgumentList.Add(NewArgument); } Debug.Assert(ParameterList.Count >= ArgumentList.Count); Count = ParameterList.Count; ArgumentStyle = source.TypeArgumentStyle; }
public CommandModuleDefinition(IModule module, YamlMappingNode node) : base(module, node) { FilePath = (string)node.Children["file"]; if (node.Children.ContainsKey("pwd")) { WorkingDirectory = (string)node.Children["pwd"]; } if (node.Children.ContainsKey("args")) { var child = node.Children["args"]; if (child is YamlScalarNode) { Arguments = (string)child; } else { if (node.Children["args"] is YamlSequenceNode args) { foreach (var item in args) { ArgumentList.Add((string)item); } } } } }
public void autoSave() { bool firstrun = true; DateTime lastsave = new DateTime(); ISender console = new ConsoleSender(); List <string> empty = new List <string>(); ArgumentList arguments = new ArgumentList(); while (isEnabled) { if (autosaveenabled) { if (!firstrun && (DateTime.UtcNow > lastsave.AddMinutes(autosaveinterval))) { if (!arguments.Contains("automap")) { arguments.Add("automap"); } MapCommand(console, arguments); lastsave = DateTime.UtcNow; } if (firstrun) { firstrun = false; lastsave = DateTime.UtcNow; } } Thread.Sleep(1000); } }
private MethodCall buildMethodCall(String methodName) { IExpression exp = new ValueExpression(DocumentType.Instance, new DocumentValue()); Argument arg = new Argument(null, exp); ArgumentList args = new ArgumentList(); args.Add(arg); return(new MethodCall(new MethodSelector(methodName), args)); }
private MethodCall buildMethodCall(String methodName) { IExpression exp = new ValueExpression(type, type.newInstance(context)); Argument arg = new Argument(null, exp); ArgumentList args = new ArgumentList(); args.Add(arg); return(new MethodCall(new MethodSelector(methodName), args)); }
private IArgumentList CreateArgumentList(params Arg[] args) { var al = new ArgumentList(); foreach (var arg in args) { al.Add(arg); } return(al); }
public IValue interpret(Context context, String errorName) { IExpression exp = this.getExpression(context); if (exp == null) { ArgumentList args = new ArgumentList(); args.Add(new Argument(new UnresolvedParameter("name"), new TextLiteral(this.GetType().Name))); args.Add(new Argument(new UnresolvedParameter("text"), new TextLiteral(this.Message))); exp = new ConstructorExpression(new CategoryType("Error"), null, args); } if (context.getRegisteredValue <INamed>(errorName) == null) { context.registerValue(new ErrorVariable(errorName)); } IValue error = exp.interpret(context); context.setValue(errorName, error); return(error); }
public void GivePlayerStartingEquipment(Player InPlayer) { string[] equipment = new string[100]; string[] data = new string[2]; ArgumentList giveArgs = new ArgumentList(Server); giveArgs.Add(InPlayer.Name); giveArgs.Add("0"); giveArgs.Add("0"); equipment = startingEquipment.Split(':'); for (int i = 0; i < equipment.Length; i++) { data = equipment[i].ToString().Split('-'); giveArgs[1] = data[1]; giveArgs[2] = data[0]; Terraria_Server.Commands.Commands.Give(Server, InPlayer, giveArgs); } }
public static System.Drawing.Bitmap map(int x1, int y1, int x2, int y2) { if (MapPlugin.initialized && !MapPlugin.instance.isMapping) { ISender console = new ConsoleSender(); ArgumentList coords = new ArgumentList(); coords.Add("api-call"); coords.Add("-x1=" + x1); coords.Add("-x2=" + x2); coords.Add("-y1=" + y1); coords.Add("-y2=" + y2); MapPlugin.instance.MapCommand(console, coords); while (MapPlugin.instance.isMapping) { ; } } return(MapPlugin.bmp); }
private static ArgumentList buildArguments(IMethodDeclaration method, String cmdLineArgs) { ArgumentList arguments = new ArgumentList(); if (method.getParameters().Count == 1) { String name = method.getParameters()[0].GetName(); IExpression value = parseCmdLineArgs(cmdLineArgs); arguments.Add(new Argument(new UnresolvedParameter(name), value)); } return(arguments); }
private IValue populateError(ExecutionError e, Context context) { IExpression exp = e.getExpression(context); if (exp == null) { ArgumentList args = new ArgumentList(); args.Add(new Argument(new UnresolvedParameter("name"), new TextLiteral(e.GetType().Name))); args.Add(new Argument(new UnresolvedParameter("text"), new TextLiteral(e.Message))); ConstructorExpression ctor = new ConstructorExpression(new CategoryType("Error"), null, args); exp = ctor; } if (context.getRegisteredValue <INamed>(errorName) == null) { context.registerValue(new ErrorVariable(errorName)); } IValue value = exp.interpret(context); context.setValue(errorName, value); return(value); }
private void ToODialect(CodeWriter writer) { type.ToDialect(writer); ArgumentList arguments = new ArgumentList(); if (copyFrom != null) { arguments.Add(new Argument(new AttributeParameter("from"), copyFrom)); } if (this.arguments != null) { arguments.AddRange(this.arguments); } arguments.ToDialect(writer); }
private bool globalMethodExists(Context context, String name) { try { IExpression exp = new ValueExpression(this, newInstance(context)); Argument arg = new Argument(null, exp); ArgumentList args = new ArgumentList(); args.Add(arg); MethodCall proto = new MethodCall(new MethodSelector(name), args); MethodFinder finder = new MethodFinder(context, proto); return(finder.findBest(true) != null); } catch (PromptoError) { return(false); } }
protected void FinishArgument() { if (CurrentArgument.Count == 0) { throw new Ex.ParseException($"No expression given for argument"); } else if (CurrentArgument.Count == 1) { ArgumentList.Add(CurrentArgument[0]); } else { // note: this is kinda cheeky; Parser will now have to spawn another Evaluator to handle this! ArgumentList.Add(new ExpressionToken(CurrentArgument)); } CurrentArgument.Clear(); }
/// <summary> /// Constructs an instance of <see cref="Invoke"/> to the given method and /// a given list of arguments. /// </summary> /// <param name="methodName">The name of the method to invoke</param> /// <param name="args">The list of arguments of the invoke</param> /// <exception cref="ArgumentNullException">If the provided <paramref name="methodName"/> /// is <c>null</c> or empty.</exception> public Invoke(ObjectName methodName, InvokeArgument[] args) { if (ObjectName.IsNullOrEmpty(methodName)) { throw new ArgumentNullException(nameof(methodName)); } MethodName = methodName; Arguments = new ArgumentList(this); if (args != null) { foreach (var arg in args) { Arguments.Add(arg); } } }
/////////////////////////////////////////////////////////////////////// private void ofdTest_FileOk( object sender, CancelEventArgs e ) { string fileName = ofdTest.FileName; if (arguments.Count == 0) { arguments.Add(fileName); } else { arguments[0] = fileName; } txtFileName.Text = fileName; }
public static ArgumentList Multiple(CharSource source, ref char chr, Dictionary <string, IFunction> funcs) { var args = new ArgumentList(); // Typically get here having seen nothing or the first character already // Running out of text here is not an error, unless specified as more to come while (source.SkipWhiteSpace(ref chr)) { var arg = Single(source, ref chr, funcs); args.Add(arg); if (!source.SkipWhiteSpace(ref chr)) { return(args); } else if (chr != ',') { return(args); } source.Advance(out chr); } // No need to throw here, as if more expected single argument parsing will catch return(args); }
private void InitFromNameDeclaration(CSharpPropertyNameDeclaration declaration) { RaiseChangedEvent = false; try { IsExplicitImplementation = declaration.IsExplicitImplementation; ValidName = declaration.Name; if (Name == "this") // Indexer { if (!HasParameter) { ArgumentList.Add("int index"); } } else if (HasParameter) // Not an indexer { ArgumentList.Clear(); } } finally { RaiseChangedEvent = true; } }
public ArgumentsWork(string[] args) { var split = args.SplitInclude(x => x.StartsWith("-"), true).ToArray(); if (File.Exists(split[0][0])) { OpenedFile = Path.GetFullPath(args[0]); OpenedFileDir = Path.GetDirectoryName(args[0]); if (split[0].Length > 1) { OpenedArgument = split[0][1]; } } else { return; } for (int i = 1; i < split.Length; i++) { ArgumentList.Add(new Argument(split[i])); } }
public void AddArgument(Argument argument) { ArgumentList.Add(argument); }
void IReceiveArgumentList.ReceiveFrom(ArgumentList argumentList) { argumentList.Add("ssrs-uri", o => SsrsUriString = o); argumentList.AddRemainder("files|directories...", o => SourcePaths.Add(o)); }
public static void kick(String name, String kickedby) { Player player = FindPlayer(name); if (player != null) { if (player.Name != null) { Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(name); Commands.Kick(sender, command); server.sendToOneClient(Packet.PLAYER_KICKED(name), kickedby); } } else { server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), kickedby); } }
private static CommandLine CreateCurrentCommandLine() { var currentArgs = Environment.GetCommandLineArgs(); System.Diagnostics.Debug.Assert(currentArgs != null); System.Diagnostics.Debug.Assert(currentArgs.Length > 0); // first Argument is path to executable if(currentArgs.Length == 0) throw new Exception(); if(currentArgs.Length == 1) return new CommandLine(currentArgs[0]); var filePath = currentArgs[0]; var args = new ArgumentList(); for(int i = 1; i < currentArgs.Length; ++i) args.Add(currentArgs[i]); return new CommandLine(filePath, args); }
void IReceiveArgumentList.ReceiveFrom(ArgumentList argumentList) { argumentList.Add("ssrs-uri", o => SsrsUriString = o); argumentList.Add("object-path", o => ObjectPath = o); }
public static void op(String name, String oppedby, String password) { Player player = FindPlayer(name); if (player != null) { if (player.Name != null) { Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(name); if (!player.Op) { command.Add(password); Commands.OpPlayer(sender, command); server.sendToOneClient(Packet.OPPED(name), oppedby); } else { Commands.DeopPlayer(sender, command); server.sendToOneClient(Packet.DEOPPED(name), oppedby); } } } else { server.sendToOneClient(Packet.PLAYER_NOT_FOUND_ERROR(), oppedby); } }
public void Test() { ArgumentList args = new ArgumentList("-test=value", "/Test", "\"/other:value\""); Assert.AreEqual(2, args.Count); Assert.AreEqual(1, args[0].Count); Assert.AreEqual("test", args[0].Name); Assert.AreEqual("value", args[1].Value); Assert.AreEqual(1, args[1].Count); Assert.AreEqual("other", args[1].Name); Assert.AreEqual("value", args[1].Value); string[] keys = args.Keys; Assert.AreEqual(2, keys.Length); Assert.AreEqual("other", keys[0]);//alpha-sorted Assert.AreEqual("test", keys[1]); Assert.AreEqual(0, new ArgumentList("unnamed").Keys.Length); Assert.AreEqual(0, new ArgumentList(/*empty*/).Keys.Length); ArgumentList.DefaultComparison = StringComparer.Ordinal; Assert.AreEqual(StringComparer.Ordinal, ArgumentList.DefaultComparison); ArgumentList.NameDelimeters = new char[] { '=' }; Assert.AreEqual('=', ArgumentList.NameDelimeters[0]); ArgumentList.PrefixChars = new char[] { '/' }; Assert.AreEqual('/' , ArgumentList.PrefixChars[0]); args = new ArgumentList("-test=value", "/Test", "\"/other:value\""); Assert.AreEqual(2, args.Count); Assert.AreEqual(0, args[0].Count); Assert.AreEqual("Test", args[0].Name); Assert.AreEqual(null, args[1].Value); Assert.AreEqual(1, args.Unnamed.Count); foreach(string sval in args.Unnamed) Assert.AreEqual("-test=value", sval); Assert.AreEqual(0, args[1].Count); Assert.AreEqual("other:value", args[1].Name); Assert.AreEqual(null, args[1].Value); args.Unnamed = new string[0]; Assert.AreEqual(0, args.Unnamed.Count); args.Add("other", "value"); Assert.AreEqual(null, (string)args["Test"]); Assert.AreEqual("value", (string)args["other"]); Assert.AreEqual("value", (string)args.SafeGet("other")); Assert.IsNotNull(args.SafeGet("other-not-existing")); Assert.AreEqual(null, (string)args.SafeGet("other-not-existing")); string test; ArgumentList.Item item; args = new ArgumentList(); Assert.AreEqual(0, args.Count); Assert.IsFalse(args.TryGetValue(String.Empty, out item)); args.Add(String.Empty, null); Assert.IsTrue(args.TryGetValue(String.Empty, out item)); args = new ArgumentList(); Assert.AreEqual(0, args.Count); Assert.IsFalse(args.TryGetValue(String.Empty, out test)); args.Add(String.Empty, null); Assert.IsTrue(args.TryGetValue(String.Empty, out test)); test = item; Assert.IsNull(test); string[] testarry = item; Assert.IsNotNull(testarry); Assert.AreEqual(0, testarry.Length); item.Value = "roger"; Assert.AreEqual("roger", item.Value); Assert.AreEqual(1, item.Values.Length); Assert.AreEqual("roger", item.Values[0]); Assert.Contains("roger", item.ToArray()); Assert.AreEqual(1, item.ToArray().Length); item.AddRange(new string[] { "wuz", "here" }); Assert.AreEqual(3, item.Values.Length); Assert.AreEqual("roger wuz here", String.Join(" ", item)); item.Values = new string[] { "roger", "was", "here" }; Assert.AreEqual("roger was here", String.Join(" ", item)); KeyValuePair<string, string[]> testkv = item; Assert.AreEqual(String.Empty, testkv.Key); Assert.AreEqual(3, testkv.Value.Length); Assert.AreEqual("roger was here", String.Join(" ", testkv.Value)); }
public static void purge(String from, String topurge) { Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(topurge); Commands.Purge(sender, command); server.sendToOneClient(Packet.PURGED(topurge), from); }
public static void spawn(String from, String target, String npc, String amount) { Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(amount); command.Add(npc); command.Add(target); Commands.SpawnNPC(sender, command); server.sendToOneClient(Packet.SPAWNED_NPC(npc, amount), from); }
/////////////////////////////////////////////////////////////////////////////////////////////// #region IExecute Members public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { ReturnCode code = ReturnCode.Ok; if (interpreter != null) { if (arguments != null) { if (arguments.Count >= 2) { // // NOTE: lambdaExpr must be a two element list {args body} or a three element // list {args body namespace}. // StringList lambdaExpr = null; code = Parser.SplitList( interpreter, arguments[1], 0, Length.Invalid, true, ref lambdaExpr, ref result); if (code == ReturnCode.Ok) { if ((lambdaExpr.Count == 2) || (lambdaExpr.Count == 3)) { byte[] hashValue = arguments[1].GetHashValue(ref result); if (hashValue != null) { INamespace @namespace = null; if (lambdaExpr.Count == 3) { @namespace = NamespaceOps.Lookup( interpreter, lambdaExpr[2], true, false, ref result); if (@namespace == null) { code = ReturnCode.Error; } } if (code == ReturnCode.Ok) { // // NOTE: Parse the arguments into a list and make sure there are enough // supplied to satisfy the request. // StringList list = null; code = Parser.SplitList( interpreter, lambdaExpr[0], 0, Length.Invalid, true, ref list, ref result); if (code == ReturnCode.Ok) { StringPairList list2 = new StringPairList(); for (int argumentIndex = 0; argumentIndex < list.Count; argumentIndex++) { StringList list3 = null; code = Parser.SplitList( interpreter, list[argumentIndex], 0, Length.Invalid, true, ref list3, ref result); if (code != ReturnCode.Ok) { break; } if (list3.Count > 2) { result = String.Format( "too many fields in argument specifier \"{0}\"", list[argumentIndex]); code = ReturnCode.Error; break; } else if ((list3.Count == 0) || String.IsNullOrEmpty(list3[0])) { result = "argument with no name"; code = ReturnCode.Error; break; } else if (!Parser.IsSimpleScalarVariableName(list3[0], String.Format(Interpreter.ArgumentNotSimpleError, list3[0]), String.Format(Interpreter.ArgumentNotScalarError, list3[0]), ref result)) { code = ReturnCode.Error; break; } string argName = list3[0]; string argDefault = (list3.Count >= 2) ? list3[1] : null; list2.Add(new StringPair(argName, argDefault)); } if (code == ReturnCode.Ok) { // // NOTE: We *MUST* have the formal arguments in an actual ArgumentList // container now. The variadic and optional argument semantics // depend on it. // ArgumentList formalArguments = new ArgumentList( list2, ArgumentFlags.NameOnly); // // NOTE: Compare lambda argument count with the total outer argument // count minus the "apply" and "lambdaExpr" arguments. // bool hasArgs = formalArguments.IsVariadic(true); int totalArgs = hasArgs ? formalArguments.Count - 1 : formalArguments.Count; int optionalArgs = formalArguments.GetOptionalCount(); if ((((arguments.Count - 2) >= (totalArgs - optionalArgs)) && ((arguments.Count - 2) <= totalArgs)) || (hasArgs && ((arguments.Count - 2) >= (totalArgs - optionalArgs)))) { string name = NextName(interpreter, @namespace); ICallFrame frame = null; try { frame = interpreter.NewProcedureCallFrame( name, CallFrameFlags.Procedure | CallFrameFlags.Lambda, new ClientData(hashValue), this, arguments); VariableDictionary variables = frame.Variables; frame.ProcedureArguments = new ArgumentList(arguments[0]); for (int argumentIndex = 0; argumentIndex < formalArguments.Count; argumentIndex++) { string varName = formalArguments[argumentIndex].Name; if (!variables.ContainsKey(varName)) { ArgumentFlags flags = ArgumentFlags.None; object varValue; if (hasArgs && (argumentIndex == (formalArguments.Count - 1))) { // // NOTE: This argument is part of an argument list. // flags |= ArgumentFlags.ArgumentList; // // NOTE: Build the list for the final formal argument value, // which consists of all the remaining argument values. // ArgumentList argsArguments = new ArgumentList(); for (int argsArgumentIndex = argumentIndex + 2; argsArgumentIndex < arguments.Count; argsArgumentIndex++) { // // NOTE: Sync up the argument name and flags for use when // debugging (below). // Argument argsArgument = Argument.GetOrCreate( interpreter, arguments[argsArgumentIndex].Flags | flags, String.Format("{0}{1}{2}", varName, Characters.Space, argsArguments.Count), arguments[argsArgumentIndex], interpreter.HasNoCacheArgument()); argsArguments.Add(argsArgument); } varValue = argsArguments; } else { if ((argumentIndex + 2) < arguments.Count) { // // NOTE: Sync up the argument name for use when // debugging (below) and use the value // supplied by the caller. // varValue = Argument.GetOrCreate(interpreter, arguments[argumentIndex + 2].Flags | flags, varName, arguments[argumentIndex + 2], interpreter.HasNoCacheArgument()); } else { // // NOTE: We cannot sync up the argument name here // because we are out-of-bounds on that list // and it cannot be extended (i.e. it would // break [info level]); therefore, we punt // on that for now. Use the default value // for this argument, if any; otherwise, use // an empty string. // object @default = formalArguments[argumentIndex].Default; varValue = (@default != null) ? @default : Argument.NoValue; } } code = interpreter.SetVariableValue2(VariableFlags.Argument, frame, varName, varValue, ref result); if (code != ReturnCode.Ok) { break; } // // BUGFIX: Now, also keep track of this argument in the procedure // arguments list. Primarily because we do not want to // have to redo this logic later (i.e. for [scope]). // frame.ProcedureArguments.Add(Argument.GetOrCreate( interpreter, flags, varName, varValue, interpreter.HasNoCacheArgument())); } } // // NOTE: Make sure we succeeded in creating the call frame. // if (code == ReturnCode.Ok) { ICallFrame savedFrame = null; interpreter.PushProcedureCallFrame(frame, true, ref savedFrame); try { #if DEBUGGER && DEBUGGER_EXECUTE if (DebuggerOps.CanHitBreakpoints(interpreter, EngineFlags.None, BreakpointType.BeforeLambdaBody)) { code = interpreter.CheckBreakpoints( code, BreakpointType.BeforeLambdaBody, this.Name, null, null, this, null, clientData, arguments, ref result); } #endif if (code == ReturnCode.Ok) { interpreter.ReturnCode = ReturnCode.Ok; code = interpreter.EvaluateScript(lambdaExpr[1], arguments[1], ref result); #if DEBUGGER && DEBUGGER_EXECUTE if (DebuggerOps.CanHitBreakpoints(interpreter, EngineFlags.None, BreakpointType.AfterLambdaBody)) { code = interpreter.CheckBreakpoints( code, BreakpointType.AfterLambdaBody, this.Name, null, null, this, null, clientData, arguments, ref result); } #endif // // BUGFIX: If an opaque object handle is being returned, add // a reference to it now. // if ((code == ReturnCode.Ok) || (code == ReturnCode.Return)) { code = interpreter.AddObjectReference( code, result, ObjectReferenceType.Return, ref result); } if (code == ReturnCode.Return) { code = Engine.UpdateReturnInformation(interpreter); } else if (code == ReturnCode.Error) { Engine.AddErrorInformation(interpreter, result, String.Format("{0} (lambda term \"{1}\" line {2})", Environment.NewLine, FormatOps.Ellipsis(arguments[1]), Interpreter.GetErrorLine(interpreter))); } } } finally { /* IGNORED */ interpreter.PopProcedureCallFrame(frame, ref savedFrame); } } } finally { if (frame != null) { IDisposable disposable = frame as IDisposable; if (disposable != null) { disposable.Dispose(); disposable = null; } frame = null; } } } else { result = String.Format( "wrong # args: should be \"apply lambdaExpr {0}\"", formalArguments.ToRawString(ToStringFlags.Decorated, Characters.Space.ToString())); code = ReturnCode.Error; } } } } } else { code = ReturnCode.Error; } } else { result = String.Format( "can't interpret \"{0}\" as a lambda expression", arguments[1]); code = ReturnCode.Error; } } } else { result = "wrong # args: should be \"apply lambdaExpr ?arg1 arg2 ...?\""; code = ReturnCode.Error; } } else { result = "invalid argument list"; code = ReturnCode.Error; } } else { result = "invalid interpreter"; code = ReturnCode.Error; } return(code); }
///////////////////////////////////////////////////////////////////////////// // converts a list of text arguments into individual ArgumentExpresion's and // return them as an ArgumentList which later need to be interpreted by ArgumentsEvaluator public ArgumentList ProcessArgumentList( Expression parent, NmpStringList strArgs ) { // ****** ArgumentList objArgs = new ArgumentList(); // ****** for( int iArg = 0; iArg < strArgs.Count; iArg++ ) { string strArg = strArgs[ iArg ]; // ****** if( string.IsNullOrEmpty(strArg) ) { // // empty string arg // objArgs.Add( new ArgumentExpression(parent, string.Empty) ); } else { char firstChar = strArg[ 0 ]; // // if we don't understand the cast maybe we should just let // it go ... // if( SC.OPEN_PAREN == firstChar && ! IgnoreCastLikeThis(strArg) ) { // // (cast) something // ArgumentExpression ae = EvaluateCastExpression( parent, strArg ); if( null != ae ) { objArgs.Add( ae ); } else { objArgs.Add( new ArgumentExpression( parent, strArg ) ); } } else if( SC.ATCHAR == firstChar && strArg.Length > 1 && '@' != strArg[1] ) { // // @macro ... // // string must be more than just "@", "@@" escapes it // objArgs.Add( EvaluateAtExpression( parent, strArg.Substring(1) ) ); } else { // // a string // objArgs.Add( new ArgumentExpression(parent, strArg) ); } } } // ****** return objArgs; }
public static void give(String from, String target, String item, String amount) { Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(target); command.Add(amount); command.Add(item); Commands.Give(sender, command); server.sendToOneClient(Packet.GAVE_ITEM(item, amount), from); }
public virtual void Run(ICommandInterpreter interpreter, string[] arguments) { ArgumentList args = new ArgumentList(arguments); if (args.Count == 1 && args.Contains("?")) { Help(); return; } //translate ordinal referenced names Argument last = null; for (int i = 0; i < _arguments.Length && args.Unnamed.Count > 0; i++) { if (_arguments[i].Type == typeof (ICommandInterpreter)) break; last = _arguments[i]; args.Add(last.DisplayName, args.Unnamed[0]); args.Unnamed.RemoveAt(0); } if (last != null && args.Unnamed.Count > 0 && last.Type.IsArray) { for (int i = 0; i < _arguments.Length && args.Unnamed.Count > 0; i++) { args.Add(last.DisplayName, args.Unnamed[0]); args.Unnamed.RemoveAt(0); } } List<object> invokeArgs = new List<object>(); foreach (Argument arg in _arguments) { object argValue = arg.GetArgumentValue(interpreter, args, arguments); invokeArgs.Add(argValue); } //make sure we actually used all arguments. List<string> names = new List<string>(args.Keys); InterpreterException.Assert(names.Count == 0, "Unknown argument(s): {0}", String.Join(", ", names.ToArray())); InterpreterException.Assert(args.Unnamed.Count == 0, "Too many arguments supplied."); Invoke(Method, Target, invokeArgs.ToArray()); }
public static void time(String time, String changedby) { Sender sender = new ConsoleSender(); ArgumentList command = new ArgumentList(); command.Add(time); Commands.Time(sender, command); server.sendToOneClient(Packet.TIME_CHANGED(time), changedby); }
public FFmpegCLI SetOutputPath(string outputMKVPath) { _arguments.Add(outputMKVPath); return(this); }
public ArgumentsWork(string[] args) { if (args.Length > 1) { FileType = args[0]; FileSource = args[1]; } else { return; } List <string[]> param = new List <string[]>(); for (int i = 2; i < args.Length; i++) { if (args[i][0] == '-') { if (param.Count > 0) { var temp = ArgumentList.LastOrDefault(); if (temp == null) { Param.Update(param); } else { temp.Parameters.Update(param); } param.Clear(); } ArgumentList.Add(new Argument(args[i].Substring(1).ToLower())); } else if (args[i][0] == '/') { param.Add(new string[] { args[i].Substring(1).ToLower(), "" }); } else { var temp = param.LastOrDefault(); if (temp != null) { temp[1] = args[i]; } else { var lastarg = ArgumentList.Last(); if (lastarg != null) { lastarg.Value = args[i]; } } } } if (param.Count > 0) { var temp = ArgumentList.Last(); if (temp == null) { Param.Update(param); } else { temp.Parameters = new Parameters(param); } param.Clear(); } }
/**************************************************************** * Function Node ***************************************************************/ public Node Function() { var funcType = new FunctionType() { AnchorToken = Type() }; var funcToken = Expect(TokenCategory.FUNCTION); var funcId = new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }; var args = new ArgumentList(); Expect(TokenCategory.PARENTHESIS_OPEN); if (CurrentToken != TokenCategory.PARENTHESIS_CLOSE) { args.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); while (CurrentToken == TokenCategory.COMMA) { Expect(TokenCategory.COMMA); args.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); } } Expect(TokenCategory.PARENTHESIS_CLOSE); var declList = EvaluateDeclarations(); var stmtList = EvaluateStatements(); var ret = new Return() { AnchorToken = Expect(TokenCategory.RETURN) }; if (this.labelCache != null) { ret.Add(this.labelCache); this.labelCache = null; } var end = new End() { AnchorToken = Expect(TokenCategory.END) }; var funcResult = new Function() { funcType, funcId, args, declList, stmtList, ret, end }; funcResult.AnchorToken = funcToken; return(funcResult); }
void IReceiveArgumentList.ReceiveFrom(ArgumentList argumentList) { argumentList.Add("file", o => FilePath = o); }
public void Test() { ArgumentList args = new ArgumentList("-test=value", "/Test", "\"/other:value\""); Assert.AreEqual(2, args.Count); Assert.AreEqual(1, args[0].Count); Assert.AreEqual("test", args[0].Name); Assert.AreEqual("value", args[1].Value); Assert.AreEqual(1, args[1].Count); Assert.AreEqual("other", args[1].Name); Assert.AreEqual("value", args[1].Value); string[] keys = args.Keys; Assert.AreEqual(2, keys.Length); Assert.AreEqual("other", keys[0]); //alpha-sorted Assert.AreEqual("test", keys[1]); Assert.AreEqual(0, new ArgumentList("unnamed").Keys.Length); Assert.AreEqual(0, new ArgumentList(/*empty*/).Keys.Length); ArgumentList.DefaultComparison = StringComparer.Ordinal; Assert.AreEqual(StringComparer.Ordinal, ArgumentList.DefaultComparison); ArgumentList.NameDelimeters = new char[] { '=' }; Assert.AreEqual('=', ArgumentList.NameDelimeters[0]); ArgumentList.PrefixChars = new char[] { '/' }; Assert.AreEqual('/', ArgumentList.PrefixChars[0]); args = new ArgumentList("-test=value", "/Test", "\"/other:value\""); Assert.AreEqual(2, args.Count); Assert.AreEqual(0, args[0].Count); Assert.AreEqual("Test", args[0].Name); Assert.AreEqual(null, args[1].Value); Assert.AreEqual(1, args.Unnamed.Count); foreach (string sval in args.Unnamed) { Assert.AreEqual("-test=value", sval); } Assert.AreEqual(0, args[1].Count); Assert.AreEqual("other:value", args[1].Name); Assert.AreEqual(null, args[1].Value); args.Unnamed = new string[0]; Assert.AreEqual(0, args.Unnamed.Count); args.Add("other", "value"); Assert.AreEqual(null, (string)args["Test"]); Assert.AreEqual("value", (string)args["other"]); Assert.AreEqual("value", (string)args.SafeGet("other")); Assert.IsNotNull(args.SafeGet("other-not-existing")); Assert.AreEqual(null, (string)args.SafeGet("other-not-existing")); string test; ArgumentList.Item item; args = new ArgumentList(); Assert.AreEqual(0, args.Count); Assert.IsFalse(args.TryGetValue(String.Empty, out item)); args.Add(String.Empty, null); Assert.IsTrue(args.TryGetValue(String.Empty, out item)); args = new ArgumentList(); Assert.AreEqual(0, args.Count); Assert.IsFalse(args.TryGetValue(String.Empty, out test)); args.Add(String.Empty, null); Assert.IsTrue(args.TryGetValue(String.Empty, out test)); test = item; Assert.IsNull(test); string[] testarry = item; Assert.IsNotNull(testarry); Assert.AreEqual(0, testarry.Length); item.Value = "roger"; Assert.AreEqual("roger", item.Value); Assert.AreEqual(1, item.Values.Length); Assert.AreEqual("roger", item.Values[0]); Assert.Contains("roger", item.ToArray()); Assert.AreEqual(1, item.ToArray().Length); item.AddRange(new string[] { "wuz", "here" }); Assert.AreEqual(3, item.Values.Length); Assert.AreEqual("roger wuz here", String.Join(" ", item)); item.Values = new string[] { "roger", "was", "here" }; Assert.AreEqual("roger was here", String.Join(" ", item)); KeyValuePair <string, string[]> testkv = item; Assert.AreEqual(String.Empty, testkv.Key); Assert.AreEqual(3, testkv.Value.Length); Assert.AreEqual("roger was here", String.Join(" ", testkv.Value)); }
public void autoSave() { bool firstrun = true; DateTime lastsave = new DateTime(); ISender console = new ConsoleSender(); List<string> empty = new List<string>(); ArgumentList arguments = new ArgumentList(); while (isEnabled) { if (autosaveenabled) { if (!firstrun && (DateTime.UtcNow > lastsave.AddMinutes(autosaveinterval))) { if (!arguments.Contains("automap")) { arguments.Add("automap"); } MapCommand(console, arguments); lastsave = DateTime.UtcNow; } if (firstrun) { firstrun = false; lastsave = DateTime.UtcNow; } } Thread.Sleep(1000); } }