Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/gravity
Path: blob/master/src/compiler/gravity_semacheck1.h
1214 views
1
//
2
// semacheck1.h
3
// gravity
4
//
5
// Created by Marco Bambini on 08/10/14.
6
// Copyright (c) 2014 CreoLabs. All rights reserved.
7
//
8
9
#ifndef __GRAVITY_SEMACHECK1__
10
#define __GRAVITY_SEMACHECK1__
11
12
// Semantic check step 1 does not have the notion of context and scope.
13
// It just gathers non-local names into a symbol table and check for uniqueness.
14
//
15
// Only declarations (non-locals) are visited and a symbol table is created.
16
//
17
//
18
// In order to debug symbol table just enable the GRAVITY_SYMTABLE_DEBUG macro
19
// in debug_macros.h
20
21
// Semantic Check Step 1 enables to resolve cases like:
22
/*
23
function foo() {
24
return bar();
25
}
26
27
function bar() {
28
...
29
}
30
31
or
32
33
class foo:bar {
34
...
35
}
36
37
class bar {
38
...
39
}
40
41
and
42
43
class foo {
44
var a;
45
46
function bar() {
47
return a + b;
48
}
49
50
var b;
51
}
52
*/
53
54
// It's a mandatory step in order to account for forward references
55
// allowed in any non-local declaration
56
57
#include "gravity_ast.h"
58
#include "gravity_delegate.h"
59
60
bool gravity_semacheck1(gnode_t *node, gravity_delegate_t *delegate);
61
62
#endif
63
64