public FundamentalVariable(string name, StackFrame stackFrame, TargetFundamentalObject obj)
		{
			this.name = name;
			this.stackFrame = stackFrame;
			this.obj = obj;
		}
Exemplo n.º 2
0
        public static TargetObject ExplicitFundamentalConversion(ScriptingContext context,
									  TargetFundamentalObject obj,
									  TargetFundamentalType type)
        {
            TargetObject retval = ImplicitFundamentalConversion (context, obj, type);
            if (retval != null)
                return retval;

            FundamentalKind tkind = type.FundamentalKind;

            try {
                object value = obj.GetObject (context.CurrentThread);
                object new_value = ImplicitFundamentalConversion (value, tkind);
                if (new_value == null)
                    return null;

                return type.Language.CreateInstance (context.CurrentThread, new_value);
            } catch {
                return null;
            }
        }
Exemplo n.º 3
0
        static TargetObject ImplicitFundamentalConversion(ScriptingContext context,
								   TargetFundamentalObject obj,
								   TargetFundamentalType type)
        {
            FundamentalKind skind = obj.Type.FundamentalKind;
            FundamentalKind tkind = type.FundamentalKind;

            if (!ImplicitFundamentalConversionExists (skind, tkind))
                return null;

            object value = obj.GetObject (context.CurrentThread);

            object new_value = ImplicitFundamentalConversion (value, tkind);
            if (new_value == null)
                return null;

            return type.Language.CreateInstance (context.CurrentThread, new_value);
        }
Exemplo n.º 4
0
        bool BreakEventCheck(MD.TargetEventArgs args)
        {
            MD.StackFrame frame = args.Frame;
            if (!(args.Data is int))
            {
                return(true);
            }

            int eventHandle = (int)args.Data;

            DL.BreakEvent be;
            if (!events.TryGetValue(eventHandle, out be))
            {
                return(true);
            }

            // Check hit count
            if (be.HitCount > 0)
            {
                be.HitCount--;
                DispatchEvent(delegate {
                    NotifyBreakEventUpdate(eventHandle, be.HitCount, null);
                });
                return(false);
            }

            MdbEvaluationContext ctx = new MdbEvaluationContext(frame.Thread, frame, null, SessionOptions.EvaluationOptions);

            DL.Breakpoint bp = be as DL.Breakpoint;
            if (bp != null && !string.IsNullOrEmpty(bp.ConditionExpression))
            {
                ML.TargetObject val = EvaluateExp(ctx, bp.ConditionExpression);
                if (val == null)
                {
                    return(false);
                }
                if (bp.BreakIfConditionChanges)
                {
                    string current = evaluator.TargetObjectToExpression(ctx, val).Value;
                    string last;
                    bool   found = lastConditionValue.TryGetValue(eventHandle, out last);
                    lastConditionValue [eventHandle] = current;
                    if (!found || last == current)
                    {
                        return(false);
                    }
                }
                else
                {
                    ML.TargetFundamentalObject fob = val as ML.TargetFundamentalObject;
                    if (fob == null)
                    {
                        return(false);
                    }
                    object ob = fob.GetObject(frame.Thread);
                    if (!(ob is bool) || !(bool)ob)
                    {
                        return(false);
                    }
                }
            }

            switch (be.HitAction)
            {
            case HitAction.Break:
                return(true);

            case HitAction.CustomAction:
                return(controller.OnCustomBreakpointAction(be.CustomActionId, eventHandle));

            case HitAction.PrintExpression:
                if (string.IsNullOrEmpty(be.TraceExpression) || frame == null)
                {
                    return(false);
                }
                ML.TargetObject val = EvaluateExp(ctx, be.TraceExpression);
                if (val != null)
                {
                    string str = evaluator.TargetObjectToString(ctx, val);
                    DispatchEvent(delegate {
                        NotifyBreakEventUpdate(eventHandle, -1, str);
                    });
                }
                return(false);
            }
            return(false);
        }