PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
16#if !CLR2
17using MSA = System.Linq.Expressions;
18#else
19using MSA = Microsoft.Scripting.Ast;
20#endif
21
22using System.Diagnostics;
23using Microsoft.Scripting;
24using Microsoft.Scripting.Utils;
25using IronRuby.Builtins;
26
27namespace IronRuby.Compiler.Ast {
28    using Ast = MSA.Expression;
29    using AstUtils = Microsoft.Scripting.Ast.Utils;
30
31    /// <summary>
32    /// Represents a symbol literal encoded by the containing source file encoding.
33    /// </summary>
34    public partial class SymbolLiteral : StringLiteral {
35        public SymbolLiteral(string/*!*/ value, RubyEncoding/*!*/ encoding, SourceSpan location)
36            : base(value, encoding, location) {
37        }
38
39        internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
40            Debug.Assert(Value is string);
41            return Ast.Constant(gen.Context.CreateSymbol((string)Value, Encoding));
42        }
43    }
44}