Expr interpolate
Console program51 lines of .st131 lines of generated C
9 8 true
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" "twice" {
returns = Int
params = [{ name = "x", type = Int }]
body = [ability.return.R]
}
ability "return" "R" {
value = x * 2
}
ability "set" "P" {
target = ability.value.p
value = address_of(ability.value.n)
}
ability "print" "Show" {
message = "${twice(data.value.n.current) + 1} ${value_at(data.value.p.current) * twice(1)} ${data.value.p.current == address_of(ability.value.n)}"
depends_on = [ability.set.P]
}vars.st
ability "value" "n" {
type = Int
initial = 4
}
data "value" "n" {
of = ability.value.n
}
ability "value" "p" {
type = Pointer
to = Int
}
data "value" "p" {
of = ability.value.p
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.function.twice
+ ability.return.R
+ ability.set.P
+ ability.print.Show
+ ability.value.n
+ ability.value.p
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 expr-interpolate # a folder holding the .st files above
structop init
structop plan
structop apply