public override Node Visit(ConstantOp op, Node n) { PlanCompiler.Assert(n.Children.Count == 0, "Constant operations don't have children."); PlanCompiler.Assert(op.Value != null, "Value must not be null"); // No need to visit children as none are expected if (md.TypeSemantics.IsEnumerationType(op.Type)) { // For enums the value can be specified either as enum (e.g. Color.Yellow) or as a number. // We need the numeric value only so if it was not specified as a number we need to cast it to the // underlying enum type. var constValue = op.Value.GetType().IsEnum ? Convert.ChangeType( op.Value, op.Value.GetType().GetEnumUnderlyingType(), CultureInfo.InvariantCulture) : op.Value; return m_command.CreateNode( m_command.CreateConstantOp( TypeHelpers.CreateEnumUnderlyingTypeUsage(op.Type), constValue)); } if (md.TypeSemantics.IsStrongSpatialType(op.Type)) { op.Type = TypeHelpers.CreateSpatialUnionTypeUsage(op.Type); } // ConstantOp has no children so there is nothing to visit - just return the original node. return n; }
/// <summary> /// Visitor pattern method for ConstantOp /// </summary> /// <param name="op"> The ConstantOp being visited </param> /// <param name="n"> The Node that references the Op </param> public virtual void Visit(ConstantOp op, Node n) { VisitConstantOp(op, n); }
/// <summary> /// Copies a ConstantOp /// </summary> /// <param name="op">The Op to Copy</param> /// <param name="n">The Node that references the Op</param> /// <returns>A copy of the original Node that references a copy of the original Op</returns> public override Node Visit(ConstantOp op, Node n) { ConstantBaseOp newOp = m_destCmd.CreateConstantOp(op.Type, op.Value); return(m_destCmd.CreateNode(newOp)); }
// <summary> // Copies a ConstantOp // </summary> // <param name="op"> The Op to Copy </param> // <param name="n"> The Node that references the Op </param> // <returns> A copy of the original Node that references a copy of the original Op </returns> public override Node Visit(ConstantOp op, Node n) { var newOp = m_destCmd.CreateConstantOp(op.Type, op.Value); return m_destCmd.CreateNode(newOp); }