Example #1
0
def goal_options():
    result = []
    for name, doc, cmdline, extra in GOALS:
        optional = False
        if name.startswith('?'):
            optional = True
            name = name[1:]
        yesdoc = doc[0].upper()+doc[1:]+extra
        result.append(BoolOption(name, yesdoc, default=False, cmdline=cmdline,
                                 negation=False))
        if not optional:
            result.append(BoolOption("no_%s" % name, "Don't "+doc, default=False,
                                     cmdline="--no-"+name, negation=False))
    return result
Example #2
0
def get_combined_translation_config(other_optdescr=None,
                                    existing_config=None,
                                    overrides=None,
                                    translating=False):
    if overrides is None:
        overrides = {}
    d = BoolOption("translating",
                   "indicates whether we are translating currently",
                   default=False,
                   cmdline=None)
    if other_optdescr is None:
        children = []
        newname = ""
    else:
        children = [other_optdescr]
        newname = other_optdescr._name
    if existing_config is None:
        children += [d, translation_optiondescription]
    else:
        children += [
            child for child in existing_config._cfgimpl_descr._children
            if child._name != newname
        ]
    descr = OptionDescription("pypy", "all options", children)
    config = Config(descr, **overrides)
    if translating:
        config.translating = True
    if existing_config is not None:
        for child in existing_config._cfgimpl_descr._children:
            if child._name == newname:
                continue
            value = getattr(existing_config, child._name)
            config._cfgimpl_values[child._name] = value
    return config
Example #3
0
IS_64_BITS = sys.maxint > 2147483647

PLATFORMS = [
    'maemo',
    'host',
    'distutils',
]

