Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wa-lang
wa
提交
8f817716
wa
项目概览
wa-lang
/
wa
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
8f817716
编写于
9月 16, 2022
作者:
3
3dgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ref WIP
上级
e11c8012
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
177 addition
and
115 deletion
+177
-115
internal/backends/compiler_wat/wir/funcion.go
internal/backends/compiler_wat/wir/funcion.go
+2
-0
internal/backends/compiler_wat/wir/instruction_emitter.go
internal/backends/compiler_wat/wir/instruction_emitter.go
+14
-0
internal/backends/compiler_wat/wir/util.go
internal/backends/compiler_wat/wir/util.go
+2
-0
internal/backends/compiler_wat/wir/value_rich.go
internal/backends/compiler_wat/wir/value_rich.go
+33
-11
internal/backends/compiler_wat/wir/wat/instruction_arith.go
internal/backends/compiler_wat/wir/wat/instruction_arith.go
+20
-20
internal/backends/compiler_wat/wir/wat/instruction_comp.go
internal/backends/compiler_wat/wir/wat/instruction_comp.go
+24
-24
internal/backends/compiler_wat/wir/wat/instruction_const.go
internal/backends/compiler_wat/wir/wat/instruction_const.go
+5
-5
internal/backends/compiler_wat/wir/wat/instruction_ctl.go
internal/backends/compiler_wat/wir/wat/instruction_ctl.go
+29
-29
internal/backends/compiler_wat/wir/wat/instruction_mem.go
internal/backends/compiler_wat/wir/wat/instruction_mem.go
+10
-10
internal/backends/compiler_wat/wir/wat/instruction_misc.go
internal/backends/compiler_wat/wir/wat/instruction_misc.go
+22
-0
internal/backends/compiler_wat/wir/wat/instruction_var.go
internal/backends/compiler_wat/wir/wat/instruction_var.go
+16
-16
未找到文件。
internal/backends/compiler_wat/wir/funcion.go
浏览文件 @
8f817716
// 版权 @2022 凹语言 作者。保留所有权利。
package
wir
import
"github.com/wa-lang/wa/internal/backends/compiler_wat/wir/wat"
...
...
internal/backends/compiler_wat/wir/instruction_emitter.go
浏览文件 @
8f817716
// 版权 @2022 凹语言 作者。保留所有权利。
package
wir
import
(
...
...
@@ -100,3 +102,15 @@ func EmitLoad(addr Value) (insts []wat.Inst, ret_type ValueType) {
}
return
}
func
EmitStore
(
value
,
addr
Value
)
(
insts
[]
wat
.
Inst
)
{
switch
addr
:=
addr
.
(
type
)
{
case
*
VarRef
:
insts
=
addr
.
EmitStore
(
value
)
default
:
logger
.
Fatalf
(
"Todo %v"
,
addr
)
}
return
}
internal/backends/compiler_wat/wir/util.go
浏览文件 @
8f817716
// 版权 @2022 凹语言 作者。保留所有权利。
package
wir
import
(
...
...
internal/backends/compiler_wat/wir/value_rich.go
浏览文件 @
8f817716
...
...
@@ -35,12 +35,33 @@ func (v *varBlock) EmitRelease() []wat.Inst {
return
insts
}
func
(
v
*
varBlock
)
emitLoad
(
addr
Value
)
[]
wat
.
Inst
{
logger
.
Fatal
(
"Todo"
)
return
nil
//if !addr.Type().(Pointer).Base.Equal(v.Type()) {
// logger.Fatal("Type not match")
// return nil
//}
insts
:=
addr
.
EmitGet
()
insts
=
append
(
insts
,
wat
.
NewInstLoad
(
wat
.
I32
{},
0
,
1
))
return
insts
}
func
(
v
*
varBlock
)
emitStore
(
addr
Value
)
[]
wat
.
Inst
{
logger
.
Fatal
(
"Todo"
)
return
nil
//if !addr.Type().(Pointer).Base.Equal(v.Type()) {
// logger.Fatal("Type not match")
// return nil
//}
insts
:=
v
.
EmitGet
()
insts
=
append
(
insts
,
wat
.
NewInstCall
(
"$wa.RT.Block.Retain"
))
insts
=
append
(
insts
,
wat
.
NewInstDrop
())
NewVar
(
""
,
v
.
kind
,
v
.
Type
())
.
emitLoad
(
addr
)
insts
=
append
(
insts
,
wat
.
NewInstCall
(
"$wa.RT.Block.Release"
))
insts
=
append
(
insts
,
addr
.
EmitGet
()
...
)
insts
=
append
(
insts
,
v
.
EmitGet
()
...
)
insts
=
append
(
insts
,
wat
.
NewInstStore
(
toWatType
(
v
.
Type
()),
0
,
1
))
return
insts
}
/**************************************
...
...
@@ -139,18 +160,19 @@ func (v *VarRef) EmitGet() []wat.Inst { return v.underlying.EmitGet() }
func
(
v
*
VarRef
)
EmitSet
()
[]
wat
.
Inst
{
return
v
.
underlying
.
EmitSet
()
}
func
(
v
*
VarRef
)
EmitRelease
()
[]
wat
.
Inst
{
return
v
.
underlying
.
EmitRelease
()
}
func
(
v
*
VarRef
)
emitLoad
(
addr
Value
)
[]
wat
.
Inst
{
logger
.
Fatal
(
"Todo"
)
return
nil
return
v
.
underlying
.
emitLoad
(
addr
)
}
func
(
v
*
VarRef
)
emitStore
(
addr
Value
)
[]
wat
.
Inst
{
logger
.
Fatal
(
"Todo"
)
return
nil
return
v
.
underlying
.
emitStore
(
addr
)
}
func
(
v
*
VarRef
)
EmitLoad
()
[]
wat
.
Inst
{
t
:=
NewVar
(
""
,
v
.
kind
,
v
.
Type
()
.
(
Ref
)
.
Base
)
return
t
.
emitLoad
(
v
.
underlying
.
Extract
(
"data"
))
}
func
(
v
*
VarRef
)
EmitStore
()
[]
wat
.
Inst
{
t
:=
NewVar
(
""
,
v
.
kind
,
v
.
Type
()
.
(
Ref
)
.
Base
)
return
t
.
emitStore
(
v
.
underlying
.
Extract
(
"data"
))
func
(
v
*
VarRef
)
EmitStore
(
d
Value
)
[]
wat
.
Inst
{
if
!
d
.
Type
()
.
Equal
(
v
.
Type
()
.
(
Ref
)
.
Base
)
{
logger
.
Fatal
(
"Type not match"
)
return
nil
}
return
d
.
emitStore
(
v
.
underlying
.
Extract
(
"data"
))
}
internal/backends/compiler_wat/wir/wat/instruction_arith.go
浏览文件 @
8f817716
...
...
@@ -12,48 +12,48 @@ type anInstruction struct {
func
(
i
*
anInstruction
)
isInstruction
()
{}
/**************************************
I
nstAdd:
i
nstAdd:
**************************************/
type
I
nstAdd
struct
{
type
i
nstAdd
struct
{
anInstruction
typ
ValueType
}
func
NewInstAdd
(
t
ValueType
)
*
InstAdd
{
return
&
I
nstAdd
{
typ
:
t
}
}
func
(
i
*
I
nstAdd
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".add"
}
func
NewInstAdd
(
t
ValueType
)
*
instAdd
{
return
&
i
nstAdd
{
typ
:
t
}
}
func
(
i
*
i
nstAdd
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".add"
}
/**************************************
I
nstSub:
i
nstSub:
**************************************/
type
I
nstSub
struct
{
type
i
nstSub
struct
{
anInstruction
typ
ValueType
}
func
NewInstSub
(
t
ValueType
)
*
InstSub
{
return
&
I
nstSub
{
typ
:
t
}
}
func
(
i
*
I
nstSub
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".sub"
}
func
NewInstSub
(
t
ValueType
)
*
instSub
{
return
&
i
nstSub
{
typ
:
t
}
}
func
(
i
*
i
nstSub
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".sub"
}
/**************************************
I
nstMul:
i
nstMul:
**************************************/
type
I
nstMul
struct
{
type
i
nstMul
struct
{
anInstruction
typ
ValueType
}
func
NewInstMul
(
t
ValueType
)
*
InstMul
{
return
&
I
nstMul
{
typ
:
t
}
}
func
(
i
*
I
nstMul
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".mul"
}
func
NewInstMul
(
t
ValueType
)
*
instMul
{
return
&
i
nstMul
{
typ
:
t
}
}
func
(
i
*
i
nstMul
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".mul"
}
/**************************************
I
nstDiv:
i
nstDiv:
**************************************/
type
I
nstDiv
struct
{
type
i
nstDiv
struct
{
anInstruction
typ
ValueType
}
func
NewInstDiv
(
t
ValueType
)
*
InstDiv
{
return
&
I
nstDiv
{
typ
:
t
}
}
func
(
i
*
I
nstDiv
)
Format
(
indent
string
)
string
{
func
NewInstDiv
(
t
ValueType
)
*
instDiv
{
return
&
i
nstDiv
{
typ
:
t
}
}
func
(
i
*
i
nstDiv
)
Format
(
indent
string
)
string
{
switch
i
.
typ
.
(
type
)
{
case
I32
:
return
indent
+
"i32.div_s"
...
...
@@ -79,15 +79,15 @@ func (i *InstDiv) Format(indent string) string {
}
/**************************************
I
nstRem:
i
nstRem:
**************************************/
type
I
nstRem
struct
{
type
i
nstRem
struct
{
anInstruction
typ
ValueType
}
func
NewInstRem
(
t
ValueType
)
*
InstRem
{
return
&
I
nstRem
{
typ
:
t
}
}
func
(
i
*
I
nstRem
)
Format
(
indent
string
)
string
{
func
NewInstRem
(
t
ValueType
)
*
instRem
{
return
&
i
nstRem
{
typ
:
t
}
}
func
(
i
*
i
nstRem
)
Format
(
indent
string
)
string
{
switch
i
.
typ
.
(
type
)
{
case
I32
:
return
indent
+
"i32.rem_s"
...
...
internal/backends/compiler_wat/wir/wat/instruction_comp.go
浏览文件 @
8f817716
...
...
@@ -5,37 +5,37 @@ package wat
import
"github.com/wa-lang/wa/internal/logger"
/**************************************
I
nstEq:
i
nstEq:
**************************************/
type
I
nstEq
struct
{
type
i
nstEq
struct
{
anInstruction
typ
ValueType
}
func
NewInstEq
(
t
ValueType
)
*
InstEq
{
return
&
I
nstEq
{
typ
:
t
}
}
func
(
i
*
I
nstEq
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".eq"
}
func
NewInstEq
(
t
ValueType
)
*
instEq
{
return
&
i
nstEq
{
typ
:
t
}
}
func
(
i
*
i
nstEq
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".eq"
}
/**************************************
I
nstNe:
i
nstNe:
**************************************/
type
I
nstNe
struct
{
type
i
nstNe
struct
{
anInstruction
typ
ValueType
}
func
NewInstNe
(
t
ValueType
)
*
InstNe
{
return
&
I
nstNe
{
typ
:
t
}
}
func
(
i
*
I
nstNe
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".ne"
}
func
NewInstNe
(
t
ValueType
)
*
instNe
{
return
&
i
nstNe
{
typ
:
t
}
}
func
(
i
*
i
nstNe
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".ne"
}
/**************************************
I
nstLt:
i
nstLt:
**************************************/
type
I
nstLt
struct
{
type
i
nstLt
struct
{
anInstruction
typ
ValueType
}
func
NewInstLt
(
t
ValueType
)
*
InstLt
{
return
&
I
nstLt
{
typ
:
t
}
}
func
(
i
*
I
nstLt
)
Format
(
indent
string
)
string
{
func
NewInstLt
(
t
ValueType
)
*
instLt
{
return
&
i
nstLt
{
typ
:
t
}
}
func
(
i
*
i
nstLt
)
Format
(
indent
string
)
string
{
switch
i
.
typ
.
(
type
)
{
case
I32
:
return
indent
+
"i32.lt_s"
...
...
@@ -60,15 +60,15 @@ func (i *InstLt) Format(indent string) string {
}
/**************************************
I
nstGt:
i
nstGt:
**************************************/
type
I
nstGt
struct
{
type
i
nstGt
struct
{
anInstruction
typ
ValueType
}
func
NewInstGt
(
t
ValueType
)
*
InstGt
{
return
&
I
nstGt
{
typ
:
t
}
}
func
(
i
*
I
nstGt
)
Format
(
indent
string
)
string
{
func
NewInstGt
(
t
ValueType
)
*
instGt
{
return
&
i
nstGt
{
typ
:
t
}
}
func
(
i
*
i
nstGt
)
Format
(
indent
string
)
string
{
switch
i
.
typ
.
(
type
)
{
case
I32
:
return
indent
+
"i32.gt_s"
...
...
@@ -93,15 +93,15 @@ func (i *InstGt) Format(indent string) string {
}
/**************************************
I
nstLe:
i
nstLe:
**************************************/
type
I
nstLe
struct
{
type
i
nstLe
struct
{
anInstruction
typ
ValueType
}
func
NewInstLe
(
t
ValueType
)
*
InstLe
{
return
&
I
nstLe
{
typ
:
t
}
}
func
(
i
*
I
nstLe
)
Format
(
indent
string
)
string
{
func
NewInstLe
(
t
ValueType
)
*
instLe
{
return
&
i
nstLe
{
typ
:
t
}
}
func
(
i
*
i
nstLe
)
Format
(
indent
string
)
string
{
switch
i
.
typ
.
(
type
)
{
case
I32
:
return
indent
+
"i32.le_s"
...
...
@@ -126,15 +126,15 @@ func (i *InstLe) Format(indent string) string {
}
/**************************************
I
nstGe:
i
nstGe:
**************************************/
type
I
nstGe
struct
{
type
i
nstGe
struct
{
anInstruction
typ
ValueType
}
func
NewInstGe
(
t
ValueType
)
*
InstGe
{
return
&
I
nstGe
{
typ
:
t
}
}
func
(
i
*
I
nstGe
)
Format
(
indent
string
)
string
{
func
NewInstGe
(
t
ValueType
)
*
instGe
{
return
&
i
nstGe
{
typ
:
t
}
}
func
(
i
*
i
nstGe
)
Format
(
indent
string
)
string
{
switch
i
.
typ
.
(
type
)
{
case
I32
:
return
indent
+
"i32.ge_s"
...
...
internal/backends/compiler_wat/wir/wat/instruction_const.go
浏览文件 @
8f817716
...
...
@@ -3,17 +3,17 @@
package
wat
/**************************************
I
nstConst:
i
nstConst:
**************************************/
type
I
nstConst
struct
{
type
i
nstConst
struct
{
anInstruction
typ
ValueType
literal
string
}
func
NewInstConst
(
typ
ValueType
,
literal
string
)
*
I
nstConst
{
return
&
I
nstConst
{
typ
:
typ
,
literal
:
literal
}
func
NewInstConst
(
typ
ValueType
,
literal
string
)
*
i
nstConst
{
return
&
i
nstConst
{
typ
:
typ
,
literal
:
literal
}
}
func
(
i
*
I
nstConst
)
Format
(
indent
string
)
string
{
func
(
i
*
i
nstConst
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".const "
+
i
.
literal
}
internal/backends/compiler_wat/wir/wat/instruction_ctl.go
浏览文件 @
8f817716
...
...
@@ -5,27 +5,27 @@ package wat
import
"strconv"
/**************************************
I
nstCall:
i
nstCall:
**************************************/
type
I
nstCall
struct
{
type
i
nstCall
struct
{
anInstruction
name
string
}
func
NewInstCall
(
name
string
)
*
InstCall
{
return
&
I
nstCall
{
name
:
name
}
}
func
(
i
*
I
nstCall
)
Format
(
indent
string
)
string
{
return
indent
+
"call $"
+
i
.
name
}
func
NewInstCall
(
name
string
)
*
instCall
{
return
&
i
nstCall
{
name
:
name
}
}
func
(
i
*
i
nstCall
)
Format
(
indent
string
)
string
{
return
indent
+
"call $"
+
i
.
name
}
/**************************************
I
nstBlock:
i
nstBlock:
**************************************/
type
I
nstBlock
struct
{
type
i
nstBlock
struct
{
anInstruction
name
string
Insts
[]
Inst
}
func
NewInstBlock
(
name
string
)
*
InstBlock
{
return
&
I
nstBlock
{
name
:
name
}
}
func
(
i
*
I
nstBlock
)
Format
(
indent
string
)
string
{
func
NewInstBlock
(
name
string
)
*
instBlock
{
return
&
i
nstBlock
{
name
:
name
}
}
func
(
i
*
i
nstBlock
)
Format
(
indent
string
)
string
{
s
:=
indent
+
"(block $"
s
+=
i
.
name
+
"
\n
"
for
_
,
v
:=
range
i
.
Insts
{
...
...
@@ -36,16 +36,16 @@ func (i *InstBlock) Format(indent string) string {
}
/**************************************
I
nstLoop:
i
nstLoop:
**************************************/
type
I
nstLoop
struct
{
type
i
nstLoop
struct
{
anInstruction
name
string
Insts
[]
Inst
}
func
NewInstLoop
(
name
string
)
*
InstLoop
{
return
&
I
nstLoop
{
name
:
name
}
}
func
(
i
*
I
nstLoop
)
Format
(
indent
string
)
string
{
func
NewInstLoop
(
name
string
)
*
instLoop
{
return
&
i
nstLoop
{
name
:
name
}
}
func
(
i
*
i
nstLoop
)
Format
(
indent
string
)
string
{
s
:=
indent
+
"(loop $"
s
+=
i
.
name
+
"
\n
"
for
_
,
v
:=
range
i
.
Insts
{
...
...
@@ -56,26 +56,26 @@ func (i *InstLoop) Format(indent string) string {
}
/**************************************
I
nstBr:
i
nstBr:
**************************************/
type
I
nstBr
struct
{
type
i
nstBr
struct
{
anInstruction
Name
string
}
func
NewInstBr
(
name
string
)
*
InstBr
{
return
&
I
nstBr
{
Name
:
name
}
}
func
(
i
*
I
nstBr
)
Format
(
indent
string
)
string
{
return
indent
+
"br $"
+
i
.
Name
}
func
NewInstBr
(
name
string
)
*
instBr
{
return
&
i
nstBr
{
Name
:
name
}
}
func
(
i
*
i
nstBr
)
Format
(
indent
string
)
string
{
return
indent
+
"br $"
+
i
.
Name
}
/**************************************
I
nstBrTable:
i
nstBrTable:
**************************************/
type
I
nstBrTable
struct
{
type
i
nstBrTable
struct
{
anInstruction
Table
[]
int
}
func
NewInstBrTable
(
t
[]
int
)
*
InstBrTable
{
return
&
I
nstBrTable
{
Table
:
t
}
}
func
(
i
*
I
nstBrTable
)
Format
(
indent
string
)
string
{
func
NewInstBrTable
(
t
[]
int
)
*
instBrTable
{
return
&
i
nstBrTable
{
Table
:
t
}
}
func
(
i
*
i
nstBrTable
)
Format
(
indent
string
)
string
{
s
:=
indent
+
"br_table"
for
_
,
v
:=
range
i
.
Table
{
s
+=
" "
+
strconv
.
Itoa
(
v
)
...
...
@@ -84,19 +84,19 @@ func (i *InstBrTable) Format(indent string) string {
}
/**************************************
I
nstIf:
i
nstIf:
**************************************/
type
I
nstIf
struct
{
type
i
nstIf
struct
{
anInstruction
True
[]
Inst
False
[]
Inst
Ret
[]
ValueType
}
func
NewInstIf
(
instsTrue
,
instsFalse
[]
Inst
,
ret
[]
ValueType
)
*
I
nstIf
{
return
&
I
nstIf
{
True
:
instsTrue
,
False
:
instsFalse
,
Ret
:
ret
}
func
NewInstIf
(
instsTrue
,
instsFalse
[]
Inst
,
ret
[]
ValueType
)
*
i
nstIf
{
return
&
i
nstIf
{
True
:
instsTrue
,
False
:
instsFalse
,
Ret
:
ret
}
}
func
(
i
*
I
nstIf
)
Format
(
indent
string
)
string
{
func
(
i
*
i
nstIf
)
Format
(
indent
string
)
string
{
s
:=
indent
+
"if"
if
len
(
i
.
Ret
)
>
0
{
s
+=
" (result"
...
...
@@ -119,11 +119,11 @@ func (i *InstIf) Format(indent string) string {
}
/**************************************
I
nstReturn:
i
nstReturn:
**************************************/
type
I
nstReturn
struct
{
type
i
nstReturn
struct
{
anInstruction
}
func
NewInstReturn
()
*
InstReturn
{
return
&
I
nstReturn
{}
}
func
(
i
*
I
nstReturn
)
Format
(
indent
string
)
string
{
return
indent
+
"return"
}
func
NewInstReturn
()
*
instReturn
{
return
&
i
nstReturn
{}
}
func
(
i
*
i
nstReturn
)
Format
(
indent
string
)
string
{
return
indent
+
"return"
}
internal/backends/compiler_wat/wir/wat/instruction_mem.go
浏览文件 @
8f817716
...
...
@@ -5,33 +5,33 @@ package wat
import
"strconv"
/**************************************
I
nstLoad:
i
nstLoad:
**************************************/
type
I
nstLoad
struct
{
type
i
nstLoad
struct
{
anInstruction
typ
ValueType
offset
,
align
int
}
func
NewInstLoad
(
typ
ValueType
,
offset
int
,
align
int
)
*
I
nstLoad
{
return
&
I
nstLoad
{
typ
:
typ
,
offset
:
offset
,
align
:
align
}
func
NewInstLoad
(
typ
ValueType
,
offset
int
,
align
int
)
*
i
nstLoad
{
return
&
i
nstLoad
{
typ
:
typ
,
offset
:
offset
,
align
:
align
}
}
func
(
i
*
I
nstLoad
)
Format
(
indent
string
)
string
{
func
(
i
*
i
nstLoad
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".load offset="
+
strconv
.
Itoa
(
i
.
offset
)
+
" align="
+
strconv
.
Itoa
(
i
.
align
)
}
/**************************************
I
nstStore:
i
nstStore:
**************************************/
type
I
nstStore
struct
{
type
i
nstStore
struct
{
anInstruction
typ
ValueType
offset
,
align
int
}
func
NewInstStore
(
typ
ValueType
,
offset
int
,
align
int
)
*
I
nstStore
{
return
&
I
nstStore
{
typ
:
typ
,
offset
:
offset
,
align
:
align
}
func
NewInstStore
(
typ
ValueType
,
offset
int
,
align
int
)
*
i
nstStore
{
return
&
i
nstStore
{
typ
:
typ
,
offset
:
offset
,
align
:
align
}
}
func
(
i
*
I
nstStore
)
Format
(
indent
string
)
string
{
func
(
i
*
i
nstStore
)
Format
(
indent
string
)
string
{
return
indent
+
i
.
typ
.
Name
()
+
".store offset="
+
strconv
.
Itoa
(
i
.
offset
)
+
" align="
+
strconv
.
Itoa
(
i
.
align
)
}
internal/backends/compiler_wat/wir/wat/instruction_misc.go
0 → 100644
浏览文件 @
8f817716
package
wat
/**************************************
instDrop:
**************************************/
type
instDrop
struct
{
anInstruction
}
func
NewInstDrop
()
*
instDrop
{
return
&
instDrop
{}
}
func
(
i
*
instDrop
)
Format
(
indent
string
)
string
{
return
indent
+
"drop"
}
/**************************************
comment:
**************************************/
type
comment
struct
{
anInstruction
name
string
}
func
NewComment
(
name
string
)
*
comment
{
return
&
comment
{
name
:
name
}
}
func
(
i
*
comment
)
Format
(
indent
string
)
string
{
return
indent
+
";;"
+
i
.
name
}
internal/backends/compiler_wat/wir/wat/instruction_var.go
浏览文件 @
8f817716
...
...
@@ -3,45 +3,45 @@
package
wat
/**************************************
I
nstGetLocal:
i
nstGetLocal:
**************************************/
type
I
nstGetLocal
struct
{
type
i
nstGetLocal
struct
{
anInstruction
name
string
}
func
NewInstGetLocal
(
name
string
)
*
InstGetLocal
{
return
&
I
nstGetLocal
{
name
:
name
}
}
func
(
i
*
I
nstGetLocal
)
Format
(
indent
string
)
string
{
return
indent
+
"local.get $"
+
i
.
name
}
func
NewInstGetLocal
(
name
string
)
*
instGetLocal
{
return
&
i
nstGetLocal
{
name
:
name
}
}
func
(
i
*
i
nstGetLocal
)
Format
(
indent
string
)
string
{
return
indent
+
"local.get $"
+
i
.
name
}
/**************************************
I
nstSetLocal:
i
nstSetLocal:
**************************************/
type
I
nstSetLocal
struct
{
type
i
nstSetLocal
struct
{
anInstruction
name
string
}
func
NewInstSetLocal
(
name
string
)
*
InstSetLocal
{
return
&
I
nstSetLocal
{
name
:
name
}
}
func
(
i
*
I
nstSetLocal
)
Format
(
indent
string
)
string
{
return
indent
+
"local.set $"
+
i
.
name
}
func
NewInstSetLocal
(
name
string
)
*
instSetLocal
{
return
&
i
nstSetLocal
{
name
:
name
}
}
func
(
i
*
i
nstSetLocal
)
Format
(
indent
string
)
string
{
return
indent
+
"local.set $"
+
i
.
name
}
/**************************************
I
nstGetGlobal:
i
nstGetGlobal:
**************************************/
type
I
nstGetGlobal
struct
{
type
i
nstGetGlobal
struct
{
anInstruction
name
string
}
func
NewInstGetGlobal
(
name
string
)
*
InstGetGlobal
{
return
&
I
nstGetGlobal
{
name
:
name
}
}
func
(
i
*
I
nstGetGlobal
)
Format
(
indent
string
)
string
{
return
indent
+
"global.get $"
+
i
.
name
}
func
NewInstGetGlobal
(
name
string
)
*
instGetGlobal
{
return
&
i
nstGetGlobal
{
name
:
name
}
}
func
(
i
*
i
nstGetGlobal
)
Format
(
indent
string
)
string
{
return
indent
+
"global.get $"
+
i
.
name
}
/**************************************
I
nstSetGlobal:
i
nstSetGlobal:
**************************************/
type
I
nstSetGlobal
struct
{
type
i
nstSetGlobal
struct
{
anInstruction
name
string
}
func
NewInstSetGlobal
(
name
string
)
*
InstSetGlobal
{
return
&
I
nstSetGlobal
{
name
:
name
}
}
func
(
i
*
I
nstSetGlobal
)
Format
(
indent
string
)
string
{
return
indent
+
"global.set $"
+
i
.
name
}
func
NewInstSetGlobal
(
name
string
)
*
instSetGlobal
{
return
&
i
nstSetGlobal
{
name
:
name
}
}
func
(
i
*
i
nstSetGlobal
)
Format
(
indent
string
)
string
{
return
indent
+
"global.set $"
+
i
.
name
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录