Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[js] Implement nqp::newexception.
Needs to be integrated with HLL support.
  • Loading branch information
pmurias committed Mar 8, 2016
1 parent 66d0ca2 commit 431361b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vm/js/Operations.nqp
Expand Up @@ -670,6 +670,8 @@ class QAST::OperationsJS {
add_simple_op('setmessage', $T_OBJ, [$T_OBJ, $T_OBJ], :sideffects);
add_simple_op('getmessage', $T_STR, [$T_OBJ]);

add_simpile_op('newexception', $T_OBJ, [], :sideffects);

add_simple_op('findmethod', $T_OBJ, [$T_OBJ, $T_STR], :sideffects);
add_simple_op('can', $T_INT, [$T_OBJ, $T_STR], :sideffects);

Expand Down
20 changes: 20 additions & 0 deletions src/vm/js/nqp-runtime/bootstrap.js
Expand Up @@ -215,4 +215,24 @@ add_to_sc_with_st_and_mo(BOOTNum);
add_to_sc_with_st_and_mo(BOOTStr);
add_to_sc_with_st_and_mo(BOOTCode);*/

function bootType(typeName, reprName) {
var meta_obj = KnowHOW_HOW._STable.REPR.allocate(KnowHOW_HOW._STable);
meta_obj.name = typeName;

var type_obj = (new reprs[reprName]).type_object_for(meta_obj);

//TODO?
//type_obj.st.MethodCache = meta_obj.methods;
//type_obj.st.ModeFlags = STable.METHOD_CACHE_AUTHORITATIVE;

core.root_objects.push(meta_obj);
meta_obj._SC = core;

add_to_sc_with_st(type_obj);

return type_obj;
}

module.exports.bootType = bootType;

module.exports.core = core;
9 changes: 9 additions & 0 deletions src/vm/js/nqp-runtime/core.js
Expand Up @@ -15,6 +15,8 @@ var hll = require('./hll.js');

var NQPArray = require('./array.js');

var bootstrap = require('./bootstrap.js');

exports.CodeRef = CodeRef;

op.atpos = function(array, index) {
Expand Down Expand Up @@ -960,3 +962,10 @@ op.setdimensions = function(array, dimensions) {
return op['bindposnd' + type](array, new NQPArray([x, y, z]), value);
};
});

var BOOTException = bootstrap.bootType("BOOTException", "VMException");
/* TODO HLL support */
op.newexception = function() {
var exType = BOOTException;
return exType._STable.REPR.allocate(exType._STable);
};

0 comments on commit 431361b

Please sign in to comment.