/// <summary>
        /// Returns true if a condition is met.
        /// </summary>
        /// <param name="debugCondition"></param>
        /// <returns></returns>
        private bool CheckIfConditionIsMet(DebugCondition debugCondition)
        {
            switch (debugCondition.Comparer)
            {
            case DebugComparer.Less_than:
                return(GetRequestedValueFromDebugVariable(debugCondition.Variable) < debugCondition.Value);

            case DebugComparer.Equals_or_less_than:
                return(GetRequestedValueFromDebugVariable(debugCondition.Variable) <= debugCondition.Value);

            case DebugComparer.Equals:
                return(Mathf.Approximately(GetRequestedValueFromDebugVariable(debugCondition.Variable), debugCondition.Value));

            case DebugComparer.Equals_or_greater_than:
                return(GetRequestedValueFromDebugVariable(debugCondition.Variable) >= debugCondition.Value);

            case DebugComparer.Greater_than:
                return(GetRequestedValueFromDebugVariable(debugCondition.Variable) > debugCondition.Value);

            default:
                return(false);
            }
        }
		public virtual void VisitAttribute(DebugCondition debugCondition)
		{
			
		}
示例#3
0
 public string VisitAttribute(DebugCondition a)
 {
     throw new NotImplementedException();
 }
			public override void VisitAttribute(DebugCondition debugCondition)
			{
				base.VisitAttribute(debugCondition);
			}
示例#5
0
        DeclarationCondition Condition(IBlockNode parent)
        {
            DeclarationCondition c = null;

            switch (laKind) {
            case Version:
                /*
                 * http://www.dlang.org/version.html#VersionSpecification
                 * VersionCondition:
                 *		version ( IntegerLiteral )
                 *		version ( Identifier )
                 *		version ( unittest )
                 *		version ( assert )
                 */
                Step ();
                if (Expect (OpenParenthesis)) {
                    switch (laKind) {
                    case Unittest:
                        Step ();
                        c = new VersionCondition ("unittest") { IdLocation = t.Location };
                        break;
                    case Assert:
                        Step ();
                        c = new VersionCondition ("assert") { IdLocation = t.Location };
                        break;
                    case Literal:
                        Step ();
                        if (t.LiteralFormat != LiteralFormat.Scalar)
                            SynErr (t.Kind, "Version number must be an integer");
                        else
                            c = new VersionCondition (Convert.ToInt32 (t.LiteralValue)) { IdLocation = t.Location };
                        break;
                    default:
                        if (Expect (Identifier))
                            c = new VersionCondition (t.Value) { IdLocation = t.Location };
                        else if (IsEOF) {
                            c = new VersionCondition (DTokens.IncompleteId);
                            parent.Add (new DVariable{ Attributes = new List<DAttribute>{ c } });
                        }
                        break;
                    }

                    Expect (CloseParenthesis);
                }

                if (c == null)
                    c = new VersionCondition ("");
                break;

            case Debug:
                /*
                 * DebugCondition:
                 *		debug
                 *		debug ( IntegerLiteral )
                 *		debug ( Identifier )
                 */
                Step ();
                if (laKind == OpenParenthesis) {
                    Step ();

                    if (laKind == Literal) {
                        Step ();
                        if (t.LiteralFormat != LiteralFormat.Scalar)
                            SynErr (t.Kind, "Debug level must be an integer");
                        else
                            c = new DebugCondition (Convert.ToInt32 (t.LiteralValue)) { IdLocation = t.Location };
                    } else if (Expect (Identifier))
                        c = new DebugCondition ((string)t.LiteralValue) { IdLocation = t.Location };
                    else if (IsEOF) {
                        c = new DebugCondition (DTokens.IncompleteId);
                        parent.Add (new DVariable{ Attributes = new List<DAttribute>{ c } });
                    }

                    Expect (CloseParenthesis);
                }

                if (c == null)
                    c = new DebugCondition ();
                break;

            case Static:
                /*
                 * StaticIfCondition:
                 *		static if ( AssignExpression )
                 */
                Step ();
                if (Expect (If) && Expect (OpenParenthesis)) {
                    var x = AssignExpression (parent);
                    c = new StaticIfCondition (x);

                    if (!Expect (CloseParenthesis) && IsEOF)
                        parent.Add (new DVariable{ Attributes = new List<DAttribute>{ c } });
                } else
                    c = new StaticIfCondition (null);
                break;

            default:
                throw new Exception("Condition() should only be called if Version/Debug/If is the next token!");
            }

            return c;
        }
