 # certain AST nodes with metadata. It would also probably rely on a symbol
 # table. But this one does nonee such thing.
 
+
 class JSCodeGenerator
-  constructor: -> # Do nothing
-  compile: (astRoot) ->
-    @ident = '  ' # I guess I should have an indent or something.
+  constructor: ->
+    @indentAmount = '  '
+
+  compile: (ast) ->
+    # I guess I should initialize the indent or something.
+    @indent = '  '
+
     # I don't know what else to do other than visit the node.
     # Regardless... here it is:
-    @visit astRoot
+    @visit ast
+
+  # Returns an action for a JS binary operator.
+  @makeBinOp: (binop) -> (node) ->
+    ['(', @visit(node.left), binop, @visit(node.right), ')']
 
   # Here's the big array of ast nodes and the actions that should be called
   # when they are visited. Each each action should return either a list or a
-  # string of JavaScript code. 
+  # string of JavaScript code.
   @actions =
     program: (node) ->
       [

      # TODO: visit the var declarations.
      vars = []

      # Compile all of the subroutines. This is the only place where we
      # increment the indent.
      oldIdent = @ident
      @ident += '  '
      subroutines =
        @visit sub for sub in node.subroutines
      @ident = oldIdent

      # Compile every statment that makes up the body...
      body =
        # Some statements are undefined... skip those.
        for stmt in node.body when stmt?
          @ident + @visit(stmt) + ';\n'

      # ...and concatenate all of the above categories.
      [].concat(vars, subroutines, body)

    'procedure': (node) ->
      # Get the names of the parameters...
      # TODO:
      params = []

      [
        @ident
        "function #{name}(#{parms.join(', ')}) {"

        # Visit this node as a generic "body" node.
        @visit node, '$body'

        @ident
        "}"
      ]


      console.warn 'No action for', node
      ''

  # Executes the function, but must indent all its output.
  indentThis: (func) ->
      # Increment the indent.
      oldIdent = @indent
      @indent += @indentAmount
      func()
      @indent = oldIdent


