/// <summary> /// Renders a single ConversionExpression to VHDL /// </summary> /// <returns>The VHDL equivalent of the expression.</returns> /// <param name="e">The expression to render</param> private string RenderExpression(SME.VHDL.CustomNodes.ConversionExpression e) { string innerexp; if (e.Expression is PrimitiveExpression) { innerexp = VHDLTypeConversion.GetPrimitiveLiteral(e.Expression, Parent.TypeLookup[e]); } else { innerexp = RenderExpression(e.Expression); } return(string.Format(e.WrappingTemplate, innerexp)); }
/// <summary> /// Renders a single PrimitiveExpression to VHDL /// </summary> /// <returns>The VHDL equivalent of the expression.</returns> /// <param name="e">The expression to render</param> private string RenderExpression(AST.PrimitiveExpression e) { var tvhdl = Parent.VHDLType(e); if (tvhdl == VHDLTypes.BOOL) { return(((bool)e.Value) ? "true" : "false"); } else if (tvhdl == VHDLTypes.SYSTEM_BOOL) { return(((bool)e.Value) ? "'1'" : "'0'"); } else if (e.SourceResultType.Resolve().IsEnum) { return(Naming.ToValidName(e.SourceResultType.FullName + "_" + e.Value.ToString())); } else { return(VHDLTypeConversion.GetPrimitiveLiteral(e, tvhdl)); } }