mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-05 20:50:43 +00:00
281b683e14
standard, implemented in Ruamoko. Currently works for a few simple "Hello, world!" programs.
74 lines
1.1 KiB
R
74 lines
1.1 KiB
R
#include "Symbol.h"
|
|
#include "hash.h"
|
|
#include "defs.h"
|
|
|
|
string SymbolGetKey (void [] ele, void [] data)
|
|
{
|
|
local Symbol s = (Symbol) ele;
|
|
|
|
return [s stringValue];
|
|
}
|
|
|
|
void SymbolFree (void [] ele, void [] data)
|
|
{
|
|
local Symbol s = (Symbol) ele;
|
|
|
|
[s release];
|
|
}
|
|
|
|
hashtab_t symbols;
|
|
Symbol lparen;
|
|
Symbol rparen;
|
|
Symbol quote;
|
|
|
|
@implementation Symbol
|
|
+ (void) initialize
|
|
{
|
|
symbols = Hash_NewTable (1024, SymbolGetKey, SymbolFree, NIL);
|
|
lparen = [Symbol forString: "("];
|
|
rparen = [Symbol forString: ")"];
|
|
quote = [Symbol forString: "'"];
|
|
|
|
}
|
|
|
|
+ (Symbol) forString: (string) s
|
|
{
|
|
return (Symbol) [self newFromString: s];
|
|
}
|
|
|
|
+ (Symbol) leftParen
|
|
{
|
|
return lparen;
|
|
}
|
|
|
|
+ (Symbol) rightParen
|
|
{
|
|
return rparen;
|
|
}
|
|
|
|
+ (Symbol) quote
|
|
{
|
|
return quote;
|
|
}
|
|
|
|
- (id) initWithString: (string) s
|
|
{
|
|
local Symbol res;
|
|
[super initWithString: s];
|
|
|
|
if ((res = Hash_Find (symbols, s))) {
|
|
[self release];
|
|
return res;
|
|
} else {
|
|
Hash_Add (symbols, self);
|
|
return self;
|
|
}
|
|
}
|
|
|
|
- (string) printForm
|
|
{
|
|
return [self stringValue];
|
|
}
|
|
|
|
|
|
@end
|