• 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.record Exception {
15}
16
17.record object_array_elem {
18	i32 value
19}
20
21.record object {
22	i32 value
23	object_array_elem[] array
24}
25
26.function void object_array_elem.ctor(object_array_elem a0, i32 a1) <ctor> {
27    lda a1
28    stobj a0, object_array_elem.value
29    return.void
30}
31
32.function void object.ctor(object a0, i32 a1) <ctor> {
33	movi v0, 0x0
34    lda a1
35    stobj a0, object.value
36	addi 0x1
37	sta v1
38	newarr v2, v1, object_array_elem[]
39jump_label_1:
40	lda v0
41	jge v1, jump_label_0
42	add v0, a1
43	sta v4
44	initobj.short object_array_elem.ctor, v4
45	starr.obj v2, v0
46	inci v0, 0x1
47	jmp jump_label_1
48jump_label_0:
49	stobj.v.obj v2, a0, object.array
50	return.void
51}
52
53.function i32 main() {
54	movi v0, 0x0
55	movi v1, 0x3e8
56	newarr v2, v1, object[]
57	mov v3, v0
58jump_label_1:
59	lda v3
60	jge v1, jump_label_0
61	initobj.short object.ctor, v3
62	starr.obj v2, v3
63	inci v3, 0x1
64	jmp jump_label_1
65jump_label_0:
66	lda v0
67	jge v1, jump_label_2
68	lda v0
69	ldarr.obj v2
70	sta.obj v3
71	ldobj.v.obj v3, v3, object.array
72	lda v0
73	ldarr.obj v3
74	sta.obj v3
75	ldobj.v v3, v3, object_array_elem.value
76	lda v0
77	shli 0x1
78	jeq v3, jump_label_3
79	ldai 1
80	return
81jump_label_3:
82	inci v0, 0x1
83	jmp jump_label_0
84jump_label_2:
85    ldai 0
86	return
87}
88