コード例 #1
0
        public JsVariableField(JsFieldType fieldType, string name, FieldAttributes fieldAttributes, object value)
        {
            m_referenceTable   = new HashSet <IJsNameReference>();
            m_declarationTable = new HashSet <IJsNameDeclaration>();

            Name       = name;
            Attributes = fieldAttributes;
            FieldValue = value;
            SetFieldsBasedOnType(fieldType);
        }
コード例 #2
0
        public JsVariableField(JsFieldType fieldType, string name, FieldAttributes fieldAttributes, object value)
        {
            m_referenceTable = new HashSet<IJsNameReference>();
            m_declarationTable = new HashSet<IJsNameDeclaration>();

            Name = name;
            Attributes = fieldAttributes;
            FieldValue = value;
            SetFieldsBasedOnType(fieldType);
        }
コード例 #3
0
        private void SetFieldsBasedOnType(JsFieldType fieldType)
        {
            FieldType = fieldType;
            switch (FieldType)
            {
            case JsFieldType.Argument:
            case JsFieldType.CatchError:
                IsDeclared = true;
                CanCrunch  = true;
                break;

            case JsFieldType.Arguments:
                IsDeclared = false;
                CanCrunch  = false;
                break;

            case JsFieldType.Global:
                CanCrunch = false;
                break;

            case JsFieldType.Local:
                CanCrunch = true;
                break;

            case JsFieldType.Predefined:
                IsDeclared = false;
                CanCrunch  = false;
                break;

            case JsFieldType.WithField:
                CanCrunch = false;
                break;

            case JsFieldType.GhostCatch:
                CanCrunch     = true;
                IsPlaceholder = true;
                break;

            case JsFieldType.GhostFunction:
                CanCrunch     = OuterField == null ? true : OuterField.CanCrunch;
                IsFunction    = true;
                IsPlaceholder = true;
                break;

            case JsFieldType.UndefinedGlobal:
                CanCrunch = false;
                break;

            default:
                // shouldn't get here
                throw new ArgumentException("Invalid field type", "fieldType");
            }
        }
コード例 #4
0
        internal JsVariableField(JsFieldType fieldType, JsVariableField outerField)
        {
            if (outerField == null)
            {
                throw new ArgumentNullException("outerField");
            }

            m_referenceTable   = new HashSet <IJsNameReference>();
            m_declarationTable = new HashSet <IJsNameDeclaration>();

            // set values based on the outer field
            OuterField = outerField;

            Name        = outerField.Name;
            Attributes  = outerField.Attributes;
            FieldValue  = outerField.FieldValue;
            IsGenerated = outerField.IsGenerated;

            // and set some other fields on our object based on the type we are
            SetFieldsBasedOnType(fieldType);
        }
コード例 #5
0
        internal JsVariableField(JsFieldType fieldType, JsVariableField outerField)
        {
            if (outerField == null)
            {
                throw new ArgumentNullException("outerField");
            }

            m_referenceTable = new HashSet<IJsNameReference>();
            m_declarationTable = new HashSet<IJsNameDeclaration>();

            // set values based on the outer field
            OuterField = outerField;

            Name = outerField.Name;
            Attributes = outerField.Attributes;
            FieldValue = outerField.FieldValue;
            IsGenerated = outerField.IsGenerated;

            // and set some other fields on our object based on the type we are
            SetFieldsBasedOnType(fieldType);
        }
コード例 #6
0
        private JsVariableField ResolveFromCollection(string name, HashSet<string> collection, JsFieldType fieldType, bool isFunction)
        {
            if (collection.Contains(name))
            {
                var variableField = new JsVariableField(fieldType, name, 0, null);
                variableField.IsFunction = isFunction;
                return AddField(variableField);
            }

            return null;
        }
コード例 #7
0
        private JsVariableField ResolveFromCollection(string name, HashSet <string> collection, JsFieldType fieldType, bool isFunction)
        {
            if (collection.Contains(name))
            {
                var variableField = new JsVariableField(fieldType, name, 0, null);
                variableField.IsFunction = isFunction;
                return(AddField(variableField));
            }

            return(null);
        }
コード例 #8
0
        private void SetFieldsBasedOnType(JsFieldType fieldType)
        {
            FieldType = fieldType;
            switch (FieldType)
            {
                case JsFieldType.Argument:
                case JsFieldType.CatchError:
                    IsDeclared = true;
                    CanCrunch = true;
                    break;

                case JsFieldType.Arguments:
                    IsDeclared = false;
                    CanCrunch = false;
                    break;

                case JsFieldType.Global:
                    CanCrunch = false;
                    break;

                case JsFieldType.Local:
                    CanCrunch = true;
                    break;

                case JsFieldType.Predefined:
                    IsDeclared = false;
                    CanCrunch = false;
                    break;

                case JsFieldType.WithField:
                    CanCrunch = false;
                    break;

                case JsFieldType.GhostCatch:
                    CanCrunch = true;
                    IsPlaceholder = true;
                    break;

                case JsFieldType.GhostFunction:
                    CanCrunch = OuterField == null ? true : OuterField.CanCrunch;
                    IsFunction = true;
                    IsPlaceholder = true;
                    break;

                case JsFieldType.UndefinedGlobal:
                    CanCrunch = false;
                    break;

                default:
                    // shouldn't get here
                    throw new ArgumentException("Invalid field type", "fieldType");
            }
        }