WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit 814ffbbd authored by Kunshan Wang's avatar Kunshan Wang
Browse files

Added the '*LValue' notation to load values.

Useful for initialising reference fields to pre-allocated objects whose
references are held in global cells.
parent 7f3709b2
......@@ -34,6 +34,7 @@ rValue
| 'NULL' # RVNull
| HAIL_NAME # RVHailRef
| '&' lValue # RVIRefOf
| '*' lValue # RVValueOf
| list # RVList
;
......
......@@ -108,6 +108,7 @@ class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, m
logger.debug("Executing init: %s".format(init.getText))
val lv = evalLValue(init.lv)
assign(lv, init.rv)
mc.deleteValue(lv.iref)
}
}
......@@ -297,6 +298,17 @@ class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, m
}
case _ => unexpectedRValueError()
}
} else if (rv.isInstanceOf[RVValueOfContext]) {
val vo = rv.asInstanceOf[RVValueOfContext]
val rir = evalLValue(vo.lValue()).iref
val rval = mc.load(NOT_ATOMIC, rir)
try {
mc.store(NOT_ATOMIC, lir, rval)
} catch {
case e: Exception => throw new UvmHailParsingException(inCtx(rv, "Failed to store to LValue. Actual RValue: %s".format(rval)), e)
}
mc.deleteValue(rir)
mc.deleteValue(rval)
} else {
lty match {
case TypeInt(len) => {
......
......@@ -259,7 +259,7 @@ class UvmHailBasicTest extends UvmHailTesterBase {
it should "recognise the '&' expression to assign internal references" in {
val mc = microVM.newContext()
loadHailFromFile(mc, "tests/uvm-hail-test/basic-hail-test-5.hail")
val hBar = mc.loadGlobal("@g_my_hybrid_r").asInstanceOf[MuRefValue]
......@@ -273,11 +273,11 @@ class UvmHailBasicTest extends UvmHailTesterBase {
assertIREqual("@g_iri64", mc.getFieldIRef(hBarIr, 0))
assertIREqual("@g_irdouble", mc.getFieldIRef(hBarIr, 1))
val hBarIr_vp = mc.getVarPartIRef(hBarIr)
assertIREqual("@g_iri8", hBarIr_vp)
val hBarIr_vp_2 = mc.shiftIRef(hBarIr_vp, mc.handleFromInt(2, 64))
val hBarIr_vp_3 = mc.shiftIRef(hBarIr_vp, mc.handleFromInt(3, 64))
......@@ -286,6 +286,36 @@ class UvmHailBasicTest extends UvmHailTesterBase {
mc.closeContext()
}
it should "recognise the '*' expression to assign existing values" in {
val mc = microVM.newContext()
val hPredef = mc.newFixed("@i64")
val hPredefIr = mc.getIRef(hPredef)
val h9 = mc.handleFromInt(9, 64)
mc.store(NOT_ATOMIC, hPredefIr, h9)
val hslotpredef = mc.handleFromGlobal("@g_slot_predef")
mc.store(NOT_ATOMIC, hslotpredef, hPredef)
loadHailFromFile(mc, "tests/uvm-hail-test/basic-hail-test-6.hail")
val hslot1v = mc.loadGlobal("@g_slot1").asInstanceOf[MuRefValue]
val hslot2v = mc.loadGlobal("@g_slot2").asInstanceOf[MuRefValue]
val hslot3v = mc.loadGlobal("@g_slot3").asInstanceOf[MuRefValue]
mc.refEq(hslot1v, hslot2v)
mc.refEq(hslot3v, hPredef)
val v1 = { val ir = mc.getIRef(hslot1v); val hi = mc.loadInt(NOT_ATOMIC, ir); mc.handleToSInt(hi) }
val v2 = { val ir = mc.getIRef(hslot2v); val hi = mc.loadInt(NOT_ATOMIC, ir); mc.handleToSInt(hi) }
val v3 = { val ir = mc.getIRef(hslot3v); val hi = mc.loadInt(NOT_ATOMIC, ir); mc.handleToSInt(hi) }
v1 shouldBe 42
v2 shouldBe 42
v3 shouldBe 9
mc.closeContext()
}
}
object UvmHailBasicTest {
......
// hail
.new $x <@i64>
.init $x = 42
.init @g_slot1 = $x
.init @g_slot2 = *@g_slot1
.init @g_slot3 = *@g_slot_predef
......@@ -80,3 +80,10 @@
.global @g_irvoid <@irefvoid>
.global @g_irvoid2 <@irefvoid>
// test-6
.global @g_slot_predef <@refi64>
.global @g_slot1 <@refi64>
.global @g_slot2 <@refi64>
.global @g_slot3 <@refi64>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment