public SoftEvaluationContext(SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options)
            : base(options)
        {
            Frame = frame;
            Thread = frame.Thread;
            Domain = frame.Domain;

            string method = frame.Method.Name;
            if (frame.Method.DeclaringType != null)
                method = frame.Method.DeclaringType.FullName + "." + method;
            var location = new DC.SourceLocation (method, frame.FileName, frame.LineNumber, frame.ColumnNumber, frame.EndLineNumber, frame.EndColumnNumber, frame.Location.SourceFileHash);
            string language;

            if (frame.Method != null) {
                language = frame.IsNativeTransition ? "Transition" : "Managed";
            } else {
                language = "Native";
            }

            Evaluator = session.GetEvaluator (new DC.StackFrame (frame.ILOffset, location, language, session.IsExternalCode (frame), true));
            Adapter = session.Adaptor;
            this.session = session;
            stackVersion = session.StackVersion;
            sourceAvailable = !string.IsNullOrEmpty (frame.FileName) && System.IO.File.Exists (frame.FileName);
        }
		public VariableReference (EvaluationContext ctx, CorValRef var, string name, DC.ObjectValueFlags flags)
			: base (ctx)
		{
			this.flags = flags;
			this.var = var;
			this.name = name;
		}
		public VariableReference (EvaluationContext ctx, TargetVariable var, DC.ObjectValueFlags flags): base (ctx)
		{
			this.flags = flags;
			this.var = var;
			if (!var.CanWrite)
				flags |= DC.ObjectValueFlags.ReadOnly;
		}
		internal CorEvaluationContext (CorDebuggerSession session, CorBacktrace backtrace, int index, DC.EvaluationOptions ops): base (ops)
		{
			Session = session;
			base.Adapter = session.ObjectAdapter;
			frameIndex = index;
			this.backtrace = backtrace;
			evalTimestamp = CorDebuggerSession.EvaluationTimestamp;
			Evaluator = session.GetEvaluator (CorBacktrace.CreateFrame (session, Frame));
		}
		public SoftEvaluationContext (SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options): base (options)
		{
			Frame = frame;
			Thread = frame.Thread;

			string method = frame.Method.Name;
			if (frame.Method.DeclaringType != null)
				method = frame.Method.DeclaringType.FullName + "." + method;
			var location = new DC.SourceLocation (method, frame.FileName, frame.LineNumber);
			var lang = frame.Method != null? "Managed" : "Native";
			
			Evaluator = session.GetEvaluator (new DC.StackFrame (frame.ILOffset, location, lang, session.IsExternalCode (frame), true));
			Adapter = session.Adaptor;
			this.session = session;
			this.stackVersion = session.StackVersion;
			sourceAvailable = !string.IsNullOrEmpty (frame.FileName) && System.IO.File.Exists (frame.FileName);
		}
		public object UpdateBreakEvent (object handle, DL.BreakEvent bp)
		{
			events [(int)handle] = bp;
			return handle;
		}
		public int InsertBreakEvent (DL.BreakEvent be, bool enable)
		{
			CancelRuntimeInvokes ();
			DL.Breakpoint bp = be as DL.Breakpoint;
			MD.Event ev = null;
			
			if (bp != null) {
				MD.SourceLocation location = new MD.SourceLocation (bp.FileName, bp.Line);
				MD.SourceBreakpoint sbp = new MD.SourceBreakpoint (session, ThreadGroup.Global, location);
				mdbAdaptor.InitializeBreakpoint (sbp);
				session.AddEvent (sbp);
				ev = sbp;
			}
			else if (be is Catchpoint) {
				lock (pendingCatchpoints) {
					Catchpoint cp = (Catchpoint) be;
					ML.TargetType exc = null;
					if (process != null) {
						foreach (Module mod in process.Modules) {
							exc = mod.Language.LookupType (cp.ExceptionName);
							if (exc != null)
								break;
						}
					}
					if (exc != null)
						ev = session.InsertExceptionCatchPoint (process.MainThread, ThreadGroup.Global, exc);
					else {
						pendingCatchpoints.Add (cp);
						return -1;
					}
				}
			}
			
			ev.IsEnabled = enable;
			
			if (!initializing) {
				lock (debugger) {
					mdbAdaptor.ActivateEvent (ev);
				}
			}
						                    
			if (bp != null && !running && !initializing && activeThread.CurrentFrame != null && !string.IsNullOrEmpty (bp.ConditionExpression) && bp.BreakIfConditionChanges) {
				// Initial expression evaluation
				MdbEvaluationContext ctx = new MdbEvaluationContext (activeThread, activeThread.CurrentFrame, null, SessionOptions.EvaluationOptions);
				ML.TargetObject ob = EvaluateExp (ctx, bp.ConditionExpression);
				if (ob != null)
					lastConditionValue [ev.Index] = evaluator.TargetObjectToExpression (ctx, ob).Value;
			}
			
			events [ev.Index] = be;
			return ev.Index;
		}