示例#1
0
        internal override void EmitUnset(CodeGenerator codeGenerator)
        {
            ChainBuilder chain = codeGenerator.ChainBuilder;

            // Template: "unset(x[y])"  Operators.UnsetItem(object obj,object index)

            // Case 3: a_[x]_[x] never reached
            Debug.Assert(chain.IsArrayItem == false);
            // Case 4,5 never reached
            // 4: a[x]->...
            // 5: ...->a[]->...
            Debug.Assert(chain.IsMember == false);

            chain.QuietRead = true;

            // 1, 2, 6, 7
            if (this.isMemberOf != null)
            {
                // 6 , 7: ...->a[]_[]_ , ...->a_[]_
                chain.Create();
                chain.Begin();
                chain.Lengthen();                 // for hop over ->
                isMemberOf.Emit(codeGenerator);
                chain.IsArrayItem  = true;
                chain.IsLastMember = false;
                chain.EmitUnsetItem(array, index);
                chain.IsArrayItem = false;
                chain.End();
                return;
            }
            // 1, 2
            if (array is ItemUse || array is DirectStFldUse || array is IndirectStFldUse /* ??? */)
            {
                // 2: a[]_[]_
                chain.Create();
                chain.Begin();
                chain.IsArrayItem  = true;
                chain.IsLastMember = true;
                chain.EmitUnsetItem(array, index);
                chain.IsArrayItem = false;
                chain.End();
                return;
            }
            // 1: a_[x]_
            chain.IsArrayItem  = true;
            chain.IsLastMember = true;
            chain.EmitUnsetItem(array, index);
            chain.IsArrayItem = false;
        }