         "label #{label2}"]
   end
 
-  def compile_if_statement([{:keyword, "if"},
-                            {:symbol, "("},
-                            {:expression, exp_parsed},
-                            {:symbol, ")"},
-                            {:symbol, "{"},
-                            {:statements, statements_parsed},
-                            {:symbol, "}"},
-                            {:keyword, "else"},
-                            {:symbol, "{"},
-                            {:statements, else_parsed},
-                            {:symbol, "}"}]) do
+  def compile_if_statement(class_name,
+        [{:keyword, "if"},
+         {:symbol, "("},
+         {:expression, exp_parsed},
+         {:symbol, ")"},
+         {:symbol, "{"},
+         {:statements, statements_parsed},
+         {:symbol, "}"}]) do
+    label1 = "ifL1$#{JackUuid.generate()}"
+    exp = compile_exp(exp_parsed)
+    statements = compile_statement(class_name, statements_parsed)
+    exp
+    ++ ["not",
+        "if-goto #{label1}"]
+    ++ statements
+    ++ ["label #{label1}"]
+  end
+
+  def compile_if_statement(class_name,
+        [{:keyword, "if"},
+         {:symbol, "("},
+         {:expression, exp_parsed},
+         {:symbol, ")"},
+         {:symbol, "{"},
+         {:statements, statements_parsed},
+         {:symbol, "}"},
+         {:keyword, "else"},
+         {:symbol, "{"},
+         {:statements, else_parsed},
+         {:symbol, "}"}]) do
     label1 = "ifL1$#{JackUuid.generate()}"
     label2 = "ifL2$#{JackUuid.generate()}"
     exp = compile_exp(exp_parsed)
-    statements = compile_statement(statements_parsed)
-    else_statements = compile_statement(else_parsed)
+    statements = compile_statement(class_name, statements_parsed)
+    else_statements = compile_statement(class_name, else_parsed)
     exp
     ++ ["not",
         "if-goto #{label1}"]


  def compile_var_dec(all), do: {[], all}

  def compile_statements([{:statements, statements_parsed} | rest]) do
    {compile_statement(statements_parsed), rest}
  end
  
  def compile_statement([{:doStatement, do_parsed} | rest]) do
    compile_do_statement(do_parsed)
    ++ compile_statement(rest)
  end

  def compile_statement([{:letStatement, let_parsed} | rest]) do
    compile_let_statement(let_parsed)
    ++ compile_statement(rest)
  end

  def compile_statement([{:whileStatement, while_parsed} | rest]) do
    compile_while_statement(while_parsed)
    ++ compile_statement(rest)
  end

  def compile_statement([{:ifStatement, if_parsed} | rest]) do
    compile_if_statement(if_parsed)
    ++ compile_statement(rest)
  end

  def compile_statement([{:returnStatement, return_parsed} | rest]) do
    compile_return_statement(return_parsed)
    ++ compile_statement(rest)
  end

  def compile_statement([]), do: []

  def compile_return_statement([{:keyword, "return"},
                                {:symbol, ";"}]) do


  def compile_exp([]), do: []

  def compile_term([{:keyword, "this"}]), do: ["push argument 0"]
  def compile_term([{:keyword, "true"}]), do: ["push constant 1", "neg"]
  def compile_term([{:keyword, "false"}]), do: ["push constant 0"]
  
