public EmitLoadDefaultOfValueType ( TypeSymbol valuetype ) : void | ||
valuetype | TypeSymbol | |
Résultat | void |
public void EmitStore(CodeGenerator cg, TypeSymbol valueType) { var type = _place.TypeOpt; // Write Ref if (_access.IsWriteRef) { if (valueType != cg.CoreTypes.PhpAlias) { Debug.Assert(false, "caller should get aliased value"); cg.EmitConvertToPhpValue(valueType, 0); valueType = cg.Emit_PhpValue_MakeAlias(); } // if (type == cg.CoreTypes.PhpAlias) { // <place> = <alias> _place.EmitStore(cg.Builder); } else if (type == cg.CoreTypes.PhpValue) { // <place> = PhpValue.Create(<alias>) cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.Create_PhpAlias); _place.EmitStore(cg.Builder); } else { Debug.Assert(false, "Assigning alias to non-aliasable variable."); cg.EmitConvert(valueType, 0, type); _place.EmitStore(cg.Builder); } } else if (_access.IsUnset) { Debug.Assert(valueType == null); // <place> = if (type == cg.CoreTypes.PhpAlias) { // new PhpAlias(void) cg.Emit_PhpValue_Void(); cg.Emit_PhpValue_MakeAlias(); } else if (type.IsReferenceType) { // null cg.Builder.EmitNullConstant(); } else { // default(T) cg.EmitLoadDefaultOfValueType(type); } _place.EmitStore(cg.Builder); } else { // if (type == cg.CoreTypes.PhpAlias) { // <place>.Value = <value> cg.EmitConvertToPhpValue(valueType, 0); cg.Emit_PhpAlias_SetValue(); } else if (type == cg.CoreTypes.PhpValue) { if (_thint.IsRef) { // Operators.SetValue(ref <place>, (PhpValue)<value>); cg.EmitConvertToPhpValue(valueType, 0); cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Operators.SetValue_PhpValueRef_PhpValue); } else { // <place> = <value> cg.EmitConvertToPhpValue(valueType, 0); _place.EmitStore(cg.Builder); } } else { cg.EmitConvert(valueType, 0, type); _place.EmitStore(cg.Builder); } } }