Changeset 14897 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators
- Timestamp:
- 04/28/17 22:52:08 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators
- Files:
-
- 2 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators/CodeGenerator/CodeGeneratorUtils.cs
r14875 r14897 3 3 4 4 namespace HeuristicLab.Problems.ProgramSynthesis.Push.Generators.CodeGenerator { 5 using Core; 6 using Expressions; 5 7 6 using HeuristicLab.Core; 7 using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Interfaces; 8 using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions; 9 using HeuristicLab.Problems.ProgramSynthesis.Push.Stack; 8 using HeuristicLab.Problems.ProgramSynthesis.Base.Erc; 9 10 using Stack; 10 11 11 12 internal static class CodeGeneratorUtils { … … 19 20 20 21 return index >= enabledExpressions.Count 21 ? customExpressions. ElementAt(index - (enabledExpressions.Count - 1)).Value22 ? customExpressions.Values.ElementAt(index - enabledExpressions.Count) 22 23 : CreateExpressionOrErc(index, random, enabledExpressions, ercOptions); 23 24 } … … 55 56 } 56 57 58 private static readonly Expression Noop = ExpressionTable.GetStatelessExpression<ExecNoopExpression>(); 57 59 /// <summary> 58 60 /// Create a ErcExpression whereby the type of the expression conforms to the passed stack type. … … 65 67 switch (type) { 66 68 case StackTypes.Integer: 67 if (ercOptions.IntegerErcOptions == null || !ercOptions.IntegerErcOptions.IsEnabled) 68 return ExpressionTable.GetStatelessExpression<ExecNoopExpression>(); 69 70 var intValue = ErcUtils.GetInteger(ercOptions.IntegerErcOptions, random); 71 72 return new IntegerPushExpression(intValue); 69 return ercOptions.IntegerErcOptions == null || !ercOptions.IntegerErcOptions.IsEnabled 70 ? Noop 71 : new IntegerPushExpression(ercOptions.IntegerErcOptions.GetErcValue(random)); 73 72 74 73 case StackTypes.Float: 75 if (ercOptions.FloatErcOptions == null || !ercOptions.FloatErcOptions.IsEnabled) 76 return ExpressionTable.GetStatelessExpression<ExecNoopExpression>(); 77 78 var doubleValue = ErcUtils.GetDouble(ercOptions.FloatErcOptions, random); 79 80 return new FloatPushExpression(doubleValue); 74 return ercOptions.FloatErcOptions == null || !ercOptions.FloatErcOptions.IsEnabled 75 ? Noop 76 : new FloatPushExpression(ercOptions.FloatErcOptions.GetErcValue(random)); 81 77 82 78 case StackTypes.Boolean: 83 79 return ercOptions.BooleanErcOptions == null || !ercOptions.BooleanErcOptions.IsEnabled 84 ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()85 : new BooleanPushExpression( ErcUtils.GetBoolean(ercOptions.BooleanErcOptions,random));80 ? Noop 81 : new BooleanPushExpression(ercOptions.BooleanErcOptions.GetErcValue(random)); 86 82 87 83 case StackTypes.Name: 88 84 return ercOptions.NameErcOptions == null || !ercOptions.NameErcOptions.IsEnabled 89 ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()90 : new NamePushExpression( ErcUtils.GetName(ercOptions.NameErcOptions,random));85 ? Noop 86 : new NamePushExpression(ercOptions.NameErcOptions.GetErcValue(random)); 91 87 92 88 case StackTypes.String: 93 89 return ercOptions.StringErcOptions == null || !ercOptions.StringErcOptions.IsEnabled 94 ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()95 : new StringPushExpression( ErcUtils.GetString(ercOptions.StringErcOptions,random));90 ? Noop 91 : new StringPushExpression(ercOptions.StringErcOptions.GetErcValue(random)); 96 92 97 93 case StackTypes.Char: 98 94 return ercOptions.CharErcOptions == null || !ercOptions.CharErcOptions.IsEnabled 99 ? ExpressionTable.GetStatelessExpression<ExecNoopExpression>()100 : new CharPushExpression( ErcUtils.GetChar(ercOptions.CharErcOptions,random));95 ? Noop 96 : new CharPushExpression(ercOptions.CharErcOptions.GetErcValue(random)); 101 97 102 98 default: 103 return ExpressionTable.GetStatelessExpression<ExecNoopExpression>();99 return Noop; 104 100 } 105 101 }
Note: See TracChangeset
for help on using the changeset viewer.