Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wa-lang
wa
提交
7cb70a8d
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 搜索 >>
提交
7cb70a8d
编写于
8月 20, 2023
作者:
3
3dgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正[low:high:max]语法未处理max的问题
上级
baf0f798
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
13 deletion
+28
-13
internal/backends/compiler_wat/compile_func.go
internal/backends/compiler_wat/compile_func.go
+5
-2
internal/backends/compiler_wat/wir/instruction_emitter.go
internal/backends/compiler_wat/wir/instruction_emitter.go
+4
-4
internal/backends/compiler_wat/wir/value_slice.go
internal/backends/compiler_wat/wir/value_slice.go
+19
-7
未找到文件。
internal/backends/compiler_wat/compile_func.go
浏览文件 @
7cb70a8d
...
...
@@ -916,15 +916,18 @@ func (g *functionGenerator) genSlice(inst *ssa.Slice) ([]wat.Inst, wir.ValueType
}
x
:=
g
.
getValue
(
inst
.
X
)
var
low
,
high
wir
.
Value
var
low
,
high
,
max
wir
.
Value
if
inst
.
Low
!=
nil
{
low
=
g
.
getValue
(
inst
.
Low
)
.
value
}
if
inst
.
High
!=
nil
{
high
=
g
.
getValue
(
inst
.
High
)
.
value
}
if
inst
.
Max
!=
nil
{
max
=
g
.
getValue
(
inst
.
Max
)
.
value
}
return
g
.
module
.
EmitGenSlice
(
x
.
value
,
low
,
high
)
return
g
.
module
.
EmitGenSlice
(
x
.
value
,
low
,
high
,
max
)
}
func
(
g
*
functionGenerator
)
genMakeSlice
(
inst
*
ssa
.
MakeSlice
)
([]
wat
.
Inst
,
wir
.
ValueType
)
{
...
...
internal/backends/compiler_wat/wir/instruction_emitter.go
浏览文件 @
7cb70a8d
...
...
@@ -469,10 +469,10 @@ func (m *Module) EmitGenIndex(x, id Value) (insts []wat.Inst, ret_type ValueType
return
}
func
(
m
*
Module
)
EmitGenSlice
(
x
,
low
,
high
Value
)
(
insts
[]
wat
.
Inst
,
ret_type
ValueType
)
{
func
(
m
*
Module
)
EmitGenSlice
(
x
,
low
,
high
,
max
Value
)
(
insts
[]
wat
.
Inst
,
ret_type
ValueType
)
{
switch
x
:=
x
.
(
type
)
{
case
*
aSlice
:
insts
=
x
.
emitSub
(
low
,
high
)
insts
=
x
.
emitSub
(
low
,
high
,
max
)
ret_type
=
x
.
Type
()
case
*
aString
:
...
...
@@ -483,12 +483,12 @@ func (m *Module) EmitGenSlice(x, low, high Value) (insts []wat.Inst, ret_type Va
switch
btype
:=
x
.
Type
()
.
(
*
Ref
)
.
Base
.
(
type
)
{
case
*
Slice
:
slt
:=
m
.
GenValueType_Slice
(
btype
.
Base
)
insts
=
slt
.
emitGenFromRefOfSlice
(
x
,
low
,
high
)
insts
=
slt
.
emitGenFromRefOfSlice
(
x
,
low
,
high
,
max
)
ret_type
=
slt
case
*
Array
:
slt
:=
m
.
GenValueType_Slice
(
btype
.
Base
)
insts
=
slt
.
emitGenFromRefOfArray
(
x
,
low
,
high
)
insts
=
slt
.
emitGenFromRefOfArray
(
x
,
low
,
high
,
max
)
ret_type
=
slt
default
:
...
...
internal/backends/compiler_wat/wir/value_slice.go
浏览文件 @
7cb70a8d
...
...
@@ -63,7 +63,7 @@ func (t *Slice) EmitLoadFromAddr(addr Value, offset int) []wat.Inst {
}
/*这个函数极其不优雅*/
func
(
t
*
Slice
)
emitGenFromRefOfSlice
(
x
*
aRef
,
low
,
high
Value
)
(
insts
[]
wat
.
Inst
)
{
func
(
t
*
Slice
)
emitGenFromRefOfSlice
(
x
*
aRef
,
low
,
high
,
max
Value
)
(
insts
[]
wat
.
Inst
)
{
//block
insts
=
append
(
insts
,
x
.
Extract
(
"d"
)
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstLoad
(
wat
.
U32
{},
0
,
1
))
...
...
@@ -93,15 +93,19 @@ func (t *Slice) emitGenFromRefOfSlice(x *aRef, low, high Value) (insts []wat.Ins
insts
=
append
(
insts
,
wat
.
NewInstSub
(
wat
.
U32
{}))
//cap:
insts
=
append
(
insts
,
x
.
Extract
(
"d"
)
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstLoad
(
wat
.
U32
{},
12
,
1
))
if
max
==
nil
{
insts
=
append
(
insts
,
x
.
Extract
(
"d"
)
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstLoad
(
wat
.
U32
{},
12
,
1
))
}
else
{
insts
=
append
(
insts
,
max
.
EmitPush
()
...
)
}
insts
=
append
(
insts
,
low
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstSub
(
wat
.
U32
{}))
return
}
func
(
t
*
Slice
)
emitGenFromRefOfArray
(
x
*
aRef
,
low
,
high
Value
)
(
insts
[]
wat
.
Inst
)
{
func
(
t
*
Slice
)
emitGenFromRefOfArray
(
x
*
aRef
,
low
,
high
,
max
Value
)
(
insts
[]
wat
.
Inst
)
{
//block
insts
=
append
(
insts
,
x
.
Extract
(
"b"
)
.
EmitPush
()
...
)
...
...
@@ -127,7 +131,11 @@ func (t *Slice) emitGenFromRefOfArray(x *aRef, low, high Value) (insts []wat.Ins
insts
=
append
(
insts
,
wat
.
NewInstSub
(
wat
.
U32
{}))
//cap:
insts
=
append
(
insts
,
array_len
.
EmitPush
()
...
)
if
max
==
nil
{
insts
=
append
(
insts
,
array_len
.
EmitPush
()
...
)
}
else
{
insts
=
append
(
insts
,
max
.
EmitPush
()
...
)
}
insts
=
append
(
insts
,
low
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstSub
(
wat
.
U32
{}))
...
...
@@ -517,7 +525,7 @@ func (v *aSlice) emitStoreToAddr(addr Value, offset int) []wat.Inst {
return
v
.
aStruct
.
emitStoreToAddr
(
addr
,
offset
)
}
func
(
v
*
aSlice
)
emitSub
(
low
,
high
Value
)
(
insts
[]
wat
.
Inst
)
{
func
(
v
*
aSlice
)
emitSub
(
low
,
high
,
max
Value
)
(
insts
[]
wat
.
Inst
)
{
//block
insts
=
append
(
insts
,
v
.
Extract
(
"b"
)
.
EmitPush
()
...
)
...
...
@@ -540,7 +548,11 @@ func (v *aSlice) emitSub(low, high Value) (insts []wat.Inst) {
insts
=
append
(
insts
,
wat
.
NewInstSub
(
wat
.
U32
{}))
//cap:
insts
=
append
(
insts
,
v
.
Extract
(
"c"
)
.
EmitPush
()
...
)
if
max
==
nil
{
insts
=
append
(
insts
,
v
.
Extract
(
"c"
)
.
EmitPush
()
...
)
}
else
{
insts
=
append
(
insts
,
max
.
EmitPush
()
...
)
}
insts
=
append
(
insts
,
low
.
EmitPush
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstSub
(
wat
.
U32
{}))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录