Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/Name/NameDefineXExecExpression.cs @ 14320

Last change on this file since 14320 was 14320, checked in by pkimmesw, 8 years ago

#2665 Added Interpreter, Parser, 16 Examples, Expressions needed for the examples

File size: 898 bytes
Line 
1using HeuristicLab.Algorithms.PushGP.Stack;
2
3namespace HeuristicLab.Algorithms.PushGP.Expressions
4{
5    public class NameDefineXExecExpression : Expression
6    {
7        public NameDefineXExecExpression(string value) : base(OpCode.NameDefineXExec)
8        {
9            this.Value = value;
10        }
11
12        public string Value { get; }
13
14        public override void Eval(IInterpreterService interpreterService)
15        {
16            Expression expression;
17            if (interpreterService.CustomExpressions.TryGetValue(this.Value, out expression))
18            {
19                interpreterService.ExecStack.Push(expression);
20            }
21            else
22            {
23                interpreterService.NameStack.Push(this.Value);
24            }
25        }
26
27        public override string ToString()
28        {
29            return this.Value;
30        }
31    }
32}
Note: See TracBrowser for help on using the repository browser.