translation_optiondescription = OptionDescription(
    "translation",
    "Translation Options",
    [
        BoolOption("continuation",
                   "enable single-shot continuations",
                   default=False,
                   cmdline="--continuation",
                   requires=[("translation.type_system", "lltype")]),
        ChoiceOption(
            "type_system",
            "Type system to use when RTyping",
            ["lltype", "ootype"],
            cmdline=None,
            default="lltype",
            requires={
                "ootype": [
                    ("translation.backendopt.constfold", False),
                    ("translation.backendopt.clever_malloc_removal", False),
                    (
                        "translation.gc", "boehm"
                    ),  # it's not really used, but some jit code expects a value here
Example #4
0
              "pypy",
              cmdline='--parser'),
 ChoiceOption("compiler",
              "which compiler to use for app-level code",
              ["cpython", "ast"],
              "ast",
              cmdline='--compiler'),
 ChoiceOption("pyversion",
              "which grammar to use for app-level code",
              ["2.3", "2.4", "2.5a"],
              "2.4",
              cmdline='--pyversion'),
 OptionDescription("opcodes", "opcodes to enable in the interpreter", [
     BoolOption(
         "CALL_LIKELY_BUILTIN",
         "emit a special bytecode for likely calls to builtin functions",
         default=False,
         requires=[("objspace.std.withmultidict", True),
                   ("translation.stackless", False)]),
     BoolOption("CALL_METHOD",
                "emit a special bytecode for expr.name()",
                default=False),
 ]),
 BoolOption("nofaking",
            "disallow faking in the object space",
            default=False,
            requires=[("objspace.usemodules.posix", True),
                      ("objspace.usemodules.time", True),
                      ("objspace.usemodules.errno", True)],
            cmdline='--nofaking'),
 OptionDescription("usemodules", "Which Modules should be used", [
     BoolOption(modname,
Example #5
0
except ImportError:
    pass

from pypy.tool import option
from py.compat.optparse import make_option
from pypy.interpreter import main, interactive, error, gateway
from pypy.config.config import OptionDescription, BoolOption, StrOption
from pypy.config.config import Config, to_optparse
from pypy.config import pypyoption
import os, sys
import time

cmdline_optiondescr = OptionDescription(
    "interactive", "the options of py.py", [
        BoolOption("verbose",
                   "show verbose interpreter-level traceback",
                   default=os.getenv("PYPY_TB"),
                   cmdline="-v"),
        BoolOption("interactive",
                   "inspect interactively after running script",
                   default=False,
                   cmdline="-i"),
        BoolOption("completer",
                   "use readline commandline completer",
                   default=False,
                   cmdline="-C"),
        BoolOption("optimize",
                   "dummy optimization flag for compatibility with CPython",
                   default=False,
                   cmdline="-O"),
        BoolOption("no_site_import",
                   "do not 'import site' on initialization",
Example #6
0
from pypy.config.config import OptionDescription, BoolOption, IntOption, ArbitraryOption, FloatOption
from pypy.config.config import ChoiceOption, StrOption, to_optparse, Config

DEFL_INLINE_THRESHOLD = 32.4  # just enough to inline add__Int_Int()
# and just small enough to prevend inlining of some rlist functions.

DEFL_PROF_BASED_INLINE_THRESHOLD = 32.4
DEFL_CLEVER_MALLOC_REMOVAL_INLINE_THRESHOLD = 32.4

translation_optiondescription = OptionDescription(
    "translation",
    "Translation Options",
    [
        BoolOption("stackless",
                   "enable stackless features during compilation",
                   default=False,
                   cmdline="--stackless",
                   requires=[("translation.type_system", "lltype")]),
        ChoiceOption(
            "type_system",
            "Type system to use when RTyping", ["lltype", "ootype"],
            cmdline=None,
            requires={
                "ootype": [
                    ("translation.backendopt.constfold", False),
                    ("translation.backendopt.heap2stack", False),
                    ("translation.backendopt.clever_malloc_removal", False),
                ]
            }),
        ChoiceOption(
            "backend",
Example #7
0
    return result


translate_optiondescr = OptionDescription(
    "translate",
    "XXX",
    [
        StrOption(
            "targetspec", "XXX", default='targetpypystandalone', cmdline=None),
        ChoiceOption("opt",
                     "optimization level",
                     OPT_LEVELS,
                     default=DEFAULT_OPT_LEVEL,
                     cmdline="--opt -O"),
        BoolOption("profile",
                   "cProfile (to debug the speed of the translation process)",
                   default=False,
                   cmdline="--profile"),
        BoolOption("pdb",
                   "Always run pdb even if the translation succeeds",
                   default=False,
                   cmdline="--pdb"),
        BoolOption("batch",
                   "Don't run interactive helpers",
                   default=False,
                   cmdline="--batch",
                   negation=False),
        IntOption("huge", "Threshold in the number of functions after which "
                  "a local call graph and not a full one is displayed",
                  default=100,
                  cmdline="--huge"),
        BoolOption("view",
Example #8
0
        if name.startswith('?'):
            optional = True
            name = name[1:]
        yesdoc = doc[0].upper()+doc[1:]+extra
        result.append(BoolOption(name, yesdoc, default=False, cmdline=cmdline,
                                 negation=False))
        if not optional:
            result.append(BoolOption("no_%s" % name, "Don't "+doc, default=False,
                                     cmdline="--no-"+name, negation=False))
    return result

translate_optiondescr = OptionDescription("translate", "XXX", [
    StrOption("targetspec", "XXX", default='targetpypystandalone',
              cmdline=None),
    BoolOption("profile",
               "cProfile (to debug the speed of the translation process)",
               default=False,
               cmdline="--profile"),
    BoolOption("batch", "Don't run interactive helpers", default=False,
               cmdline="--batch", negation=False),
    IntOption("huge", "Threshold in the number of functions after which "
                      "a local call graph and not a full one is displayed",
              default=100, cmdline="--huge"),
    BoolOption("text", "Don't start the pygame viewer", default=False,
               cmdline="--text", negation=False),
    BoolOption("help", "show this help message and exit", default=False,
               cmdline="-h --help", negation=False),
    ArbitraryOption("goals", "XXX",
                    defaultfactory=list),
    # xxx default goals ['annotate', 'rtype', 'backendopt', 'source', 'compile']
    ArbitraryOption("skipped_goals", "XXX",
                    defaultfactory=lambda: ['run']),
Example #9
0
        return validator
    else:
        return None


pypy_optiondescription = OptionDescription(
    "objspace",
    "Object Space Options",
    [
        ChoiceOption("name",
                     "Object Space name", ["std", "flow", "thunk", "dump"],
                     "std",
                     cmdline='--objspace -o'),
        OptionDescription("opcodes", "opcodes to enable in the interpreter", [
            BoolOption("CALL_METHOD",
                       "emit a special bytecode for expr.name()",
                       default=False),
        ]),
        BoolOption("nofaking",
                   "disallow faking in the object space",
                   default=False,
                   requires=[("objspace.usemodules.posix", True),
                             ("objspace.usemodules.time", True),
                             ("objspace.usemodules.errno", True)],
                   cmdline='--nofaking'),
        OptionDescription("usemodules", "Which Modules should be used", [
            BoolOption(modname,
                       "use module %s" % (modname, ),
                       default=modname in default_modules,
                       cmdline="--withmod-%s" % (modname, ),
                       requires=module_dependencies.get(modname, []),
Example #10
0
    pass

import pypy
from pypy.tool import option
from optparse import make_option
from pypy.interpreter import main, interactive, error, gateway
from pypy.config.config import OptionDescription, BoolOption, StrOption
from pypy.config.config import Config, to_optparse
from pypy.config import pypyoption
import os, sys
import time

cmdline_optiondescr = OptionDescription(
    "interactive", "the options of py.py", [
        BoolOption("verbose",
                   "show verbose interpreter-level traceback",
                   default=os.getenv("PYPY_TB"),
                   cmdline="-v"),
        BoolOption("interactive",
                   "inspect interactively after running script",
                   default=False,
                   cmdline="-i"),
        BoolOption("completer",
                   "use readline commandline completer",
                   default=False,
                   cmdline="-C"),
        BoolOption("optimize",
                   "dummy optimization flag for compatibility with CPython",
                   default=False,
                   cmdline="-O"),
        BoolOption("no_site_import",
                   "do not 'import site' on initialization",
Example #11
0
#from pypy.translator.js.test.runtest import compile_function
#from pypy.translator.translator import TranslationContext
from pypy.translator.driver import TranslationDriver
from pypy.translator.js.js import JS
from pypy.tool.error import AnnotatorError, FlowingError, debug
from pypy.rlib.nonconst import NonConstant
from pypy.annotation.policy import AnnotatorPolicy
from py.compat import optparse
from pypy.config.config import OptionDescription, BoolOption, StrOption
from pypy.config.config import Config, to_optparse
import py
import sys

js_optiondescr = OptionDescription("jscompile", "", [
    BoolOption("view", "View flow graphs",
               default=False, cmdline="--view"),
    BoolOption("use_pdb", "Use debugger",
               default=False, cmdline="--pdb"),
    StrOption("output", "File to save results (default output.js)",
              default="output.js", cmdline="--output")])


class FunctionNotFound(Exception):
    pass

class BadSignature(Exception):
    pass

class JsPolicy(AnnotatorPolicy):
    allow_someobjects = False