[Mono-list] Doubt in Reflection.Emit
mono devel
nvineeth_mono@yahoo.com
Tue, 9 Mar 2004 06:38:59 -0800 (PST)
hello,
I have doubt in Reflection.Emit.Opcodes.
I have noticed that before setting a variable , or
calling a function
Opcodes.ldarg_0 is always emitted.
I want to know if ldarg_0 contains a reference to
current object(something like "this" pointer) ::
The example i came accross is as follows ( i have
marked the lines which do this )::
FieldBuilder xField =
pointTypeBld.DefineField("x", typeof(int),
FieldAttributes.Public);
FieldBuilder yField =
pointTypeBld.DefineField("y", typeof(int),
FieldAttributes.Public);
Type objType = Type.GetType("System.Object");
ConstructorInfo objCtor =
objType.GetConstructor(new Type[0]);
ConstructorBuilder pointCtor =
pointTypeBld.DefineConstructor(
MethodAttributes.Public,
CallingConventions.Standard,
ctorParams);
ILGenerator ctorIL =
pointCtor.GetILGenerator();
// First, you build the constructor.
ctorIL.Emit(OpCodes.Ldarg_0);//<--Here####
ctorIL.Emit(OpCodes.Call, objCtor);//objCtor is
the constructor of System.Object;
ctorIL.Emit(OpCodes.Ldarg_0);//<--Here#######
ctorIL.Emit(OpCodes.Ldarg_1);
ctorIL.Emit(OpCodes.Stfld, xField);
ctorIL.Emit(OpCodes.Ldarg_0);//<--Here#####
ctorIL.Emit(OpCodes.Ldarg_2);
ctorIL.Emit(OpCodes.Stfld, yField);
ctorIL.Emit(OpCodes.Ret);
//--------------------------------
can someone please rectify this doubt.
thanks,
vineeth
=====
vineeth N
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com