public override bool Use() { // Fill in empty string arguments with state results. for (int i = 0; i < _args.Length; i++) { if (_args[i] == null) _args[i] = TagArg.FromString(I.PopResultString()); } // Create an argument table so the args can be accessed by name. var argTable = _args.Select((arg, i) => new KeyValuePair<string, TagArg>(_subroutine.Parameters[i].Item1, arg)).ToDictionary(pair => pair.Key, pair => pair.Value); // Create the state for the subroutine code var state = new Interpreter.State(I, _subroutine.Source, I.CurrentState.Output); // Pre-blueprint pushes args state.AddPreBlueprint(new FunctionBlueprint(I, _ => { _.SubArgStack.Push(argTable); return false; })); // Post-blueprint pops args state.AddPostBlueprint(new FunctionBlueprint(I, _ => { _.SubArgStack.Pop(); return false; })); // Push the state onto the stack I.PushState(state); return true; }
public AnyBlueprint(Interpreter interpreter, Interpreter.State target, IEnumerable <Token <R> > payload) : base(interpreter) { _target = target; _payload = payload; _old = _target.Output.Size; }
public Interpreter.State AsState() { var bsVersion = BethesdaVersion.HasValue ? BethesdaVersion.Value : 0; var headerValue = new Interpreter.State() { ParameterCompoundStates = new Dictionary <string, Interpreter.State>(), ParameterValues = new Dictionary <string, long>() { ["BS Version"] = bsVersion, } }; var userVersion = UserVersion.HasValue ? UserVersion.Value : 0; return(new Interpreter.State() { ParameterCompoundStates = new Dictionary <string, Interpreter.State>() { ["BS Header"] = headerValue }, ParameterValues = new Dictionary <string, long>() { ["User Version"] = userVersion, ["Version"] = NifVersion }, }); }
public override bool Use() { // Fill in empty string arguments with state results. for (int i = 0; i < _args.Length; i++) { if (_args[i] == null) { _args[i] = Argument.FromString(I.PopResultString()); } } // Create an argument table so the args can be accessed by name. var argTable = _args.Select((arg, i) => new KeyValuePair <string, Argument>(_subroutine.Parameters[i].Item1, arg)).ToDictionary(pair => pair.Key, pair => pair.Value); // Create the state for the subroutine code var state = new Interpreter.State(I, _subroutine.Source, I.CurrentState.Output); // Pre-blueprint pushes args state.AddPreBlueprint(new FunctionBlueprint(I, _ => { _.SubArgStack.Push(argTable); return(false); })); // Post-blueprint pops args state.AddPostBlueprint(new FunctionBlueprint(I, _ => { _.SubArgStack.Pop(); return(false); })); // Push the state onto the stack I.PushState(state); return(true); }
public AltBlueprint(Interpreter interpreter, Interpreter.State target, IEnumerable<Token<TokenType>> payload) : base(interpreter) { _target = target; _payload = payload; _old = target.Output.Size; }