MCPcopy
hub / github.com/wa-lang/wa

github.com/wa-lang/wa @v1.8.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.8.0 ↗
13,939 symbols 41,039 edges 1,018 files 6,057 documented · 43%
README

凹语言

主页 | Playground | 路线 | 社区 | 日志

凹语言(凹读音“Wā”)是针对 WebAssembly 设计的编程语言,目标是为高性能网页应用提供一门简洁、可靠、易用、强类型的编译型通用语言。凹语言的代码生成器及运行时为全自主研发(不依赖于LLVM等外部项目),实现了全链路自主可控。目前凹语言处于工程试用阶段。

说明: 凹语言编译器代码以 AGPL-v3 开源协议授权, 标准库以 MIT 协议授权,这意味着您使用凹语言开发的程序可以安全商用无需开源。若您希望在自己的项目中整合凹语言编译器的代码,而又不希望受 AGPL-v3 的传染性限制,您可以联系我们单独为您定制授权协议。

如何参与开发

项目尚处于原型开源阶段,如果有共建和PR需求请参考 如何贡献代码。我们不再接受针对第三方依赖库修改的 PR。

向本仓库提交PR视同您认可并接受凹语言贡献者协议,但在实际签署之前,您的PR不会被评审或接受。

特别注意:与 Issue 相比,发起 PR 更容易获得贡献点(贡献点可用于参加回馈活动,如:首次凹语言贡献者回馈活动)。当您在项目中找到问题发起 Issue后,不妨与我们联系,我们会帮助您将 Issue 转为 PR。

凹语言编译器架构

凹语言设计采用中英文双前端,对接到凹语言IR统一的中间表示,后端对接中英文自研汇编器,最终对接到不同的指令集架构, 最终实现全链路自研(没有GCC/LLVM等外部依赖).

graph LR
    wa_ext(凹语言英文.wa);
    wz_ext(凹语言中文.wz);

    wa_ast(凹语言英文 AST);
    wz_ast(凹语言中文 AST);

    wair(凹语言IR);

    wasm(WASM);
    nasm(凹语言汇编器);
    c_cpp(C/C++);

    x64(X64);
    loong64(龙芯64);
    riscv(RISCV);
    arm64(ARM64);

    wa_ext --> wa_ast;
    wz_ext --> wz_ast;

    wa_ast --> wair;
    wz_ast --> wair;

    wair --> wasm
    wair --> nasm
    wair --> c_cpp

    nasm --> loong64
    nasm --> x64
    nasm --> riscv
    nasm --> arm64
  • 注: 其中RISCV平台因为缺少环境, 尚未进行真机测试.
  • 注: 凹语言IR 尚在设计完善中, 目前以wasm作为中间IR.

Playground 在线预览

https://wa-lang.org/playground

贪吃蛇游戏

WASM4游戏

  • Wasm4/Snake: https://wa-lang.org/wa/w4-snake/
  • 贪吃蛇源码 (英文): https://gitcode.com/wa-lang/wa/tree/master/waroot/examples/w4-snake/
  • 贪吃蛇源码 (中文): https://gitcode.com/wa-lang/wa/tree/master/waroot/examples/w4-snake-wz/
  • Wasm4/2048: https://wa-lang.org/wa/w4-2048/

NES小霸王游戏机模拟器

WebGPU 模拟土星和小行星

P5 儿童编程

  • https://wa-lang.org/smalltalk/st0037.html

Arduino Nano 33 开发板

  • https://wa-lang.org/smalltalk/st0052.html

例子: 凹语言(中文版)

打印字符串:

注: 你好,世界!

引入 "书"

函数·主控:
    书·说("你好,凹语言中文版!")
完毕

运行并输出结果:

$ wa run hello.wz 
你好,凹语言中文版!

例子: 凹语言(英文版)

打印字符和调用函数:

import "fmt"

global year: i32 = 2023

func main {
    println("hello, Wa!")
    println(add(40, 2), year)

    fmt.Println(1+1)
}

func add(a: i32, b: i32) => i32 {
    return a+b
}

运行并输出结果:

$ wa run hello.wa 
你好,凹语言!
42 2023
2

例子: 打印素数

