Example #1
0
def _ici(meta):
    import pixie.vm.reader as reader
    line = rt._val_at(meta, reader.LINE_KW, nil)
    line_number = rt._val_at(meta, reader.LINE_NUMBER_KW, nil)
    col_number = rt._val_at(meta, reader.COLUMN_NUMBER_KW, nil)
    file = rt._val_at(meta, reader.FILE_KW, nil)

    return InterpreterCodeInfo(line,
                               line_number.int_val() if line_number is not nil else 0,
                               col_number.int_val() if col_number is not nil else 0,
                               rt.name(file) if file is not nil else u"<unknown>")
Example #2
0
def _throw(ex):
    from pixie.vm.keyword import keyword
    if isinstance(ex, RuntimeException):
        raise WrappedException(ex)
    if rt._satisfies_QMARK_(IVector, ex):
        data = rt.nth(ex, rt.wrap(0))
        msg = rt.nth(ex, rt.wrap(1))
    elif rt._satisfies_QMARK_(ILookup, ex):
        data = rt._val_at(ex, keyword(u"data"), nil)
        msg = rt._val_at(ex, keyword(u"msg"), nil)
    else:
        affirm(False, u"Can only throw vectors, maps and exceptions")
        return nil
    raise WrappedException(RuntimeException(msg, data))
Example #3
0
def _throw(ex):
    from pixie.vm.keyword import keyword
    if isinstance(ex, RuntimeException):
        raise WrappedException(ex)
    if rt._satisfies_QMARK_(IVector, ex):
        data = rt.nth(ex, rt.wrap(0))
        msg = rt.nth(ex, rt.wrap(1))
    elif rt._satisfies_QMARK_(ILookup, ex):
        data = rt._val_at(ex, keyword(u"data"), nil)
        msg = rt._val_at(ex, keyword(u"msg"), nil)
    else:
        affirm(False, u"Can only throw vectors, maps and exceptions")
        return nil
    raise WrappedException(RuntimeException(msg, data))
Example #4
0
def test_hashmap_create():

    acc = rt.hashmap(rt.wrap(1), rt.wrap(2))

    val = rt._val_at(acc, rt.wrap(1), nil)

    assert val.int_val() == 2
Example #5
0
def test_hashmap_create():

    acc = rt.hashmap(Integer(1), Integer(2))

    val = rt._val_at(acc, Integer(1), nil)

    assert val.int_val() == 2
Example #6
0
def test_hashmap_create():

    acc = rt.hashmap(rt.wrap(1), rt.wrap(2))

    val = rt._val_at(acc, rt.wrap(1), nil)

    assert val.int_val() == 2
Example #7
0
def compile_def(form, ctx):
    form = rt.next(form)
    name = rt.first(form)
    form = rt.next(form)
    val = rt.first(form)

    affirm(isinstance(name, symbol.Symbol), u"Def'd name must be a symbol")

    var = NS_VAR.deref().intern_or_make(rt.name(name))

    if rt._val_at(rt.meta(name), DYNAMIC_KW, nil) is true:
        assert isinstance(var, code.Var)
        var.set_dynamic()

    ctx.push_const(var)
    compile_form(val, ctx)
    ctx.bytecode.append(code.SET_VAR)
    ctx.sub_sp(1)
Example #8
0
def compile_def(form, ctx):
    form = rt.next(form)
    name = rt.first(form)
    form = rt.next(form)
    val = rt.first(form)

    affirm(isinstance(name, symbol.Symbol), u"Def'd name must be a symbol")

    var = NS_VAR.deref().intern_or_make(rt.name(name))

    if rt._val_at(rt.meta(name), DYNAMIC_KW, nil) is true:
        assert isinstance(var, code.Var)
        var.set_dynamic()

    ctx.push_const(var)
    compile_form(val, ctx)
    ctx.bytecode.append(code.SET_VAR)
    ctx.sub_sp(1)
Example #9
0
def _val_at(self, key, not_found):
    assert isinstance(self, PersistentHashSet)
    return rt._val_at(self._map, key, not_found)
Example #10
0
def _val_at(self, key, not_found):
    assert isinstance(self, PersistentHashSet)
    return rt._val_at(self._map, key, not_found)
Example #11
0
File: code.py Project: jmglov/pixie
 def get_var_value(self, var, not_found):
     return rt._val_at(self.current_frame(), var, not_found)
Example #12
0
 def get_var_value(self, var, not_found):
     return rt._val_at(self.current_frame(), var, not_found)