本文整理汇总了C#中IScope.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# IScope.Resolve方法的具体用法?C# IScope.Resolve怎么用?C# IScope.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScope
的用法示例。
在下文中一共展示了IScope.Resolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckEvt
public void CheckEvt(IScope currScope, LSLAst id)
{
EventSymbol evt = (EventSymbol)currScope.Resolve(id.Text + "()");
Debug.Assert(evt != null);
//try to find this event in our table
if (!_supportedEvents.HasEventByName(id.Text))
{
_listener.Error("line " + id.Token.Line + ":" +
id.Token.CharPositionInLine + " No event evailable with name '" + id.Text + "'");
return;
}
//also try to resolve the arguments
List<VarType> passedEvtArgs = evt.ExtractArgumentTypes();
if (!_supportedEvents.HasEventBySig(id.Text, VarType.Void, passedEvtArgs))
{
string paramList = this.FormatParamTypeList(_supportedEvents.GetArguments(id.Text));
_listener.Error("line " + id.Token.Line + ":" +
id.Token.CharPositionInLine + " Incorrect parameters for event " + id.Text +
paramList);
}
}
示例2: EnsureResolve
public Symbol EnsureResolve(LSLAst node, IScope scope, string symName)
{
Symbol sym = scope.Resolve(symName);
if (sym == null)
{
_listener.Error("line " + node.Token.Line + ":" +
node.Token.CharPositionInLine + " Undefined symbol '" + symName + "'");
return null;
}
//globals are always ok to ref, so skip the rest of the checks if this is a global
if (sym.Scope == Globals)
{
return sym;
}
//consts are always ok to ref
if (sym is ConstantSymbol)
{
return sym;
}
if (sym.Def == null)
{
_listener.Error(String.Format("INTERNAL COMPILER ERROR: Symbol definition not set: {0}", sym));
return sym;
}
//if the symbol is local, it cant be used before it's defined
if (sym.Def.TokenStartIndex > node.TokenStartIndex)
{
//if we are in a local scope, check if there is a version of this symbol in the function (parameter) scope
//then check if there is a version of this symbol on the global scope
Symbol methodSymbol = FindSymbolInMethodScope(sym, scope);
Symbol globalSymbol = Globals.Resolve(symName);
if (methodSymbol == null && globalSymbol == null)
{
//there is no global by this name, it's only defined locally and it's defined after
//its use
_listener.Error("line " + node.Token.Line + ":" +
node.Token.CharPositionInLine + " Symbol '" + symName + "' can not be used before it is defined");
}
if (methodSymbol != null) sym = methodSymbol;
else sym = globalSymbol;
}
//also if this symbol is local, it can not be defined in the root of the expression from which it is being used
else if (IsChildNodeOf((LSLAst)sym.Def.GetAncestor(LSLParser.VAR_DECL), node))
{
//the symbol we found is a parent of the declaration and is therefore not valid for use
//check parent scopes for a valid symbol
Symbol methodSymbol = FindSymbolInMethodScope(sym, scope);
Symbol globalSymbol = Globals.Resolve(symName);
if (methodSymbol == null && globalSymbol == null)
{
//there is no global by this name, it's only defined locally and it's defined after
//its use
_listener.Error("line " + node.Token.Line + ":" +
node.Token.CharPositionInLine + " Symbol '" + symName + "' can not be used before it is defined");
}
if (methodSymbol != null) sym = methodSymbol;
else sym = globalSymbol;
}
return sym;
}