internal override MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen) { #if SILVERLIGHT return(Ast.Constant(null, typeof(Encoding))); #else if (gen.Encoding == null) { return(Ast.Constant(null, typeof(Encoding))); } return(Methods.CreateEncoding.OpCall(Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding)))); #endif }
internal override MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen) { if (IsAscii || gen.Encoding == BinaryEncoding.Instance) { return(Methods.CreateMutableStringB.OpCall(Ast.Constant(_value))); } else if (IsUTF8 || gen.Encoding == BinaryEncoding.UTF8) { return(Methods.CreateMutableStringU.OpCall(Ast.Constant(_value))); } else { return(Methods.CreateMutableStringE.OpCall( Ast.Constant(_value), Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding)) )); } }
internal static MSA.Expression /*!*/ TransformConcatentation(AstGenerator /*!*/ gen, List <Expression> /*!*/ parts, Func <string, MethodInfo> /*!*/ opFactory, MSA.Expression additionalArg) { var opSuffix = new StringBuilder(Math.Min(parts.Count, 4)); List <MSA.Expression> merged = ConcatLiteralsAndTransform(gen, parts, opSuffix); if (merged.Count <= RubyOps.MakeStringParamCount) { if (merged.Count == 0) { merged.Add(Ast.Constant(String.Empty)); opSuffix.Append(RubyOps.SuffixBinary); } if (opSuffix.IndexOf(RubyOps.SuffixEncoded) != -1) { merged.Add(Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding))); } if (additionalArg != null) { merged.Add(additionalArg); } return(opFactory(opSuffix.ToString()).OpCall(merged)); } else { var paramArray = Ast.NewArrayInit(typeof(object), merged); var codePage = Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding)); return((additionalArg != null) ? opFactory("N").OpCall(paramArray, codePage, additionalArg) : opFactory("N").OpCall(paramArray, codePage)); } }