diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-06-18 14:20:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-18 14:20:03 -0700 |
commit | 28e88b9f993a2e45662fde0b10920aa22e7b1b7f (patch) | |
tree | 77bbd5f1dd1bfcb089b12f6fa9fcf828c135c099 /test/binaryen.js | |
parent | 97e277c51218778d1d76fd59fed3b4ca7756382e (diff) | |
download | binaryen-28e88b9f993a2e45662fde0b10920aa22e7b1b7f.tar.gz binaryen-28e88b9f993a2e45662fde0b10920aa22e7b1b7f.tar.bz2 binaryen-28e88b9f993a2e45662fde0b10920aa22e7b1b7f.zip |
[EH] Replace event with tag (#3937)
We recently decided to change 'event' to 'tag', and to 'event section'
to 'tag section', out of the rationale that the section contains a
generalized tag that references a type, which may be used for something
other than exceptions, and the name 'event' can be confusing in the web
context.
See
- https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130
- https://github.com/WebAssembly/exception-handling/pull/161
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/event.js.txt | 15 | ||||
-rw-r--r-- | test/binaryen.js/exception-handling.js | 6 | ||||
-rw-r--r-- | test/binaryen.js/exception-handling.js.txt | 4 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js | 46 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js.txt | 18 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 16 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 26 | ||||
-rw-r--r-- | test/binaryen.js/tag.js (renamed from test/binaryen.js/event.js) | 16 | ||||
-rw-r--r-- | test/binaryen.js/tag.js.txt | 15 |
9 files changed, 81 insertions, 81 deletions
diff --git a/test/binaryen.js/event.js.txt b/test/binaryen.js/event.js.txt deleted file mode 100644 index 94e1b1a7a..000000000 --- a/test/binaryen.js/event.js.txt +++ /dev/null @@ -1,15 +0,0 @@ -GetEvent is equal: true -getEventInfo={"name":"a-event","module":"","base":"","attribute":0,"params":2,"results":0} -(module - (type $i32_=>_none (func (param i32))) - (type $i32_f32_=>_none (func (param i32 f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) - (event $a-event (attr 0) (param i32)) - (export "a-event-exp" (event $a-event)) -) - -(module - (type $i32_f32_=>_none (func (param i32 f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) -) - diff --git a/test/binaryen.js/exception-handling.js b/test/binaryen.js/exception-handling.js index a8d3dd3a4..1f512bbe8 100644 --- a/test/binaryen.js/exception-handling.js +++ b/test/binaryen.js/exception-handling.js @@ -2,7 +2,7 @@ function cleanInfo(info) { var ret = {}; for (var x in info) { // Filter out address pointers and only print meaningful info - if (x == 'id' || x == 'type' || x == 'name' || x == 'event' || + if (x == 'id' || x == 'type' || x == 'name' || x == 'tag' || x == 'target' || x == 'hasCatchAll' || x == 'delegateTarget' || x == 'isDelegate') { ret[x] = info[x]; @@ -19,7 +19,7 @@ var module = new binaryen.Module(); module.setFeatures(binaryen.Features.ReferenceTypes | binaryen.Features.ExceptionHandling); -var event_ = module.addEvent("e", 0, binaryen.i32, binaryen.none); +module.addTag("e", 0, binaryen.i32, binaryen.none); // (try $l0 // (do @@ -52,7 +52,7 @@ var try_catch = module.try( // (do // (try // (do -// (throw $a-event (i32.const 0)) +// (throw $a-tag (i32.const 0)) // ) // (delegate $try_outer) // ) diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt index 0fbdc3668..e711f7bfd 100644 --- a/test/binaryen.js/exception-handling.js.txt +++ b/test/binaryen.js/exception-handling.js.txt @@ -1,7 +1,7 @@ (module (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (func $test (try $l0 (do @@ -34,7 +34,7 @@ ) ) -getExpressionInfo(throw) = {"id":46,"type":1,"event":"e"} +getExpressionInfo(throw) = {"id":46,"type":1,"tag":"e"} getExpressionInfo(rethrow) = {"id":47,"type":1,"target":"l0"} getExpressionInfo(try_catch) = {"id":45,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0} getExpressionInfo(try_delegate) = {"id":45,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0} diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index ca45933a7..40d4194fd 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -1565,22 +1565,22 @@ console.log("# RefEq"); console.log("# Try"); (function testTry() { const module = new binaryen.Module(); - module.addEvent("event1", 0, binaryen.none, binaryen.none); - module.addEvent("event2", 0, binaryen.none, binaryen.none); - module.addEvent("event3", 0, binaryen.none, binaryen.none); + module.addTag("tag1", 0, binaryen.none, binaryen.none); + module.addTag("tag2", 0, binaryen.none, binaryen.none); + module.addTag("tag3", 0, binaryen.none, binaryen.none); var body = module.i32.const(1); var catchBodies = [ module.i32.const(2), module.i32.const(3) ]; - const theTry = binaryen.Try(module.try('', body, ["event1"], catchBodies, '')); + const theTry = binaryen.Try(module.try('', body, ["tag1"], catchBodies, '')); assert(theTry instanceof binaryen.Try); assert(theTry instanceof binaryen.Expression); assert(theTry.body === body); assertDeepEqual(theTry.catchBodies, catchBodies); assert(theTry.type === binaryen.i32); - assert(theTry.getNumCatchEvents() == 1); + assert(theTry.getNumCatchTags() == 1); assert(theTry.getNumCatchBodies() == 2); assert(theTry.hasCatchAll() == 1); console.log(theTry.toText()); @@ -1596,31 +1596,31 @@ console.log("# Try"); assertDeepEqual(theTry.getCatchBodies(), catchBodies); console.log(theTry.toText()); - theTry.insertCatchEventAt(1, "event2"); + theTry.insertCatchTagAt(1, "tag2"); theTry.insertCatchBodyAt(0, module.i32.const(6)); - assert(theTry.getNumCatchEvents() == 2); + assert(theTry.getNumCatchTags() == 2); assert(theTry.getNumCatchBodies() == 2); assert(theTry.hasCatchAll() == 0); console.log(theTry.toText()); - assert(theTry.removeCatchEventAt(1) == "event2"); + assert(theTry.removeCatchTagAt(1) == "tag2"); theTry.removeCatchBodyAt(1); - assert(theTry.getNumCatchEvents() == 1); + assert(theTry.getNumCatchTags() == 1); assert(theTry.getNumCatchBodies() == 1); console.log(theTry.toText()); - theTry.appendCatchEvent("event3"); + theTry.appendCatchTag("tag3"); theTry.appendCatchBody(module.drop(module.i32.const(7))); - assert(theTry.getCatchEventAt(0) == "event1"); - assert(theTry.getCatchEventAt(1) == "event3"); - theTry.setCatchEvents(["event2", "event3"]); - assertDeepEqual(theTry.getCatchEvents(), ["event2", "event3"]); + assert(theTry.getCatchTagAt(0) == "tag1"); + assert(theTry.getCatchTagAt(1) == "tag3"); + theTry.setCatchTags(["tag2", "tag3"]); + assertDeepEqual(theTry.getCatchTags(), ["tag2", "tag3"]); theTry.setCatchBodies([module.i32.const(8), module.i32.const(9)]); - assert(theTry.getCatchEventAt(0) == "event2"); - assert(theTry.getCatchEventAt(1) == "event3"); - theTry.setCatchEventAt(1, "event1"); + assert(theTry.getCatchTagAt(0) == "tag2"); + assert(theTry.getCatchTagAt(1) == "tag3"); + theTry.setCatchTagAt(1, "tag1"); theTry.setCatchBodyAt(1, module.i32.const(10)); - assert(theTry.getCatchEventAt(1) == "event1"); + assert(theTry.getCatchTagAt(1) == "tag1"); console.log(theTry.toText()); theTry.type = binaryen.f64; @@ -1643,20 +1643,20 @@ console.log("# Throw"); (function testThrow() { const module = new binaryen.Module(); - var event = "foo"; + var tag = "foo"; var operands = [ module.i32.const(1), module.i32.const(2) ]; - const theThrow = binaryen.Throw(module.throw(event, operands)); + const theThrow = binaryen.Throw(module.throw(tag, operands)); assert(theThrow instanceof binaryen.Throw); assert(theThrow instanceof binaryen.Expression); - assert(theThrow.event === event); + assert(theThrow.tag === tag); assertDeepEqual(theThrow.operands, operands); assert(theThrow.type === binaryen.unreachable); - theThrow.event = "bar"; - assert(theThrow.event === "bar"); + theThrow.tag = "bar"; + assert(theThrow.tag === "bar"); theThrow.operands = operands = [ module.i32.const(3), // set module.i32.const(4), // set diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt index 1d38104af..b9107f5c1 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -238,7 +238,7 @@ (do (i32.const 1) ) - (catch $event1 + (catch $tag1 (i32.const 2) ) (catch_all @@ -250,7 +250,7 @@ (do (i32.const 4) ) - (catch $event1 + (catch $tag1 (i32.const 5) ) ) @@ -259,10 +259,10 @@ (do (i32.const 4) ) - (catch $event1 + (catch $tag1 (i32.const 6) ) - (catch $event2 + (catch $tag2 (i32.const 5) ) ) @@ -271,7 +271,7 @@ (do (i32.const 4) ) - (catch $event1 + (catch $tag1 (i32.const 6) ) ) @@ -280,10 +280,10 @@ (do (i32.const 4) ) - (catch $event2 + (catch $tag2 (i32.const 8) ) - (catch $event1 + (catch $tag1 (i32.const 10) ) ) @@ -292,10 +292,10 @@ (do (i32.const 4) ) - (catch $event2 + (catch $tag2 (i32.const 8) ) - (catch $event1 + (catch $tag1 (i32.const 10) ) ) diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index a8e69e381..dd942b7d7 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -191,8 +191,8 @@ function test_core() { module = new binaryen.Module(); - // Create an event - var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); + // Create a tag + var tag = module.addTag("a-tag", 0, binaryen.i32, binaryen.none); // Literals and consts @@ -593,8 +593,8 @@ function test_core() { // Exception handling module.try( '', - module.throw("a-event", [module.i32.const(0)]), - ["a-event"], + module.throw("a-tag", [module.i32.const(0)]), + ["a-tag"], [module.drop(module.i32.pop())], '' ), @@ -702,13 +702,13 @@ function test_core() { module.addFunctionImport("an-imported", "module", "base", iF, binaryen.f32); module.addGlobalImport("a-global-imp", "module", "base", binaryen.i32, false); module.addGlobalImport("a-mut-global-imp", "module", "base", binaryen.i32, true); - module.addEventImport("a-event-imp", "module", "base", 0, binaryen.i32, binaryen.none); + module.addTagImport("a-tag-imp", "module", "base", 0, binaryen.i32, binaryen.none); // Exports module.addFunctionExport("kitchen()sinker", "kitchen_sinker"); module.addGlobalExport("a-global", "a-global-exp"); - module.addEventExport("a-event", "a-event-exp"); + module.addTagExport("a-tag", "a-tag-exp"); // Tables module.addTable("t1", 0, 2); @@ -973,7 +973,7 @@ function test_binaries() { var adder = module.addFunction("adder", ii, binaryen.i32, [], add); var initExpr = module.i32.const(3); var global = module.addGlobal("a-global", binaryen.i32, false, initExpr) - var event_ = module.addEvent("a-event", 0, binaryen.createType([binaryen.i32, binaryen.i32]), binaryen.none); + var tag = module.addTag("a-tag", 0, binaryen.createType([binaryen.i32, binaryen.i32]), binaryen.none); binaryen.setDebugInfo(true); // include names section buffer = module.emitBinary(); binaryen.setDebugInfo(false); @@ -1038,7 +1038,7 @@ function test_parsing() { var adder = module.addFunction("adder", ii, binaryen.i32, [], add); var initExpr = module.i32.const(3); var global = module.addGlobal("a-global", binaryen.i32, false, initExpr) - var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); + var tag = module.addTag("a-tag", 0, binaryen.i32, binaryen.none); text = module.emitText(); module.dispose(); module = null; diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index b8b671de5..745df85f0 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -128,17 +128,17 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (global $a-mut-global-imp (mut i32))) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32))) (global $a-global i32 (i32.const 1)) (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data "I am passive") (table $t0 1 funcref) (elem $e0 (i32.const 0) "$kitchen()sinker") - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) - (export "a-event-exp" (event $a-event)) + (export "a-tag-exp" (tag $a-tag)) (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) @@ -2091,11 +2091,11 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (try (do - (throw $a-event + (throw $a-tag (i32.const 0) ) ) - (catch $a-event + (catch $a-tag (drop (pop i32) ) @@ -2220,17 +2220,17 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (global $a-mut-global-imp (mut i32))) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32))) (global $a-global i32 (i32.const 1)) (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data "I am passive") (table $t0 1 funcref) (elem $e0 (i32.const 0) "$kitchen()sinker") - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) - (export "a-event-exp" (event $a-event)) + (export "a-tag-exp" (tag $a-tag)) (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) @@ -4183,11 +4183,11 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (try (do - (throw $a-event + (throw $a-tag (i32.const 0) ) ) - (catch $a-event + (catch $a-tag (drop (pop i32) ) @@ -4779,7 +4779,7 @@ module loaded from binary form: (type $i32_i32_=>_none (func (param i32 i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (event $event$0 (attr 0) (param i32 i32)) + (tag $tag$0 (attr 0) (param i32 i32)) (func $adder (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -4821,7 +4821,7 @@ test_parsing text: (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (func $adder (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -4835,7 +4835,7 @@ module loaded from text form: (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (func $ADD_ER (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) diff --git a/test/binaryen.js/event.js b/test/binaryen.js/tag.js index f705edc38..17822236d 100644 --- a/test/binaryen.js/event.js +++ b/test/binaryen.js/tag.js @@ -13,21 +13,21 @@ module.setFeatures(binaryen.Features.ReferenceTypes | var pairType = binaryen.createType([binaryen.i32, binaryen.f32]); -var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); +var tag = module.addTag("a-tag", 0, binaryen.i32, binaryen.none); -console.log("GetEvent is equal: " + (event_ === module.getEvent("a-event"))); +console.log("GetTag is equal: " + (tag === module.getTag("a-tag"))); -var eventInfo = binaryen.getEventInfo(event_); -console.log("getEventInfo=" + JSON.stringify(cleanInfo(eventInfo))); +var tagInfo = binaryen.getTagInfo(tag); +console.log("getTagInfo=" + JSON.stringify(cleanInfo(tagInfo))); -module.addEventExport("a-event", "a-event-exp"); -module.addEventImport("a-event-imp", "module", "base", 0, pairType, binaryen.none); +module.addTagExport("a-tag", "a-tag-exp"); +module.addTagImport("a-tag-imp", "module", "base", 0, pairType, binaryen.none); assert(module.validate()); console.log(module.emitText()); -module.removeExport("a-event-exp"); -module.removeEvent("a-event"); +module.removeExport("a-tag-exp"); +module.removeTag("a-tag"); assert(module.validate()); console.log(module.emitText()); diff --git a/test/binaryen.js/tag.js.txt b/test/binaryen.js/tag.js.txt new file mode 100644 index 000000000..51a0d33ee --- /dev/null +++ b/test/binaryen.js/tag.js.txt @@ -0,0 +1,15 @@ +GetTag is equal: true +getTagInfo={"name":"a-tag","module":"","base":"","attribute":0,"params":2,"results":0} +(module + (type $i32_=>_none (func (param i32))) + (type $i32_f32_=>_none (func (param i32 f32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32 f32))) + (tag $a-tag (attr 0) (param i32)) + (export "a-tag-exp" (tag $a-tag)) +) + +(module + (type $i32_f32_=>_none (func (param i32 f32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32 f32))) +) + |