打印 30 以内的素数:

// 版权 @2021 凹语言™ 作者。保留所有权利。

func main {
    for n := 2; n <= 30; n = n + 1 {
        isPrime: int = 1
        for i := 2; i*i <= n; i = i + 1 {
            if x := n % i; x == 0 {
                isPrime = 0
            }
        }
        if isPrime != 0 {
            println(n)
        }
    }
}

运行并输出结果:

$ cd waroot && wa run examples/prime
2
3
5
7
11
13
17
19
23
29

更多例子 waroot/examples

贡献者名单

贡献者 贡献点
柴树杉 124650
丁尔男 116650
史斌 10000
扈梦明 72500
赵普明 10000
宋汝阳 2000
刘云峰 1000
王潇南 1000
王泽龙 1000
吴烜 3000
刘斌 2500
尹贻浩 2000
安博超 3000
yuqiaoyu 600
qstesiro 200
small_broken_gong 100
tk103331 100
蔡兴 3000
王任义 1000
imalasong 2000
杨刚 4000
崔爽 2000
李瑾 20000
王委委 100
雪碧 100

贡献点变更记录见 waroot/cplog 目录。

联系我们

电子邮箱:dev@wa-lang.org

微信号:walang_dev

Extension points exported contracts — how you extend this code

Generic (Interface)
Generic is a generic parseable type identified by a specific flag [8 implementers]
internal/3rdparty/cli/flag_generic.go
Key (Interface)
Key is used as the identity of a Label. Keys are intended to be compared by pointer only, the name should be unique for [17 …
internal/lsp/event/label/label.go
Importer (Interface)
An Importer resolves import paths to Packages. CAUTION: This interface does not support the import of locally vendored [6 …
internal/types/api.go
CIRStringer (Interface)
************************************** CIRStringer: **************************************/ [47 implementers]
internal/backends/compiler_c/cir/expr.go
Callee (Interface)
************************************** Callee: 调用接口 **************************************/ [13 implementers]
internal/wire/ins_expr_call.go
LibHandle (Interface)
(no doc) [10 implementers]
internal/dlopen/dlopen.go
Member (Interface)
A Member is a member of a Go package, implemented by *NamedConst, *Global, *Function, or *Type; they are created by pack [4 …
internal/ssa/ssa.go
Device (Interface)
设备接口 设备无法提前预知被挂载的地址, 这里读写的地址是设备自身的地址 [4 implementers]
internal/native/wemu/device/bus.go

Core symbols most depended-on inside this repo

WriteString
called by 932
internal/3rdparty/wazero/api/wasm.go
assert
called by 499
internal/native/wat2la/utils.go
assert
called by 499
internal/native/wat2arm64/utils.go
assert
called by 499
internal/native/wat2rv/utils.go
emit
called by 449
internal/3rdparty/wazero/internal/wazeroir/compiler.go
CompileRegisterToRegister
called by 448
internal/3rdparty/wazero/internal/asm/assembler.go
isS12Overflow
called by 426
internal/native/wat2la/la64_ins.go
isS12Overflow
called by 426
internal/native/wat2arm64/a64_ins.go

Shape

Method 7,170
Function 4,219
Struct 2,021
TypeAlias 265
Interface 141
Class 75
FuncType 47
Route 1

Languages

Go89%
TypeScript11%
Python1%

Modules by API surface

internal/lsp/protocol/tsprotocol.go486 symbols
internal/app/appplay/_static/playground/playground-full.js462 symbols
internal/app/appplay/_static/playground/codemirror.js435 symbols
internal/app/appbuild/assets/wasm4.js324 symbols
internal/3rdparty/wazero/internal/wazeroir/operations.go302 symbols
internal/3rdparty/go-dap/schematypes.go245 symbols
internal/ssa/ssa.go231 symbols
internal/ast/ast.go217 symbols
internal/wat/ast/ins.go185 symbols
internal/wat/parser/module_func_instruction.go178 symbols
internal/3rdparty/wazero/internal/engine/compiler/impl_amd64.go153 symbols
internal/3rdparty/wazero/internal/engine/compiler/compiler.go150 symbols

For agents

$ claude mcp add wa \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact