Mono.CSharp.EmitContext.EmitStoreFromPtr C# (CSharp) Method

EmitStoreFromPtr() public method

public EmitStoreFromPtr ( System.TypeSpec type ) : void
type System.TypeSpec
return void
		public void EmitStoreFromPtr (TypeSpec type)
		{
			if (type.IsEnum)
				type = EnumSpec.GetUnderlyingType (type);

			if (type == TypeManager.int32_type || type == TypeManager.uint32_type)
				ig.Emit (OpCodes.Stind_I4);
			else if (type == TypeManager.int64_type || type == TypeManager.uint64_type)
				ig.Emit (OpCodes.Stind_I8);
			else if (type == TypeManager.char_type || type == TypeManager.short_type ||
				 type == TypeManager.ushort_type)
				ig.Emit (OpCodes.Stind_I2);
			else if (type == TypeManager.float_type)
				ig.Emit (OpCodes.Stind_R4);
			else if (type == TypeManager.double_type)
				ig.Emit (OpCodes.Stind_R8);
			else if (type == TypeManager.byte_type || type == TypeManager.sbyte_type ||
				 type == TypeManager.bool_type)
				ig.Emit (OpCodes.Stind_I1);
			else if (type == TypeManager.intptr_type)
				ig.Emit (OpCodes.Stind_I);
			else if (TypeManager.IsStruct (type) || TypeManager.IsGenericParameter (type))
				ig.Emit (OpCodes.Stobj, type.GetMetaInfo ());
			else
				ig.Emit (OpCodes.Stind_Ref);
		}

Usage Example

Example #1
0
        public override void Emit(EmitContext ec)
        {
            Expression argExp;
            TypeSpec   typeSpec;

            switch (mg.Name)
            {
            case "Emit":
                if (arguments.Count == 1)
                {
                    ec.Emit(opcode);
                }
                break;

            case "Load":
                argExp = arguments [0].Expr;
                if (argExp is BoxedCast)
                {
                    argExp = ((BoxedCast)argExp).Child;
                }
                argExp.Emit(ec);
                break;

            case "LoadAddr":
                argExp = arguments [0].Expr;
                if (argExp is BoxedCast)
                {
                    argExp = ((BoxedCast)argExp).Child;
                }
                var memloc = argExp as IMemoryLocation;
                memloc.AddressOf(ec, AddressOp.Load | AddressOp.Store);
                break;

            case "LoadInd":
                if ((bool)(arguments [1].Expr as BoolConstant).GetValue())
                {
                    ec.Emit(OpCodes.Dup);
                }
                typeSpec = ((TypeOf)arguments [0].Expr).TypeArgument;
                ec.EmitLoadFromPtr(typeSpec);
                break;

            case "Store":
                argExp = arguments [0].Expr;
                if (argExp is BoxedCast)
                {
                    argExp = ((BoxedCast)argExp).Child;
                }
                var t = argExp as IAssignMethod;
                t.EmitAssign(ec, _dummyExpr, (bool)(arguments [1].Expr as BoolConstant).GetValue(), false);
                break;

            case "StoreInd":
                if ((bool)(arguments [1].Expr as BoolConstant).GetValue())
                {
                    ec.Emit(OpCodes.Dup);
                }
                typeSpec = ((TypeOf)arguments [0].Expr).TypeArgument;
                ec.EmitStoreFromPtr(typeSpec);
                break;
            }
        }
All Usage Examples Of Mono.CSharp.EmitContext::EmitStoreFromPtr