Example #1
0
		public void Visit(BlockStatement expression)
		{
			Builder.AppendLine("{");
			indent++;
			foreach (var statement in expression.Statements)
			{
				Indent();
				statement.Accept(this);
				Builder.AppendLine();
			}
			indent--;
			Indent();
			Builder.AppendLine("}");
		}
Example #2
0
        public void Visit(BlockStatement statement)
        {
            Statement oldStatement = CurrentStatement;
            foreach (var s in statement.Statements) {
                CurrentStatement = s;

                if (DebugMode) {
                    OnStep(CreateDebugInformation(s));
                }

                Result = null;
                s.Accept(this);

                if (StopStatementFlow()) {
                    return;
                }
            }
            CurrentStatement = oldStatement;
        }
        public JsFunction CreateFunction(IFunctionDeclaration functionDeclaration) {
            JsFunction f = Global.FunctionClass.New();

            var statementsWithDefaultReturn = new BlockStatement();
            
            // injects a default return statement at the end of each function
            statementsWithDefaultReturn.Statements.AddLast(functionDeclaration.Statement);
            statementsWithDefaultReturn.Statements.AddLast(new ReturnStatement(new Identifier("undefined")));
            f.Statement = statementsWithDefaultReturn;

            f.Name = functionDeclaration.Name;
            f.Scope = CurrentScope; // copy current scope hierarchy

            f.Arguments = functionDeclaration.Parameters;
            if (HasOption(Options.Strict)) {
                foreach (string arg in f.Arguments) {
                    if (arg == "eval" || arg == "arguments")
                        throw new JsException(Global.StringClass.New("The parameters do not respect strict mode"));
                }
            }

            return f;
        }
Example #4
0
 public CaseClause()
 {
     Statements = new BlockStatement();
 }
Example #5
0
    // $ANTLR start "functionBody"
    // I:\\Developpement\\Evaluant - R&D\\Jint\\trunk\\Jint\\ES3.g:1818:1: functionBody returns [Statement value] : lb= LBRACE ( sourceElement )* RBRACE ;
    public ES3Parser.functionBody_return functionBody() // throws RecognitionException [1]
    {   
        ES3Parser.functionBody_return retval = new ES3Parser.functionBody_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken lb = null;
        IToken RBRACE184 = null;
        ES3Parser.sourceElement_return sourceElement183 = null;


        object lb_tree=null;
        object RBRACE184_tree=null;


        BlockStatement block = new BlockStatement();
        retval.value =  block;

        try 
    	{
            // I:\\Developpement\\Evaluant - R&D\\Jint\\trunk\\Jint\\ES3.g:1823:2: (lb= LBRACE ( sourceElement )* RBRACE )
            // I:\\Developpement\\Evaluant - R&D\\Jint\\trunk\\Jint\\ES3.g:1823:4: lb= LBRACE ( sourceElement )* RBRACE
            {
            	root_0 = (object)adaptor.GetNilNode();

            	lb=(IToken)Match(input,LBRACE,FOLLOW_LBRACE_in_functionBody6713); 
            		lb_tree = (object)adaptor.Create(lb);
            		adaptor.AddChild(root_0, lb_tree);

            	// I:\\Developpement\\Evaluant - R&D\\Jint\\trunk\\Jint\\ES3.g:1823:14: ( sourceElement )*
            	do 
            	{
            	    int alt86 = 2;
            	    int LA86_0 = input.LA(1);

            	    if ( ((LA86_0 >= NULL && LA86_0 <= BREAK) || LA86_0 == CONTINUE || (LA86_0 >= DELETE && LA86_0 <= DO) || (LA86_0 >= FOR && LA86_0 <= IF) || (LA86_0 >= NEW && LA86_0 <= WITH) || LA86_0 == LBRACE || LA86_0 == LPAREN || LA86_0 == LBRACK || LA86_0 == SEMIC || (LA86_0 >= ADD && LA86_0 <= SUB) || (LA86_0 >= INC && LA86_0 <= DEC) || (LA86_0 >= NOT && LA86_0 <= INV) || (LA86_0 >= Identifier && LA86_0 <= StringLiteral) || LA86_0 == RegularExpressionLiteral || (LA86_0 >= DecimalLiteral && LA86_0 <= HexIntegerLiteral)) )
            	    {
            	        alt86 = 1;
            	    }


            	    switch (alt86) 
            		{
            			case 1 :
            			    // I:\\Developpement\\Evaluant - R&D\\Jint\\trunk\\Jint\\ES3.g:1823:15: sourceElement
            			    {
            			    	PushFollow(FOLLOW_sourceElement_in_functionBody6716);
            			    	sourceElement183 = sourceElement();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, sourceElement183.Tree);
            			    	 block.Statements.AddLast(((sourceElement183 != null) ? sourceElement183.value : null)); 

            			    }
            			    break;

            			default:
            			    goto loop86;
            	    }
            	} while (true);

            	loop86:
            		;	// Stops C# compiler whining that label 'loop86' has no statements

            	RBRACE184=(IToken)Match(input,RBRACE,FOLLOW_RBRACE_in_functionBody6723); 
            		RBRACE184_tree = (object)adaptor.Create(RBRACE184);
            		adaptor.AddChild(root_0, RBRACE184_tree);


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (object)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
Example #6
0
 void Analyze(BlockStatement Stmt)
 {
     SetCurrentLineAndCharNos(Stmt);
     if(Stmt.Statements != null) Analyze(Stmt.Statements);
 }
Example #7
0
 public CaseClause()
 {
     Statements = new BlockStatement();
 }