Esempio n. 1
0
        public FunctionContext GetNewFunctionContext(ExecutingFunctionContext executingContext)
        {
            var newContext = new FunctionContext(Name, Arguments, Tokens, IsAsync);

            var newPolis = new List <Token>();

            foreach (var token in POLIS)
            {
                newPolis.Add(new Token(token.Value, token.Lexem));
            }
            newContext.POLIS = newPolis;

            var newTriads = new List <Triad>();

            foreach (var triad in Triads)
            {
                newTriads.Add(new Triad(triad.LeftOperand?.GetCopy(), triad.RightOperand?.GetCopy(), new Token(triad.Operation.Value, triad.Operation.Lexem), triad.Type));
            }
            newContext.Triads = newTriads;

            var newOptimizedTriads = new List <Triad>();

            foreach (var triad in OptimizedTriads)
            {
                newOptimizedTriads.Add(new Triad(triad.LeftOperand?.GetCopy(), triad.RightOperand?.GetCopy(), new Token(triad.Operation.Value, triad.Operation.Lexem), triad.Type));
            }
            newContext.OptimizedTriads = newOptimizedTriads;

            newContext.ExecutingContext = executingContext.GetNewExecutingContext();
            return(newContext);
        }
        public ExecutingFunctionContext GetNewExecutingContext()
        {
            var newContext = new ExecutingFunctionContext();

            var newTriadResults = new List <TriadWithResult>();

            foreach (var triadResult in TriadResults)
            {
                newTriadResults.Add(new TriadWithResult(triadResult.TriadIndex, triadResult.Value));
            }
            newContext.TriadResults = newTriadResults;

            var newVariables = new List <Variable>();

            foreach (var variable in Variables)
            {
                newVariables.Add(new Variable(variable.Name, variable.Value));
            }
            newContext.Variables = newVariables;


            newContext.CurrentIndex = CurrentIndex;

            newContext.Parameters = Parameters?.GetNewParameters();

            return(newContext);
        }
Esempio n. 3
0
 private void Initialize()
 {
     ExecutingContext = new ExecutingFunctionContext();
 }