示例#1
0
		public void Visit(Identifier expression)
		{
			Builder.Append(expression.Text);
		}
示例#2
0
        public void Visit(Identifier expression)
        {
            Result = null;

            string propertyName = lastIdentifier = expression.Text;

            Descriptor result = null;
            if (CurrentScope.TryGetDescriptor(propertyName, out result)) {
                if (!result.isReference)
                    Result = result.Get(CurrentScope);
                else {
                    LinkedDescriptor r = result as LinkedDescriptor;
                    SetResult(r.Get(CurrentScope), r.targetObject);
                }

                if (Result != null)
                    return;
            }

            if (propertyName == "null") {
                Result = JsNull.Instance;
            }

            if (propertyName == "undefined") {
                Result = JsUndefined.Instance;
            }

            // Try to record full path in case it's a type
            if (Result == null) {
                typeFullname.Append(propertyName);
            }
        }
示例#3
0
 void Analyze(Identifier Stmt)
 {
     SetCurrentLineAndCharNos(Stmt);
     if (Stmt.Text != null)
     {
         if (JintStack.Count == 0)
         {
             AddToJintStack(Stmt.Source, JintState.Identifier, Stmt.Text);
             return;
         }
         int LastItem = JintStack.Count - 1;
         switch (JintStack[LastItem].State)
         {
             case (JintState.AssignmentExpressionLeft):
             case (JintState.AssignmentExpressionRight):
             case (JintState.MethodCallArgument):
                 AddToJintStack(Stmt.Source, JintState.Identifier, Stmt.Text);
                 break;
             case (JintState.Identifier):
                 AddToJintStack(Stmt.Source, JintState.Property, Stmt.Text);
                 break;
             case (JintState.Indexer):
                 AddToJintStack(Stmt.Source, JintState.Identifier, Stmt.Text);
                 break;
             case(JintState.MethodArgument):
                 RemoveJintStackFrom(JintStack.Count - 1);
                 AddToJintStack(Stmt.Source, JintState.MethodArgumentIdentifier, Stmt.Text);
                 break;
             default:
                 AddToJintStack(Stmt.Source, JintState.Identifier, Stmt.Text);
                 break;
         }
     }
 }
示例#4
0
        public void Visit(Identifier expression)
        {
            Result = null;

            string propertyName = lastIdentifier = expression.Text;


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

                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);
            }

            // escalade scopes
            JsDictionaryObject oldCallTarget = callTarget;
            try
            {
                foreach (JsDictionaryObject scope in Scopes.ToArray())
                {
                    callTarget = scope;
                    JsInstance result = null;
                    if (scope.TryGetProperty(propertyName, out result))
                    {
                        Result = result;
                        if (Result != null)
                            return;
                    }
                }
            }
            finally
            {
                callTarget = oldCallTarget;
            }

            if (propertyName == "null")
            {
                Result = JsNull.Instance;
                return;
            }

            if (propertyName == "undefined")
            {
                Result = JsUndefined.Instance;
                return;
            }

            // Try to record full path in case it's a type
            if (Result == null)
            {
                typeFullname.Append(propertyName);
            }

            Result = JsUndefined.Instance;
        }
示例#5
0
        public void Visit(Identifier expression)
        {
            Result = null;

            string propertyName = lastIdentifier = expression.Text;

            if (propertyName == "null")
            {
                Result = JsNull.Instance;
                return;
            }

            if (propertyName == "undefined")
            {
                Result = JsUndefined.Instance;
                return;
            }

            JsInstance result = null;
            CurrentScope.TryGetProperty(propertyName, out result);
            Result = result;

            return;
        }