aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2017-10-29 16:44:44 +0000
committergingerBill <bill@gingerbill.org>2017-10-29 16:44:44 +0000
commitd2588f9d1da112b48f4a3f224b643bdd8f47f429 (patch)
tree792e7ab26b3e2abc0a7803ff867cbc6010774cb9 /src/parser.cpp
parent1eb9994d88b874b2f4ac3fdc4d314b1e67fa511b (diff)
Infix proc calling convention `proc "std" (...)`
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index c2a4dc4e4..422612c4d 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2098,6 +2098,7 @@ void parse_proc_tags(AstFile *f, u64 *tags, ProcCallingConvention *calling_conve
GB_ASSERT(tags != nullptr);
ProcCallingConvention cc = ProcCC_Invalid;
+ if (calling_convention) cc = *calling_convention;
while (f->curr_token.kind == Token_Hash) {
AstNode *tag_expr = parse_tag_expr(f, nullptr);
@@ -3299,13 +3300,40 @@ AstNode *parse_proc_type(AstFile *f, Token proc_token) {
AstNode *params = nullptr;
AstNode *results = nullptr;
+ ProcCallingConvention cc = ProcCC_Invalid;
+ if (f->curr_token.kind == Token_String) {
+ Token token = expect_token(f, Token_String);
+ String conv = token.string;
+ if (conv == "odin") {
+ cc = ProcCC_Odin;
+ } else if (conv == "contextless") {
+ cc = ProcCC_Contextless;
+ } else if (conv == "cdecl" || conv == "c") {
+ cc = ProcCC_C;
+ } else if (conv == "stdcall" || conv == "std") {
+ cc = ProcCC_Std;
+ } else if (conv == "fastcall" || conv == "fast") {
+ cc = ProcCC_Fast;
+ } else {
+ syntax_error(token, "Unknown procedure tag #%.*s\n", LIT(conv));
+ }
+
+ if (cc == ProcCC_Invalid) {
+ if (f->in_foreign_block) {
+ cc = ProcCC_C;
+ } else {
+ cc = ProcCC_Odin;
+ }
+ }
+ }
+
+
expect_token(f, Token_OpenParen);
params = parse_field_list(f, nullptr, FieldFlag_Signature, Token_CloseParen, true, true);
expect_token_after(f, Token_CloseParen, "parameter list");
results = parse_results(f);
u64 tags = 0;
- ProcCallingConvention cc = ProcCC_Invalid;
parse_proc_tags(f, &tags, &cc);
bool is_generic = false;