Exemplo n.º 1
0
        bool CheckBreak(Thread th)
        {
            var tuple      = th.GetCurrentCallFrameInfo();
            var file       = tuple.Item1;
            var line       = tuple.Item2;
            var call_level = tuple.Item3;

            bool need_break = false;

            if (line < 1)
            {
                return(false);// some code line is set -1 or 0(F**k ME)
            }
            else if (_break_mode == BreakMode.StopForOnce)
            {
                _break_mode = BreakMode.Point;
                need_break  = true;// must break
            }
            else if (IsSameWithCurrentBreak(file, line, call_level))
            {
                return(false);// one line can have several code
            }
            else if (HitBreakPoint(file, line, call_level))
            {
                need_break = true;// hit BreakPoint
            }
            else
            {
                // other situation
                switch (_break_mode)
                {
                case BreakMode.StepIn:
                    need_break = true;
                    break;

                case BreakMode.StepOut:
                    need_break = call_level < _cur_call_level;
                    break;

                case BreakMode.StepOver:
                    need_break = call_level <= _cur_call_level;
                    break;
                }
            }

            if (need_break)
            {
                _cur_file       = file;
                _cur_line       = line;
                _cur_call_level = call_level;
            }
            else
            {
                // do not need do any thing
                // so can break many times in for
                //_cur_line = -1;
                //_cur_call_level = -1;// call level can not change, or step over will fail
            }
            return(need_break);
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            if (value.Is("auto"))
                _mode = BreakMode.Auto;
            else if (value.Is("avoid"))
                _mode = BreakMode.Avoid;
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            BreakMode mode;

            if (value is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode))
                _mode = mode;
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var mode = value.ToBreakInsideMode();

            if (mode.HasValue)
            {
                _mode = mode.Value;
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        protected override Boolean IsValid(CSSValue value)
        {
            BreakMode mode;

            if (value is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode))
            {
                _mode = mode;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
        protected override Boolean IsValid(CSSValue value)
        {
            if (value.Is("auto"))
            {
                _mode = BreakMode.Auto;
            }
            else if (value.Is("avoid"))
            {
                _mode = BreakMode.Avoid;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            if (value.Is(Keywords.Auto))
            {
                _mode = BreakMode.Auto;
            }
            else if (value.Is(Keywords.Avoid))
            {
                _mode = BreakMode.Avoid;
            }
            else
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            if (value is CSSIdentifierValue)
            {
                var ident = (CSSIdentifierValue)value;
                BreakMode mode;

                if (modes.TryGetValue(ident.Value, out mode))
                {
                    _mode = mode;
                    return true;
                }
            }
            else if (value == CSSValue.Inherit)
                return true;

            return false;
        }
Exemplo n.º 9
0
        protected override Boolean IsValid(CSSValue value)
        {
            if (value is CSSIdentifierValue)
            {
                var       ident = (CSSIdentifierValue)value;
                BreakMode mode;

                if (modes.TryGetValue(ident.Value, out mode))
                {
                    _mode = mode;
                    return(true);
                }
            }
            else if (value == CSSValue.Inherit)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
 public void TryTickBreakPoint(Tick tick)
 {
     if (breakMode != BreakMode.Tick)
     {
         return;
     }
     if (breakType == BreakType.Time)
     {
         if (tick.Time >= time)
         {
             breakMode = BreakMode.None;
             BreakOnATick();
         }
     }
     if (breakType == BreakType.Count)
     {
         if (strategy.Data.Ticks.BarCount == count)
         {
             breakMode = BreakMode.None;
             BreakOnATick();
         }
     }
 }
Exemplo n.º 11
0
 public void TryBarBreakPoint(Bars bars)
 {
     if (breakMode != BreakMode.Bar)
     {
         return;
     }
     if (breakType == BreakType.Count)
     {
         if (bars.BarCount == count)
         {
             breakMode = BreakMode.None;
             BreakOnABar();
         }
     }
     if (breakType == BreakType.Time)
     {
         if (bars.Time[0] >= time)
         {
             breakMode = BreakMode.None;
             BreakOnABar();
         }
     }
 }
Exemplo n.º 12
0
        private void Format(DocumentationCommentTriviaSyntax node, CancellationToken cancellationToken = default)
        {
            // Only single line comments are supported.
            if (node.Kind() != SyntaxKind.SingleLineDocumentationCommentTrivia)
            {
                return;
            }

            _text = node.SyntaxTree.GetText(cancellationToken);

            _column         = GetInitialColumn(node.GetFirstToken(), _tabSize, cancellationToken);
            _exteriorIndent = _column;

            _interiorLinePrefix = GetInteriorLinePrefix(node);
            _interiorIndent     = 0;

            _breakStart = node.FullSpan.Start;
            _wordStart  = _breakStart;
            _wordEnd    = _wordStart;
            _breakMode  = BreakMode.FirstBreak;

            FormatXmlNodes(node.Content);
            BreakFinal(node.EndOfComment);
        }
Exemplo n.º 13
0
 public void SetState(BreakMode mode)
 {
     _mode = mode;
 }
Exemplo n.º 14
0
 internal override void Reset()
 {
     _mode = BreakMode.Auto;
 }
Exemplo n.º 15
0
 protected CSSBreakProperty(String name)
     : base(name)
 {
     _mode      = BreakMode.Auto;
     _inherited = false;
 }
Exemplo n.º 16
0
 public static void SetTickBreakPoint(int value)
 {
     breakMode = BreakMode.Tick;
     breakType = BreakType.Count;
     count     = value;
 }
 internal CSSPageBreakInsideProperty()
     : base(PropertyNames.PageBreakInside)
 {
     _mode      = BreakMode.Auto;
     _inherited = false;
 }
Exemplo n.º 18
0
        public void RunIntCode(BreakMode breakMode = BreakMode.Output)
        {
            while (!IsHalted)
            {
                ExecutedInstructions++;
                var instruction = _intCode[_instructionPointer].ToString().PadLeft(5, '0');
                var opCode      = (OpCode)(GetNumber(instruction[3]) * 10 + GetNumber(instruction[4]));
                var modeParam1  = (Mode)GetNumber(instruction[2]);
                var modeParam2  = (Mode)GetNumber(instruction[1]);
                var modeParam3  = (Mode)GetNumber(instruction[0]);

                switch (opCode)
                {
                case OpCode.Sum:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    var param2Value = GetParamValue(modeParam2, _instructionPointer + 2);
                    var value       = param1Value + param2Value;
                    WriteMem(modeParam3, _instructionPointer + 3, value);
                    _instructionPointer += 4;
                    break;
                }

                case OpCode.Multiply:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    var param2Value = GetParamValue(modeParam2, _instructionPointer + 2);
                    var value       = param1Value * param2Value;
                    WriteMem(modeParam3, _instructionPointer + 3, value);
                    _instructionPointer += 4;
                    break;
                }

                case OpCode.Input:
                {
                    if (breakMode == BreakMode.Input && Inputs.Count == 0)
                    {
                        return;
                    }

                    WriteMem(modeParam1, _instructionPointer + 1, Inputs.Dequeue());
                    _instructionPointer += 2;
                    break;
                }

                case OpCode.Output:
                {
                    var param2Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    Output.Enqueue(param2Value);
                    _instructionPointer += 2;

                    if (breakMode == BreakMode.Output)
                    {
                        return;
                    }
                    break;
                }

                case OpCode.JumpIfTrue:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    var param2Value = GetParamValue(modeParam2, _instructionPointer + 2);
                    _instructionPointer = param1Value != 0 ? param2Value : _instructionPointer + 3;
                    break;
                }

                case OpCode.JumpIfFalse:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    var param2Value = GetParamValue(modeParam2, _instructionPointer + 2);
                    _instructionPointer = param1Value == 0 ? param2Value : _instructionPointer + 3;
                    break;
                }

                case OpCode.LessThan:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    var param2Value = GetParamValue(modeParam2, _instructionPointer + 2);
                    WriteMem(modeParam3, _instructionPointer + 3, param1Value < param2Value ? 1 : 0);
                    _instructionPointer += 4;
                    break;
                }

                case OpCode.Equals:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    var param2Value = GetParamValue(modeParam2, _instructionPointer + 2);
                    WriteMem(modeParam3, _instructionPointer + 3, param1Value == param2Value ? 1 : 0);
                    _instructionPointer += 4;
                    break;
                }

                case OpCode.RelativeBaseOffset:
                {
                    var param1Value = GetParamValue(modeParam1, _instructionPointer + 1);
                    _relativeBase       += param1Value;
                    _instructionPointer += 2;
                    break;
                }

                case OpCode.Halt:
                    IsHalted = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException($"!Unknown OpCode {opCode}!");
                }
            }
        }
