Ejemplo n.º 1
0
		public void Visit(TryStatement expression)
		{
			throw new System.NotImplementedException();
		}
Ejemplo n.º 2
0
        public void Visit(TryStatement statement)
        {
            try {
                statement.Statement.Accept(this);
            }
            catch (Exception e) {
                // there might be no catch statement defined
                if (statement.Catch != null) {
                    JsException jsException = e as JsException;

                    if (jsException == null)
                        jsException = new JsException(Global.ErrorClass.New(e.Message));

                    // handle thrown exception assignment to a local variable: catch(e)
                    if (statement.Catch.Identifier != null) {
                        // if catch is called, Result contains the thrown value
                        Assign(new MemberExpression(new PropertyExpression(statement.Catch.Identifier), null), jsException.Value);
                    }

                    statement.Catch.Statement.Accept(this);
                }
                else {
                    throw;
                }
            }
            finally {

                if (statement.Finally != null) {
                    JsObject catchScope = new JsObject();
                    statement.Finally.Statement.Accept(this);
                }
            }
        }
Ejemplo n.º 3
0
 void Analyze(TryStatement Stmt)
 {
     SetCurrentLineAndCharNos(Stmt);
     if (Stmt.Catch != null) Analyze(Stmt.Catch);
     if (Stmt.Finally != null) Analyze(Stmt.Finally);
     if (Stmt.Statement != null) Analyze(Stmt.Statement);
 }
Ejemplo n.º 4
0
        public void Visit(TryStatement statement)
        {
            EnterScope(new JsObject());

            try
            {
                statement.Statement.Accept(this);
            }
            catch (JsException jsException)
            {
                ExitScope();

                EnterScope(new JsObject());

                // handle thrown exception assignment to a local variable: catch(e)
                if (statement.Catch.Identifier != null)
                {
                    // if catch is called, Result contains the thrown value
                    Assign(new MemberExpression(new PropertyExpression(statement.Catch.Identifier), null), jsException.Value);
                }

                statement.Catch.Statement.Accept(this);
            }
            finally
            {
                ExitScope();

                if (statement.Finally != null)
                {
                    JsObject catchScope = new JsObject();
                    EnterScope(catchScope);

                    statement.Finally.Statement.Accept(this);

                    ExitScope();
                }
            }

        }
Ejemplo n.º 5
0
        public void Visit(TryStatement statement)
        {
            EnterScope(new JsObject()); // ExitScope is called in Finally

            try {
                statement.Statement.Accept(this);
            }
            catch (JsException e) {
                // there might be no catch statement defined
                if (statement.Catch != null) {
                    // there is another exitscope called in Finally
                    ExitScope();
                    EnterScope(new JsObject());

                    // handle thrown exception assignment to a local variable: catch(e)
                    if (statement.Catch.Identifier != null) {
                        // if catch is called, Result contains the thrown value
                        Assign(new MemberExpression(new PropertyExpression(statement.Catch.Identifier), null), e.Value);
                    }

                    statement.Catch.Statement.Accept(this);
                }
                else {
                    throw;
                }
            }
            finally {
                ExitScope();

                if (statement.Finally != null) {
                    JsObject catchScope = new JsObject();
                    EnterScope(catchScope);

                    try {
                        statement.Finally.Statement.Accept(this);
                    }
                    finally {
                        ExitScope();
                    }
                }
            }
        }