本文整理汇总了C#中Scope.GetOrAddSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.GetOrAddSymbol方法的具体用法?C# Scope.GetOrAddSymbol怎么用?C# Scope.GetOrAddSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scope
的用法示例。
在下文中一共展示了Scope.GetOrAddSymbol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeReadIdentifierExpression
private ReadIdentifierExpression MakeReadIdentifierExpression(Scope scope, string identifier, int offset)
{
return MakeReadIdentifierExpression(scope.GetOrAddSymbol(identifier), offset);
}
示例2: MakeWriteIdentifierExpression
//Externally, the MakeAssignment should be used
private WriteIdentifierExpression MakeWriteIdentifierExpression(Scope scope, string identifier, Expression value)
{
return MakeWriteIdentifierExpression(scope.GetOrAddSymbol(identifier), MakeGuardedCast(value));
}
示例3: AnalyzeScope
/// <summary>
/// This function will only analyze the scope of one function
/// </summary>
private void AnalyzeScope(Scope scope)
{
Debug.WriteLine("Analyzing scope {0}", scope);
if (scope.IsFunction)
{
CollectPropertiesFromInnerScopes(scope);
if (scope.HasEval)
{
///When we have eval, we should be very conservative and assume everything is possible.
///this is the place to do that after all symbols are already processed.
if (!scope.HasArgumentsSymbol)
{
var arguments = scope.GetOrAddSymbol(JSFunctionArguments.Name);
Debug.Assert(
arguments.SymbolType == JSSymbol.SymbolTypes.Local
|| arguments.SymbolType == JSSymbol.SymbolTypes.Unknown
, "invalide arguments type {0}", arguments.SymbolType);
arguments.SymbolType = JSSymbol.SymbolTypes.Arguments;
scope.HasArgumentsSymbol = true;
}
}
}
foreach (var s in scope.Symbols)
{
s.ValueIndex = _currFuncMetadata.TotalSymbolCount + s.Index;
AnalyzeSymbol(s);
}
_currFuncMetadata.TotalSymbolCount += scope.Symbols.Count;
foreach (var s in scope.InnerScopes)
{
if (!s.IsFunction)
{
AnalyzeScope(s);
//TODO: should we have this code : scope.HasParentLocalSymbol = scope.HasParentLocalSymbol || s.HasParentLocalSymbol;
}
else
{
Debug.Assert(
scope.ContainerFunction.FunctionIR.Scope.IsProgram //We are in program and sub-functions are not analyzed
|| s.ContainerFunction.CurrentStatus >= JSFunctionMetadata.Status.Analyzed //we are not in program and sub-function must be done
, "A function must be analyzed only after all of its sub-functions are analyzed.");
}
}
}