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

◆ GetPrimitiveDefaultValue()

static object System.Linq.Expressions.Interpreter.ScriptingRuntimeHelpers.GetPrimitiveDefaultValue ( Type type)
inlinestaticpackage

Definition at line 20 of file ScriptingRuntimeHelpers.cs.

21 {
22 object obj;
23 switch (type.GetTypeCode())
24 {
25 case TypeCode.Boolean:
26 obj = Utils.BoxedFalse;
27 break;
28 case TypeCode.SByte:
29 obj = Utils.BoxedDefaultSByte;
30 break;
31 case TypeCode.Byte:
32 obj = Utils.BoxedDefaultByte;
33 break;
34 case TypeCode.Char:
35 obj = Utils.BoxedDefaultChar;
36 break;
37 case TypeCode.Int16:
38 obj = Utils.BoxedDefaultInt16;
39 break;
40 case TypeCode.Int32:
41 obj = Utils.BoxedInt0;
42 break;
43 case TypeCode.Int64:
44 obj = Utils.BoxedDefaultInt64;
45 break;
46 case TypeCode.UInt16:
47 obj = Utils.BoxedDefaultUInt16;
48 break;
49 case TypeCode.UInt32:
50 obj = Utils.BoxedDefaultUInt32;
51 break;
52 case TypeCode.UInt64:
53 obj = Utils.BoxedDefaultUInt64;
54 break;
55 case TypeCode.Single:
56 return Utils.BoxedDefaultSingle;
57 case TypeCode.Double:
58 return Utils.BoxedDefaultDouble;
59 case TypeCode.DateTime:
60 return Utils.BoxedDefaultDateTime;
61 case TypeCode.Decimal:
62 return Utils.BoxedDefaultDecimal;
63 default:
64 return null;
65 }
66 if (type.IsEnum)
67 {
68 obj = Enum.ToObject(type, obj);
69 }
70 return obj;
71 }

References System.Linq.Expressions.Utils.BoxedDefaultByte, System.Linq.Expressions.Utils.BoxedDefaultChar, System.Linq.Expressions.Utils.BoxedDefaultDateTime, System.Linq.Expressions.Utils.BoxedDefaultDecimal, System.Linq.Expressions.Utils.BoxedDefaultDouble, System.Linq.Expressions.Utils.BoxedDefaultInt16, System.Linq.Expressions.Utils.BoxedDefaultInt64, System.Linq.Expressions.Utils.BoxedDefaultSByte, System.Linq.Expressions.Utils.BoxedDefaultSingle, System.Linq.Expressions.Utils.BoxedDefaultUInt16, System.Linq.Expressions.Utils.BoxedDefaultUInt32, System.Linq.Expressions.Utils.BoxedDefaultUInt64, System.Linq.Expressions.Utils.BoxedFalse, System.Linq.Expressions.Utils.BoxedInt0, System.obj, System.Enum.ToObject(), and System.type.

Referenced by System.Linq.Expressions.Interpreter.LightCompiler.CompileDefaultExpression(), and System.Linq.Expressions.Interpreter.InstructionList.EmitInitializeLocal().