Example #1
0
		public NewEx(Position position, TypeRef/*!*/ classNameRef, List<ActualParam>/*!*/ parameters)
			: base(position)
		{
			Debug.Assert(classNameRef != null && parameters != null);
			this.classNameRef = classNameRef;
			this.callSignature = new CallSignature(parameters, TypeRef.EmptyList);
		}
Example #2
0
        public StaticFieldUse(Position position, TypeRef typeRef)
            : base(position)
        {
            Debug.Assert(typeRef != null);

            this.typeRef = typeRef;
        }
Example #3
0
		public InstanceOfEx(Text.Span span, Expression/*!*/ expression, TypeRef/*!*/ classNameRef)
            : base(span)
		{
			Debug.Assert(expression != null && classNameRef != null);

			this.expression = expression;
			this.classNameRef = classNameRef;
		}
Example #4
0
        public StaticFieldUse(Text.Span span, Text.Span nameSpan, TypeRef typeRef)
            : base(span)
        {
            Debug.Assert(typeRef != null);

            this.typeRef = typeRef;
            this.NameSpan = nameSpan;
        }
Example #5
0
		public InstanceOfEx(Position position, Expression/*!*/ expression, TypeRef/*!*/ classNameRef)
			: base(position)
		{
			Debug.Assert(expression != null && classNameRef != null);

			this.expression = expression;
			this.classNameRef = classNameRef;
		}
Example #6
0
		/// <summary>
		/// Emits IL instructions that ensure that a static field is of <see cref="PhpObject"/> or <see cref="PhpArray"/>
		/// type. Handles the case when field name is known at compile time (see <see cref="AST.DirectStFldUse"/>).
		/// </summary>
		/// <param name="property">The corresponding <see cref="DProperty"/> or <B>null</B>.</param>
        /// <param name="typeRef">The class type reference (identifier index).</param>
		/// <param name="fieldName">The field name (identifier index).</param>
		/// <param name="ensureArray">Whether to ensure that static field is an array (or an object).</param>
		/// <remarks>
		/// Nothing is expected on the evaluation stack. A <see cref="PhpObject"/> or <see cref="DObject"/> is left
		/// on the evaluation stack or the last emitted instruction is unconditional branch to <see cref="Chain.ErrorLabel"/>.
		/// </remarks>
		public PhpTypeCode EmitEnsureStaticProperty(DProperty property, TypeRef typeRef,
			VariableName fieldName, bool ensureArray)
		{
			ILEmitter il = codeGenerator.IL;

			PhpField php_field = property as PhpField;
			if (php_field != null)
			{
				// HACK HACK
				EmitEnsureStaticPhpFieldDirect(php_field, ensureArray);

				EmitErrorCheck(ensureArray);
				return (ensureArray) ? PhpTypeCode.PhpArray : PhpTypeCode.DObject;
			}
            else return EmitEnsureStaticProperty(typeRef, fieldName, null, ensureArray);
		}
Example #7
0
		/// <summary>
		/// Emits IL instructions that ensure that a static field is of <see cref="PhpObject"/> or <see cref="PhpArray"/>
		/// type. Handles the case when field name is unknown at compile time (see <see cref="AST.IndirectStFldUse"/>).
		/// </summary>
        /// <param name="typeRef">The class name (identifier index).</param>
		/// <param name="propertyName">The property name.</param>
		/// <param name="propertyNameExpr">The expression that evaluates to property name.</param>
		/// <param name="ensureArray">Whether to ensure that static field is an array (or an object).</param>
		/// <remarks>
		/// Nothing is expected on the evaluation stack. A <see cref="PhpArray"/> or <see cref="DObject"/> is left on the
		/// evaluation stack.
		/// </remarks>
		public PhpTypeCode EmitEnsureStaticProperty(TypeRef typeRef, VariableName? propertyName,
			Expression propertyNameExpr, bool ensureArray)
		{
			Debug.Assert(propertyName != null ^ propertyNameExpr != null);

			ResolveTypeFlags flags = ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors;

			// LOAD Operators.EnsureStaticFieldIs[Object|Array](<type desc>, <field name>, <type desc>, <context>)
            typeRef.EmitLoadTypeDesc(codeGenerator, flags);

			if (propertyNameExpr != null)
				codeGenerator.EmitBoxing(propertyNameExpr.Emit(codeGenerator));
			else
				codeGenerator.IL.Emit(OpCodes.Ldstr, propertyName.Value.ToString());

			codeGenerator.EmitLoadClassContext();
			codeGenerator.EmitLoadScriptContext();

			if (ensureArray)
				codeGenerator.IL.Emit(OpCodes.Call, Methods.Operators.EnsureStaticPropertyIsArray);
			else
				codeGenerator.IL.Emit(OpCodes.Call, Methods.Operators.EnsureStaticPropertyIsObject);

			EmitErrorCheck(ensureArray);
			return (ensureArray) ? PhpTypeCode.PhpArray : PhpTypeCode.DObject;
		}
Example #8
0
 public IndirectStMtdCall(Text.Span span,
                          TypeRef/*!*/typeRef, CompoundVarUse/*!*/ mtdNameVar,
                          List<ActualParam>/*!*/ parameters, List<TypeRef>/*!*/ genericParams)
     : base(span, mtdNameVar.Span, typeRef, parameters, genericParams)
 {
     this.methodNameVar = mtdNameVar;
 }