Exemplo n.º 19
0
 internal CSSPageBreakProperty(String name)
     : base(name)
 {
     _mode      = BreakMode.Auto;
     _inherited = false;
 }
Exemplo n.º 20
0
 public void SetBreakMode(BreakMode mode)
 {
     _break_mode = mode;
 }
Exemplo n.º 21
0
 public static void SetBarBreakPoint(int value)
 {
     breakMode = BreakMode.Bar;
     breakType = BreakType.Count;
     count     = value;
 }
 internal CSSPageBreakInsideProperty()
     : base(PropertyNames.PageBreakInside)
 {
     _mode = BreakMode.Auto;
     _inherited = false;
 }
Exemplo n.º 23
0
 internal override void Reset()
 {
     _mode = Default;
 }
Exemplo n.º 24
0
 public BreakValue(BreakMode mode, string toActionId = null)
 {
     Mode = mode; GotoActionID = toActionId;
 }
Exemplo n.º 25
0
 internal CSSPageBreakProperty(String name)
     : base(name)
 {
     _mode = BreakMode.Auto;
     _inherited = false;
 }
Exemplo n.º 26
0
        private void Break(BreakMode nextBreakMode = BreakMode.None)
        {
            Debug.Assert(_breakStart <= _wordStart);
            Debug.Assert(_wordStart <= _wordEnd);

            if (_preserve > 0)
            {
                nextBreakMode |= BreakMode.Preserve;
            }

            // Defer break if there has been no word since the last break.
            if (_wordStart == _wordEnd)
            {
                _breakMode |= nextBreakMode;
                return;
            }

            Debug.Assert(_breakStart <= _wordStart);
            Debug.Assert(_wordStart <= _wordEnd);

            // Dequeue changes applicable to the word.
            while (_queuedChanges.Count > 0)
            {
                var change = _queuedChanges.Peek();
                if (change.Span.Start >= _wordEnd)
                {
                    break;
                }
                Debug.Assert(change.Span.Start >= _wordStart);
                Debug.Assert(change.Span.End <= _wordEnd);
                _wordChanges.Add(_queuedChanges.Dequeue());
            }

            // Calculate the length of the word.
            int wordNewTextLength = _wordEnd - _wordStart;

            foreach (var change in _wordChanges)
            {
                wordNewTextLength += change.NewText.Length - change.Span.Length;
            }

            // Construct the break.
            string breakNewText = BuildBreakText(wordNewTextLength);

            // Recompute column after the break.
            _column = GetColumnFromText(breakNewText, _column, _tabSize);

            // Add the break change.
            var    breakSpan = TextSpan.FromBounds(_breakStart, _wordStart);
            string breakText = GetText(breakSpan);

            if (breakNewText != breakText)
            {
                _changes.Add(new TextChange(breakSpan, breakNewText));
            }

            // Recompute column after the word.
            _column = GetColumnFromSourceTextWithChanges(_text, TextSpan.FromBounds(_wordStart, _wordEnd), _wordChanges, _column, _tabSize);

            // Add the word changes.
            _changes.AddRange(_wordChanges);
            _wordChanges.Clear();

            // Prepare for next word.
            _           = _breakText.Clear();
            _breakStart = _wordEnd;
            _wordStart  = _breakStart;
            _breakMode  = nextBreakMode;
        }
Exemplo n.º 27
0
 public static void SetTickBreakPoint(TimeStamp value)
 {
     breakMode = BreakMode.Tick;
     breakType = BreakType.Time;
     time      = value;
 }