بنقرة واحدة
macro-code-gen
How libraries (html_cbi, preact_cbi, react_cbi, solid_cbi, universal_cbi) generate code
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
How libraries (html_cbi, preact_cbi, react_cbi, solid_cbi, universal_cbi) generate code
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Comprehensive guide to the Chemical compiler test infrastructure — how tests are organized, written, and executed. Covers the test framework, @test annotation dispatch, test_env and test libraries, and how compiler plugins get tested via lang/tests/build.lab.
Comprehensive deep-dive into the Chemical build pipeline — how chemical.mod is converted to build.lab, how build scripts are JIT-compiled via TinyCC, how jobs are created and executed, and how ASTProcessor orchestrates the parallel compilation passes.
All documentation related to building and running Project or Tests
Comprehensive guide to the Chemical Compiler Binding Interface (CBI) — how compiler plugins are built, registered, and integrated into the compilation pipeline.
Documentation of Syntax and APIs for Chemical Programming Language, A must read before implementing something in chemical programming language.s
Comprehensive guide to Chemical's compiler intrinsic functions and reflection APIs — how GlobalFunctions.cpp provides interpreter-friendly implementations, compile-time reflection, and metadata access.
استنادا إلى تصنيف SOC المهني
| name | Macro Code gen |
| description | How libraries (html_cbi, preact_cbi, react_cbi, solid_cbi, universal_cbi) generate code |
When you write in chemical
func my_html(page : &mut HtmlPage) {
#html {
<span>Hello World</span>
}
}
Whats actually happening is, behind the scenes this code gets generated
func my_html(page : &mut HtmlPage) {
page.append_html_view("<span>Hello World</span>");
}
Its not the exact code, but its pretty close, The difference happens when you use a chemical value, for example This code
func my_html(page : &mut HtmlPage, name : &std::string_view) {
#html {
<span>Hello {name}</span>
}
}
generates
func my_html(page : &mut HtmlPage, name : &std::string_view) {
page.append_html_view("<span>Hello ");
// this method basically calls append_html
// it exists in lang/libs/page/src/PageWriter.ch
name.writeToPageBody(page)
page.append_html_view("</span>");
}
This is how we handle chemical values, But you may notice that we support top level macros
#preact, #react, #solid, #universal All these component framework libraries are top level macros. The reason being
that these handle components and that's why.
for example
#preact Greeting(props) {
return <div>Hello {props.name}</div>
}
It doesn't have a encapsulating function, so it generates one, it generates code like
func Greeting(page : &mut HtmlPage) {
if(!page.requires_component(123)) {
return;
}
page.set_has_component(123)
page.append_head_js_view("function Greeting_component(props) { ... }")
}
The function names maybe a little different, but they accomplish similar logic, however universal is different
universal lib generate a function that takes two more parameters, an SsrAttributeList, content for the children
universal lib also generates in both bundles, HTML that is server side rendered (from the component) and then a js function
that would hydrate the emitted html.
universal components are fast and they render everywhere, they work in react, preact and solid components. They work in #html too.
For more information on universal components, load the universal skill. For developing new compiler plugins or understanding the plugin API, load the cbi_plugin_api skill. For understanding the compiler intrinsics and reflection APIs that macros can use at compile time, load the intrinsics_compiler_reflection skill.