internal void SetString(string /*!*/ value, StringLiteralEncoding encoding) { Assert.NotNull(value); String = value; _integer1 = (int)encoding; _type = TokenValueType.String; }
private static StringLiteralEncoding CombineEncoding(StringLiteralEncoding encoding, StringLiteral literal) { if (encoding == StringLiteralEncoding.UTF8 || literal.IsUTF8) { return(StringLiteralEncoding.UTF8); } if (encoding == StringLiteralEncoding.Ascii && literal.IsAscii) { return(StringLiteralEncoding.Ascii); } return(StringLiteralEncoding.Default); }
private static char OpSuffix(AstGenerator /*!*/ gen, StringLiteralEncoding encoding) { if (encoding == StringLiteralEncoding.Ascii) { return(RubyOps.SuffixBinary); } else if (encoding == StringLiteralEncoding.UTF8 || gen.Encoding == Encoding.UTF8) { return(RubyOps.SuffixUTF8); } else if (gen.Encoding == BinaryEncoding.Instance) { return(RubyOps.SuffixBinary); } else { return(RubyOps.SuffixEncoded); } }
internal void SetString(string/*!*/ value, StringLiteralEncoding encoding) { Assert.NotNull(value); String = value; _integer1 = (int)encoding; _type = TokenValueType.String; }
internal void SetString(string/*!*/ value, StringLiteralEncoding encoding) { Assert.NotNull(value); String = value; Integer1 = (int)encoding; }
// // Traverses expressions in "parts" and concats all contiguous literal strings. // Notes: // - Instead of usign StringBuilder we place the string values that can be concatenated so far in to "literals" list and keep track // of their total length in "concatLength" and encoding in "concatEncoding". // If we reach a non-literal expression and we have some literals ready in "literals" array we do the concat and clear the list // and "concatLength" and "concatEncoding". // - "result" list contains argument expressions to the CreateMutableString* overloads. // - "opName" contains the name of the operation. This method appends suffix based on the argument types (see RubyOps.Suffix*). // private static void ConcatLiteralsAndTransformRecursive(AstGenerator /*!*/ gen, List <Expression> /*!*/ parts, List <string> /*!*/ literals, ref int concatLength, ref StringLiteralEncoding concatEncoding, List <MSA.Expression> /*!*/ result, StringBuilder /*!*/ opName) { for (int i = 0; i < parts.Count; i++) { Expression part = parts[i]; StringLiteral literal; StringConstructor ctor; if ((literal = part as StringLiteral) != null) { literals.Add(literal.Value); concatEncoding = CombineEncoding(concatEncoding, literal); concatLength += literal.Value.Length; } else if ((ctor = part as StringConstructor) != null) { ConcatLiteralsAndTransformRecursive(gen, ctor.Parts, literals, ref concatLength, ref concatEncoding, result, opName); } else { if (literals.Count > 0) { result.Add(Ast.Constant(Concat(literals, concatLength))); opName.Append(OpSuffix(gen, concatEncoding)); concatLength = 0; concatEncoding = StringLiteralEncoding.Ascii; literals.Clear(); } result.Add( Ast.Dynamic( ConvertToSAction.Instance, typeof(MutableString), gen.CurrentScopeVariable, part.TransformRead(gen) ) ); opName.Append(RubyOps.SuffixMutable); } } }
internal StringLiteral(string /*!*/ value, StringLiteralEncoding encoding, SourceSpan location) : base(location) { _value = value; _encoding = encoding; }
internal StringLiteral(string/*!*/ value, StringLiteralEncoding encoding, SourceSpan location) : base(location) { _value = value; _encoding = encoding; }
private static char OpSuffix(AstGenerator/*!*/ gen, StringLiteralEncoding encoding) { if (encoding == StringLiteralEncoding.Ascii) { return RubyOps.SuffixBinary; } else if (encoding == StringLiteralEncoding.UTF8 || gen.Encoding == Encoding.UTF8) { return RubyOps.SuffixUTF8; } else if (gen.Encoding == BinaryEncoding.Instance) { return RubyOps.SuffixBinary; } else { return RubyOps.SuffixEncoded; } }
private static StringLiteralEncoding CombineEncoding(StringLiteralEncoding encoding, StringLiteral literal) { if (encoding == StringLiteralEncoding.UTF8 || literal.IsUTF8) { return StringLiteralEncoding.UTF8; } if (encoding == StringLiteralEncoding.Ascii && literal.IsAscii) { return StringLiteralEncoding.Ascii; } return StringLiteralEncoding.Default; }
// // Traverses expressions in "parts" and concats all contiguous literal strings. // Notes: // - Instead of usign StringBuilder we place the string values that can be concatenated so far in to "literals" list and keep track // of their total length in "concatLength" and encoding in "concatEncoding". // If we reach a non-literal expression and we have some literals ready in "literals" array we do the concat and clear the list // and "concatLength" and "concatEncoding". // - "result" list contains argument expressions to the CreateMutableString* overloads. // - "opName" contains the name of the operation. This method appends suffix based on the argument types (see RubyOps.Suffix*). // private static void ConcatLiteralsAndTransformRecursive(AstGenerator/*!*/ gen, List<Expression>/*!*/ parts, List<string>/*!*/ literals, ref int concatLength, ref StringLiteralEncoding concatEncoding, List<MSA.Expression>/*!*/ result, StringBuilder/*!*/ opName) { for (int i = 0; i < parts.Count; i++) { Expression part = parts[i]; StringLiteral literal; StringConstructor ctor; if ((literal = part as StringLiteral) != null) { literals.Add(literal.Value); concatEncoding = CombineEncoding(concatEncoding, literal); concatLength += literal.Value.Length; } else if ((ctor = part as StringConstructor) != null) { ConcatLiteralsAndTransformRecursive(gen, ctor.Parts, literals, ref concatLength, ref concatEncoding, result, opName); } else { if (literals.Count > 0) { result.Add(Ast.Constant(Concat(literals, concatLength))); opName.Append(OpSuffix(gen, concatEncoding)); concatLength = 0; concatEncoding = StringLiteralEncoding.Ascii; literals.Clear(); } result.Add( Ast.Dynamic( ConvertToSAction.Instance, typeof(MutableString), Methods.GetContextFromScope.OpCall(gen.CurrentScopeVariable), part.TransformRead(gen) ) ); opName.Append(RubyOps.SuffixMutable); } } }