本文整理汇总了C#中Token.GetSourceRef方法的典型用法代码示例。如果您正苦于以下问题:C# Token.GetSourceRef方法的具体用法?C# Token.GetSourceRef怎么用?C# Token.GetSourceRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.GetSourceRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForLoopStatement
public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken)
: base(lcontext)
{
// for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end |
// lexer already at the '=' ! [due to dispatching vs for-each]
CheckTokenType(lcontext, TokenType.Op_Assignment);
m_Start = Expression.Expr(lcontext);
CheckTokenType(lcontext, TokenType.Comma);
m_End = Expression.Expr(lcontext);
if (lcontext.Lexer.Current.Type == TokenType.Comma)
{
lcontext.Lexer.Next();
m_Step = Expression.Expr(lcontext);
}
else
{
m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(1));
}
lcontext.Scope.PushBlock();
m_VarName = lcontext.Scope.DefineLocal(nameToken.Text);
m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do));
m_InnerBlock = new CompositeStatement(lcontext);
m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef();
m_StackFrame = lcontext.Scope.PopBlock();
lcontext.Source.Refs.Add(m_RefFor);
lcontext.Source.Refs.Add(m_RefEnd);
}
示例2: ForEachLoopStatement
public ForEachLoopStatement(ScriptLoadingContext lcontext, Token firstNameToken, Token forToken)
: base(lcontext)
{
// for namelist in explist do block end |
List<string> names = new List<string>();
names.Add(firstNameToken.Text);
while (lcontext.Lexer.Current.Type == TokenType.Comma)
{
lcontext.Lexer.Next();
Token name = CheckTokenType(lcontext, TokenType.Name);
names.Add(name.Text);
}
CheckTokenType(lcontext, TokenType.In);
m_RValues = new ExprListExpression(Expression.ExprList(lcontext), lcontext);
lcontext.Scope.PushBlock();
m_Names = names
.Select(n => lcontext.Scope.TryDefineLocal(n))
.ToArray();
m_NameExps = m_Names
.Select(s => new SymbolRefExpression(lcontext, s))
.Cast<IVariable>()
.ToArray();
m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do));
m_Block = new CompositeStatement(lcontext);
m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef();
m_StackFrame = lcontext.Scope.PopBlock();
lcontext.Source.Refs.Add(m_RefFor);
lcontext.Source.Refs.Add(m_RefEnd);
}