Parent

Class Index [+]

Quicksearch

RKelly::Visitors::ECMAVisitor

Public Class Methods

new() click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 4
      def initialize
        @indent = 0
      end

Public Instance Methods

visit_ArgumentsNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 72
      def visit_ArgumentsNode(o)
        o.value.map { |x| x.accept(self) }.join(', ')
      end
visit_ArrayNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 139
      def visit_ArrayNode(o)
        "[#{o.value.map { |x| x ? x.accept(self) : '' }.join(', ')}]"
      end
visit_AssignExprNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 24
      def visit_AssignExprNode(o)
        " = #{o.value.accept(self)}"
      end
visit_BitwiseNotNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 131
      def visit_BitwiseNotNode(o)
        "~#{o.value.accept(self)}"
      end
visit_BlockNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 55
      def visit_BlockNode(o)
        @indent += 1
        "{\n#{o.value.accept(self)}\n#{@indent -=1; indent}}"
      end
visit_BracketAccessorNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 302
      def visit_BracketAccessorNode(o)
        "#{o.value.accept(self)}[#{o.accessor.accept(self)}]"
      end
visit_BreakNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 99
      def visit_BreakNode(o)
        "break" + (o.value ? " #{o.value}" : '') + ';'
      end
visit_CaseBlockNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 225
      def visit_CaseBlockNode(o)
        @indent += 1
        "{\n" + (o.value ? o.value.map { |x| x.accept(self) }.join('') : '') +
          "#{@indent -=1; indent}}"
      end
visit_CaseClauseNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 231
      def visit_CaseClauseNode(o)
        case_code = "#{indent}case #{o.left ? o.left.accept(self) : nil}:\n"
        @indent += 1
        case_code += "#{o.value.accept(self)}\n"
        @indent -= 1
        case_code
      end
visit_CommaNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 277
      def visit_CommaNode(o)
        "#{o.left.accept(self)}, #{o.value.accept(self)}"
      end
visit_ConditionalNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 286
      def visit_ConditionalNode(o)
        "#{o.conditions.accept(self)} ? #{o.value.accept(self)} : " +
          "#{o.else.accept(self)}"
      end
visit_ConstStatementNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 16
      def visit_ConstStatementNode(o)
        "const #{o.value.map { |x| x.accept(self) }.join(', ')};"
      end
visit_ContinueNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 103
      def visit_ContinueNode(o)
        "continue" + (o.value ? " #{o.value}" : '') + ';'
      end
visit_DeleteNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 135
      def visit_DeleteNode(o)
        "delete #{o.value.accept(self)}"
      end
visit_DoWhileNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 239
      def visit_DoWhileNode(o)
        "do #{o.left.accept(self)} while(#{o.value.accept(self)});"
      end
visit_DotAccessorNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 123
      def visit_DotAccessorNode(o)
        "#{o.value.accept(self)}.#{o.accessor}"
      end
visit_ElementNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 143
      def visit_ElementNode(o)
        o.value.accept(self)
      end
visit_EmptyStatementNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 115
      def visit_EmptyStatementNode(o)
        ';'
      end
visit_ExpressionStatementNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 60
      def visit_ExpressionStatementNode(o)
        "#{o.value.accept(self)};"
      end
visit_FalseNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 111
      def visit_FalseNode(o)
        "false"
      end
visit_ForInNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 291
      def visit_ForInNode(o)
        "for(#{o.left.accept(self)} in #{o.right.accept(self)}) " +
          "#{o.value.accept(self)}"
      end
visit_ForNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 32
      def visit_ForNode(o)
        init    = o.init ? o.init.accept(self) : ';'
        test    = o.test ? o.test.accept(self) : ''
        counter = o.counter ? o.counter.accept(self) : ''
        "for(#{init} #{test}; #{counter}) #{o.value.accept(self)}"
      end
visit_FunctionBodyNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 94
      def visit_FunctionBodyNode(o)
        @indent += 1
        "{\n#{o.value.accept(self)}\n#{@indent -=1; indent}}"
      end
visit_FunctionCallNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 68
      def visit_FunctionCallNode(o)
        "#{o.value.accept(self)}(#{o.arguments.accept(self)})"
      end
visit_FunctionDeclNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 84
      def visit_FunctionDeclNode(o)
        "#{indent}function #{o.value}(" +
          "#{o.arguments.map { |x| x.accept(self) }.join(', ')})" +
          "#{o.function_body.accept(self)}"
      end
visit_FunctionExprNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 272
      def visit_FunctionExprNode(o)
        "#{o.value}(#{o.arguments.map { |x| x.accept(self) }.join(', ')}) " +
          "#{o.function_body.accept(self)}"
      end
visit_GetterPropertyNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 264
      def visit_GetterPropertyNode(o)
        "get #{o.name}#{o.value.accept(self)}"
      end
