public override Node ExitStringLiteral(Token node) { var s = this.DoEscapes(node.Image); var element = new StringLiteralElement(s); node.AddValue(element); return(node); }
private static void EmitLiteral(FieldInfo fi, FleeIlGenerator ilg, IServiceProvider services) { var value = RuntimeHelpers.GetObjectValue(fi.GetValue(null)); var t = value.GetType(); LiteralElement elem; switch (Type.GetTypeCode(t)) { case TypeCode.Boolean: elem = new BooleanLiteralElement((bool)value); goto IL_F4; case TypeCode.Char: case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: elem = new Int32LiteralElement(Convert.ToInt32(RuntimeHelpers.GetObjectValue(value))); goto IL_F4; case TypeCode.UInt32: elem = new UInt32LiteralElement((uint)value); goto IL_F4; case TypeCode.Int64: elem = new Int64LiteralElement((long)value); goto IL_F4; case TypeCode.UInt64: elem = new UInt64LiteralElement((ulong)value); goto IL_F4; case TypeCode.Single: elem = new SingleLiteralElement((float)value); goto IL_F4; case TypeCode.Double: elem = new DoubleLiteralElement((double)value); goto IL_F4; case TypeCode.String: elem = new StringLiteralElement((string)value); goto IL_F4; } elem = null; Debug.Fail("Unsupported constant type"); IL_F4: elem.Emit(ilg, services); }