Esempio n. 1
0
    def trace_map(self):
        from pixie.vm.string import String
        from pixie.vm.keyword import keyword

        tp = self._tp
        assert isinstance(tp, Type)
        tm = {keyword(u"type") : keyword(u"polymorphic")}
        tm[keyword(u"name")] = String(self._name)
        tm[keyword(u"tp")] = String(tp._name)
        return tm
Esempio n. 2
0
    def trace_map(self):
        from pixie.vm.string import String
        from pixie.vm.numbers import Integer
        from pixie.vm.keyword import keyword

        tm = {keyword(u"type"): keyword(u"interpreter")}
        tm[keyword(u"line")] = String(self._line.__repr__())
        tm[keyword(u"line-number")] = Integer(self._line_number)
        tm[keyword(u"column-number")] = Integer(self._column_number)
        tm[keyword(u"file")] = String(self._file)
        return tm
Esempio n. 3
0
    def trace_map(self):
        from pixie.vm.string import String
        from pixie.vm.keyword import keyword

        tm = {keyword(u"type") : keyword(u"pixie")}
        tm[keyword(u"name")] = String(self._name)
        return tm
Esempio n. 4
0
    def wrap(x):
        if isinstance(x, bool):
            return true if x else false
        if isinstance(x, int):
            return numbers.Integer(x)
        if isinstance(x, rbigint):
            return numbers.BigInteger(x)
        if isinstance(x, float):
            return numbers.Float(x)
        if isinstance(x, unicode):
            return String(x)
        if isinstance(x, py_str):
            return String(unicode(x))
        if isinstance(x, Object):
            return x
        if x is None:
            return nil

        if not we_are_translated():
            print x, type(x)
        affirm(False, u"Bad wrap")
Esempio n. 5
0
 def ffi_get_value(self, ptr):
     casted = rffi.cast(rffi.CCHARPP, ptr)
     if casted[0] == lltype.nullptr(rffi.CCHARP.TO):
         return nil
     else:
         return String(unicode(rffi.charp2str(casted[0])))
Esempio n. 6
0
def read_obj(rdr):
    tag = read_tag(rdr)

    if tag == INT:
        return Integer(intmask(read_raw_integer(rdr)))
    elif tag == CODE:
        return read_code(rdr)
    elif tag == NIL:
        return nil
    elif tag == VAR:
        return read_var(rdr)
    elif tag == STRING:
        return String(read_raw_string(rdr))
    elif tag == KEYWORD:
        return keyword(read_raw_string(rdr))
    elif tag == SYMBOL:
        return symbol(read_raw_string(rdr))
    elif tag == LINE_PROMISE:
        lp = LinePromise()
        lp._str = read_raw_string(rdr)
        return lp
    elif tag == MAP:
        return read_map(rdr)
    elif tag == TRUE:
        return true
    elif tag == FALSE:
        return false
    elif tag == NIL:
        return nil
    elif tag == VECTOR:
        return read_vector(rdr)
    elif tag == SEQ:
        return read_seq(rdr)
    elif tag == FLOAT:
        return read_float(rdr)
    elif tag == NAMESPACE:
        return read_namespace(rdr)
    elif tag == INT_STRING:
        return Integer(int(read_raw_string(rdr)))

    elif tag == NEW_CACHED_OBJ:
        return rdr.read_and_cache()
    elif tag == CACHED_OBJ:
        return rdr.read_cached_obj()

    elif tag == EOF:
        from pixie.vm.reader import eof
        return eof

    elif tag == CODE_INFO:
        return read_interpreter_code_info(rdr)

    elif tag == TAGGED:
        tp_name = read_raw_string(rdr)
        tp = get_type_by_name(tp_name)
        handler = read_handlers.get(tp, None)
        if handler is None:
            runtime_error(u"No type handler for " + tp_name)

        obj = read_obj(rdr)
        return handler.invoke([obj])
    else:
        runtime_error(u"No dispatch for bytecode: " + unicode(tag_name[tag]))

    return nil
Esempio n. 7
0
from rpython.translator.platform import platform
import pixie.vm.rt as rt
from pixie.vm.string import String
from pixie.vm.code import as_var
from rpython.rlib.clibffi import get_libc_name
import os

as_var("pixie.platform", "os")(String(unicode(os.name)))
as_var("pixie.platform", "name")(String(unicode(platform.name)))
as_var("pixie.platform", "so-ext")(String(unicode(platform.so_ext)))
as_var("pixie.platform", "lib-c-name")(String(unicode(get_libc_name())))