Even Wiik Thomassen avatar Even Wiik Thomassen committed c73e739

Added some print statements to easier debug.

Comments (0)

Files changed (2)

pyhaskell/interpreter/jscparser.py

 from pypy.rlib.parsing.ebnfparse import parse_ebnf, make_parse_function
 from pypy.rlib.parsing.tree import RPythonVisitor, Nonterminal
 from pypy.rlib.streamio import open_file_as_stream
-from pypy.rlib.jit import elidable
 
 from pyhaskell.interpreter.module import CoreMod
 from pyhaskell.interpreter.primtype import Int, Double, Char, Addr
     def visit_expression(self, node):
         """Visit an expression node (exp) or atomic expr (aexp)."""
         type_ = get_string(node.children[0].children[0])
-        #print "EXP:", type_, len(node.children)
+        print "Visit expr:", type_, len(node.children)
 
         # Atomic expressions
         if type_ == 'qvar':
             expr = self.visit_literal(node.children[0].children[1])
         elif type_ == 'aexp' and len(node.children) == 1:
             expr = self.visit_expression(node.children[0].children[1])
+            print "test", node
 
         # Application
         elif type_ == 'aexp' and len(node.children) == 2:
             # let, cast, note, label etc not implemented yet
             raise NotImplementedError("Expr type not supported: %s" % type_)
 
+        print "[%i]" % (node.getsourcepos().lineno + 1), type(expr), expr
         assert isinstance(expr, HaskellObject)
         return expr
 
         methods starting with visit_.
         """
         type_ = get_string(node.children[0].children[0])
+        print "Handle case:", type_, len(node.children)
 
         # Default case-alternative
         if type_ == '%_':
                 symbol = Symbol.get_symbol(data_constr.name)
                 pattern = make_constructor(symbol, vbinds)
 
+        print "Case:", expr
         assert isinstance(pattern, HaskellObject)
         assert isinstance(expr, HaskellObject)
         return pattern, expr
         """Returns an instance of a literal."""
         type_ = get_string(node.children[0].children[0])
         value = get_string(node.children[0].children[1])
+        print "Visit literal:", type_, value
 
         if type_ == 'int':
             return Int(int(value))
         """Visit a variable definition node."""
         mod, name = self._module(node.children[0].children[1])
         var = Var(name)
+        print "Visit var:", var
         return add_variable(mod, name, var)
 
     def visit_value_definition(self, node):
         """Visit a value definition which returns an expression."""
         expr = self.visit_expression(node.children[2].children[1])
         mod, name = self._module(node.children[0].children[1])
+        print "Visit value def:", expr, name
         return add_variable(mod, name, expr)
 
 
     return var
 
 
-@elidable
 def get_module(name):
     """Returns module 'name', load from external JSCore file if necessary."""
     assert name in CoreMod.all_modules

pyhaskell/main.py

 # -*- coding: utf-8 -*-
 import os
 import sys
+import time
 
 from pyhaskell.interpreter import jscparser, haskell, module, primtype, prim
 
     main_module = module.CoreMod("main:Main")
     module.CoreMod.all_modules["main::Main"] = main_module
 
+    start_time = time.time()
     js = jscparser.parse_js(path)
     jscparser.AST().get_ast(js)
+    parse_time = time.time()
+    print "### Parsing took %.2f secs" % (parse_time - start_time)
+
     haskell.evaluate_hnf(main_module.qvars["main"])
+    print "### Evaluation took %.2f secs" % (time.time() - parse_time)
 
 
 def main(args):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.