private AST MemberExpression(AST expression, ArrayList newContexts, out bool canBeQualid, ref bool canBeAttribute){ bool noMoreForAttr = false; canBeQualid = true; for(;;){ this.noSkipTokenSet.Add(NoSkipTokenSet.s_MemberExprNoSkipTokenSet); try{ switch (this.currentToken.token){ case JSToken.LeftParen: if (noMoreForAttr) canBeAttribute = false; else noMoreForAttr = true; canBeQualid = false; ASTList args = null; RecoveryTokenException callError = null; this.noSkipTokenSet.Add(NoSkipTokenSet.s_ParenToken); try{ args = ParseExpressionList(JSToken.RightParen); }catch(RecoveryTokenException exc){ args = (ASTList)exc._partiallyComputedNode; if (IndexOfToken(NoSkipTokenSet.s_ParenToken, exc) == -1) callError = exc; // thrown later on }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ParenToken); } //treat eval and print specially if (expression is Lookup){ String name = expression.ToString(); if (name.Equals("eval")){ expression.context.UpdateWith(args.context); if (args.count > 0) expression = new Eval(expression.context, args[0]); else expression = new Eval(expression.context, new ConstantWrapper("", CurrentPositionContext())); }else if (this.Globals.engine.doPrint && name.Equals("print")){ expression.context.UpdateWith(args.context); expression = new Print(expression.context, args); }else{ if (name == "GetObject") this.ForceReportInfo(JSError.GetObjectNotSupportedOnRotor); expression = new Call(expression.context.CombineWith(args.context), expression, args, false); } }else expression = new Call(expression.context.CombineWith(args.context), expression, args, false); if (null != newContexts && newContexts.Count > 0){ ((Context)newContexts[newContexts.Count - 1]).UpdateWith(expression.context); if (!(expression is Call)) expression = new Call((Context)newContexts[newContexts.Count - 1], expression, new ASTList(CurrentPositionContext()), false); else expression.context = (Context)newContexts[newContexts.Count - 1]; ((Call)expression).isConstructor = true; newContexts.RemoveAt(newContexts.Count - 1); } if (callError != null){ callError._partiallyComputedNode = expression; throw callError; } GetNextToken(); break; case JSToken.LeftBracket: canBeQualid = false; canBeAttribute = false; this.noSkipTokenSet.Add(NoSkipTokenSet.s_BracketToken); try{ args = ParseExpressionList(JSToken.RightBracket); }catch(RecoveryTokenException exc){ if(IndexOfToken(NoSkipTokenSet.s_BracketToken, exc) == -1){ if (exc._partiallyComputedNode != null){ exc._partiallyComputedNode = new Call(expression.context.CombineWith(this.currentToken.Clone()), expression, (ASTList)exc._partiallyComputedNode, true); }else{ exc._partiallyComputedNode = expression; } throw exc; }else args = (ASTList)exc._partiallyComputedNode; }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_BracketToken); } expression = new Call(expression.context.CombineWith(this.currentToken.Clone()), expression, args, true); if (null != newContexts && newContexts.Count > 0){ ((Context)newContexts[newContexts.Count - 1]).UpdateWith(expression.context); expression.context = (Context)newContexts[newContexts.Count - 1]; ((Call)expression).isConstructor = true; newContexts.RemoveAt(newContexts.Count - 1); } GetNextToken(); break; case JSToken.AccessField: if (noMoreForAttr) canBeAttribute = false; ConstantWrapper id = null; GetNextToken(); if (JSToken.Identifier != this.currentToken.token){ string identifier = JSKeyword.CanBeIdentifier(this.currentToken.token); if (null != identifier){ ForceReportInfo(JSError.KeywordUsedAsIdentifier); id = new ConstantWrapper(identifier, this.currentToken.Clone()); }else{ ReportError(JSError.NoIdentifier); SkipTokensAndThrow(expression); } }else id = new ConstantWrapper(this.scanner.GetIdentifier(), this.currentToken.Clone()); GetNextToken(); expression = new Member(expression.context.CombineWith(id.context), expression, id); break; default: if (null != newContexts){ while (newContexts.Count > 0){ ((Context)newContexts[newContexts.Count - 1]).UpdateWith(expression.context); expression = new Call((Context)newContexts[newContexts.Count - 1], expression, new ASTList(CurrentPositionContext()), false); ((Call)expression).isConstructor = true; newContexts.RemoveAt(newContexts.Count - 1); } } return expression; } }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_MemberExprNoSkipTokenSet, exc) != -1) expression = exc._partiallyComputedNode; else{ Debug.Assert(exc._partiallyComputedNode == expression); throw exc; } }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_MemberExprNoSkipTokenSet); } } }
private AST MemberExpression(AST expression, ArrayList newContexts, out bool canBeQualid, ref bool canBeAttribute) { AST ast; bool flag = false; canBeQualid = true; Label_0005: this.noSkipTokenSet.Add(NoSkipTokenSet.s_MemberExprNoSkipTokenSet); try { try { ASTList list; ConstantWrapper wrapper; switch (this.currentToken.token) { case JSToken.LeftParen: if (!flag) { break; } canBeAttribute = false; goto Label_0048; case JSToken.LeftBracket: canBeQualid = false; canBeAttribute = false; this.noSkipTokenSet.Add(NoSkipTokenSet.s_BracketToken); try { list = this.ParseExpressionList(JSToken.RightBracket); } catch (RecoveryTokenException exception3) { if (this.IndexOfToken(NoSkipTokenSet.s_BracketToken, exception3) == -1) { if (exception3._partiallyComputedNode != null) { exception3._partiallyComputedNode = new Call(expression.context.CombineWith(this.currentToken.Clone()), expression, (ASTList) exception3._partiallyComputedNode, true); } else { exception3._partiallyComputedNode = expression; } throw exception3; } list = (ASTList) exception3._partiallyComputedNode; } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_BracketToken); } expression = new Call(expression.context.CombineWith(this.currentToken.Clone()), expression, list, true); if ((newContexts != null) && (newContexts.Count > 0)) { ((Context) newContexts[newContexts.Count - 1]).UpdateWith(expression.context); expression.context = (Context) newContexts[newContexts.Count - 1]; ((Call) expression).isConstructor = true; newContexts.RemoveAt(newContexts.Count - 1); } this.GetNextToken(); goto Label_0005; case JSToken.AccessField: { if (flag) { canBeAttribute = false; } wrapper = null; this.GetNextToken(); if (JSToken.Identifier == this.currentToken.token) { goto Label_03EF; } string str2 = JSKeyword.CanBeIdentifier(this.currentToken.token); if (str2 != null) { this.ForceReportInfo(JSError.KeywordUsedAsIdentifier); wrapper = new ConstantWrapper(str2, this.currentToken.Clone()); } else { this.ReportError(JSError.NoIdentifier); this.SkipTokensAndThrow(expression); } goto Label_040C; } default: if (newContexts != null) { while (newContexts.Count > 0) { ((Context) newContexts[newContexts.Count - 1]).UpdateWith(expression.context); expression = new Call((Context) newContexts[newContexts.Count - 1], expression, new ASTList(this.CurrentPositionContext()), false); ((Call) expression).isConstructor = true; newContexts.RemoveAt(newContexts.Count - 1); } } return expression; } flag = true; Label_0048: canBeQualid = false; list = null; RecoveryTokenException exception = null; this.noSkipTokenSet.Add(NoSkipTokenSet.s_ParenToken); try { list = this.ParseExpressionList(JSToken.RightParen); } catch (RecoveryTokenException exception2) { list = (ASTList) exception2._partiallyComputedNode; if (this.IndexOfToken(NoSkipTokenSet.s_ParenToken, exception2) == -1) { exception = exception2; } } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ParenToken); } if (expression is Lookup) { string str = expression.ToString(); if (str.Equals("eval")) { expression.context.UpdateWith(list.context); if (list.count == 1) { expression = new Eval(expression.context, list[0], null); } else if (list.count > 1) { expression = new Eval(expression.context, list[0], list[1]); } else { expression = new Eval(expression.context, new ConstantWrapper("", this.CurrentPositionContext()), null); } canBeAttribute = false; } else if (this.Globals.engine.doPrint && str.Equals("print")) { expression.context.UpdateWith(list.context); expression = new Print(expression.context, list); canBeAttribute = false; } else { expression = new Call(expression.context.CombineWith(list.context), expression, list, false); } } else { expression = new Call(expression.context.CombineWith(list.context), expression, list, false); } if ((newContexts != null) && (newContexts.Count > 0)) { ((Context) newContexts[newContexts.Count - 1]).UpdateWith(expression.context); if (expression is Call) { expression.context = (Context) newContexts[newContexts.Count - 1]; } else { expression = new Call((Context) newContexts[newContexts.Count - 1], expression, new ASTList(this.CurrentPositionContext()), false); } ((Call) expression).isConstructor = true; newContexts.RemoveAt(newContexts.Count - 1); } if (exception != null) { exception._partiallyComputedNode = expression; throw exception; } this.GetNextToken(); goto Label_0005; Label_03EF: wrapper = new ConstantWrapper(this.scanner.GetIdentifier(), this.currentToken.Clone()); Label_040C: this.GetNextToken(); expression = new Member(expression.context.CombineWith(wrapper.context), expression, wrapper); } catch (RecoveryTokenException exception4) { if (this.IndexOfToken(NoSkipTokenSet.s_MemberExprNoSkipTokenSet, exception4) == -1) { throw exception4; } expression = exception4._partiallyComputedNode; } goto Label_0005; } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_MemberExprNoSkipTokenSet); } return ast; }