Float both targets
Console program96 lines of .st166 lines of generated Cbuilds as C and Rust
16777216.000000 0.000000 16777216.000000 inf -inf false 16777216.000000 16777216.000000 0.000000 16777216.000000 true true true 52707136.000000 3.141590 false 35929920.000000 arg 52707136.000000 52707136.000000 kept 52707136.000000 false
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
}
}main.st
variable "a" {
type = Float
default = 16777216.0
}
variable "big" {
type = Float
default = 300000000000000000000000000000000000000.0
}
variable "n" {
type = Int
default = 16777217
}
variable "tenth" {
type = Float
default = 0.1
}
ability "print" "Edge" {
message = "${var.a + 1.0} ${var.a + 1.0 - var.a} ${var.a + 1}"
}
ability "print" "Overflow" {
message = "${var.big * 10.0} ${0.0 - var.big * 10.0} ${var.big * 10.0 - var.big * 10.0 == var.big * 10.0 - var.big * 10.0}"
depends_on = [ability.print.Edge]
}
ability "print" "Mixed" {
message = "${var.n + 0.0} ${var.n * 1.0} ${var.n - var.a} ${var.a / 3.0 * 3.0}"
depends_on = [ability.print.Overflow]
}
ability "print" "Compare" {
message = "${var.tenth == 0.1} ${var.tenth + 0.2 == 0.3} ${var.tenth * 3.0 == 0.3}"
depends_on = [ability.print.Mixed]
}
ability "define" "PI" {
value = 3.14159
}
ability "print" "Define" {
message = "${const.PI * var.a} ${const.PI} ${const.PI * var.a > 52707135.0} ${var.a * const.PI - var.a}"
depends_on = [ability.print.Compare]
}
ability "function" "Show" {
params = [{ name = "x", type = Float }]
body = [ability.print.Echo]
}
ability "print" "Echo" {
message = "arg ${x} ${x + 1.0}"
}
ability "call" "Pass" {
function = ability.function.Show
args = [const.PI * var.a]
depends_on = [ability.print.Define]
}
ability "value" "kept" {
type = Float
initial = 0.0
}
data "value" "kept" {
of = ability.value.kept
}
ability "set" "Keep" {
target = ability.value.kept
value = const.PI * var.a
depends_on = [ability.call.Pass]
}
ability "print" "Kept" {
message = "kept ${data.value.kept.current} ${data.value.kept.current == const.PI * var.a}"
depends_on = [ability.set.Keep]
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.print.Edge
+ ability.print.Overflow
+ ability.print.Mixed
+ ability.print.Compare
+ ability.define.PI
+ ability.print.Define
+ ability.function.Show
+ ability.print.Echo
+ ability.call.Pass
+ ability.value.kept
+ ability.set.Keep
+ ability.print.Kept
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-runGenerated main.rs (the same .st built as Rust)
To inspect this generated file, select Rust in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd float-both-targets # a folder holding the .st files above
structop init
structop plan
structop apply