/IronPython_Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/SymbolLiteral.cs

# · C# · 44 lines · 22 code · 5 blank · 17 comment · 0 complexity · d4256c5a7648124abdc3e75fd3cfcd2f MD5 · raw file

  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. #if !CLR2
  16. using MSA = System.Linq.Expressions;
  17. #else
  18. using MSA = Microsoft.Scripting.Ast;
  19. #endif
  20. using System.Diagnostics;
  21. using Microsoft.Scripting;
  22. using Microsoft.Scripting.Utils;
  23. using IronRuby.Builtins;
  24. namespace IronRuby.Compiler.Ast {
  25. using Ast = MSA.Expression;
  26. using AstUtils = Microsoft.Scripting.Ast.Utils;
  27. /// <summary>
  28. /// Represents a symbol literal encoded by the containing source file encoding.
  29. /// </summary>
  30. public partial class SymbolLiteral : StringLiteral {
  31. public SymbolLiteral(string/*!*/ value, RubyEncoding/*!*/ encoding, SourceSpan location)
  32. : base(value, encoding, location) {
  33. }
  34. internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
  35. Debug.Assert(Value is string);
  36. return Ast.Constant(gen.Context.CreateSymbol((string)Value, Encoding));
  37. }
  38. }
  39. }