public override Expression Compile(ParameterExpression stateParameterExpression, LabelTarget returnTarget, LogicExpression valueExpression) { var value = this.Target.Compile(stateParameterExpression, returnTarget); var convertedValue = Expression.Convert(value, typeof(LogicStructureInstance)); var valueVariable = Expression.Variable(typeof(LogicStructureInstance), "value"); var field = Expression.Variable(typeof(LogicField), "field"); Expression<Func<LogicStructureInstance, string, LogicField>> lookupField = (x, z) => x.Fields.Keys.First(y => y.Name == z); var assignValue = Expression.Assign(valueVariable, convertedValue); var assignFieldName = Expression.Assign( field, Expression.Invoke(lookupField, valueVariable, Expression.Constant(this.Field))); var assignField = Expression.Assign( Expression.Property(Expression.Property(valueVariable, "Fields"), "Item", field), Expression.Convert(valueExpression.Compile(stateParameterExpression, returnTarget), typeof(object))); var assignFieldSet = Expression.Assign( Expression.Property(Expression.Property(valueVariable, "FieldsSet"), "Item", field), Expression.Constant(true)); return Expression.Block( new[] { valueVariable, field }, assignValue, assignFieldName, assignField, assignFieldSet); }
public AdditionLogicExpression( LogicExpression leftHandExpression, string op, LogicExpression rightHandExpression) { this.LeftHandExpression = leftHandExpression; this.Op = op; this.RightHandExpression = rightHandExpression; }
public ComparisonLogicExpression( LogicExpression leftHandExpression, string op, LogicExpression rightHandExpression) { this.LeftHandExpression = leftHandExpression; this.Op = op; this.RightHandExpression = rightHandExpression; }
public override Expression Compile( ParameterExpression stateParameterExpression, LabelTarget returnTarget, LogicExpression valueExpression) { return Expression.Assign( Expression.Property( Expression.Property(stateParameterExpression, "Variables"), "Item", Expression.Constant(this.Identifier)), Expression.Convert(valueExpression.Compile(stateParameterExpression, returnTarget), typeof(object))); }
public override Expression Compile( ParameterExpression stateParameterExpression, LabelTarget returnTarget, LogicExpression valueExpression) { return (Expression.Assign( Expression.Property( Expression.Property(stateParameterExpression, "Variables"), "Item", Expression.Constant(this.Identifier)), Expression.Convert(valueExpression.Compile(stateParameterExpression, returnTarget), typeof(object)))); }
public AssignLogicStatement(LogicAssignmentTarget assignmentTarget, string op, LogicExpression expression) { this.AssignmentTarget = assignmentTarget; switch (op) { case "=": this.Expression = expression; break; case "+=": this.Expression = new AdditionLogicExpression( this.AssignmentTarget.GetReadExpression(), "+", expression); break; case "-=": this.Expression = new AdditionLogicExpression( this.AssignmentTarget.GetReadExpression(), "-", expression); break; case "*=": this.Expression = new MultiplyLogicExpression( this.AssignmentTarget.GetReadExpression(), "*", expression); break; case "/=": this.Expression = new MultiplyLogicExpression( this.AssignmentTarget.GetReadExpression(), "/", expression); break; default: throw new InvalidOperationException(); } }
public WhileLogicStatement(LogicExpression condition, LogicStatement statement) { this.Condition = condition; this.Statement = statement; }
public abstract Expression Compile(ParameterExpression stateParameterExpression, LabelTarget returnTarget, LogicExpression valueExpression);
public FieldLogicAssignmentTarget(LogicExpression target, string field) { this.Target = target; this.Field = field; }
public IfElseLogicStatement(LogicExpression condition, LogicStatement statement, LogicStatement elseStatement) { this.Condition = condition; this.Statement = statement; this.ElseStatement = elseStatement; }
public UnaryLogicExpression(string op, LogicExpression expression) { this.Op = op; this.Expression = expression; }
public MultiplyLogicExpression(LogicExpression leftHandExpression, string op, LogicExpression rightHandExpression) { this.LeftHandExpression = leftHandExpression; this.Op = op; this.RightHandExpression = rightHandExpression; }
public ReturnLogicStatement(LogicExpression expression) { this.Expression = expression; }
public LookupLogicExpression(LogicExpression expression, string field) { this.Expression = expression; this.Field = field; }
public override Expression Compile(ParameterExpression stateParameterExpression, LabelTarget returnTarget, LogicExpression valueExpression) { var value = this.Target.Compile(stateParameterExpression, returnTarget); var convertedValue = Expression.Convert(value, typeof(LogicStructureInstance)); var valueVariable = Expression.Variable(typeof(LogicStructureInstance), "value"); var field = Expression.Variable(typeof(LogicField), "field"); Expression <Func <LogicStructureInstance, string, LogicField> > lookupField = (x, z) => x.Fields.Keys.First(y => y.Name == z); var assignValue = Expression.Assign(valueVariable, convertedValue); var assignFieldName = Expression.Assign( field, Expression.Invoke(lookupField, valueVariable, Expression.Constant(this.Field))); var assignField = Expression.Assign( Expression.Property(Expression.Property(valueVariable, "Fields"), "Item", field), Expression.Convert(valueExpression.Compile(stateParameterExpression, returnTarget), typeof(object))); var assignFieldSet = Expression.Assign( Expression.Property(Expression.Property(valueVariable, "FieldsSet"), "Item", field), Expression.Constant(true)); return(Expression.Block( new[] { valueVariable, field }, assignValue, assignFieldName, assignField, assignFieldSet)); }