Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
fa663278
Commit
fa663278
authored
Jun 03, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing MuCtxIRBuilderPart
parent
d89e5324
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
320 additions
and
23 deletions
+320
-23
migrate_scripts/irbuildertomuctx.py
migrate_scripts/irbuildertomuctx.py
+21
-21
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
+5
-1
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
+135
-1
src/test/scala/uvm/refimpl/MuCtxIRBuilderTest.scala
src/test/scala/uvm/refimpl/MuCtxIRBuilderTest.scala
+159
-0
No files found.
migrate_scripts/irbuildertomuctx.py
View file @
fa663278
...
...
@@ -12,29 +12,29 @@ end = "SCRIPT: END HERE"
replaces
=
[(
re
.
compile
(
x
),
y
)
for
(
x
,
y
)
in
[
(
r'BN'
,
'MuBundleNode'
),
(
r'
CN\[_\s*<:\s*
Identified\]'
,
'MuChildNode'
),
(
r'
CN\[
IdentifiedSettable\]'
,
'MuChildNode'
),
(
r'
CN
\[Type\w*\]'
,
'MuTypeNode'
),
(
r'
CN
\[Abstract\w+Type\]'
,
'MuTypeNode'
),
(
r'
CN
\[FuncSig\]'
,
'MuFuncSigNode'
),
(
r'
CN
\[Const\w+\]'
,
'MuConstNode'
),
(
r'
CN
\[GlobalCell\]'
,
'MuGlobalNode'
),
(
r'
CN
\[Function\]'
,
'MuFuncNode'
),
(
r'
CN
\[ExposedFunc\]'
,
'MuExpFuncNode'
),
(
r'
CN
\[FuncVer\]'
,
'MuFuncVerNode'
),
(
r'
CN
\[BasicBlock\]'
,
'MuBBNode'
),
(
r'
CN
\[BB\]'
,
'MuBBNode'
),
(
r'
CN
\[SSAVariable\]'
,
'MuVarNode'
),
(
r'
CN
\[Var\]'
,
'MuVarNode'
),
(
r'
CN
\[LocalVariable\]'
,
'MuLocalVarNode'
),
(
r'
CN
\[NorParam\]'
,
'MuNorParamNode'
),
(
r'
CN
\[ExcParam\]'
,
'MuExcParamNode'
),
(
r'
CN
\[InstResult\]'
,
'MuInstResNode'
),
(
r'
CN
\[Inst\w+\]'
,
'MuInstNode'
),
(
r'
CN
\[HasKeepAliveClause\]'
,
'MuInstNode'
),
(
r'
(CN|ChildNode)\[(_\s*<:\s*)?
Identified\]'
,
'MuChildNode'
),
(
r'
(CN|ChildNode)\[(_\s*<:\s*)?
IdentifiedSettable\]'
,
'MuChildNode'
),
(
r'
(CN|ChildNode)
\[Type\w*\]'
,
'MuTypeNode'
),
(
r'
(CN|ChildNode)
\[Abstract\w+Type\]'
,
'MuTypeNode'
),
(
r'
(CN|ChildNode)
\[FuncSig\]'
,
'MuFuncSigNode'
),
(
r'
(CN|ChildNode)
\[Const\w+\]'
,
'MuConstNode'
),
(
r'
(CN|ChildNode)
\[GlobalCell\]'
,
'MuGlobalNode'
),
(
r'
(CN|ChildNode)
\[Function\]'
,
'MuFuncNode'
),
(
r'
(CN|ChildNode)
\[ExposedFunc\]'
,
'MuExpFuncNode'
),
(
r'
(CN|ChildNode)
\[FuncVer\]'
,
'MuFuncVerNode'
),
(
r'
(CN|ChildNode)
\[BasicBlock\]'
,
'MuBBNode'
),
(
r'
(CN|ChildNode)
\[BB\]'
,
'MuBBNode'
),
(
r'
(CN|ChildNode)
\[SSAVariable\]'
,
'MuVarNode'
),
(
r'
(CN|ChildNode)
\[Var\]'
,
'MuVarNode'
),
(
r'
(CN|ChildNode)
\[LocalVariable\]'
,
'MuLocalVarNode'
),
(
r'
(CN|ChildNode)
\[NorParam\]'
,
'MuNorParamNode'
),
(
r'
(CN|ChildNode)
\[ExcParam\]'
,
'MuExcParamNode'
),
(
r'
(CN|ChildNode)
\[InstResult\]'
,
'MuInstResNode'
),
(
r'
(CN|ChildNode)
\[Inst\w+\]'
,
'MuInstNode'
),
(
r'
(CN|ChildNode)
\[HasKeepAliveClause\]'
,
'MuInstNode'
),
]]
sig
=
re
.
compile
(
r'^( def
(\w+)
\(([^)]*)\):\s+\w+\s+=)'
,
re
.
MULTILINE
)
sig
=
re
.
compile
(
r'^( def
\s+(\w+)\s*
\(([^)]*)\):\s+\w+\s+=)'
,
re
.
MULTILINE
)
arg
=
re
.
compile
(
r'(\w*):\s+([a-zA-Z0-9\[\]]+)'
)
node_like
=
re
.
compile
(
r'Mu\w+Node'
)
node_seq_like
=
re
.
compile
(
r'Seq\[Mu\w+Node\]'
)
...
...
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
View file @
fa663278
...
...
@@ -58,12 +58,16 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
new
ChildNode
(
ent
)
}
def
getID
(
b
:
BN
,
node
:
CN
[
_
<:
Identified
])
:
Int
=
{
def
getID
(
b
:
BN
,
node
:
CN
[
Identified
])
:
Int
=
{
node
.
id
}
def
setName
(
b
:
BN
,
node
:
CN
[
IdentifiedSettable
],
name
:
String
)
:
Unit
=
{
node
.
name
=
Some
(
name
)
// NOTE: When the name is set, the TrantientBundle's namespaces still do not index the object by its name,
// because the objects are added before their names are set. But by the time when the TrantientBundle is merged with
// the GlobalBundle, all objects in all namespaces will have been re-added to the GlobalBundle. For this reason,
// globalBundle.someNs.get("@the.name.of.object") will still return the object as long as it has a name.
}
// format: OFF
...
...
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
View file @
fa663278
...
...
@@ -94,11 +94,81 @@ trait MuCtxIRBuilderPart {
irBuilder
.
setName
(
b
,
node
,
name
)
}
def
newTypeInt
(
b
:
MuBundleNode
,
len
:
Int
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeInt
(
b
,
len
))
}
def
newTypeFloat
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeFloat
(
b
))
}
def
newTypeDouble
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeDouble
(
b
))
}
def
newTypeUPtr
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeUPtr
(
b
))
}
def
newTypeUFuncPtr
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeUFuncPtr
(
b
))
}
def
newTypeVoid
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeVoid
(
b
))
}
def
newTypeRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeRef
(
b
))
}
def
newTypeIRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeIRef
(
b
))
}
def
newTypeWeakRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeWeakRef
(
b
))
}
def
newTypeFuncRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeFuncRef
(
b
))
}
def
newTypeTagRef64
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeTagRef64
(
b
))
}
def
newTypeThreadRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeThreadRef
(
b
))
}
def
newTypeStackRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeStackRef
(
b
))
}
def
newTypeFrameCursorRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeFrameCursorRef
(
b
))
}
def
newTypeIRNodeRef
(
b
:
MuBundleNode
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
addHandle
(
irBuilder
.
newTypeIRNodeRef
(
b
))
}
def
newTypeStruct
(
b
:
MuBundleNode
,
fieldTys
:
Seq
[
MuTypeNode
])
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
for
((
n
,
i
)
<-
fieldTys
.
zipWithIndex
)
require
(!
n
.
isNull
,
"fieldTys[%d] must not be NULL"
.
format
(
i
))
...
...
@@ -112,17 +182,54 @@ trait MuCtxIRBuilderPart {
addHandle
(
irBuilder
.
newTypeHybrid
(
b
,
fixedTys
,
varTy
))
}
def
newTypeArray
(
b
:
MuBundleNode
,
elemTy
:
MuTypeNode
,
len
:
Long
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
elemTy
.
isNull
,
"elemTy must not be NULL"
)
addHandle
(
irBuilder
.
newTypeArray
(
b
,
elemTy
,
len
))
}
def
newTypeVector
(
b
:
MuBundleNode
,
elemTy
:
MuTypeNode
,
len
:
Long
)
:
MuTypeNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
elemTy
.
isNull
,
"elemTy must not be NULL"
)
addHandle
(
irBuilder
.
newTypeVector
(
b
,
elemTy
,
len
))
}
def
setTypeUFuncPtr
(
ufuncptr
:
MuTypeNode
,
sig
:
ChildNode
[
FuncSig
])
:
Unit
=
{
def
setTypeUPtr
(
uptr
:
MuTypeNode
,
ty
:
MuTypeNode
)
:
Unit
=
{
require
(!
uptr
.
isNull
,
"uptr must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
irBuilder
.
setTypeUPtr
(
uptr
,
ty
)
}
def
setTypeRef
(
ref
:
MuTypeNode
,
ty
:
MuTypeNode
)
:
Unit
=
{
require
(!
ref
.
isNull
,
"ref must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
irBuilder
.
setTypeRef
(
ref
,
ty
)
}
def
setTypeIRef
(
iref
:
MuTypeNode
,
ty
:
MuTypeNode
)
:
Unit
=
{
require
(!
iref
.
isNull
,
"iref must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
irBuilder
.
setTypeIRef
(
iref
,
ty
)
}
def
setTypeWeakRef
(
weakref
:
MuTypeNode
,
ty
:
MuTypeNode
)
:
Unit
=
{
require
(!
weakref
.
isNull
,
"weakref must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
irBuilder
.
setTypeWeakRef
(
weakref
,
ty
)
}
def
setTypeUFuncPtr
(
ufuncptr
:
MuTypeNode
,
sig
:
MuFuncSigNode
)
:
Unit
=
{
require
(!
ufuncptr
.
isNull
,
"ufuncptr must not be NULL"
)
require
(!
sig
.
isNull
,
"sig must not be NULL"
)
irBuilder
.
setTypeUFuncPtr
(
ufuncptr
,
sig
)
}
def
setTypeFuncRef
(
funcref
:
MuTypeNode
,
sig
:
MuFuncSigNode
)
:
Unit
=
{
require
(!
funcref
.
isNull
,
"funcref must not be NULL"
)
require
(!
sig
.
isNull
,
"sig must not be NULL"
)
irBuilder
.
setTypeFuncRef
(
funcref
,
sig
)
}
def
newFuncSig
(
b
:
MuBundleNode
,
paramTys
:
Seq
[
MuTypeNode
],
retTys
:
Seq
[
MuTypeNode
])
:
MuFuncSigNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
for
((
n
,
i
)
<-
paramTys
.
zipWithIndex
)
require
(!
n
.
isNull
,
"paramTys[%d] must not be NULL"
.
format
(
i
))
...
...
@@ -130,12 +237,37 @@ trait MuCtxIRBuilderPart {
addHandle
(
irBuilder
.
newFuncSig
(
b
,
paramTys
,
retTys
))
}
def
newConstInt
(
b
:
MuBundleNode
,
ty
:
MuTypeNode
,
value
:
BigInt
)
:
MuConstNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
addHandle
(
irBuilder
.
newConstInt
(
b
,
ty
,
value
))
}
def
newConstFloat
(
b
:
MuBundleNode
,
ty
:
MuTypeNode
,
value
:
Float
)
:
MuConstNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
addHandle
(
irBuilder
.
newConstFloat
(
b
,
ty
,
value
))
}
def
newConstDouble
(
b
:
MuBundleNode
,
ty
:
MuTypeNode
,
value
:
Double
)
:
MuConstNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
addHandle
(
irBuilder
.
newConstDouble
(
b
,
ty
,
value
))
}
def
newConstNull
(
b
:
MuBundleNode
,
ty
:
MuTypeNode
)
:
MuConstNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
addHandle
(
irBuilder
.
newConstNull
(
b
,
ty
))
}
def
newConstSeq
(
b
:
MuBundleNode
,
ty
:
MuTypeNode
,
elems
:
Seq
[
MuConstNode
])
:
MuConstNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
for
((
n
,
i
)
<-
elems
.
zipWithIndex
)
require
(!
n
.
isNull
,
"elems[%d] must not be NULL"
.
format
(
i
))
addHandle
(
irBuilder
.
newConstSeq
(
b
,
ty
,
elems
))
}
def
newGlobalCell
(
b
:
MuBundleNode
,
ty
:
MuTypeNode
)
:
MuGlobalNode
=
{
require
(!
b
.
isNull
,
"b must not be NULL"
)
require
(!
ty
.
isNull
,
"ty must not be NULL"
)
...
...
@@ -487,5 +619,7 @@ trait MuCtxIRBuilderPart {
addHandle
(
irBuilder
.
newCommInst
(
bb
,
opcode
,
flags
,
tys
,
sigs
,
args
))
}
// END: auto-generated code
}
\ No newline at end of file
src/test/scala/uvm/refimpl/MuCtxIRBuilderTest.scala
0 → 100644
View file @
fa663278
package
uvm.refimpl
import
org.scalatest._
import
ch.qos.logback.classic.Level._
import
uvm._
import
uvm.refimpl._
import
uvm.refimpl.RichMuCtx._
import
uvm.refimpl.itpr._
import
uvm.refimpl.mem._
import
uvm.ssavariables._
import
uvm.ssavariables.AtomicRMWOptr._
import
uvm.ssavariables.MemoryOrder._
import
uvm.types._
import
uvm.ir.textinput.ExtraMatchers
class
MuCtxIRBuilderTest
extends
UvmBundleTesterBase
with
ExtraMatchers
{
setLogLevels
(
ROOT_LOGGER_NAME
->
INFO
,
"uvm"
->
INFO
)
override
def
makeMicroVM
()
=
new
MicroVM
(
new
VMConf
())
behavior
of
"The IR Builder of MuCtx"
it
should
"create an empty bundle"
in
{
val
ctx
=
microVM
.
newContext
()
val
b
=
ctx
.
newBundle
()
ctx
.
loadBundleFromNode
(
b
)
ctx
.
closeContext
()
}
it
should
"create a bundle that contains types and sigs"
in
{
val
ctx
=
microVM
.
newContext
()
val
b
=
ctx
.
newBundle
()
val
hi1
=
ctx
.
newTypeInt
(
b
,
1
)
val
hi8
=
ctx
.
newTypeInt
(
b
,
8
)
val
hi8_id
=
ctx
.
getID
(
b
,
hi8
)
val
hi16
=
ctx
.
newTypeInt
(
b
,
16
)
val
hi16_id
=
ctx
.
getID
(
b
,
hi16
)
val
hi32
=
ctx
.
newTypeInt
(
b
,
32
)
val
hi32_id
=
ctx
.
getID
(
b
,
hi32
)
val
hi64
=
ctx
.
newTypeInt
(
b
,
64
)
val
hi64_id
=
ctx
.
getID
(
b
,
hi64
)
ctx
.
setName
(
b
,
hi64
,
"@i64"
)
val
hf
=
ctx
.
newTypeFloat
(
b
)
val
hd
=
ctx
.
newTypeDouble
(
b
)
val
hs
=
ctx
.
newTypeStruct
(
b
,
Seq
(
hi8
,
hi16
,
hi32
,
hi64
))
val
hh
=
ctx
.
newTypeHybrid
(
b
,
Seq
(
hf
,
hd
),
hi8
)
val
ha
=
ctx
.
newTypeArray
(
b
,
hi8
,
100
)
val
hv
=
ctx
.
newTypeVector
(
b
,
hf
,
4
)
val
hsig
=
ctx
.
newFuncSig
(
b
,
Seq
(
hi8
,
hi16
),
Seq
(
hi32
))
val
hsig_id
=
ctx
.
getID
(
b
,
hsig
)
val
htr64
=
ctx
.
newTypeTagRef64
(
b
)
val
hsr
=
ctx
.
newTypeStackRef
(
b
)
val
htr
=
ctx
.
newTypeThreadRef
(
b
)
val
hfcr
=
ctx
.
newTypeFrameCursorRef
(
b
)
val
hinr
=
ctx
.
newTypeIRNodeRef
(
b
)
val
hp
=
ctx
.
newTypeUPtr
(
b
)
val
hfp
=
ctx
.
newTypeUFuncPtr
(
b
)
val
hr
=
ctx
.
newTypeRef
(
b
)
val
hir
=
ctx
.
newTypeIRef
(
b
)
val
hwr
=
ctx
.
newTypeWeakRef
(
b
)
val
hfr
=
ctx
.
newTypeFuncRef
(
b
)
ctx
.
setTypeUPtr
(
hp
,
hi64
)
ctx
.
setTypeUFuncPtr
(
hfp
,
hsig
)
ctx
.
setTypeRef
(
hr
,
hi64
)
ctx
.
setTypeIRef
(
hir
,
hi64
)
ctx
.
setTypeWeakRef
(
hwr
,
hi64
)
ctx
.
setTypeFuncRef
(
hfr
,
hsig
)
val
hr1
=
ctx
.
newTypeRef
(
b
)
val
hs1
=
ctx
.
newTypeStruct
(
b
,
Seq
(
hi64
,
hr1
))
ctx
.
setTypeRef
(
hr1
,
hs1
)
val
hr1_id
=
ctx
.
getID
(
b
,
hr1
)
val
hs1_id
=
ctx
.
getID
(
b
,
hs1
)
ctx
.
loadBundleFromNode
(
b
)
val
gb
=
microVM
.
globalBundle
gb
.
typeNs
(
hi64_id
)
shouldBeA
[
TypeInt
]
{
its
=>
its
.
length
shouldBe
64
}
gb
.
typeNs
(
"@i64"
)
shouldBe
gb
.
typeNs
(
hi64_id
)
gb
.
typeNs
(
hr1_id
)
shouldBeA
[
TypeRef
]
{
its
=>
its
.
ty
shouldBe
gb
.
typeNs
(
hs1_id
)
}
gb
.
typeNs
(
hs1_id
)
shouldBeA
[
TypeStruct
]
{
its
=>
its
.
fieldTys
shouldBe
Seq
(
gb
.
typeNs
(
hi64_id
),
gb
.
typeNs
(
hr1_id
))
}
gb
.
funcSigNs
(
hsig_id
)
shouldBeA
[
FuncSig
]
{
its
=>
its
.
paramTys
shouldBe
Seq
(
gb
.
typeNs
(
hi8_id
),
gb
.
typeNs
(
hi16_id
))
its
.
retTys
shouldBe
Seq
(
gb
.
typeNs
(
hi32_id
))
}
ctx
.
closeContext
()
}
it
should
"create a bundle with constants and global cells"
in
{
val
ctx
=
microVM
.
newContext
()
val
b
=
ctx
.
newBundle
()
val
hi64
=
ctx
.
newTypeInt
(
b
,
64
)
val
hf
=
ctx
.
newTypeFloat
(
b
)
val
hd
=
ctx
.
newTypeDouble
(
b
)
val
hs
=
ctx
.
newTypeStruct
(
b
,
Seq
(
hi64
,
hi64
))
val
hr
=
ctx
.
newTypeRef
(
b
)
ctx
.
setTypeRef
(
hr
,
hi64
)
val
hc1
=
ctx
.
newConstInt
(
b
,
hi64
,
0x123456789abcdef0
L
)
val
hc2
=
ctx
.
newConstInt
(
b
,
hi64
,
0xfedcba9876543210
L
)
val
hc3
=
ctx
.
newConstSeq
(
b
,
hs
,
Seq
(
hc1
,
hc2
))
val
hc4
=
ctx
.
newConstFloat
(
b
,
hf
,
3.14F
)
val
hc5
=
ctx
.
newConstDouble
(
b
,
hd
,
3.14
)
val
hc6
=
ctx
.
newConstNull
(
b
,
hr
)
val
hc1_id
=
ctx
.
getID
(
b
,
hc1
)
val
hc2_id
=
ctx
.
getID
(
b
,
hc2
)
val
hc3_id
=
ctx
.
getID
(
b
,
hc3
)
val
hc4_id
=
ctx
.
getID
(
b
,
hc4
)
val
hc5_id
=
ctx
.
getID
(
b
,
hc5
)
val
hc6_id
=
ctx
.
getID
(
b
,
hc6
)
val
hg
=
ctx
.
newGlobalCell
(
b
,
hi64
)
val
hg_id
=
ctx
.
getID
(
b
,
hg
)
ctx
.
loadBundleFromNode
(
b
)
val
gb
=
microVM
.
globalBundle
gb
.
constantNs
(
hc1_id
)
shouldBeA
[
ConstInt
]
{
its
=>
its
.
num
shouldBe
0x123456789abcdef0
L
}
gb
.
constantNs
(
hc2_id
)
shouldBeA
[
ConstInt
]
{
its
=>
its
.
num
shouldBe
0xfedcba9876543210
L
}
gb
.
constantNs
(
hc3_id
)
shouldBeA
[
ConstSeq
]
{
its
=>
its
.
elems
.
map
(
_
.
asInstanceOf
[
ConstInt
].
num
)
shouldBe
Seq
(
0x123456789abcdef0
L
,
0xfedcba9876543210
L
)
}
gb
.
constantNs
(
hc4_id
)
shouldBeA
[
ConstFloat
]
{
its
=>
its
.
num
shouldBe
3.14f
}
gb
.
constantNs
(
hc5_id
)
shouldBeA
[
ConstDouble
]
{
its
=>
its
.
num
shouldBe
3.14
}
gb
.
constantNs
(
hc6_id
)
shouldBeA
[
ConstNull
]
thatsIt
gb
.
globalCellNs
(
hg_id
)
shouldBeA
[
GlobalCell
]
{
its
=>
its
.
cellTy
shouldBeA
[
TypeInt
]
{
itss
=>
itss
.
length
shouldBe
64
}}
val
hc1v
=
ctx
.
handleFromConst
(
hc1_id
).
asInstanceOf
[
MuIntValue
]
val
hc1vv
=
ctx
.
handleToSInt
(
hc1v
)
hc1vv
shouldBe
0x123456789abcdef0
L
val
hirg
=
ctx
.
handleFromGlobal
(
hg_id
)
val
hirg_v0
=
ctx
.
load
(
NOT_ATOMIC
,
hirg
).
asInstanceOf
[
MuIntValue
]
val
hirg_v0v
=
ctx
.
handleToSInt
(
hirg_v0
)
hirg_v0v
shouldBe
0
ctx
.
store
(
NOT_ATOMIC
,
hirg
,
hc1v
)
val
hirg_v1
=
ctx
.
load
(
NOT_ATOMIC
,
hirg
).
asInstanceOf
[
MuIntValue
]
val
hirg_v1v
=
ctx
.
handleToSInt
(
hirg_v1
)
hirg_v1v
shouldBe
0x123456789abcdef0
L
ctx
.
closeContext
()
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment