File tree Expand file tree Collapse file tree 5 files changed +22
-17
lines changed
Expand file tree Collapse file tree 5 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ std::string escape(std::string code) {
7979 code = code.replace (curr, 2 , " \\\\ n" );
8080 curr += 3 ; // skip this one
8181 }
82+ curr = 0 ;
83+ while ((curr = code.find (" \\ t" , curr)) != std::string::npos) {
84+ code = code.replace (curr, 2 , " \\\\ t" );
85+ curr += 3 ; // skip this one
86+ }
8287 // replace double quotes with escaped single quotes
8388 curr = 0 ;
8489 while ((curr = code.find (' "' , curr)) != std::string::npos) {
Original file line number Diff line number Diff line change 11#include < emscripten/em_asm.h>
22
33int main () {
4- EM_ASM ({ Module.print (" Hello world" ); });
4+ EM_ASM ({ Module.print (" Hello \\ world\t\n " ); });
55 int x = EM_ASM_INT ({ return $0 + $1 ; }, 13 , 27 );
66 EM_ASM_ ({ Module.print (" Got " + $0 ); }, x);
77 return 0 ;
Original file line number Diff line number Diff line change 66 (import " env" " emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32 ) (result i32 )))
77 (memory $0 2 )
88 (data $.rodata (i32.const 568 ) " \00 ii\00 i\00 " )
9- (data $em_asm (i32.const 574 ) " { Module.print(\" Hello world\" ); }\00 { return $0 + $1; }\00 { Module.print(\" Got \" + $0); }\00 " )
9+ (data $em_asm (i32.const 574 ) " { Module.print(\" Hello \\\\ world\\ t \\ n \" ); }\00 { return $0 + $1; }\00 { Module.print(\" Got \" + $0); }\00 " )
1010 (table $0 1 1 funcref )
1111 (global $__stack_pointer (mut i32 ) (i32.const 66208 ))
1212 (global $global$1 i32 (i32.const 574 ))
13- (global $global$2 i32 (i32.const 658 ))
13+ (global $global$2 i32 (i32.const 665 ))
1414 (export " memory" (memory $0 ))
1515 (export " __wasm_call_ctors" (func $__wasm_call_ctors ))
1616 (export " main" (func $main ))
4242 (i32.store
4343 (local.get $0 )
4444 (call $emscripten_asm_const_int
45- (i32.const 607 )
45+ (i32.const 614 )
4646 (i32.const 569 )
4747 (i32.add
4848 (local.get $0 )
5252 )
5353 (drop
5454 (call $emscripten_asm_const_int
55- (i32.const 627 )
55+ (i32.const 634 )
5656 (i32.const 572 )
5757 (local.get $0 )
5858 )
Original file line number Diff line number Diff line change 66 (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
77 (global $__stack_pointer (mut i32) (i32.const 66208))
88 (global $global$1 i32 (i32.const 574))
9- (global $global$2 i32 (i32.const 658 ))
9+ (global $global$2 i32 (i32.const 665 ))
1010 (memory $0 2)
1111 (table $0 1 1 funcref)
1212 (export "memory" (memory $0))
3939 (i32.store
4040 (local.get $0)
4141 (call $emscripten_asm_const_int
42- (i32.const 607 )
42+ (i32.const 614 )
4343 (i32.const 569)
4444 (i32.add
4545 (local.get $0)
4949 )
5050 (drop
5151 (call $emscripten_asm_const_int
52- (i32.const 627 )
52+ (i32.const 634 )
5353 (i32.const 572)
5454 (local.get $0)
5555 )
7070--BEGIN METADATA --
7171{
7272 "asmConsts": {
73- "574": "{ Module.print(\"Hello world\"); }",
74- "607 ": "{ return $0 + $1; }",
75- "627 ": "{ Module.print(\"Got \" + $0); }"
73+ "574": "{ Module.print(\"Hello \\ world\\t\\n \"); }",
74+ "614 ": "{ return $0 + $1; }",
75+ "634 ": "{ Module.print(\"Got \" + $0); }"
7676 },
7777 "declares": [
7878 "emscripten_asm_const_int"
Original file line number Diff line number Diff line change 66 (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
77 (global $__stack_pointer (mut i32) (i32.const 66208))
88 (global $global$1 i32 (i32.const 574))
9- (global $global$2 i32 (i32.const 658 ))
9+ (global $global$2 i32 (i32.const 665 ))
1010 (memory $0 2)
1111 (data $.rodata (i32.const 568) "\00ii\00i\00")
1212 (data $em_asm (i32.const 574) "")
4141 (i32.store
4242 (local.get $0)
4343 (call $emscripten_asm_const_int
44- (i32.const 607 )
44+ (i32.const 614 )
4545 (i32.const 569)
4646 (i32.add
4747 (local.get $0)
5151 )
5252 (drop
5353 (call $emscripten_asm_const_int
54- (i32.const 627 )
54+ (i32.const 634 )
5555 (i32.const 572)
5656 (local.get $0)
5757 )
7272--BEGIN METADATA --
7373{
7474 "asmConsts": {
75- "574": "{ Module.print(\"Hello world\"); }",
76- "607 ": "{ return $0 + $1; }",
77- "627 ": "{ Module.print(\"Got \" + $0); }"
75+ "574": "{ Module.print(\"Hello \\ world\\t\\n \"); }",
76+ "614 ": "{ return $0 + $1; }",
77+ "634 ": "{ Module.print(\"Got \" + $0); }"
7878 },
7979 "declares": [
8080 "emscripten_asm_const_int"
You can’t perform that action at this time.
0 commit comments