aboutsummaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-22 12:58:13 -0800
committerMichael Forney <mforney@mforney.org>2019-02-22 12:58:13 -0800
commit4df0c2114cd0afd7aded5e67bd9e9af35b149fab (patch)
tree5820fb19ec0ccf2dc4a212e46114771f944984d9 /scope.c
parenta1a5214bbae2b1b4c988e5f3d1b6415b64a890c6 (diff)
Keep track of built-in kind in declaration
Also, populate filescope with builtins outside of main.
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/scope.c b/scope.c
index 6c1d5fd..bd550e8 100644
--- a/scope.c
+++ b/scope.c
@@ -3,11 +3,34 @@
#include <stdint.h>
#include <string.h>
#include "util.h"
+#include "decl.h"
#include "htab.h"
#include "scope.h"
+#include "type.h"
struct scope filescope;
+void
+scopeinit(void)
+{
+ static struct builtin {
+ char *name;
+ struct declaration decl;
+ } builtins[] = {
+ {"__builtin_va_list", {.kind = DECLTYPE, .type = &typevalist}},
+ {"__builtin_va_start", {.kind = DECLBUILTIN, .builtin = BUILTINVASTART}},
+ {"__builtin_va_copy", {.kind = DECLBUILTIN, .builtin = BUILTINVACOPY}},
+ {"__builtin_va_arg", {.kind = DECLBUILTIN, .builtin = BUILTINVAARG}},
+ {"__builtin_va_end", {.kind = DECLBUILTIN, .builtin = BUILTINVAEND}},
+ {"__builtin_offsetof", {.kind = DECLBUILTIN, .builtin = BUILTINOFFSETOF}},
+ {"__builtin_alloca", {.kind = DECLBUILTIN, .builtin = BUILTINALLOCA}},
+ };
+ struct builtin *b;
+
+ for (b = builtins; b < builtins + LEN(builtins); ++b)
+ scopeputdecl(&filescope, b->name, &b->decl);
+}
+
struct scope *
mkscope(struct scope *parent)
{