Esempio n. 1
0
		public void Visit(PropertyExpression expression)
		{
			Builder.Append(expression.Text);
		}
Esempio n. 2
0
        public void Visit(PropertyExpression expression)
        {

            Result = null;

            string propertyName = lastIdentifier = expression.Text;

            if (propertyName == JsDictionaryObject.PROTOTYPE)
            {
                Result = CurrentScope.Prototype;
                return;
            }

            JsInstance result = null;

            JsDictionaryObject oldCallTarget = callTarget;
            callTarget = CurrentScope;
            try
            {// Closure ?
                callTarget = CurrentScope;
                if (CurrentScope.Class == JsFunction.TYPEOF)
                {
                    JsScope scope = ((JsFunction)CurrentScope).Scope;
                    if (scope.TryGetProperty(propertyName, out result))
                    {
                        Result = result;
                        return;
                    }
                }

                callTarget = CurrentScope;
                if (CurrentScope.TryGetProperty(propertyName, out result))
                {
                    Result = result;
                    return;
                }
            }
            finally
            {
                callTarget = oldCallTarget;
            }


            // Search for .NET property or method
            if (CurrentScope.IsClr && CurrentScope.Value != null)
            {
                EnsureClrAllowed();

                // enum ?
                var type = CurrentScope.Value as Type;
                if (type != null && type.IsEnum)
                {
                    Result = new JsClr(this, Enum.Parse(type, propertyName));
                    return;
                }

                var propertyInfo = propertyGetter.GetValue(CurrentScope.Value, propertyName);
                if (propertyInfo != null)
                {
                    Result = Global.WrapClr(propertyInfo.GetValue(CurrentScope.Value, null));
                    return;
                }


                var fieldInfo = fieldGetter.GetValue(CurrentScope.Value, propertyName);
                if (fieldInfo != null)
                {
                    Result = Global.WrapClr(fieldInfo.GetValue(CurrentScope.Value));
                    return;
                }

                // Not a property, then must be a method
                Result = new JsClrMethodInfo(propertyName);
                return;

                throw new JintException("Invalid property name: " + propertyName);
            }


            // Search for a static CLR call
            if (Result == null && typeFullname.Length > 0)
            {
                Type type = typeResolver.ResolveType(typeFullname.ToString());

                if (type != null)
                {
                    EnsureClrAllowed();

                    var propertyInfo = propertyGetter.GetValue(type, propertyName);
                    if (propertyInfo != null)
                    {
                        Result = Global.WrapClr(propertyInfo.GetValue(type, null));
                        return;
                    }

                    var fieldInfo = fieldGetter.GetValue(type, propertyName);
                    if (fieldInfo != null)
                    {
                        Result = Global.WrapClr(fieldInfo.GetValue(type));
                        return;
                    }

                    // Not a property, then must be a method
                    Result = new JsClrMethodInfo(propertyName);
                    return;

                    throw new JintException("Invalid property name: " + propertyName);
                }
            }

            if (Result == null && typeFullname.Length > 0)
            {
                typeFullname.Append('.').Append(propertyName);
            }

            Result = JsUndefined.Instance;
        }
Esempio n. 3
0
        public void Visit(PropertyExpression expression)
        {
            // save base of current expression
            var callTarget = Result as JsDictionaryObject;

            // this check is disabled becouse it prevents Clr names to resolve
            //if ((callTarget) == null || callTarget == JsUndefined.Instance || callTarget == JsNull.Instance)
            //{
            //    throw new JsException( Global.TypeErrorClass.New( String.Format("An object is required: {0} while resolving property {1}", lastIdentifier, expression.Text) ) );
            //}

            Result = null;

            string propertyName = lastIdentifier = expression.Text;

            JsInstance result = null;

            if (callTarget != null && callTarget.TryGetProperty(propertyName, out result)) {
                SetResult(result, callTarget);
                return;
            }

            if (Result == null && typeFullname.Length > 0) {
                typeFullname.Append('.').Append(propertyName);
            }

            SetResult(JsUndefined.Instance, callTarget);
        }
Esempio n. 4
0
 void Analyze(PropertyExpression Stmt)
 {
     SetCurrentLineAndCharNos(Stmt);
     if (Stmt.Text != null)
     {
         AddToJintStack(Stmt.Source, JintState.Property, Stmt.Text);
     }
 }