forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSSymbolTable.h
127 lines (83 loc) · 3.65 KB
/
FSSymbolTable.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* FSSymbolTable.h Copyright (c) 1998-2008 Philippe Mougin. */
/* This software is open source. See the license. */
#import <Foundation/Foundation.h>
@class FSArray;
enum FSContext_symbol_status {DEFINED, UNDEFINED};
@interface SymbolTableValueWrapper : NSObject <NSCopying , NSCoding>
{
@public
enum FSContext_symbol_status status;
id value;
NSString *symbol;
NSUInteger retainCount;
}
- (id)copy;
- (id)copyWithZone:(NSZone *)zone;
- (void)encodeWithCoder:(NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
- (id)initWrapperWithValue:(id)theValue symbol:(NSString *)theSymbol;
- (id)initWrapperWithValue:(id)theValue symbol:(NSString *)theSymbol status:(enum FSContext_symbol_status)theStatus;
// symbol is not copied.
- (void)setValue:(id)theValue;
- (enum FSContext_symbol_status)status;
- (NSString *)symbol;
- (id)value;
@end
struct FSContextIndex
{
int index;
int level;
};
struct FSContextValueWrapper
{
enum FSContext_symbol_status status;
id value;
NSString *symbol;
};
@interface FSSymbolTable : NSObject <NSCopying , NSCoding>
{
@package
__strong struct FSContextValueWrapper *locals;
NSUInteger localCount;
BOOL receiverRetained; // When entering a method, the symbol table for this method does not retain the object associated with the "self" symbol
// (i.e., the receiver), as it might not be initialized yet (if we are entering in a init... method). This BOOL will
// be set to NO. The F-Script run-time will then retain the receiver as soon as it determine that it is okay and set this
// boolean to YES in order to remember the job has been done and thus avoid over retaining.
@private
NSUInteger retainCount;
FSSymbolTable *parent;
BOOL tryToAttachWhenDecoding;
}
+ (void)initialize;
+ (id)symbolTable;
- (FSArray *)allDefinedSymbols;
- (BOOL) containsSymbolAtFirstLevel:(NSString *)theKey;
- (id)copy;
- (id)copyWithZone:(NSZone *)zone;
- (void)dealloc;
- (void) didSendDeallocToSymbolAtIndex:(struct FSContextIndex)index;
- (void)encodeWithCoder:(NSCoder *)coder;
- (struct FSContextIndex)findOrInsertSymbol:(NSString*)theKey;
// Find the symbol or insert it in the highest parent possible (or in self if we don't have a parent)
- (struct FSContextIndex)indexOfSymbol:(NSString *)theKey;
// Note : field "index" of the result is set to -1 if symbol is not found
- (id)init;
- (id)initWithParent:(FSSymbolTable *)theParent;
- (id)initWithParent:(FSSymbolTable *)theParent tryToAttachWhenDecoding:(BOOL)shouldTry;
- (id)initWithParent:(FSSymbolTable *)theParent tryToAttachWhenDecoding:(BOOL)shouldTry locals:(struct FSContextValueWrapper *)theLocals localCount:(NSUInteger)theLocalCount;
- (id)initWithCoder:(NSCoder *)coder;
- (struct FSContextIndex)insertSymbol:(NSString*)theKey object:(id)theObject;
- (struct FSContextIndex)insertSymbol:(NSString*)theKey object:(id)theObject status:(enum FSContext_symbol_status)theStatus; // theKey is not copied
- (BOOL) isEmpty;
- (id)objectForIndex:(struct FSContextIndex)index isDefined:(BOOL *)isDefined;
- (id)objectForSymbol:(NSString *)symbol found:(BOOL *)found; // foud may be passed as NULL
- (FSSymbolTable *) parent;
- (void)removeAllObjects;
- (void)setObject:(id)object forSymbol:(NSString *)symbol;
- (void)setParent:(FSSymbolTable *)theParent;
- (void)setToNilSymbolsFrom:(NSUInteger)ind;
- (id)setObject:(id)theValue forIndex:(struct FSContextIndex)theIndex;
- (NSString *)symbolForIndex:(struct FSContextIndex)index;
- (void) undefineSymbolAtIndex:(struct FSContextIndex)index;
- (void) willSendReleaseToSymbolAtIndex:(struct FSContextIndex)index;
@end