crashanalysercmd/PerfToolsSharedLibraries/Engine/SymBuildParsingLib/Parser/Framework/Nodes/SymNodeConditionalExpression.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 using System;
       
    19 using SymBuildParsingLib.Tree;
       
    20 using SymBuildParsingLib.Token;
       
    21 using SymbianTree;
       
    22 
       
    23 #region Example layout
       
    24 //
       
    25 // SymNodeConditionalExpression
       
    26 //     |
       
    27 //     +----- [if] SymNodeCondition [neg]
       
    28 //     +---------- { 
       
    29 //     +---------- do something
       
    30 //     +---------- [if] SymNodeCondition [pos, but inherits neg]
       
    31 //     +--------------- { 
       
    32 //     +--------------- do something else
       
    33 //     +--------------- } 
       
    34 //     +---------- } 
       
    35 //     |
       
    36 //     +----- [else if] SymNodeCondition [neg]
       
    37 //     +---------- { 
       
    38 //     +---------- do something else
       
    39 //     +---------- } 
       
    40 //     |
       
    41 //     +----- [else if] SymNodeCondition [pos]
       
    42 //     +---------- { 
       
    43 //     +---------- do something else
       
    44 //     +---------- } 
       
    45 //     |
       
    46 //     +----- [else] SymNodeCondition [neg]
       
    47 //     +---------- { 
       
    48 //     +---------- do something else
       
    49 //     +---------- } 
       
    50 //
       
    51 #endregion
       
    52 
       
    53 namespace SymBuildParsingLib.Parser.Framework.Nodes
       
    54 {
       
    55 	public class SymNodeConditionalExpression : SymNodeToken
       
    56 	{
       
    57 		#region Constructors & destructor
       
    58 		public SymNodeConditionalExpression( SymToken aType )
       
    59 			: base( aType )
       
    60 		{
       
    61 		}
       
    62 		#endregion
       
    63 
       
    64 		#region Properties
       
    65 		public bool InheritedValue
       
    66 		{
       
    67 			get { return iInheritedValue; }
       
    68 			set { iInheritedValue = value; }
       
    69 		}
       
    70 
       
    71 		public bool HasPositiveBranch
       
    72 		{
       
    73 			get
       
    74 			{
       
    75 				bool found = ( PositiveBranch != null );
       
    76 				return found;
       
    77 			}
       
    78 		}
       
    79 
       
    80 		public SymNodeCondition PositiveBranch
       
    81 		{
       
    82 			get
       
    83 			{
       
    84 				SymNodeCondition found = null;
       
    85 				//
       
    86 				foreach( SymNode c in this )
       
    87 				{
       
    88 					if	( c is SymNodeCondition )
       
    89 					{
       
    90 						SymNodeCondition cond = (SymNodeCondition) c;
       
    91 						if	( cond.IsEvaluated && cond.EvaluationResult == true )
       
    92 						{
       
    93 							found = cond;
       
    94 							break;
       
    95 						}
       
    96 					}
       
    97 				}
       
    98 				//
       
    99 				return found;
       
   100 			}
       
   101 		}
       
   102 
       
   103 		public bool HasCondition
       
   104 		{
       
   105 			get
       
   106 			{
       
   107 				int count = ChildCountByType( typeof(SymNodeCondition) );
       
   108 				return count > 0;
       
   109 			}
       
   110 		}
       
   111 
       
   112 		public SymNodeCondition CurrentCondition
       
   113 		{
       
   114 			get
       
   115 			{
       
   116 				SymNodeCondition ret = (SymNodeCondition) LastChild;
       
   117 				return ret;
       
   118 			}
       
   119 		}
       
   120 		#endregion
       
   121 
       
   122 		#region Data members
       
   123 		private bool iInheritedValue;
       
   124 		#endregion
       
   125 	}
       
   126 }