Skip to content

Instantly share code, notes, and snippets.

@AchalaSB
Created December 21, 2019 16:13
Show Gist options
  • Select an option

  • Save AchalaSB/e80c94cd85b9121360d276b61268db5c to your computer and use it in GitHub Desktop.

Select an option

Save AchalaSB/e80c94cd85b9121360d276b61268db5c to your computer and use it in GitHub Desktop.
{
"items": [
{
"fn": {
"attrs": [
{
"style": "outer",
"path": {
"segments": [
{
"ident": "no_mangle"
}
]
}
}
],
"vis": "pub",
"abi": {},
"ident": "sum",
"inputs": [
{
"typed": {
"pat": {
"ident": {
"ident": "x"
}
},
"ty": {
"path": {
"segments": [
{
"ident": "u64"
}
]
}
}
}
},
{
"typed": {
"pat": {
"ident": {
"ident": "y"
}
},
"ty": {
"path": {
"segments": [
{
"ident": "u64"
}
]
}
}
}
}
],
"output": {
"path": {
"segments": [
{
"ident": "u64"
}
]
}
},
"stmts": [
{
"expr": {
"binary": {
"left": {
"path": {
"segments": [
{
"ident": "x"
}
]
}
},
"op": "%",
"right": {
"path": {
"segments": [
{
"ident": "y"
}
]
}
}
}
}
}
]
}
},
{
"fn": {
"attrs": [
{
"style": "outer",
"path": {
"segments": [
{
"ident": "no_mangle"
}
]
}
}
],
"vis": "pub",
"abi": {},
"ident": "sum1",
"inputs": [
{
"typed": {
"pat": {
"ident": {
"ident": "x"
}
},
"ty": {
"path": {
"segments": [
{
"ident": "f64"
}
]
}
}
}
},
{
"typed": {
"pat": {
"ident": {
"ident": "y"
}
},
"ty": {
"path": {
"segments": [
{
"ident": "f64"
}
]
}
}
}
}
],
"output": {
"tuple": {
"elems": [
{
"path": {
"segments": [
{
"ident": "f64"
}
]
}
},
{
"path": {
"segments": [
{
"ident": "f64"
}
]
}
},
{
"path": {
"segments": [
{
"ident": "f64"
}
]
}
}
]
}
},
"stmts": [
{
"expr": {
"tuple": {
"elems": [
{
"path": {
"segments": [
{
"ident": "x"
}
]
}
},
{
"path": {
"segments": [
{
"ident": "y"
}
]
}
},
{
"binary": {
"left": {
"binary": {
"left": {
"path": {
"segments": [
{
"ident": "x"
}
]
}
},
"op": "+",
"right": {
"path": {
"segments": [
{
"ident": "y"
}
]
}
}
}
},
"op": "+",
"right": {
"path": {
"segments": [
{
"ident": "x"
}
]
}
}
}
}
]
}
}
}
]
}
},
{
"fn": {
"ident": "main",
"inputs": [],
"output": null,
"stmts": []
}
}
]
}
// generated using https://mholt.github.io/json-to-go/
type AutoGenerated struct {
Items []struct {
Fn struct {
Attrs []struct {
Style string `json:"style"`
Path struct {
Segments []struct {
Ident string `json:"ident"`
} `json:"segments"`
} `json:"path"`
} `json:"attrs"`
Vis string `json:"vis"`
Abi struct {
} `json:"abi"`
Ident string `json:"ident"`
Inputs []struct {
Typed struct {
Pat struct {
Ident struct {
Ident string `json:"ident"`
} `json:"ident"`
} `json:"pat"`
Ty struct {
Path struct {
Segments []struct {
Ident string `json:"ident"`
} `json:"segments"`
} `json:"path"`
} `json:"ty"`
} `json:"typed"`
} `json:"inputs"`
Output struct {
Path struct {
Segments []struct {
Ident string `json:"ident"`
} `json:"segments"`
} `json:"path"`
} `json:"output"`
Stmts []struct {
Expr struct {
Binary struct {
Left struct {
Path struct {
Segments []struct {
Ident string `json:"ident"`
} `json:"segments"`
} `json:"path"`
} `json:"left"`
Op string `json:"op"`
Right struct {
Path struct {
Segments []struct {
Ident string `json:"ident"`
} `json:"segments"`
} `json:"path"`
} `json:"right"`
} `json:"binary"`
} `json:"expr"`
} `json:"stmts"`
} `json:"fn,omitempty"`
Fn struct {
Ident string `json:"ident"`
Inputs []interface{} `json:"inputs"`
Output interface{} `json:"output"`
Stmts []interface{} `json:"stmts"`
} `json:"fn,omitempty"`
} `json:"items"`
}
#[no_mangle]
pub extern fn sum(x:u64, y:u64) -> u64 {
x % y
}
#[no_mangle]
pub extern fn sum1(x:f64, y:f64) -> (f64,f64,f64) {
(x, y, x + y + x)
}
fn main(){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment