Exemple #1
0
		internal override PhpTypeCode EmitGet(CodeGenerator/*!*/ codeGenerator, IPlace instance, bool wantRef,
			ConstructedType constructedType, bool runtimeVisibilityCheck)
		{
			return codeGenerator.EmitGetStaticPropertyOperator(declaringType, this.FullName, null, wantRef);
		}
Exemple #2
0
		internal override PhpTypeCode EmitGet(CodeGenerator/*!*/ codeGenerator, IPlace instance, bool wantRef,
			ConstructedType constructedType, bool runtimeVisibilityCheck)
		{
			Debug.Assert(IsStatic == (instance == null));

			ILEmitter il = codeGenerator.IL;

			if (IsStatic && runtimeVisibilityCheck)
			{
				// let the operator to check the visibility:
				return codeGenerator.EmitGetStaticPropertyOperator(DeclaringType, this.FullName, null, wantRef);
			}

			EmitGetEventObject(il, codeGenerator.ScriptContextPlace, instance, false);

			if (wantRef) il.Emit(OpCodes.Newobj, Constructors.PhpReference_Object);
			return (wantRef ? PhpTypeCode.PhpReference : PhpTypeCode.DObject);
		}
Exemple #3
0
		internal override PhpTypeCode EmitGet(CodeGenerator/*!*/ codeGenerator, IPlace instance, bool wantRef,
			ConstructedType constructedType, bool runtimeVisibilityCheck)
		{
			Debug.Assert(IsStatic == (instance == null));
			Debug.Assert(hasGetter, "TODO");

			ILEmitter il = codeGenerator.IL;

			if (IsStatic)
			{
				if (runtimeVisibilityCheck)
				{
					// let the operator to check the visibility:
					return codeGenerator.EmitGetStaticPropertyOperator(DeclaringType, this.FullName, null, wantRef);
				}
			}
			else
			{
				instance.EmitLoad(il);
			}

			MethodInfo getter = this.Getter;

			il.Emit(getter.IsVirtual ? OpCodes.Callvirt : OpCodes.Call, getter);

			PhpTypeCode result = ClrOverloadBuilder.EmitConvertToPhp(il, getter.ReturnType/*, codeGenerator.ScriptContextPlace*/);

			codeGenerator.EmitReferenceDereference(ref result, wantRef);
			return result;
		}
Exemple #4
0
		internal override PhpTypeCode EmitGet(CodeGenerator/*!*/ codeGenerator, IPlace instance, bool wantRef,
			ConstructedType constructedType, bool runtimeVisibilityCheck)
		{
			Debug.Assert(IsStatic == (instance == null));

			ILEmitter il = codeGenerator.IL;

			if (IsStatic)
			{
				if (runtimeVisibilityCheck)
				{
					// let the operator to check the visibility:
					return codeGenerator.EmitGetStaticPropertyOperator(DeclaringType, this.FullName, null, wantRef);
				}
				il.Emit(OpCodes.Ldsfld, fieldInfo);
			}
			else
			{
				instance.EmitLoad(il);
				il.Emit(OpCodes.Ldfld, fieldInfo);
			}

			PhpTypeCode result = ClrOverloadBuilder.EmitConvertToPhp(il, fieldInfo.FieldType/*, codeGenerator.ScriptContextPlace*/);

			codeGenerator.EmitReferenceDereference(ref result, wantRef);
			return result;
		}
Exemple #5
0
		private PhpTypeCode EmitGetInternal(CodeGenerator/*!*/ codeGenerator, IPlace instance, bool wantRef,
			ConstructedType constructedType, bool runtimeVisibilityCheck, bool setAliasedFlag)
		{
			ILEmitter il = codeGenerator.IL;

			if (IsStatic)
			{
				if (runtimeVisibilityCheck || UpgradesVisibility)
				{
					// let the operator to check the visibility:
					return codeGenerator.EmitGetStaticPropertyOperator(DeclaringType, this.FullName, null, wantRef);
				}

				if (!IsAppStatic) Implementor.EmitThreadStaticInit(codeGenerator, constructedType);

				// retrieve field value
				il.Emit(OpCodes.Ldsfld, DType.MakeConstructed(RealField, constructedType));
				if (wantRef)
				{
					if (setAliasedFlag)
					{
						// set IsAliased to true
						il.Emit(OpCodes.Dup);
						il.Emit(OpCodes.Ldc_I4_1);
						il.EmitCall(OpCodes.Callvirt, Properties.PhpReference_IsAliased.GetSetMethod(), null);
					}

					return PhpTypeCode.PhpReference;
				}
				else
				{
					il.Emit(OpCodes.Ldfld, Fields.PhpReference_Value);

					return PhpTypeCode.Object;
				}
			}
			else
			{
				// LOAD Operators.GetObjectFieldDirect[Ref](this,this.<field>,<name>,<type desc>,[<quiet>]);
				codeGenerator.EmitLoadSelf();
				instance.EmitLoad(il);
				il.Emit(OpCodes.Ldfld, DType.MakeConstructed(RealField, constructedType));
				il.Emit(OpCodes.Ldstr, Name.ToString());
				codeGenerator.EmitLoadClassContext();

				if (wantRef)
				{
					il.Emit(OpCodes.Call, Methods.Operators.GetObjectFieldDirectRef);

					return PhpTypeCode.PhpReference;
				}
				else
				{
					il.LoadBool(codeGenerator.ChainBuilder.QuietRead);
					il.Emit(OpCodes.Call, Methods.Operators.GetObjectFieldDirect);

					return PhpTypeCode.Object;
				}
			}
		}