From 4df0c2114cd0afd7aded5e67bd9e9af35b149fab Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 22 Feb 2019 12:58:13 -0800 Subject: Keep track of built-in kind in declaration Also, populate filescope with builtins outside of main. --- scope.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'scope.c') diff --git a/scope.c b/scope.c index 6c1d5fd..bd550e8 100644 --- a/scope.c +++ b/scope.c @@ -3,11 +3,34 @@ #include #include #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) { -- cgit v1.2.3