EmitGetProperty() private method

private EmitGetProperty ( IPlace holder, PropertySymbol prop ) : TypeSymbol
holder IPlace
prop Pchp.CodeAnalysis.Symbols.PropertySymbol
return TypeSymbol
Exemplo n.º 1
0
        internal void EmitGetCurrent(CodeGenerator cg, BoundReferenceExpression valueVar, BoundReferenceExpression keyVar)
        {
            Debug.Assert(_enumeratorLoc != null);

            var enumeratorPlace = new LocalPlace(_enumeratorLoc);

            if (valueVar is BoundListEx)
            {
                throw new NotImplementedException();    // TODO: list(vars) = enumerator.GetCurrent()
            }

            if (_currentValue != null && _currentKey != null)
            {
                // special PhpArray enumerator

                if (keyVar != null)
                {
                    //cg.EmitSequencePoint(keyVar.PhpSyntax);
                    var keyTarget = keyVar.BindPlace(cg);
                    keyTarget.EmitStorePrepare(cg);
                    keyTarget.EmitStore(cg, cg.EmitGetProperty(enumeratorPlace, _currentKey));
                }

                //cg.EmitSequencePoint(valueVar.PhpSyntax);
                var valueTarget = valueVar.BindPlace(cg);
                valueTarget.EmitStorePrepare(cg);
                valueTarget.EmitStore(cg, cg.EmitGetProperty(enumeratorPlace, _currentValue));
            }
            else
            {
                Debug.Assert(_current != null);

                if (keyVar != null)
                {
                    throw new InvalidOperationException();
                }

                var valueTarget = valueVar.BindPlace(cg);
                valueTarget.EmitStorePrepare(cg);
                var t = cg.EmitGetProperty(enumeratorPlace, _current);  // TOOD: PhpValue.FromClr
                valueTarget.EmitStore(cg, t);
            }
        }