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:
926 bytes
|
Line | |
---|
1 | using HeuristicLab.Algorithms.PushGP.Interpreter;
|
---|
2 |
|
---|
3 | namespace HeuristicLab.Algorithms.PushGP.Expressions.Exec
|
---|
4 | {
|
---|
5 | public class ExecIfExpression : Expression
|
---|
6 | {
|
---|
7 | public override bool IsCodeOp { get { return false; } }
|
---|
8 |
|
---|
9 | public override void Eval(IInterpreter interpreter)
|
---|
10 | {
|
---|
11 | // not enough arguments on stack
|
---|
12 | if (interpreter.BooleanStack.Count == 0 ||
|
---|
13 | interpreter.ExecStack.Count < 2)
|
---|
14 | return;
|
---|
15 |
|
---|
16 | var condition = interpreter.BooleanStack.Pop();
|
---|
17 | var expressionTrue = interpreter.ExecStack.Pop();
|
---|
18 | var expressionFalse = interpreter.ExecStack.Pop();
|
---|
19 |
|
---|
20 | interpreter.ExecStack.Push(condition
|
---|
21 | ? expressionTrue
|
---|
22 | : expressionFalse);
|
---|
23 | }
|
---|
24 |
|
---|
25 | public override string ToString()
|
---|
26 | {
|
---|
27 | return Symbols.ExecIf;
|
---|
28 | }
|
---|
29 | }
|
---|
30 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.