51 lines
1.1 KiB
Plaintext

module: Main
import: os
struct: Address
fields:
declare country: int
declare city: int
init:
params:
country: int
city: int
body:
this.country = country
this.city = city
end body
end init
end struct
struct: Person
fields:
declare name: int
declare addr: Address
init:
params:
name: int
addr: Address
body:
this.name = name
this.addr = addr
end body
end init
function: getName
returns: int
body:
return this.name
end body
end function
end struct
function: main
returns: void
body:
// 初始化 Person 和 Address 的实例
declare p: Person = new Person(123, new Address(1, 2))
os.print(p.getName) // 打印 name
end body
end function
end module