Example #1
0
		internal override void EmitStoreRefAssign(CodeGenerator codeGenerator)
		{
			ILEmitter il = codeGenerator.IL;

			if (varName.IsThisVariableName)
			{
				// emit error throwing code
				il.Emit(OpCodes.Pop);
				codeGenerator.EmitPhpException(Methods.PhpException.CannotReassignThis);
			}
			else if (codeGenerator.VariableIsAutoGlobal(varName))
			{
				// Check if the variable is auto-global
				codeGenerator.EmitAutoGlobalStoreRefAssign(varName);
			}
			else if (codeGenerator.OptimizedLocals)
			{
				VariablesTable.Entry entry = codeGenerator.CurrentVariablesTable[varName];
				entry.Variable.EmitStore(il);
			}
			else
			{
				// call instance IDictionary.set_Item(object, object)
				// OBSOLETE: il.Emit(OpCodes.Callvirt, Methods.IDictionary_SetItem);
				il.Emit(OpCodes.Call, Methods.Operators.SetVariableRef);
			}
		}