Inheritance: HoistedVariable
Exemple #1
0
		public void CaptureLocalVariable (ResolveContext ec, LocalVariable localVariable)
		{
			if (this is StateMachine) {
				if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock)
					ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			} else {
				ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			}

			var hoisted = localVariable.HoistedVariant;
			if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) {
				// TODO: It's too late the field is defined in HoistedLocalVariable ctor
				hoisted.Storey.hoisted_locals.Remove (hoisted);
				hoisted = null;
			}

			if (hoisted == null) {
				hoisted = new HoistedLocalVariable (this, localVariable, GetVariableMangledName (localVariable));
				localVariable.HoistedVariant = hoisted;

				if (hoisted_locals == null)
					hoisted_locals = new List<HoistedVariable> ();

				hoisted_locals.Add (hoisted);
			}

			if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine))
				hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
		}
Exemple #2
0
		public void CaptureLocalVariable (ResolveContext ec, LocalVariable localVariable)
		{
			if (this is StateMachine) {
				if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock)
					ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			} else {
				ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			}

			var hoisted = localVariable.HoistedVariant;
			if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) {
				//
				// Variable is already hoisted but we need it in storey which can be shared
				//
				hoisted.Storey.hoisted_locals.Remove (hoisted);
				hoisted.Storey.Members.Remove (hoisted.Field);
				hoisted = null;
			}

			if (hoisted == null) {
				hoisted = new HoistedLocalVariable (this, localVariable, GetVariableMangledName (localVariable));
				localVariable.HoistedVariant = hoisted;

				if (hoisted_locals == null)
					hoisted_locals = new List<HoistedVariable> ();

				hoisted_locals.Add (hoisted);
			}

			if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine))
				hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
		}
Exemple #3
0
		public void CaptureLocalVariable (ResolveContext ec, LocalVariable localVariable)
		{
			if (this is StateMachine) {
				if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock)
					ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			} else {
				ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			}

			var hoisted = localVariable.HoistedVariant;
			if (hoisted == null) {
				hoisted = new HoistedLocalVariable (this, localVariable, GetVariableMangledName (localVariable));
				localVariable.HoistedVariant = hoisted;

				if (hoisted_locals == null)
					hoisted_locals = new List<HoistedVariable> ();

				hoisted_locals.Add (hoisted);
			}

			if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit)
				hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
		}
Exemple #4
0
		public void CaptureLocalVariable (ResolveContext ec, LocalVariable local_info)
		{
			ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			if (ec.CurrentBlock.Explicit != local_info.Block.Explicit)
				AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);

			if (local_info.HoistedVariant != null)
				return;

			HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info));
			local_info.HoistedVariant = var;

			if (hoisted_locals == null)
				hoisted_locals = new List<HoistedVariable> ();

			hoisted_locals.Add (var);
		}
Exemple #5
0
		public void CaptureLocalVariable (EmitContext ec, LocalInfo local_info)
		{
			if (local_info.HoistedVariableReference != null)
				return;

			HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info));
			local_info.HoistedVariableReference = var;
			has_hoisted_variable = true;

			if (hoisted_locals == null)
				hoisted_locals = new ArrayList ();

			hoisted_locals.Add (var);
		}