示例#6
0
 public AbstractType VisitAttribute(DebugCondition a)
 {
     throw new NotImplementedException();
 }
示例#7
0
        DeclarationCondition Condition(IBlockNode parent)
        {
            DeclarationCondition c = null;

            /*
             * http://www.dlang.org/version.html#VersionSpecification
             * VersionCondition:
             *		version ( IntegerLiteral )
             *		version ( Identifier )
             *		version ( unittest )
             *		version ( assert )
             */
            if (laKind == Version)
            {
                Step();
                if (Expect(OpenParenthesis))
                {
                    TrackerVariables.ExpectingIdentifier = true;
                    if (laKind == Unittest)
                    {
                        Step();
                        c = new VersionCondition("unittest") { IdLocation = t.Location };
                    }
                    else if (laKind == Assert)
                    {
                        Step();
                        c = new VersionCondition("assert") { IdLocation = t.Location };
                    }
                    else if (laKind == Literal)
                    {
                        Step();
                        if (t.LiteralFormat != LiteralFormat.Scalar)
                            SynErr(t.Kind, "Version number must be an integer");
                        else
                            c = new VersionCondition(Convert.ToInt32(t.LiteralValue)) { IdLocation = t.Location };
                    }
                    else if (Expect(Identifier))
                        c = new VersionCondition(t.Value) { IdLocation = t.Location };

                    if (Expect(CloseParenthesis))
                        TrackerVariables.ExpectingIdentifier = false;
                }

                if(c==null)
                    c = new VersionCondition("");
            }

            /*
             * DebugCondition:
             *		debug
             *		debug ( IntegerLiteral )
             *		debug ( Identifier )
             */
            else if (laKind == Debug)
            {
                Step();
                if (laKind == OpenParenthesis)
                {
                    Step();
                    TrackerVariables.ExpectingIdentifier = true;

                    if (laKind == Literal)
                    {
                        Step();
                        if (t.LiteralFormat != LiteralFormat.Scalar)
                            SynErr(t.Kind, "Debug level must be an integer");
                        else
                            c = new DebugCondition(Convert.ToInt32(t.LiteralValue)) { IdLocation = t.Location };
                    }
                    else if (Expect(Identifier))
                        c = new DebugCondition((string)t.LiteralValue) { IdLocation = t.Location };
                    else
                        c = new DebugCondition();

                    if (Expect(CloseParenthesis))
                        TrackerVariables.ExpectingIdentifier = false;
                }
                else
                    c = new DebugCondition();
            }

            /*
             * StaticIfCondition:
             *		static if ( AssignExpression )
             */
            else if (laKind == Static)
            {
                Step ();
                if (Expect (If) && Expect(OpenParenthesis))
                {
                    var x = AssignExpression(parent);
                    c = new StaticIfCondition(x);

                    Expect(CloseParenthesis);
                }
                else
                    c = new StaticIfCondition(null);
            }
            else
                throw new Exception("Condition() should only be called if Version/Debug/If is the next token!");

            LastParsedObject = c;

            return c;
        }
 public override void VisitAttribute(DebugCondition c)
 {
     if (c.DebugIdHash == DTokens.IncompleteIdHash) {
         halt = true;
         // TODO: Perhaps show all globally defined debug IDs
         explicitlyNoCompletion = true;
     }
     else
         base.VisitAttribute (c);
 }
示例#9
0
 public override void VisitAttribute(DebugCondition debugCondition)
 {
     base.VisitAttribute(debugCondition);
 }
示例#10
0
 public ulong VisitAttribute(DebugCondition a)
 {
     return(1000199 + (a.DebugIdHash == 0 ? a.DebugLevel : (ulong)a.DebugIdHash) << 32);
 }
		public override void VisitAttribute (DebugCondition c)
		{
			if (c.DebugIdHash == DTokens.IncompleteIdHash) {
				halt = true;
				prv = new DebugSpecificationCompletionProvider(cdgen);
			}
			else
				base.VisitAttribute (c);
		}
示例#12
0
 public static void LogContext(string value, Color color, UnityEngine.Object context, DebugCondition condition)
 {
     if (MathUtil.ContainsFlag((int)DataHolder.DebugCondition, (int)condition))
     {
         var msg = TextUtil.ApplyRichTextColor(value, color);
         Debug.Log(msg, context);
     }
 }
示例#13
0
 public CompletionItemKind VisitAttribute(DebugCondition a)
 {
     throw new NotImplementedException();
 }