Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryEmitILConstant()

static bool System.Linq.Expressions.Compiler.ILGen.TryEmitILConstant ( this ILGenerator il,
object value,
Type type )
inlinestaticprivate

Definition at line 386 of file ILGen.cs.

387 {
388 if (type.IsNullableType())
389 {
390 Type nonNullableType = type.GetNonNullableType();
391 if (il.TryEmitILConstant(value, nonNullableType))
392 {
394 return true;
395 }
396 return false;
397 }
398 switch (type.GetTypeCode())
399 {
400 case TypeCode.Boolean:
401 il.EmitPrimitive((bool)value);
402 return true;
403 case TypeCode.SByte:
404 il.EmitPrimitive((sbyte)value);
405 return true;
406 case TypeCode.Int16:
407 il.EmitPrimitive((short)value);
408 return true;
409 case TypeCode.Int32:
410 il.EmitPrimitive((int)value);
411 return true;
412 case TypeCode.Int64:
413 il.EmitPrimitive((long)value);
414 return true;
415 case TypeCode.Single:
416 il.EmitPrimitive((float)value);
417 return true;
418 case TypeCode.Double:
419 il.EmitPrimitive((double)value);
420 return true;
421 case TypeCode.Char:
422 il.EmitPrimitive((char)value);
423 return true;
424 case TypeCode.Byte:
425 il.EmitPrimitive((byte)value);
426 return true;
427 case TypeCode.UInt16:
428 il.EmitPrimitive((ushort)value);
429 return true;
430 case TypeCode.UInt32:
431 il.EmitPrimitive((uint)value);
432 return true;
433 case TypeCode.UInt64:
434 il.EmitPrimitive((ulong)value);
435 return true;
436 case TypeCode.Decimal:
437 il.EmitDecimal((decimal)value);
438 return true;
439 case TypeCode.String:
440 il.EmitString((string)value);
441 return true;
442 default:
443 return false;
444 }
445 }
static ConstructorInfo GetNullableConstructor(Type nullableType)
Definition TypeUtils.cs:34
static readonly OpCode Newobj
Definition OpCodes.cs:233

References System.Reflection.Emit.ILGenerator.Emit(), System.Dynamic.Utils.TypeUtils.GetNullableConstructor(), System.Reflection.Emit.OpCodes.Newobj, System.type, and System.value.