• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14# Assert that operation initobj works fine
15
16.record R {
17    i32 field1
18    i32 field2
19    i32 field3
20    i32 field4
21}
22
23.function void R.ctor(R a0, i32 a1, i32 a2, i32 a3, i32 a4) <ctor> {
24    lda a1
25    stobj a0, R.field1
26    lda a2
27    stobj a0, R.field2
28    lda a3
29    stobj a0, R.field3
30    lda a4
31    stobj a0, R.field4
32    return.void
33}
34
35.function i32 main() {
36    movi v0, 10
37    movi v1, 20
38    movi v2, 30
39    movi v3, 40
40    initobj R.ctor, v0, v1, v2, v3
41    sta.obj v4
42    ldobj v4, R.field1
43    jne v0, error1
44    ldobj v4, R.field2
45    jne v1, error2
46    ldobj v4, R.field3
47    jne v2, error3
48    ldobj v4, R.field4
49    jne v3, error4
50    ldai 0
51    return
52error1:
53    ldai 1
54    return
55error2:
56    ldai 2
57    return
58error3:
59    ldai 3
60    return
61error4:
62    ldai 4
63    return
64}
65