public AssignmentStatement(ScriptLoadingContext lcontext, Token startToken) : base(lcontext) { List <string> names = new List <string>(); Token first = startToken; while (true) { Token name = CheckTokenType(lcontext, TokenType.Name); names.Add(name.Text); if (lcontext.Lexer.Current.Type != TokenType.Comma) { break; } lcontext.Lexer.Next(); } if (lcontext.Lexer.Current.Type == TokenType.Op_Assignment) { CheckTokenType(lcontext, TokenType.Op_Assignment); m_RValues = Expression.ExprList(lcontext); } else { m_RValues = new List <Expression>(); if (names.Count > 0) { m_RValues = new List <Expression>(new Expression[] { new LiteralExpression(lcontext, DynValue.Nil) }); } } foreach (string name in names) { var localVar = lcontext.Scope.TryDefineLocal(name); var symbol = new SymbolRefExpression(lcontext, localVar); m_LValues.Add(symbol); } Token last = lcontext.Lexer.Current; m_Ref = first.GetSourceRefUpTo(last); lcontext.Source.Refs.Add(m_Ref); }
public AssignmentStatement(ScriptLoadingContext lcontext, Token startToken) : base(lcontext) { var names = new List <string>(); var first = startToken; while (true) { var name = CheckTokenType(lcontext, TokenType.Name); names.Add(name.Text); if (lcontext.Lexer.Current.Type != TokenType.Comma) { break; } lcontext.Lexer.Next(); } if (lcontext.Lexer.Current.Type == TokenType.Op_Assignment) { CheckTokenType(lcontext, TokenType.Op_Assignment); _rValues = Expression.ExprList(lcontext); } else { _rValues = new List <Expression>(); } foreach (string name in names) { var localVar = lcontext.Scope.TryDefineLocal(name); var symbol = new SymbolRefExpression(lcontext, localVar); _lValues.Add(symbol); } var last = lcontext.Lexer.Current; _ref = first.GetSourceRefUpTo(last); lcontext.Source.Refs.Add(_ref); }