public ChunkStatement(ScriptLoadingContext lcontext) : base(lcontext) { lcontext.Scope.PushFunction(this, true); m_Env = lcontext.Scope.DefineLocal(WellKnownSymbols.ENV); m_VarArgs = lcontext.Scope.DefineLocal(WellKnownSymbols.VARARGS); m_Block = new CompositeStatement(lcontext); if (lcontext.Lexer.Current.Type != TokenType.Eof) throw new SyntaxErrorException(lcontext.Lexer.Current, "<eof> expected near '{0}'", lcontext.Lexer.Current.Text); m_StackFrame = lcontext.Scope.PopFunction(); }
private FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool pushSelfParam, Table globalContext, bool isLambda) : base(lcontext) { if (globalContext != null) CheckTokenType(lcontext, TokenType.Function); // here lexer should be at the '(' or at the '|' var openRound = CheckTokenType(lcontext, isLambda ? TokenType.Lambda : TokenType.Brk_Open_Round); var paramnames = BuildParamList(lcontext, pushSelfParam, openRound, isLambda); // here lexer is at first token of body m_Begin = openRound.GetSourceRefUpTo(lcontext.Lexer.Current); // create scope lcontext.Scope.PushFunction(this, m_HasVarArgs); if (globalContext != null) { m_GlobalEnv = globalContext; m_Env = lcontext.Scope.TryDefineLocal(WellKnownSymbols.ENV); } else { lcontext.Scope.ForceEnvUpValue(); } m_ParamNames = DefineArguments(paramnames, lcontext); if (isLambda) m_Statement = CreateLambdaBody(lcontext); else m_Statement = CreateBody(lcontext); m_StackFrame = lcontext.Scope.PopFunction(); lcontext.Source.Refs.Add(m_Begin); lcontext.Source.Refs.Add(m_End); }