Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2665 Set .NET version to 4.5, C# version to 5.0, Added expression templates and factory

File size: 903 bytes
Line 
1using HeuristicLab.Algorithms.PushGP.Interpreter;
2
3namespace HeuristicLab.Algorithms.PushGP.Expressions.Name
4{
5    public class NameDefineXExecExpression : Expression
6    {
7        private readonly string name;
8        public NameDefineXExecExpression(string name)
9        {
10            this.name = name;
11        }
12
13        public override bool IsCodeOp { get { return false; } }
14
15        public override void Eval(IInterpreter interpreter)
16        {
17            Expression expression;
18            if (interpreter.CustomExpressions.TryGetValue(this.name, out expression))
19            {
20                interpreter.ExecStack.Push(expression);
21            }
22            else
23            {
24                interpreter.NameStack.Push(this.name);
25            }
26        }
27
28        public override string ToString()
29        {
30            return this.name;
31        }
32    }
33}
Note: See TracBrowser for help on using the repository browser.