Skip to content

Commit

Permalink
Replace builtin ast with pythonparser.ast.
Browse files Browse the repository at this point in the history
whitequark committed May 27, 2015
1 parent f30d671 commit c75fd6b
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion artiq/py2llvm/ast_body.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ast
from pythonparser import ast

import llvmlite.ir as ll

4 changes: 2 additions & 2 deletions artiq/py2llvm/fractions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inspect
import ast
from pythonparser import parse, ast

import llvmlite.ir as ll

@@ -18,7 +18,7 @@ def _gcd(a, b):


def init_module(module):
func_def = ast.parse(inspect.getsource(_gcd)).body[0]
func_def = parse(inspect.getsource(_gcd)).body[0]
function, _ = module.compile_function(func_def,
{"a": VInt(64), "b": VInt(64)})
function.linkage = "internal"
5 changes: 3 additions & 2 deletions artiq/py2llvm/infer_types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import ast
import pythonparser.algorithm
from pythonparser import ast
from copy import deepcopy

from artiq.py2llvm.ast_body import Visitor
from artiq.py2llvm import base_types


class _TypeScanner(ast.NodeVisitor):
class _TypeScanner(pythonparser.algorithm.Visitor):
def __init__(self, env, ns):
self.exprv = Visitor(env, ns)

6 changes: 3 additions & 3 deletions artiq/test/py2llvm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
import ast
from pythonparser import parse, ast
import inspect
from fractions import Fraction
from ctypes import CFUNCTYPE, c_int, c_int32, c_int64, c_double
@@ -43,7 +43,7 @@ def _base_types(choice):

def _build_function_types(f):
return infer_function_types(
None, ast.parse(inspect.getsource(f)),
None, parse(inspect.getsource(f)),
dict())


@@ -111,7 +111,7 @@ class CompiledFunction:
def __init__(self, function, param_types):
module = Module()

func_def = ast.parse(inspect.getsource(function)).body[0]
func_def = parse(inspect.getsource(function)).body[0]
function, retval = module.compile_function(func_def, param_types)
argvals = [param_types[arg.arg] for arg in func_def.args.args]

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
requirements = [
"sphinx", "sphinx-argparse", "pyserial", "numpy", "scipy",
"python-dateutil", "prettytable", "h5py", "pydaqmx", "pyelftools",
"quamash", "pyqtgraph"
"quamash", "pyqtgraph", "pythonparser"
]

scripts = [

0 comments on commit c75fd6b

Please sign in to comment.