internal void Push(PropertyDeclarationExpression propertyExpression)
        {
            if (propertyExpression.Name == null)
            {
                propertyExpression.Name = propertyExpression.Mode.ToString().ToLower();
                propertyExpression.Mode = PropertyExpressionType.Data;
            }
            if (Values.ContainsKey(propertyExpression.Name))
            {
                PropertyDeclarationExpression exp = Values[propertyExpression.Name] as PropertyDeclarationExpression;
                if (exp == null)
                {
                    throw new JintException("A property cannot be both an accessor and data");
                }
                switch (propertyExpression.Mode)
                {
                case PropertyExpressionType.Data:
                    if (propertyExpression.Mode == PropertyExpressionType.Data)
                    {
                        Values[propertyExpression.Name] = propertyExpression.Expression;
                    }
                    else
                    {
                        throw new JintException("A property cannot be both an accessor and data");
                    }
                    break;

                case PropertyExpressionType.Get:
                    exp.SetGet(propertyExpression);
                    break;

                case PropertyExpressionType.Set:
                    exp.SetSet(propertyExpression);
                    break;
                }
            }
            else
            {
                Values.Add(propertyExpression.Name, propertyExpression);
                switch (propertyExpression.Mode)
                {
                case PropertyExpressionType.Data:
                    Values[propertyExpression.Name] = propertyExpression;
                    break;

                case PropertyExpressionType.Get:
                    propertyExpression.SetGet(propertyExpression);
                    break;

                case PropertyExpressionType.Set:
                    propertyExpression.SetSet(propertyExpression);
                    break;
                }
            }
        }
Exemple #2
0
 internal void Push(PropertyDeclarationExpression propertyExpression)
 {
     if (propertyExpression.Name == null)
     {
         propertyExpression.Name = propertyExpression.Mode.ToString().ToLower();
         propertyExpression.Mode = PropertyExpressionType.Data;
     }
     if (Values.ContainsKey(propertyExpression.Name))
     {
         PropertyDeclarationExpression exp = Values[propertyExpression.Name] as PropertyDeclarationExpression;
         if (exp == null)
             throw new JintException("A property cannot be both an accessor and data");
         switch (propertyExpression.Mode)
         {
             case PropertyExpressionType.Data:
                 if (propertyExpression.Mode == PropertyExpressionType.Data)
                     Values[propertyExpression.Name] = propertyExpression.Expression;
                 else
                     throw new JintException("A property cannot be both an accessor and data");
                 break;
             case PropertyExpressionType.Get:
                 exp.SetGet(propertyExpression);
                 break;
             case PropertyExpressionType.Set:
                 exp.SetSet(propertyExpression);
                 break;
         }
     }
     else
     {
         Values.Add(propertyExpression.Name, propertyExpression);
         switch (propertyExpression.Mode)
         {
             case PropertyExpressionType.Data:
                 Values[propertyExpression.Name] = propertyExpression;
                 break;
             case PropertyExpressionType.Get:
                 propertyExpression.SetGet(propertyExpression);
                 break;
             case PropertyExpressionType.Set:
                 propertyExpression.SetSet(propertyExpression);
                 break;
         }
     }
 }
Exemple #3
0
		public void Visit(PropertyDeclarationExpression expression)
		{
			throw new System.NotImplementedException();
		}
 internal void SetSet(PropertyDeclarationExpression propertyExpression)
 {
     SetExpression = propertyExpression.Expression;
 }
Exemple #5
0
        public void Visit(PropertyDeclarationExpression expression)
        {
            // previous result was the object in which we need to define a property
            var target = Result as JsDictionaryObject;

            switch (expression.Mode) {
                case PropertyExpressionType.Data:
                    expression.Expression.Accept(this);
                    target.DefineOwnProperty(new ValueDescriptor(target, expression.Name, Result) );
                    break;
                case PropertyExpressionType.Get:
                case PropertyExpressionType.Set:
                    JsFunction get = null, set = null;
                    if (expression.GetExpression != null) {
                        expression.GetExpression.Accept(this);
                        get = (JsFunction)Result;
                    }
                    if (expression.SetExpression != null) {
                        expression.SetExpression.Accept(this);
                        set = (JsFunction)Result;
                    }
                    target.DefineOwnProperty(new PropertyDescriptor(Global, target, expression.Name) { GetFunction = get, SetFunction = set, Enumerable = true });
                    break;
                default:
                    break;
            }
        }
Exemple #6
0
 public void Visit(PropertyDeclarationExpression expression)
 {
     switch (expression.Mode)
     {
         case PropertyExpressionType.Data:
             expression.Expression.Accept(this);
             Result = new ValueDescriptor(CurrentScope, expression.Name, Result);
             break;
         case PropertyExpressionType.Get:
         case PropertyExpressionType.Set:
             JsFunction get = null, set = null;
             if (expression.GetExpression != null)
             {
                 expression.GetExpression.Accept(this);
                 get = (JsFunction)Result;
             }
             if (expression.SetExpression != null)
             {
                 expression.SetExpression.Accept(this);
                 set = (JsFunction)Result;
             }
             Result = new PropertyDescriptor(Global, CurrentScope, expression.Name) { GetFunction = get, SetFunction = set, Enumerable = true };
             break;
         default:
             break;
     }
 }
Exemple #7
0
 void Analyze(PropertyDeclarationExpression Stmt)
 {
     SetCurrentLineAndCharNos(Stmt);
     if (Stmt.Expression != null) Analyze(Stmt.Expression);
     if (Stmt.GetExpression != null) Analyze(Stmt.GetExpression);
     if (Stmt.SetExpression != null) Analyze(Stmt.SetExpression);
     //if (Stmt.Name != null) Analyzer.CheckIdentifier(Stmt.Name);
 }
 internal void SetGet(PropertyDeclarationExpression propertyExpression)
 {
     GetExpression = propertyExpression.Expression;
 }