Forward decl
Console program49 lines of .st124 lines of generated C
The sum of 5 and 2 is 7
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
}
}main.st
ability "call" "Z" {
function = ability.function.sum
args = [5, var.y]
result = ability.value.z
}
ability "print" "Show" {
message = "The sum of 5 and ${var.y} is ${data.value.z.current}"
depends_on = [ability.call.Z]
}
ability "set" "Res" {
target = res
value = a + b
}
ability "function" "sum" {
returns = Int
params = [{ name = "a", type = Int }, { name = "b", type = Int }]
locals = [{ name = "res", type = Int }]
body = [ability.set.Res]
return = res
}vars.st
variable "y" {
type = Int
default = 2
}
ability "value" "z" {
type = Int
}
data "value" "z" {
of = ability.value.z
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.call.Z
+ ability.print.Show
+ ability.set.Res
+ ability.function.sum
+ ability.value.z
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 c-forward-decl # a folder holding the .st files above
structop init
structop plan
structop apply