Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wa-lang
wa
提交
decb015c
wa
项目概览
wa-lang
/
wa
10 个月 前同步成功
通知
68
Star
655
Fork
45
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
wa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
decb015c
编写于
7月 01, 2023
作者:
3
3dgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加! ^ 单目操作符
上级
f7145176
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
10 deletion
+32
-10
internal/backends/compiler_wat/compile_func.go
internal/backends/compiler_wat/compile_func.go
+11
-7
internal/backends/compiler_wat/wir/instruction_emitter.go
internal/backends/compiler_wat/wir/instruction_emitter.go
+20
-3
internal/backends/compiler_wat/wir/wat/wat.go
internal/backends/compiler_wat/wir/wat/wat.go
+1
-0
未找到文件。
internal/backends/compiler_wat/compile_func.go
浏览文件 @
decb015c
...
...
@@ -68,10 +68,6 @@ func (g *functionGenerator) getValue(i ssa.Value) valueWrap {
return
valueWrap
{
value
:
wir
.
NewConst
(
"0"
,
g
.
module
.
I32
)}
}
case
types
.
Int
:
val
,
_
:=
constant
.
Int64Val
(
v
.
Value
)
return
valueWrap
{
value
:
wir
.
NewConst
(
strconv
.
Itoa
(
int
(
val
)),
g
.
module
.
I32
)}
case
types
.
Uint8
:
val
,
_
:=
constant
.
Uint64Val
(
v
.
Value
)
return
valueWrap
{
value
:
wir
.
NewConst
(
strconv
.
Itoa
(
int
(
val
)),
g
.
module
.
U8
)}
...
...
@@ -88,11 +84,11 @@ func (g *functionGenerator) getValue(i ssa.Value) valueWrap {
// val, _ := constant.Int64Val(v.Value)
// return valueWrap{value: wir.NewConst(strconv.Itoa(int(val)), g.module.I16)}
case
types
.
Uint32
,
types
.
Uintptr
:
case
types
.
Uint32
,
types
.
Uintptr
,
types
.
Uint
:
val
,
_
:=
constant
.
Uint64Val
(
v
.
Value
)
return
valueWrap
{
value
:
wir
.
NewConst
(
strconv
.
Itoa
(
int
(
val
)),
g
.
module
.
U32
)}
case
types
.
Int32
:
case
types
.
Int32
,
types
.
Int
:
val
,
_
:=
constant
.
Int64Val
(
v
.
Value
)
if
t
.
Name
()
==
"rune"
{
return
valueWrap
{
value
:
wir
.
NewConst
(
strconv
.
Itoa
(
int
(
val
)),
g
.
module
.
RUNE
)}
...
...
@@ -343,7 +339,7 @@ func (g *functionGenerator) genInstruction(inst ssa.Instruction) (insts []wat.In
insts
=
append
(
insts
,
s
...
)
default
:
logger
.
Fatal
(
"Todo:"
,
inst
.
String
()
)
logger
.
Fatal
f
(
"Todo: %[1]v: %[1]T"
,
inst
)
}
insts
=
append
(
insts
,
wat
.
NewBlank
())
return
...
...
@@ -429,6 +425,14 @@ func (g *functionGenerator) genUnOp(inst *ssa.UnOp) (insts []wat.Inst, ret_type
x
:=
g
.
getValue
(
inst
.
X
)
return
g
.
module
.
EmitUnOp
(
x
.
value
,
wat
.
OpCodeSub
)
case
token
.
XOR
:
x
:=
g
.
getValue
(
inst
.
X
)
return
g
.
module
.
EmitUnOp
(
x
.
value
,
wat
.
OpCodeXor
)
case
token
.
NOT
:
x
:=
g
.
getValue
(
inst
.
X
)
return
g
.
module
.
EmitUnOp
(
x
.
value
,
wat
.
OpCodeNot
)
default
:
logger
.
Fatalf
(
"Todo: %[1]v: %[1]T"
,
inst
)
}
...
...
internal/backends/compiler_wat/wir/instruction_emitter.go
浏览文件 @
decb015c
...
...
@@ -36,9 +36,26 @@ func (m *Module) EmitUnOp(x Value, op wat.OpCode) (insts []wat.Inst, ret_type Va
logger
.
Fatal
(
"Todo"
)
}
ret_type
=
x
.
Type
()
insts
=
append
(
insts
,
NewConst
(
"0"
,
ret_type
)
.
EmitPush
()
...
)
insts
=
append
(
insts
,
x
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstSub
(
toWatType
(
ret_type
)))
switch
op
{
case
wat
.
OpCodeSub
:
insts
=
append
(
insts
,
NewConst
(
"0"
,
ret_type
)
.
EmitPush
()
...
)
insts
=
append
(
insts
,
x
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstSub
(
toWatType
(
ret_type
)))
case
wat
.
OpCodeXor
:
insts
=
append
(
insts
,
NewConst
(
"-1"
,
ret_type
)
.
EmitPush
()
...
)
insts
=
append
(
insts
,
x
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstXor
(
toWatType
(
ret_type
)))
case
wat
.
OpCodeNot
:
insts
=
append
(
insts
,
x
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstEqz
(
toWatType
(
ret_type
)))
default
:
logger
.
Fatal
(
"Todo: %[1]v: %[1]T"
,
op
)
}
return
}
...
...
internal/backends/compiler_wat/wir/wat/wat.go
浏览文件 @
decb015c
...
...
@@ -92,6 +92,7 @@ const (
OpCodeAnd
OpCodeOr
OpCodeXor
OpCodeNot
OpCodeShl
OpCodeShr
OpCodeAndNot
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录