本文整理汇总了C#中Microsoft.JScript.Context.UpdateWith方法的典型用法代码示例。如果您正苦于以下问题:C# Context.UpdateWith方法的具体用法?C# Context.UpdateWith怎么用?C# Context.UpdateWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.JScript.Context
的用法示例。
在下文中一共展示了Context.UpdateWith方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseConstructorCall
//-------------------------------------------------------------------------------------------
// ParseConstructorCall
//
// ConstructorCall :
// 'this' Arguments
// 'super' Arguments
//--------------------------------------------------------------------------------------------
private AST ParseConstructorCall(Context superCtx){
bool isSuperConstructorCall = JSToken.Super == this.currentToken.token;
GetNextToken();
Context listCtx = this.currentToken.Clone();
ASTList args = new ASTList(listCtx);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_ParenToken);
try{
args = ParseExpressionList(JSToken.RightParen);
GetNextToken(); //Skip the )
}catch(RecoveryTokenException exc){
if (exc._partiallyComputedNode != null)
args = (ASTList)exc._partiallyComputedNode;
if (IndexOfToken(NoSkipTokenSet.s_ParenToken, exc) == -1
&& IndexOfToken(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet, exc) == -1){
exc._partiallyComputedNode = new ConstructorCall(superCtx, args, isSuperConstructorCall);
throw exc;
}else{
if (exc._token == JSToken.RightParen)
GetNextToken();
}
}finally{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ParenToken);
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet);
}
superCtx.UpdateWith(listCtx);
return new ConstructorCall(superCtx, args, isSuperConstructorCall);
}
示例2: ParsePackage
//.........这里部分代码省略.........
}
}else{
if (qualid == null){
// this is pretty screwy, let's ignore the package keyword for a start
ReportError(JSError.SyntaxError, packageContext);
if (JSScanner.CanStartStatement(nonSenseToken.token)){
// this is tricky we assign nonSenseToken to this.currentToken and call ParseStatement, because we know it is a statement start token.
// The parser should then call GetNextToken() which will return the this.currentToken that is assigned to this.errorToken
this.currentToken = nonSenseToken;
return ParseStatement();
}else{
//ReportError(JSError.SyntaxError, nonSenseToken);
if (JSScanner.CanStartStatement(this.currentToken.token)){
this.errorToken = null;
return ParseStatement();
}else{
ReportError(JSError.SyntaxError);
SkipTokensAndThrow();
}
}
}else{
if (gotLineBreak){
// we are here with the following: 'package' <line break> QalifiedIdentifier' however we do not have a left curly.
// if the token in our hand can start an expression we go with two expressions, otherwise we accept it as a package
//if (JSScanner.CanParseAsExpression(this.currentToken.token)){
ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
Block block = new Block(packageContext.Clone());
block.Append(new Lookup("package", packageContext));
qualid = MemberExpression(qualid, null);
bool isLeftHandSide;
qualid = ParsePostfixExpression(qualid, out isLeftHandSide);
qualid = ParseExpression(qualid, false, true, JSToken.None);
block.Append(new Expression(qualid.context.Clone(), qualid));
block.context.UpdateWith(qualid.context);
return block;
//}
}
// the package production rule is entered regardless of the presence of a left curly.
ReportError(JSError.NoLeftCurly);
}
}
PackageScope pscope = new PackageScope(Globals.ScopeStack.Peek());
Globals.ScopeStack.Push(pscope); //Give declarations a place to go while building AST
try{
string name = (qualid != null) ? qualid.ToString() : "anonymous package";
pscope.name = name;
packageContext.UpdateWith(this.currentToken);
ASTList classList = new ASTList(packageContext);
GetNextToken();
this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_PackageBodyNoSkipTokenSet);
try{
while (this.currentToken.token != JSToken.RightCurly){
AST ast = null;
try{
switch (this.currentToken.token){
case JSToken.Interface:
case JSToken.Class:
classList.Append(ParseClass((FieldAttributes)0, false, this.currentToken.Clone(), false, false, null));
break;
case JSToken.Enum:
classList.Append(ParseEnum((FieldAttributes)0, this.currentToken.Clone(), null));
示例3: ParseStaticInitializer
//---------------------------------------------------------------------------------------
// ParseStaticInitializer
//
// StaticInitializer :
// '{' FunctionBody '}'
//---------------------------------------------------------------------------------------
private AST ParseStaticInitializer(Context initContext){
Block body = null;
FunctionScope scope = new FunctionScope(Globals.ScopeStack.Peek());
scope.isStatic = true;
// make a new state and save the old one
ArrayList blockType = this.blockType;
this.blockType = new ArrayList(16);
SimpleHashtable labelTable = this.labelTable;
this.labelTable = new SimpleHashtable(16);
this.blockType.Add(BlockType.Block);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_StartStatementNoSkipTokenSet);
try{
Globals.ScopeStack.Push(scope); //Give declarations a place to go while building AST
// parse the block locally to get the exact end of function
body = new Block(this.currentToken.Clone());
GetNextToken();
while (JSToken.RightCurly != this.currentToken.token){
try{
body.Append(ParseStatement());
}catch(RecoveryTokenException exc){
if (exc._partiallyComputedNode != null)
body.Append(exc._partiallyComputedNode);
if (IndexOfToken(NoSkipTokenSet.s_StartStatementNoSkipTokenSet, exc) == -1)
throw exc;
}
}
}catch(RecoveryTokenException exc){
if (IndexOfToken(NoSkipTokenSet.s_BlockNoSkipTokenSet, exc) == -1){
exc._partiallyComputedNode = new StaticInitializer(initContext, body, scope);
throw exc;
}
}finally{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_StartStatementNoSkipTokenSet);
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_BlockNoSkipTokenSet);
this.blockType = blockType;
this.labelTable = labelTable;
Globals.ScopeStack.Pop();
}
body.context.UpdateWith(this.currentToken);
initContext.UpdateWith(this.currentToken);
GetNextToken();
return new StaticInitializer(initContext, body, scope);
}
示例4: ParseEnum
//---------------------------------------------------------------------------------------
// ParseEnum
//
// Enum :
// 'enum' identifier [':' baseType] EnumBody (in the guise of ClassBody with a param)
//
//---------------------------------------------------------------------------------------
private AST ParseEnum(FieldAttributes visibilitySpec, Context enumCtx, CustomAttributeList customAttributes){
IdentifierLiteral name = null;
AST baseId = null;
TypeExpression baseType = null;
Block body = null;
GetNextToken();
if (JSToken.Identifier == this.currentToken.token){
name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone());
}else{
ReportError(JSError.NoIdentifier);
if (JSToken.Colon != this.currentToken.token && JSToken.LeftCurly != this.currentToken.token)
SkipTokensAndThrow(); // what the is this?
name = new IdentifierLiteral("##Missing Enum Name##" + s_cDummyName++, CurrentPositionContext());
}
GetNextToken();
if (JSToken.Colon == this.currentToken.token){
this.noSkipTokenSet.Add(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet);
try{
baseId = ParseQualifiedIdentifier(JSError.NeedType);
}catch(RecoveryTokenException exc){
if (IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exc) == -1){
exc._partiallyComputedNode = null;
throw exc;
}else{
baseId = exc._partiallyComputedNode;
}
}finally{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet);
}
}
if (baseId != null)
baseType = new TypeExpression(baseId);
if (JSToken.LeftCurly != this.currentToken.token)
ReportError(JSError.NoLeftCurly);
// make a new state and save the old one
ArrayList blockType = this.blockType;
this.blockType = new ArrayList(16);
SimpleHashtable labelTable = this.labelTable;
this.labelTable = new SimpleHashtable(16);
Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject)Globals.ScopeStack.Peek()).GetGlobalScope())); //Give declarations a place to go while building AST
try{
body = ParseClassBody(true, false);
enumCtx.UpdateWith(body.context);
EnumDeclaration result = new EnumDeclaration(enumCtx, name, baseType, body, visibilitySpec, customAttributes);
if (customAttributes != null) customAttributes.SetTarget(result);
return result;
}catch(RecoveryTokenException exc){
enumCtx.UpdateWith(exc._partiallyComputedNode.context);
exc._partiallyComputedNode = new EnumDeclaration(enumCtx, name, baseType, (Block)exc._partiallyComputedNode, visibilitySpec, customAttributes);
if (customAttributes != null) customAttributes.SetTarget(exc._partiallyComputedNode);
throw exc;
}finally{
Globals.ScopeStack.Pop();
this.blockType = blockType;
this.labelTable = labelTable;
}
}
示例5: ParseFunction
//.........这里部分代码省略.........
paramArrayContext = null;
}
String id = null;
TypeExpression typeExpr = null;
this.noSkipTokenSet.Add(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet);
try{
if (JSToken.ParamArray == this.currentToken.token){
paramArrayContext = this.currentToken.Clone();
GetNextToken();
}
if (JSToken.Identifier != this.currentToken.token && (id = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null){
if (JSToken.LeftCurly == this.currentToken.token){
ReportError(JSError.NoRightParen);
break;
}else if (JSToken.Comma == this.currentToken.token){
// We're missing an argument (or previous argument was malformed and
// we skipped to the comma.) Keep trying to parse the argument list --
// we will skip the comma below.
ReportError(JSError.SyntaxError, true);
}else{
ReportError(JSError.SyntaxError, true);
SkipTokensAndThrow();
}
}else{
if (null == id)
id = this.scanner.GetIdentifier();
else
ForceReportInfo(JSError.KeywordUsedAsIdentifier);
Context paramCtx = this.currentToken.Clone();
GetNextToken();
if (JSToken.Colon == this.currentToken.token){
typeExpr = ParseTypeExpression();
if (null != typeExpr)
paramCtx.UpdateWith(typeExpr.context);
}
CustomAttributeList custAttrs = null;
if (paramArrayContext != null){
custAttrs = new CustomAttributeList(paramArrayContext);
custAttrs.Append(new CustomAttribute(paramArrayContext, new Lookup("...", paramArrayContext), new ASTList(null)));
}
formalParameters.Add(new ParameterDeclaration(paramCtx, id, typeExpr, custAttrs));
}
// got an arg, it should be either a ',' or ')'
if (JSToken.RightParen == this.currentToken.token)
break;
else if (JSToken.Comma != this.currentToken.token){
// deal with error in some "intelligent" way
if (JSToken.LeftCurly == this.currentToken.token){
ReportError(JSError.NoRightParen);
break;
}else{
if (JSToken.Identifier == this.currentToken.token && typeExpr == null){
// it's possible that the guy was writing the type in C/C++ style (i.e. int x)
ReportError(JSError.NoCommaOrTypeDefinitionError);
}else
ReportError(JSError.NoComma);
}
}
GetNextToken();
}catch(RecoveryTokenException exc){
if (IndexOfToken(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet, exc) == -1)
throw exc;
}finally{
示例6: ParseStaticInitializer
private AST ParseStaticInitializer(Context initContext)
{
if (this.demandFullTrustOnFunctionCreation)
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
}
Block body = null;
FunctionScope item = new FunctionScope(this.Globals.ScopeStack.Peek()) {
isStatic = true
};
ArrayList blockType = this.blockType;
this.blockType = new ArrayList(0x10);
SimpleHashtable labelTable = this.labelTable;
this.labelTable = new SimpleHashtable(0x10);
this.blockType.Add(BlockType.Block);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_StartStatementNoSkipTokenSet);
try
{
this.Globals.ScopeStack.Push(item);
body = new Block(this.currentToken.Clone());
this.GetNextToken();
while (JSToken.RightCurly != this.currentToken.token)
{
try
{
body.Append(this.ParseStatement());
continue;
}
catch (RecoveryTokenException exception)
{
if (exception._partiallyComputedNode != null)
{
body.Append(exception._partiallyComputedNode);
}
if (this.IndexOfToken(NoSkipTokenSet.s_StartStatementNoSkipTokenSet, exception) == -1)
{
throw exception;
}
continue;
}
}
}
catch (RecoveryTokenException exception2)
{
if (this.IndexOfToken(NoSkipTokenSet.s_BlockNoSkipTokenSet, exception2) == -1)
{
exception2._partiallyComputedNode = new StaticInitializer(initContext, body, item);
throw exception2;
}
}
finally
{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_StartStatementNoSkipTokenSet);
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_BlockNoSkipTokenSet);
this.blockType = blockType;
this.labelTable = labelTable;
this.Globals.ScopeStack.Pop();
}
body.context.UpdateWith(this.currentToken);
initContext.UpdateWith(this.currentToken);
this.GetNextToken();
return new StaticInitializer(initContext, body, item);
}
示例7: ParseClass
//---------------------------------------------------------------------------------------
// ParseClass
//
// Class :
// 'class' identifier OptionalExtends ClassBody
//
// Extends :
// 'extends' QualifiedIdentifier
//
//---------------------------------------------------------------------------------------
private AST ParseClass(FieldAttributes visibilitySpec, bool isStatic, Context classCtx, bool isAbstract, bool isFinal, CustomAttributeList customAttributes){
AST name = null;
AST baseId = null;
TypeExpression baseType = null;
Block body = null;
ArrayList interfaces = new ArrayList();
bool isInterface = JSToken.Interface == this.currentToken.token;
GetNextToken();
if (JSToken.Identifier == this.currentToken.token){
name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone());
}else{
ReportError(JSError.NoIdentifier);
if (JSToken.Extends != this.currentToken.token
&& JSToken.Implements != this.currentToken.token
&& JSToken.LeftCurly != this.currentToken.token)
SkipTokensAndThrow(); // what the is this?
name = new IdentifierLiteral("##Missing Class Name##" + s_cDummyName++, CurrentPositionContext());
}
GetNextToken();
if (JSToken.Extends == this.currentToken.token || JSToken.Implements == this.currentToken.token){
if (isInterface && JSToken.Extends == this.currentToken.token)
this.currentToken.token = JSToken.Implements;
if (JSToken.Extends == this.currentToken.token){
this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet);
try{
baseId = ParseQualifiedIdentifier(JSError.NeedType);
}catch(RecoveryTokenException exc){
if (IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exc) == -1){
exc._partiallyComputedNode = null;
throw exc;
}else{
baseId = exc._partiallyComputedNode;
}
}finally{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet);
}
}
if (JSToken.Implements == this.currentToken.token){
do{
AST typeId = null;
this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet);
try{
typeId = ParseQualifiedIdentifier(JSError.NeedType);
interfaces.Add(new TypeExpression(typeId));
}catch(RecoveryTokenException exc){
if (IndexOfToken(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet, exc) == -1){
exc._partiallyComputedNode = null;
throw exc;
}else{
if (exc._partiallyComputedNode != null)
interfaces.Add(new TypeExpression(exc._partiallyComputedNode));
}
}finally{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet);
}
}while (JSToken.Comma == this.currentToken.token);
}
}
if (baseId != null)
baseType = new TypeExpression(baseId);
if (JSToken.LeftCurly != this.currentToken.token){
ReportError(JSError.NoLeftCurly);
}
// make a new state and save the old one
ArrayList blockType = this.blockType;
this.blockType = new ArrayList(16);
SimpleHashtable labelTable = this.labelTable;
this.labelTable = new SimpleHashtable(16);
Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject)Globals.ScopeStack.Peek()).GetGlobalScope())); //Give declarations a place to go while building AST
TypeExpression[] ifaces;
try{
body = ParseClassBody(false, isInterface);
classCtx.UpdateWith(body.context);
ifaces = new TypeExpression[interfaces.Count]; interfaces.CopyTo(ifaces);
Class result = new Class(classCtx, name, baseType, ifaces, body, visibilitySpec, isAbstract, isFinal, isStatic, isInterface, customAttributes);
if (customAttributes != null) customAttributes.SetTarget(result);
return result;
}catch(RecoveryTokenException exc){
classCtx.UpdateWith(exc._partiallyComputedNode.context);
ifaces = new TypeExpression[interfaces.Count]; interfaces.CopyTo(ifaces);
exc._partiallyComputedNode =
new Class(classCtx, name, baseType, ifaces, (Block)exc._partiallyComputedNode, visibilitySpec, isAbstract, isFinal, isStatic, isInterface, customAttributes);
if (customAttributes != null) customAttributes.SetTarget(exc._partiallyComputedNode);
throw exc;
//.........这里部分代码省略.........
示例8: ParsePackage
private AST ParsePackage(Context packageContext)
{
AST ast4;
this.GetNextToken();
AST expression = null;
bool flag = this.scanner.GotEndOfLine();
if (JSToken.Identifier != this.currentToken.token)
{
if (JSScanner.CanParseAsExpression(this.currentToken.token))
{
bool flag2;
this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
expression = new Lookup("package", packageContext);
expression = this.MemberExpression(expression, null);
expression = this.ParsePostfixExpression(expression, out flag2);
expression = this.ParseExpression(expression, false, flag2, JSToken.None);
return new Expression(expression.context.Clone(), expression);
}
if (flag)
{
this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
return new Lookup("package", packageContext);
}
if ((JSToken.Increment == this.currentToken.token) || (JSToken.Decrement == this.currentToken.token))
{
bool flag3;
this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
expression = new Lookup("package", packageContext);
expression = this.ParsePostfixExpression(expression, out flag3);
expression = this.ParseExpression(expression, false, false, JSToken.None);
return new Expression(expression.context.Clone(), expression);
}
}
else
{
this.errorToken = this.currentToken;
expression = this.ParseQualifiedIdentifier(JSError.NoIdentifier);
}
Context context = null;
if ((JSToken.LeftCurly != this.currentToken.token) && (expression == null))
{
context = this.currentToken.Clone();
this.GetNextToken();
}
if (JSToken.LeftCurly == this.currentToken.token)
{
if (expression == null)
{
if (context == null)
{
context = this.currentToken.Clone();
}
this.ReportError(JSError.NoIdentifier, context, true);
}
}
else if (expression == null)
{
this.ReportError(JSError.SyntaxError, packageContext);
if (JSScanner.CanStartStatement(context.token))
{
this.currentToken = context;
return this.ParseStatement();
}
if (JSScanner.CanStartStatement(this.currentToken.token))
{
this.errorToken = null;
return this.ParseStatement();
}
this.ReportError(JSError.SyntaxError);
this.SkipTokensAndThrow();
}
else
{
if (flag)
{
bool flag4;
this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
Block block = new Block(packageContext.Clone());
block.Append(new Lookup("package", packageContext));
expression = this.MemberExpression(expression, null);
expression = this.ParsePostfixExpression(expression, out flag4);
expression = this.ParseExpression(expression, false, true, JSToken.None);
block.Append(new Expression(expression.context.Clone(), expression));
block.context.UpdateWith(expression.context);
return block;
}
this.ReportError(JSError.NoLeftCurly);
}
PackageScope item = new PackageScope(this.Globals.ScopeStack.Peek());
this.Globals.ScopeStack.Push(item);
try
{
string name = (expression != null) ? expression.ToString() : "anonymous package";
item.name = name;
packageContext.UpdateWith(this.currentToken);
ASTList classList = new ASTList(packageContext);
this.GetNextToken();
this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_PackageBodyNoSkipTokenSet);
try
//.........这里部分代码省略.........
示例9: ParseFunction
//.........这里部分代码省略.........
{
if (JSToken.LeftCurly == this.currentToken.token)
{
this.ReportError(JSError.NoRightParen);
break;
}
if (JSToken.Comma == this.currentToken.token)
{
this.ReportError(JSError.SyntaxError, true);
}
else
{
this.ReportError(JSError.SyntaxError, true);
this.SkipTokensAndThrow();
}
}
else
{
if (str2 == null)
{
str2 = this.scanner.GetIdentifier();
}
else
{
this.ForceReportInfo(JSError.KeywordUsedAsIdentifier);
}
Context context2 = this.currentToken.Clone();
this.GetNextToken();
if (JSToken.Colon == this.currentToken.token)
{
type = this.ParseTypeExpression();
if (type != null)
{
context2.UpdateWith(type.context);
}
}
CustomAttributeList list3 = null;
if (context != null)
{
list3 = new CustomAttributeList(context);
list3.Append(new Microsoft.JScript.CustomAttribute(context, new Lookup("...", context), new ASTList(null)));
}
parameters.Add(new ParameterDeclaration(context2, str2, type, list3));
}
if (JSToken.RightParen == this.currentToken.token)
{
break;
}
if (JSToken.Comma != this.currentToken.token)
{
if (JSToken.LeftCurly == this.currentToken.token)
{
this.ReportError(JSError.NoRightParen);
break;
}
if ((JSToken.Identifier == this.currentToken.token) && (type == null))
{
this.ReportError(JSError.NoCommaOrTypeDefinitionError);
}
else
{
this.ReportError(JSError.NoComma);
}
}
this.GetNextToken();
}
示例10: ParseEnum
private AST ParseEnum(FieldAttributes visibilitySpec, Context enumCtx, CustomAttributeList customAttributes)
{
IdentifierLiteral name = null;
AST ast = null;
TypeExpression baseType = null;
Block body = null;
AST ast2;
this.GetNextToken();
if (JSToken.Identifier == this.currentToken.token)
{
name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone());
}
else
{
this.ReportError(JSError.NoIdentifier);
if ((JSToken.Colon != this.currentToken.token) && (JSToken.LeftCurly != this.currentToken.token))
{
this.SkipTokensAndThrow();
}
name = new IdentifierLiteral("##Missing Enum Name##" + s_cDummyName++, this.CurrentPositionContext());
}
this.GetNextToken();
if (JSToken.Colon == this.currentToken.token)
{
this.noSkipTokenSet.Add(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet);
try
{
ast = this.ParseQualifiedIdentifier(JSError.NeedType);
}
catch (RecoveryTokenException exception)
{
if (this.IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exception) == -1)
{
exception._partiallyComputedNode = null;
throw exception;
}
ast = exception._partiallyComputedNode;
}
finally
{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet);
}
}
if (ast != null)
{
baseType = new TypeExpression(ast);
}
if (JSToken.LeftCurly != this.currentToken.token)
{
this.ReportError(JSError.NoLeftCurly);
}
ArrayList blockType = this.blockType;
this.blockType = new ArrayList(0x10);
SimpleHashtable labelTable = this.labelTable;
this.labelTable = new SimpleHashtable(0x10);
this.Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject) this.Globals.ScopeStack.Peek()).GetGlobalScope()));
try
{
body = this.ParseClassBody(true, false);
enumCtx.UpdateWith(body.context);
EnumDeclaration target = new EnumDeclaration(enumCtx, name, baseType, body, visibilitySpec, customAttributes);
if (customAttributes != null)
{
customAttributes.SetTarget(target);
}
ast2 = target;
}
catch (RecoveryTokenException exception2)
{
enumCtx.UpdateWith(exception2._partiallyComputedNode.context);
exception2._partiallyComputedNode = new EnumDeclaration(enumCtx, name, baseType, (Block) exception2._partiallyComputedNode, visibilitySpec, customAttributes);
if (customAttributes != null)
{
customAttributes.SetTarget(exception2._partiallyComputedNode);
}
throw exception2;
}
finally
{
this.Globals.ScopeStack.Pop();
this.blockType = blockType;
this.labelTable = labelTable;
}
return ast2;
}
示例11: ParseConstructorCall
private AST ParseConstructorCall(Context superCtx)
{
bool isSuperConstructorCall = JSToken.Super == this.currentToken.token;
this.GetNextToken();
Context context = this.currentToken.Clone();
ASTList arguments = new ASTList(context);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet);
this.noSkipTokenSet.Add(NoSkipTokenSet.s_ParenToken);
try
{
arguments = this.ParseExpressionList(JSToken.RightParen);
this.GetNextToken();
}
catch (RecoveryTokenException exception)
{
if (exception._partiallyComputedNode != null)
{
arguments = (ASTList) exception._partiallyComputedNode;
}
if ((this.IndexOfToken(NoSkipTokenSet.s_ParenToken, exception) == -1) && (this.IndexOfToken(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet, exception) == -1))
{
exception._partiallyComputedNode = new ConstructorCall(superCtx, arguments, isSuperConstructorCall);
throw exception;
}
if (exception._token == JSToken.RightParen)
{
this.GetNextToken();
}
}
finally
{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ParenToken);
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet);
}
superCtx.UpdateWith(context);
return new ConstructorCall(superCtx, arguments, isSuperConstructorCall);
}
示例12: ParseClass
private AST ParseClass(FieldAttributes visibilitySpec, bool isStatic, Context classCtx, bool isAbstract, bool isFinal, CustomAttributeList customAttributes)
{
AST name = null;
AST ast2 = null;
TypeExpression superTypeExpression = null;
Block body = null;
TypeExpression[] expressionArray;
AST ast4;
ArrayList list = new ArrayList();
bool isInterface = JSToken.Interface == this.currentToken.token;
this.GetNextToken();
if (JSToken.Identifier == this.currentToken.token)
{
name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone());
}
else
{
this.ReportError(JSError.NoIdentifier);
if (((JSToken.Extends != this.currentToken.token) && (JSToken.Implements != this.currentToken.token)) && (JSToken.LeftCurly != this.currentToken.token))
{
this.SkipTokensAndThrow();
}
name = new IdentifierLiteral("##Missing Class Name##" + s_cDummyName++, this.CurrentPositionContext());
}
this.GetNextToken();
if ((JSToken.Extends == this.currentToken.token) || (JSToken.Implements == this.currentToken.token))
{
if (isInterface && (JSToken.Extends == this.currentToken.token))
{
this.currentToken.token = JSToken.Implements;
}
if (JSToken.Extends == this.currentToken.token)
{
this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet);
try
{
ast2 = this.ParseQualifiedIdentifier(JSError.NeedType);
}
catch (RecoveryTokenException exception)
{
if (this.IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exception) == -1)
{
exception._partiallyComputedNode = null;
throw exception;
}
ast2 = exception._partiallyComputedNode;
}
finally
{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet);
}
}
if (JSToken.Implements == this.currentToken.token)
{
do
{
AST expression = null;
this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet);
try
{
expression = this.ParseQualifiedIdentifier(JSError.NeedType);
list.Add(new TypeExpression(expression));
}
catch (RecoveryTokenException exception2)
{
if (this.IndexOfToken(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet, exception2) == -1)
{
exception2._partiallyComputedNode = null;
throw exception2;
}
if (exception2._partiallyComputedNode != null)
{
list.Add(new TypeExpression(exception2._partiallyComputedNode));
}
}
finally
{
this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet);
}
}
while (JSToken.Comma == this.currentToken.token);
}
}
if (ast2 != null)
{
superTypeExpression = new TypeExpression(ast2);
}
if (JSToken.LeftCurly != this.currentToken.token)
{
this.ReportError(JSError.NoLeftCurly);
}
ArrayList blockType = this.blockType;
this.blockType = new ArrayList(0x10);
SimpleHashtable labelTable = this.labelTable;
this.labelTable = new SimpleHashtable(0x10);
this.Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject) this.Globals.ScopeStack.Peek()).GetGlobalScope()));
try
{
body = this.ParseClassBody(false, isInterface);
classCtx.UpdateWith(body.context);
//.........这里部分代码省略.........