本文整理汇总了C#中Scope.GetSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.GetSymbol方法的具体用法?C# Scope.GetSymbol怎么用?C# Scope.GetSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scope
的用法示例。
在下文中一共展示了Scope.GetSymbol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CatchClause
public CatchClause(Scope scope, ReadIdentifierExpression identifier, Statement statement)
{
Debug.Assert(scope != null, "Catch clause must have its own scope");
Debug.Assert(identifier != null, "Catch clause identifier cannot be null");
Debug.Assert(identifier.Symbol != null, "Catch clause identifier must have a symbol");
Debug.Assert(scope.GetSymbol(identifier.Symbol.Name) == identifier.Symbol, "Catch clause identifier must belong to its inner scope");
Scope = scope;
Identifier = identifier;
Statement = statement;
SourceOffset = statement.SourceOffset;
Use(Identifier);
}
示例2: MakeFunctionExpression
public FunctionExpression MakeFunctionExpression(Scope scope, IIdentifier name, IIdentifierList parameters,
IStatement statement, Scope newScope)
{
var namedParams = parameters as List<ReadIdentifierExpression>;
Debug.Assert(namedParams.Count == 0 || newScope.IsFunction, "parameters must be declared in a function scope");
for (var i = 0; i < namedParams.Count; ++i)
{
var symbol = namedParams[i].Symbol;
Debug.Assert(newScope.GetSymbol(symbol.Name) == symbol && symbol.ContainerScope == newScope, "Invalid situation, parameter symbol is not in the newScope");
symbol.SymbolType = JSSymbol.SymbolTypes.Local; //already know symbol.ContainerScope.IsFunction, so no need for hoisting
symbol.ParameterIndex = i;
}
var funcName = name as ReadIdentifierExpression;
if (newScope.IsFunctionDeclaration)
{
Debug.Assert(funcName != null, "the function declaration must have a name");
Debug.Assert(scope.GetSymbol(funcName.Symbol.Name) == funcName.Symbol && funcName.Symbol.ContainerScope == scope, "Name of function declaration must exist in the outer scope");
DeclareHoistedLocal(funcName.Symbol); //This is defined now in its scope!
}
else if (newScope.IsProgram)
{
Debug.Assert(funcName == null, "program scope cannot have a name!");
}
else
{
Debug.Assert(newScope.IsFunction == true, "The FunctionExpression scope is not properly marked");
if (funcName != null)
{
Debug.Assert(newScope.GetSymbol(funcName.Symbol.Name) == funcName.Symbol && funcName.Symbol.ContainerScope == newScope, "Name of function expression must exist in its own scope");
funcName.Symbol.SymbolType = JSSymbol.SymbolTypes.Local; //This is defined now in its scope, & we already know funcName.Symbol.ContainerScope.IsFunction, so no need for hoisting
}
}
var func = new FunctionExpression(newScope, funcName, namedParams, (BlockStatement)statement);
var metadata = new JSFunctionMetadata(func);
func.Metadata = metadata;
if (scope != null) scope.AddSubFunction(metadata);
return func;
}
示例3: MakeCatchClause
public CatchClause MakeCatchClause(IIdentifier identifier, IStatement statement, Scope innerScope)
{
var readId = identifier as ReadIdentifierExpression;
Debug.Assert(readId != null, "Catch clause identifier {0} is not a ReadIdentifierExpression", ((Identifier)identifier));
Debug.Assert(readId.Symbol != null, "Cannot find symbol for identifier {0} in catch clause", ((Identifier)identifier));
Debug.Assert(innerScope.GetSymbol(readId.Symbol.Name) == readId.Symbol, "Catch clause identifier {0} must belong to its inner scope", readId);
readId.Symbol.SymbolType = JSSymbol.SymbolTypes.Local; //this symbol is trully local to the innerScope
return new CatchClause(innerScope, readId, (Statement)statement);
}