CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
61 lines
2.5 KiB
Plaintext
61 lines
2.5 KiB
Plaintext
# RUN: toyc-ch7 %s -emit=ast 2>&1 | FileCheck %s
|
|
|
|
struct Struct {
|
|
var a;
|
|
var b;
|
|
}
|
|
|
|
# User defined generic function may operate on struct types as well.
|
|
def multiply_transpose(Struct value) {
|
|
# We can access the elements of a struct via the '.' operator.
|
|
return transpose(value.a) * transpose(value.b);
|
|
}
|
|
|
|
def main() {
|
|
# We initialize struct values using a composite initializer.
|
|
Struct value = {[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]};
|
|
|
|
# We pass these arguments to functions like we do with variables.
|
|
var c = multiply_transpose(value);
|
|
print(c);
|
|
}
|
|
|
|
# CHECK: Module:
|
|
# CHECK-NEXT: Struct: Struct @{{.*}}struct-ast.toy:3:1
|
|
# CHECK-NEXT: Variables: [
|
|
# CHECK-NEXT: VarDecl a<> @{{.*}}struct-ast.toy:4:3
|
|
# CHECK-NEXT: VarDecl b<> @{{.*}}struct-ast.toy:5:3
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT:Function
|
|
# CHECK-NEXT: Proto 'multiply_transpose' @{{.*}}struct-ast.toy:9:1
|
|
# CHECK-NEXT: Params: [value]
|
|
# CHECK-NEXT: Block {
|
|
# CHECK-NEXT: Return
|
|
# CHECK-NEXT: BinOp: * @{{.*}}struct-ast.toy:11:31
|
|
# CHECK-NEXT: Call 'transpose' [ @{{.*}}struct-ast.toy:11:10
|
|
# CHECK-NEXT: BinOp: . @{{.*}}struct-ast.toy:11:26
|
|
# CHECK-NEXT: var: value @{{.*}}struct-ast.toy:11:20
|
|
# CHECK-NEXT: var: a @{{.*}}struct-ast.toy:11:26
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: Call 'transpose' [ @{{.*}}struct-ast.toy:11:31
|
|
# CHECK-NEXT: BinOp: . @{{.*}}struct-ast.toy:11:47
|
|
# CHECK-NEXT: var: value @{{.*}}struct-ast.toy:11:41
|
|
# CHECK-NEXT: var: b @{{.*}}struct-ast.toy:11:47
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT:Function
|
|
# CHECK-NEXT: Proto 'main' @{{.*}}struct-ast.toy:14:1
|
|
# CHECK-NEXT: Params: []
|
|
# CHECK-NEXT: Block {
|
|
# CHECK-NEXT: VarDecl value<Struct> @{{.*}}struct-ast.toy:16:3
|
|
# CHECK-NEXT: Struct Literal: Literal: <2, 3>[ <3>[ 1.000000e+00, 2.000000e+00, 3.000000e+00], <3>[ 4.000000e+00, 5.000000e+00, 6.000000e+00]] @{{.*}}struct-ast.toy:16:19
|
|
# CHECK-NEXT: Literal: <2, 3>[ <3>[ 1.000000e+00, 2.000000e+00, 3.000000e+00], <3>[ 4.000000e+00, 5.000000e+00, 6.000000e+00]] @{{.*}}struct-ast.toy:16:43
|
|
# CHECK-NEXT: @{{.*}}struct-ast.toy:16:18
|
|
# CHECK-NEXT: VarDecl c<> @{{.*}}struct-ast.toy:19:3
|
|
# CHECK-NEXT: Call 'multiply_transpose' [ @{{.*}}struct-ast.toy:19:11
|
|
# CHECK-NEXT: var: value @{{.*}}struct-ast.toy:19:30
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: Print [ @{{.*}}struct-ast.toy:20:3
|
|
# CHECK-NEXT: var: c @{{.*}}struct-ast.toy:20:9
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: } |