本文整理汇总了C#中Microsoft.JScript.AST.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# AST.ToString方法的具体用法?C# AST.ToString怎么用?C# AST.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.JScript.AST
的用法示例。
在下文中一共展示了AST.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Try
internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext)
: base(context) {
this.body = body;
this.type = type;
this.handler = handler;
this.finally_block = finally_block;
ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek();
while (current_scope is WithObject) //Can only happen at run time and only if there is an eval
current_scope = current_scope.GetParent();
this.handler_scope = null;
this.field = null;
if (identifier != null){
this.fieldName = identifier.ToString();
this.field = current_scope.GetField(this.fieldName, BindingFlags.Public|BindingFlags.Instance|BindingFlags.Static);
if (this.field != null){
if (type == null && (field is JSVariableField && field.IsStatic && ((JSVariableField)field).type == null) && !field.IsLiteral && !field.IsInitOnly)
return; //preserve legacy semantics by using the existing variable
if (((IActivationObject)current_scope).GetLocalField(this.fieldName) != null)
identifier.context.HandleError(JSError.DuplicateName, false);
}
this.handler_scope = new BlockScope(current_scope);
this.handler_scope.catchHanderScope = true;
JSVariableField f = this.handler_scope.AddNewField(identifier.ToString(), Missing.Value, FieldAttributes.Public); // must be a local
this.field = f; f.originalContext = identifier.context;
if (identifier.context.document.debugOn && this.field is JSLocalField){
this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field);
}
}
this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt;
this.tryEndContext = tryEndContext;
}
示例2: ClassScope
internal ClassScope(AST name, GlobalScope scope) : base(scope)
{
this.name = name.ToString();
base.engine = scope.engine;
base.fast = scope.fast;
this.noExpando = true;
base.isKnownAtCompileTime = true;
this.owner = null;
this.constructors = new JSConstructor[0];
ScriptObject parent = base.engine.ScriptObjectStackTop();
while (parent is WithObject)
{
parent = parent.GetParent();
}
if (parent is ClassScope)
{
this.package = ((ClassScope) parent).GetPackage();
}
else if (parent is PackageScope)
{
this.package = (PackageScope) parent;
}
else
{
this.package = null;
}
this.itemProp = null;
this.outerClassField = null;
this.inStaticInitializerCode = false;
this.staticInitializerUsesEval = false;
this.instanceInitializerUsesEval = false;
}
示例3: TypeExpression
internal TypeExpression(AST expression)
: base(expression.context) {
this.expression = expression;
this.isArray = false;
this.rank = 0;
this.recursive = false;
this.cachedIR = null;
if (expression is Lookup){
String name = expression.ToString();
Object ptype = Globals.TypeRefs.GetPredefinedType(name);
if (ptype != null)
this.expression = new ConstantWrapper(ptype, expression.context);
}
}
示例4: FunctionExpression
internal FunctionExpression(Context context, AST id, ParameterDeclaration[] formal_parameters, TypeExpression return_type, Block body, FunctionScope own_scope, FieldAttributes attributes)
: base(context){
if (attributes != (FieldAttributes)0){
this.context.HandleError(JSError.SyntaxError);
attributes = (FieldAttributes)0;
}
ScriptObject enclosingScope = Globals.ScopeStack.Peek();
this.name = id.ToString();
if (this.name.Length == 0)
this.name = "anonymous "+(uniqueNumber++).ToString(CultureInfo.InvariantCulture);
else
this.AddNameTo(enclosingScope);
this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, enclosingScope, this.context, MethodAttributes.Static|MethodAttributes.Public);
}
示例5: Class
internal Class(Context context, AST id, TypeExpression superTypeExpression, TypeExpression[] interfaces, Block body,
FieldAttributes attributes, bool isAbstract, bool isFinal, bool isStatic, bool isInterface, CustomAttributeList customAttributes)
: base(context) {
this.name = id.ToString();
this.superTypeExpression = superTypeExpression;
this.interfaces = interfaces;
this.body = body;
this.enclosingScope = (ScriptObject)Globals.ScopeStack.Peek(1);
this.attributes = TypeAttributes.Class|TypeAttributes.Serializable;
this.SetAccessibility(attributes);
if (isAbstract)
this.attributes |= TypeAttributes.Abstract;
this.isAbstract = isAbstract || isInterface;
this.isAlreadyPartiallyEvaluated = false;
if (isFinal)
this.attributes |= TypeAttributes.Sealed;
if (isInterface)
this.attributes |= TypeAttributes.Interface | TypeAttributes.Abstract;
this.isCooked = false;
this.cookedType = null;
this.isExpando = false;
this.isInterface = isInterface;
this.isStatic = isStatic;
this.needsEngine = !isInterface;
this.validOn = (AttributeTargets)0;
this.allowMultiple = true;
this.classob = (ClassScope)Globals.ScopeStack.Peek();
this.classob.name = this.name;
this.classob.owner = this;
this.implicitDefaultConstructor = null;
if (!isInterface && !(this is EnumDeclaration))
this.SetupConstructors();
this.EnterNameIntoEnclosingScopeAndGetOwnField(id, isStatic);
this.fields = this.classob.GetMemberFields();
this.superClass = null;
this.superIR = null;
this.superMembers = null;
this.firstIndex = null;
this.fieldInitializer = null;
this.customAttributes = customAttributes;
this.clsCompliance = CLSComplianceSpec.NotAttributed;
this.generateCodeForExpando = false;
this.expandoItemProp = null;
this.getHashTableMethod = null;
this.getItem = null;
this.setItem = null;
}
示例6: ClassScope
internal bool inStaticInitializerCode; //Set this to true when partially evaluating the initializer of a static variable, false otherwise
internal ClassScope(AST name, GlobalScope scope)
: base(scope) { //The parent must be set to a proper value before the class can be used.
this.name = name.ToString();
this.engine = scope.engine;
this.fast = scope.fast;
this.noExpando = true;
this.isKnownAtCompileTime = true;
this.owner = null; //set by Class constructor
this.constructors = new JSConstructor[0];
ScriptObject enclosingScope = this.engine.ScriptObjectStackTop();
while (enclosingScope is WithObject)
enclosingScope = enclosingScope.GetParent();
if (enclosingScope is ClassScope)
this.package = ((ClassScope)enclosingScope).GetPackage();
else if (enclosingScope is PackageScope)
this.package = (PackageScope)enclosingScope;
else
this.package = null;
this.itemProp = null;
this.outerClassField = null;
this.inStaticInitializerCode = false;
}
示例7: MemberExpression
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;
//.........这里部分代码省略.........