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