forked from Lambda-Mountain-Compiler-Backend/lambda-mountain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd-c-compile-function-args.lsts
More file actions
39 lines (38 loc) · 1.5 KB
/
std-c-compile-function-args.lsts
File metadata and controls
39 lines (38 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
let std-c-compile-function-args(ctx: FContext, lhs: AST): S = (
match lhs {
App{ rest=left, right:App{ left:Lit{key:c":"}, right:App{ v-t=left:Var{k1=key}, right:AType{kt=tt} } } } => (
let decl = std-c-mangle-declaration(kt, lhs);
let text = std-c-compile-function-args(ctx, rest);
text = text + SAtom(c",");
if can-unify( type-c-vararg, kt ) {
text = text + SAtom(c"...");
} else if can-unify( type-c-void, kt ) {
text = text + SAtom(c"void");
} else {
text = text + decl.first;
text = text + SAtom(c" ");
let def-bound = std-c-fragment-context.lookup(v-t, mk-fragment());
text = text + def-bound.get(c"expression"); # the uuid
text = text + decl.second;
};
text
);
App{ left:Lit{key:c":"}, right:App{ v-t=left:Var{k2=key}, right:AType{kt=tt} } } => (
let decl = std-c-mangle-declaration(kt, lhs);
let text = SNil();
if can-unify( type-c-vararg, kt ) {
text = text + SAtom(c"...");
} else if can-unify( type-c-void, kt ) {
text = text + SAtom(c"void");
} else {
text = text + decl.first;
text = text + SAtom(c" ");
let def-bound = std-c-fragment-context.lookup(v-t, mk-fragment());
text = text + def-bound.get(c"expression"); # the uuid
text = text + decl.second;
};
text
);
_ => SNil();
}
);