2 // literal.cs: Literal representation for the IL tree.
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) 2001 Ximian, Inc.
10 // Notice that during parsing we create objects of type Literal, but the
11 // types are not loaded (thats why the Resolve method has to assign the
12 // type at that point).
14 // Literals differ from the constants in that we know we encountered them
15 // as a literal in the source code (and some extra rules apply there) and
16 // they have to be resolved (since during parsing we have not loaded the
17 // types yet) while constants are created only after types have been loaded
18 // and are fully resolved when born.
22 using System
.Reflection
;
23 using System
.Reflection
.Emit
;
25 namespace Mono
.MonoBASIC
{
27 public class NullLiteral
: Constant
{
28 public static readonly NullLiteral Null
;
32 Null
= new NullLiteral ();
38 throw new Exception ("More than one null has been created!");
39 eclass
= ExprClass
.Value
;
42 override public string AsString ()
47 public override object GetValue ()
52 public override Expression
DoResolve (EmitContext ec
)
54 type
= TypeManager
.object_type
;
58 public override void Emit (EmitContext ec
)
60 ec
.ig
.Emit (OpCodes
.Ldnull
);
64 public class BoolLiteral
: BoolConstant
{
65 public BoolLiteral (bool val
) : base (val
)
69 public override Expression
DoResolve (EmitContext ec
)
71 type
= TypeManager
.bool_type
;
76 public class CharLiteral
: CharConstant
{
77 public CharLiteral (char c
) : base (c
)
81 public override Expression
DoResolve (EmitContext ec
)
83 type
= TypeManager
.char_type
;
88 public class IntLiteral
: IntConstant
{
89 public IntLiteral (int l
) : base (l
)
93 public override Expression
DoResolve (EmitContext ec
)
95 type
= TypeManager
.int32_type
;
100 public class ShortLiteral
: ShortConstant
{
101 public ShortLiteral (short l
) : base (l
)
105 public override Expression
DoResolve (EmitContext ec
)
107 type
= TypeManager
.short_type
;
112 public class UIntLiteral
: UIntConstant
{
113 public UIntLiteral (uint l
) : base (l
)
117 public override Expression
DoResolve (EmitContext ec
)
119 type
= TypeManager
.uint32_type
;
124 public class LongLiteral
: LongConstant
{
125 public LongLiteral (long l
) : base (l
)
129 public override Expression
DoResolve (EmitContext ec
)
131 type
= TypeManager
.int64_type
;
137 public class ULongLiteral
: ULongConstant
{
138 public ULongLiteral (ulong l
) : base (l
)
142 public override Expression
DoResolve (EmitContext ec
)
144 type
= TypeManager
.uint64_type
;
149 public class FloatLiteral
: FloatConstant
{
151 public FloatLiteral (float f
) : base (f
)
155 public override Expression
DoResolve (EmitContext ec
)
157 type
= TypeManager
.float_type
;
162 public class DoubleLiteral
: DoubleConstant
{
163 public DoubleLiteral (double d
) : base (d
)
167 public override Expression
DoResolve (EmitContext ec
)
169 type
= TypeManager
.double_type
;
175 public class DecimalLiteral
: DecimalConstant
{
176 public DecimalLiteral (decimal d
) : base (d
)
180 public override Expression
DoResolve (EmitContext ec
)
182 type
= TypeManager
.decimal_type
;
187 public class StringLiteral
: StringConstant
{
188 public StringLiteral (string s
) : base (s
)
192 public override Expression
DoResolve (EmitContext ec
)
194 type
= TypeManager
.string_type
;
200 public class DateLiteral
: DateConstant
{
201 public DateLiteral (DateTime s
) : base (s
)
205 public override Expression
DoResolve (EmitContext ec
)
207 type
= TypeManager
.date_type
;