-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModuleScope.zu
75 lines (63 loc) · 1.75 KB
/
ModuleScope.zu
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# The Zimbu compiler written in Zimbu
#
# ModuleScope class.
#
# A Scope used for the toplevel of a module.
#
# Copyright 2011 Bram Moolenaar All Rights Reserved.
# Licensed under the Apache License, Version 2.0. See the LICENSE file or
# obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0
#
IMPORT "Builtin.zu"
IMPORT "SContext.zu"
IMPORT "Scope.zu"
CLASS ModuleScope EXTENDS Scope @items=public
bool $builtin # TRUE for module in lib/
# Return TRUE when at the toplevel class scope, not in SHARED section inside
# a class or in a method.
FUNC $isTopClassScope() bool @define
RETURN FALSE
}
# Can symbols be used before defined?
FUNC $isForwardDeclare() bool @define
RETURN TRUE
}
# Are variables initialized when declared?
# FALSE when a method does the initialization.
FUNC $isInitVar() bool @define
RETURN TRUE
}
# Can there be statements in this Scope?
FUNC $hasStatements() bool @define
RETURN FALSE
}
PROC $initPass(Scope outer)
$fillFromOuter(outer)
# Don't copy the return symbol from the outer scope.
$returnType = NIL
}
# Set the $needPass flag in this scope and outer scopes.
PROC $setNeedPass(SContext ctx) @replace
$needPass = TRUE
IF $outer != NIL
$outer.setNeedPass(ctx)
}
# If at the scope of a builtin module, make sure it appears in the list of
# builtin modules for the current topscope. It may have been in another
# topscope only.
IF $builtin
Builtin.useModule($name, ctx)
}
}
# Return TRUE if this scope or an outer scope is a builtin module scope.
FUNC $insideBuiltin() bool @replace
IF $builtin
RETURN TRUE
}
IF $outer != NIL
RETURN $outer.insideBuiltin()
}
RETURN FALSE
}
}