Example #9
0
        public StaticMtdCall(Text.Span span, Text.Span methodNamePosition, TypeRef typeRef, List<ActualParam>/*!*/ parameters, List<TypeRef>/*!*/ genericParams)
            : base(span, methodNamePosition, parameters, genericParams)
        {
            Debug.Assert(typeRef != null);

            this.typeRef = typeRef;
        }
Example #10
0
 public IndirectStFldUse(Text.Span span, TypeRef typeRef, Expression/*!*/ fieldNameExpr)
     : base(span, fieldNameExpr.Span, typeRef)
 {
     this.fieldNameExpr = fieldNameExpr;
 }
Example #11
0
        public ClassConstUse(Position position, TypeRef/*!*/typeRef, string/*!*/ name, Position namePosition)
            : base(position)
        {
            Debug.Assert(typeRef != null);
            Debug.Assert(!string.IsNullOrEmpty(name));

            this.typeRef = typeRef;
			this.name = new VariableName(name);
            this.NamePosition = namePosition;
        }
Example #12
0
		internal void EmitInstanceOfOperator(string typeFullName, TypeRef typeNameRef, DType type)
		{
            DebugHelper.AssertNonNull(1, typeFullName, typeNameRef, type);

			// LOAD Operators.InstanceOf(STACK, <type desc>);
			EmitLoadTypeDesc(typeFullName, typeNameRef, type, ResolveTypeFlags.None);
			il.Emit(OpCodes.Call, Methods.Operators.InstanceOf);
		}
Example #13
0
		public TypeOfEx(Text.Span span, TypeRef/*!*/ classNameRef)
            : base(span)
		{
			Debug.Assert(classNameRef != null);

			this.classNameRef = classNameRef;
		}
Example #14
0
 public PseudoClassConstUse(Text.Span span, TypeRef/*!*/typeRef, Types type, Text.Span namePosition)
     : base(span, typeRef, type.ToString().ToLowerInvariant(), namePosition)
 {
     this.consttype = type;
 }
Example #15
0
 public PseudoClassConstUse(Position position, TypeRef/*!*/typeRef, Types type, Position namePosition)
     : base(position, typeRef, type.ToString().ToLowerInvariant(), namePosition)
 {
     this.consttype = type;
 }
Example #16
0
 public DirectStFldUse(Text.Span span, TypeRef typeRef, VariableName propertyName, Text.Span propertyNamePosition)
     : base(span, propertyNamePosition, typeRef)
 {
     this.propertyName = propertyName;
 }
Example #17
0
		private void EmitLoadTypeDesc(string typeFullName, TypeRef typeNameRef, DType type, ResolveTypeFlags flags)
		{
            DebugHelper.AssertNonNull(1, typeFullName, typeNameRef, type);

			if (typeFullName != null)
				EmitLoadTypeDescOperator(typeFullName, null, flags);
			else if (typeNameRef != null)
				typeNameRef.EmitLoadTypeDesc(this, flags);
			else
				type.EmitLoadTypeDesc(this, flags);
		}
Example #18
0
		internal void EmitNewOperator(string typeFullName, TypeRef typeNameRef, DType type, CallSignature callSignature)
		{
            DebugHelper.AssertNonNull(1, typeFullName, typeNameRef, type);

			// prepare stack frame for the constructor:
			callSignature.EmitLoadOnPhpStack(this);

			// CALL Operators.New(<type desc>, <context type desc>, <context>);
			EmitLoadTypeDesc(typeFullName, typeNameRef, type, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors);
			this.EmitLoadClassContext();
			this.EmitLoadScriptContext();
			this.EmitLoadNamingContext();
			il.Emit(OpCodes.Call, Methods.Operators.New);
		}
Example #19
0
		public TypeOfEx(Position position, TypeRef/*!*/ classNameRef)
			: base(position)
		{
			Debug.Assert(classNameRef != null);

			this.classNameRef = classNameRef;
		}
Example #20
0
		internal void EmitTypeOfOperator(string typeFullName, TypeRef typeNameRef, DType type)
		{
            DebugHelper.AssertNonNull(1, typeFullName, typeNameRef, type);

			// LOAD Operators.InstanceOf(STACK, <type desc>, <context type desc>, <script context>);
			EmitLoadTypeDesc(typeFullName, typeNameRef, type, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors);
			il.Emit(OpCodes.Call, Methods.Operators.TypeOf);
		}
Example #21
0
 public IndirectStFldUse(Position position, TypeRef typeRef, Expression/*!*/ fieldNameExpr)
     : base(position, fieldNameExpr.Position, typeRef)
 {
     this.fieldNameExpr = fieldNameExpr;
 }
Example #22
0
        public StaticMtdCall(Position position, TypeRef typeRef, List<ActualParam>/*!*/ parameters, List<TypeRef>/*!*/ genericParams)
            : base(position, parameters, genericParams)
        {
            Debug.Assert(typeRef != null);

            this.typeRef = typeRef;
        }
Example #23
0
 public DirectStFldUse(Position position, TypeRef typeRef, VariableName propertyName, Position propertyNamePosition)
     : base(position, propertyNamePosition, typeRef)
 {
     this.propertyName = propertyName;
 }