visit_IfNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 281
      def visit_IfNode(o)
        "if(#{o.conditions.accept(self)}) #{o.value.accept(self)}" +
          (o.else ? " else #{o.else.accept(self)}" : '')
      end
visit_LabelNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 247
      def visit_LabelNode(o)
        "#{o.name}: #{o.value.accept(self)}"
      end
visit_LessNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 39
      def visit_LessNode(o)
        "#{o.left.accept(self)} < #{o.value.accept(self)}"
      end
visit_LogicalNotNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 147
      def visit_LogicalNotNode(o)
        "!#{o.value.accept(self)}"
      end
visit_NewExprNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 306
      def visit_NewExprNode(o)
        "new #{o.value.accept(self)}(#{o.arguments.accept(self)})"
      end
visit_NullNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 80
      def visit_NullNode(o)
        "null"
      end
visit_NumberNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 28
      def visit_NumberNode(o)
        o.value.to_s
      end
visit_ObjectLiteralNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 251
      def visit_ObjectLiteralNode(o)
        @indent += 1
        lit = "{" + (o.value.length > 0 ? "\n" : ' ') +
          o.value.map { |x| "#{indent}#{x.accept(self)}" }.join(",\n") +
          (o.value.length > 0 ? "\n" : '') + '}'
        @indent -= 1
        lit
      end
visit_OpEqualNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 64
      def visit_OpEqualNode(o)
        "#{o.left.accept(self)} = #{o.value.accept(self)}"
      end
visit_ParameterNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 90
      def visit_ParameterNode(o)
        o.value
      end
visit_PostfixNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 47
      def visit_PostfixNode(o)
        "#{o.operand.accept(self)}#{o.value}"
      end
visit_PrefixNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 51
      def visit_PrefixNode(o)
        "#{o.value}#{o.operand.accept(self)}"
      end
visit_PropertyNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 260
      def visit_PropertyNode(o)
        "#{o.name}: #{o.value.accept(self)}"
      end
visit_RegexpNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 119
      def visit_RegexpNode(o)
        o.value
      end
visit_ResolveNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 43
      def visit_ResolveNode(o)
        o.value
      end
visit_ReturnNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 159
      def visit_ReturnNode(o)
        "return" + (o.value ? " #{o.value.accept(self)}" : '') + ';'
      end
visit_SetterPropertyNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 268
      def visit_SetterPropertyNode(o)
        "set #{o.name}#{o.value.accept(self)}"
      end
visit_SourceElementsNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 8
      def visit_SourceElementsNode(o)
        o.value.map { |x| "#{indent}#{x.accept(self)}" }.join("\n")
      end
visit_StringNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 76
      def visit_StringNode(o)
        o.value
      end
visit_SwitchNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 221
      def visit_SwitchNode(o)
        "switch(#{o.left.accept(self)}) #{o.value.accept(self)}"
      end
visit_ThisNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 127
      def visit_ThisNode(o)
        "this"
      end
visit_ThrowNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 163
      def visit_ThrowNode(o)
        "throw #{o.value.accept(self)};"
      end
visit_TrueNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 107
      def visit_TrueNode(o)
        "true"
      end
visit_TryNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 296
      def visit_TryNode(o)
        "try #{o.value.accept(self)}" +
          (o.catch_block ? " catch(#{o.catch_var}) #{o.catch_block.accept(self)}" : '') +
          (o.finally_block ? " finally #{o.finally_block.accept(self)}" : '')
      end
visit_TypeOfNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 167
      def visit_TypeOfNode(o)
        "typeof #{o.value.accept(self)}"
      end
visit_UnaryMinusNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 151
      def visit_UnaryMinusNode(o)
        "-#{o.value.accept(self)}"
      end
visit_UnaryPlusNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 155
      def visit_UnaryPlusNode(o)
        "+#{o.value.accept(self)}"
      end
visit_VarDeclNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 20
      def visit_VarDeclNode(o)
        "#{o.name}#{o.value ? o.value.accept(self) : nil}"
      end
visit_VarStatementNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 12
      def visit_VarStatementNode(o)
        "var #{o.value.map { |x| x.accept(self) }.join(', ')};"
      end
visit_VoidNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 171
      def visit_VoidNode(o)
        "void(#{o.value.accept(self)})"
      end
visit_WhileNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 217
      def visit_WhileNode(o)
        "while(#{o.left.accept(self)}) #{o.value.accept(self)}"
      end
visit_WithNode(o) click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 243
      def visit_WithNode(o)
        "with(#{o.left.accept(self)}) #{o.value.accept(self)}"
      end

Private Instance Methods

indent() click to toggle source

(Not documented)

# File lib/rkelly/visitors/ecma_visitor.rb, line 311
      def indent; ' ' * @indent * 2; end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.