Value local pointer
Console program57 lines of .st133 lines of generated C
1,2,9 1,2,9
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
standard = "c11"
}
}
lib_provider {
C_lang = {
source = "StructOp/c"
version = "@latest"
}
}
}main.st
ability "function" "Work" {
body = [ability.value.Nums, ability.value.Ptr, ability.set.Aim, ability.store.ViaPtr, ability.print.Show]
}
ability "value" "Nums" {
type = Array
of = Int
size = 3
initial = [1, 2, 3]
}
data "value" "Nums" {
of = ability.value.Nums
}
ability "value" "Ptr" {
type = Pointer
to = Int
}
ability "set" "Aim" {
target = ability.value.Ptr
value = address_of(ability.value.Nums[2])
}
ability "store" "ViaPtr" {
pointer = ability.value.Ptr
value = 9
}
ability "print" "Show" {
message = "${data.value.Nums.current[0]},${data.value.Nums.current[1]},${data.value.Nums.current[2]}"
}
ability "call" "Once" {
function = ability.function.Work
}
ability "call" "Twice" {
function = ability.function.Work
depends_on = [ability.call.Once]
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.function.Work
+ ability.value.Nums
+ ability.value.Ptr
+ ability.set.Aim
+ ability.store.ViaPtr
+ ability.print.Show
+ ability.call.Once
+ ability.call.Twice
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.c
To inspect this generated file, select C in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd value-local-pointer # a folder holding the .st files above
structop init
structop plan
structop apply