private StyleVariableResolver.Result ResolveVariable(string variableName)
        {
            StyleVariable styleVariable;
            bool          flag = !this.variableContext.TryFindVariable(variableName, out styleVariable);

            StyleVariableResolver.Result result;
            if (flag)
            {
                result = StyleVariableResolver.Result.NotFound;
            }
            else
            {
                bool flag2 = this.m_ResolvedVarStack.Contains(styleVariable.name);
                if (flag2)
                {
                    result = StyleVariableResolver.Result.NotFound;
                }
                else
                {
                    this.m_ResolvedVarStack.Push(styleVariable.name);
                    StyleVariableResolver.Result result2 = StyleVariableResolver.Result.Valid;
                    int num = 0;
                    while (num < styleVariable.handles.Length && result2 == StyleVariableResolver.Result.Valid)
                    {
                        StyleValueHandle handle = styleVariable.handles[num];
                        bool             flag3  = handle.IsVarFunction();
                        if (flag3)
                        {
                            int    num2;
                            string variableName2;
                            StyleVariableResolver.ParseVarFunction(styleVariable.sheet, styleVariable.handles, ref num, out num2, out variableName2);
                            result2 = this.ResolveVariable(variableName2);
                        }
                        else
                        {
                            StylePropertyValue spv = new StylePropertyValue
                            {
                                sheet  = styleVariable.sheet,
                                handle = handle
                            };
                            result2 = this.ValidateResolve(spv);
                        }
                        num++;
                    }
                    this.m_ResolvedVarStack.Pop();
                    result = result2;
                }
            }
            return(result);
        }
 private StyleVariableResolver.Result ResolveFallback(ref int index)
 {
     StyleVariableResolver.Result result = StyleVariableResolver.Result.Valid;
     while (index < this.m_Handles.Length && result == StyleVariableResolver.Result.Valid)
     {
         StyleValueHandle handle = this.m_Handles[index];
         bool             flag   = handle.IsVarFunction();
         if (flag)
         {
             int    num;
             string variableName;
             StyleVariableResolver.ParseVarFunction(this.m_Sheet, this.m_Handles, ref index, out num, out variableName);
             result = this.ResolveVariable(variableName);
             bool flag2 = result == StyleVariableResolver.Result.NotFound;
             if (flag2)
             {
                 bool flag3 = num > 1;
                 if (flag3)
                 {
                     StyleValueHandle[] arg_6D_0 = this.m_Handles;
                     int num2 = index + 1;
                     index  = num2;
                     handle = arg_6D_0[num2];
                     Debug.Assert(handle.valueType == StyleValueType.FunctionSeparator, string.Format("Unexpected value type {0} in var function", handle.valueType));
                     bool flag4 = handle.valueType == StyleValueType.FunctionSeparator && index + 1 < this.m_Handles.Length;
                     if (flag4)
                     {
                         index++;
                         result = this.ResolveFallback(ref index);
                     }
                 }
             }
         }
         else
         {
             StylePropertyValue spv = new StylePropertyValue
             {
                 sheet  = this.m_Sheet,
                 handle = handle
             };
             result = this.ValidateResolve(spv);
         }
         index++;
     }
     return(result);
 }
예제 #3
0
        private void SetupReferences()
        {
            bool flag = this.complexSelectors == null || this.rules == null;

            if (!flag)
            {
                StyleRule[] rules = this.rules;
                for (int i = 0; i < rules.Length; i++)
                {
                    StyleRule       styleRule  = rules[i];
                    StyleProperty[] properties = styleRule.properties;
                    for (int j = 0; j < properties.Length; j++)
                    {
                        StyleProperty styleProperty = properties[j];
                        bool          flag2         = StyleSheet.CustomStartsWith(styleProperty.name, StyleSheet.kCustomPropertyMarker);
                        if (flag2)
                        {
                            styleRule.customPropertiesCount++;
                            styleProperty.isCustomProperty = true;
                        }
                        StyleValueHandle[] values = styleProperty.values;
                        for (int k = 0; k < values.Length; k++)
                        {
                            StyleValueHandle handle = values[k];
                            bool             flag3  = handle.IsVarFunction();
                            if (flag3)
                            {
                                styleProperty.requireVariableResolve = true;
                                break;
                            }
                        }
                    }
                }
                int l   = 0;
                int num = this.complexSelectors.Length;
                while (l < num)
                {
                    this.complexSelectors[l].CachePseudoStateMasks();
                    l++;
                }
                this.orderedClassSelectors = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal);
                this.orderedNameSelectors  = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal);
                this.orderedTypeSelectors  = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal);
                int m = 0;
                while (m < this.complexSelectors.Length)
                {
                    StyleComplexSelector styleComplexSelector = this.complexSelectors[m];
                    bool flag4 = styleComplexSelector.ruleIndex < this.rules.Length;
                    if (flag4)
                    {
                        styleComplexSelector.rule = this.rules[styleComplexSelector.ruleIndex];
                    }
                    styleComplexSelector.orderInStyleSheet = m;
                    StyleSelector     styleSelector     = styleComplexSelector.selectors[styleComplexSelector.selectors.Length - 1];
                    StyleSelectorPart styleSelectorPart = styleSelector.parts[0];
                    string            key = styleSelectorPart.value;
                    Dictionary <string, StyleComplexSelector> dictionary = null;
                    switch (styleSelectorPart.type)
                    {
                    case StyleSelectorType.Wildcard:
                    case StyleSelectorType.Type:
                        key        = (styleSelectorPart.value ?? "*");
                        dictionary = this.orderedTypeSelectors;
                        break;

                    case StyleSelectorType.Class:
                        dictionary = this.orderedClassSelectors;
                        break;

                    case StyleSelectorType.PseudoClass:
                        key        = "*";
                        dictionary = this.orderedTypeSelectors;
                        break;

                    case StyleSelectorType.RecursivePseudoClass:
                        goto IL_22B;

                    case StyleSelectorType.ID:
                        dictionary = this.orderedNameSelectors;
                        break;

                    default:
                        goto IL_22B;
                    }
IL_249:
                    bool flag5 = dictionary != null;
                    if (flag5)
                    {
                        StyleComplexSelector nextInTable;
                        bool flag6 = dictionary.TryGetValue(key, out nextInTable);
                        if (flag6)
                        {
                            styleComplexSelector.nextInTable = nextInTable;
                        }
                        dictionary[key] = styleComplexSelector;
                    }
                    m++;
                    continue;
IL_22B:
                    Debug.LogError(string.Format("Invalid first part type {0}", styleSelectorPart.type));
                    goto IL_249;
                }
            }
        }