api
emitter.ch
Declarations in emitter.ch
1 declarationsjs_parser
Declarations
Public only
JsNodeEmitter#
Publicinterface
interface JsNodeEmitter
JsNodeEmitter is a static interface that abstracts how converted JS output
is emitted.
The compiler plugin (js_cbi) implements this interface by accumulating text
into a buffer and emitting `page.append_js(...)` calls into the generated
chemical AST (through flush() and emit_chemical_value()).
The runtime package (js) implements this interface by appending text
directly into a std::string, so users can parse JS and get the resulting
JS source back as a string in their executable.
Since this is a static interface, only a single implementation may exist
in a program. The js_parser package contains the shared conversion logic
(convert_js_node / convert_js_root) which drives this interface.
emit_text#
Publicfunction
emit_char#
Publicfunction
func emit_char(self : &JsNodeEmitter, c : char) : void
emit_integer#
Publicfunction
func emit_integer(self : &JsNodeEmitter, v : i64) : void
emit_chemical_value#
Publicfunction
* called when a chemical value is embedded inside the js code
* (for example `var x = ${value};`)
flush#
Publicfunction
func flush(self : &JsNodeEmitter) : void
* called to flush any pending buffered text
has_jsx_parent#
Publicfunction
func has_jsx_parent(self : &JsNodeEmitter) : bool
* whether the emitted node is inside a jsx component (only meaningful
* for the compiler implementation, runtime always returns false)