Esempio n. 1
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. 2
0
 def ffi_get_value(self, ptr):
     casted = rffi.cast(rffi.INTP, ptr)
     return Integer(rffi.cast(rffi.LONG, casted[0]))
Esempio n. 3
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