Emit_PhpAlias_GetValueRef() public méthode

Emits load of PhpAlias.Value, expecting PhpAlias on top of evaluation stack, pushing PhpValue on top of the stack.
public Emit_PhpAlias_GetValueRef ( ) : void
Résultat void
Exemple #1
0
        internal override TypeSymbol Emit(CodeGenerator cg)
        {
            Debug.Assert(Access.IsRead || Access.IsNone);

            var type = cg.Emit(Operand);

            //
            if (Access.IsNone)
            {
                cg.EmitPop(type);
                return cg.CoreTypes.Void;
            }

            // dereference
            if (type == cg.CoreTypes.PhpAlias)
            {
                // <alias>.Value.AsObject()
                cg.Emit_PhpAlias_GetValueRef();
                type = cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.AsObject);
            }

            // PhpValue -> object
            if (type == cg.CoreTypes.PhpValue)
            {
                // Template: Operators.AsObject(value) is T
                type = cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Operators.AsObject_PhpValue);
            }

            //
            if (AsType.ResolvedType != null)
            {
                if (type.IsReferenceType && type != cg.CoreTypes.PhpArray && type != cg.CoreTypes.PhpString)
                {
                    // Template: value is T : object
                    cg.Builder.EmitOpCode(ILOpCode.Isinst);
                    cg.EmitSymbolToken(AsType.ResolvedType, null);

                    // object != null
                    cg.Builder.EmitNullConstant(); // .ldnull
                    cg.Builder.EmitOpCode(ILOpCode.Cgt_un); // .cgt.un
                }
                else
                {
                    cg.EmitPop(type);   // Operand is never an object instance

                    // FALSE
                    cg.Builder.EmitBoolConstant(false);
                }

                //
                return cg.CoreTypes.Boolean;
            }
            else
            {
                AsType.EmitLoadTypeInfo(cg, false);

                // Template: Operators.IsInstanceOf(value, type);
                return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Operators.IsInstanceOf_Object_PhpTypeInfo);
            }

            throw new NotImplementedException();
        }