Skip to content

Commit

Permalink
Propagate WastLexer change through to JavaScript/Emscripten wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
keithw committed Oct 3, 2022
1 parent f1b4ee8 commit 3ab7222
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/emscripten-helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ void wabt_destroy_features(wabt::Features* f) {

wabt::WastLexer* wabt_new_wast_buffer_lexer(const char* filename,
const void* data,
size_t size) {
size_t size,
Errors* errors) {
std::unique_ptr<wabt::WastLexer> lexer =
wabt::WastLexer::CreateBufferLexer(filename, data, size);
wabt::WastLexer::CreateBufferLexer(filename, data, size, errors);
return lexer.release();
}

Expand Down
13 changes: 7 additions & 6 deletions src/wabt.post.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ FEATURES.forEach(function(feature) {


/// Lexer
function Lexer(filename, buffer) {
function Lexer(filename, buffer, errors) {
this.filenameObj = allocateCString(filename);
this.bufferObj = allocateBuffer(buffer);
this.addr = Module._wabt_new_wast_buffer_lexer(
this.filenameObj.addr, this.bufferObj.addr, this.bufferObj.size);
this.filenameObj.addr, this.bufferObj.addr, this.bufferObj.size,
errors.addr);
}
Lexer.prototype = Object.create(Object.prototype);

Expand Down Expand Up @@ -159,10 +160,9 @@ OutputBuffer.prototype.destroy = function() {


/// Errors
function Errors(kind, lexer) {
function Errors(kind) {
this.kind = kind;
this.addr = Module._wabt_new_errors();
this.lexer = lexer;
}
Errors.prototype = Object.create(Object.prototype);

Expand Down Expand Up @@ -194,8 +194,9 @@ Errors.prototype.destroy = function() {

/// parseWat
function parseWat(filename, buffer, options) {
var lexer = new Lexer(filename, buffer);
var errors = new Errors('text', lexer);
var errors = new Errors('text');
var lexer = new Lexer(filename, buffer, errors);
errors.lexer = lexer;
var features = new Features(options || {});

try {
Expand Down

0 comments on commit 3ab7222

Please sign in to comment.