Skip to content
Browse files

Fixed last known problem (ST4 now passes TestCompiler, TestCoreBasics…

…, TestDictionaries, TestFunction, TestGroups, TestLexer, TestLists, TestSubtemplates, and TestWhitespace.).

Obviously there are more tests to implement and most likely more bugs to uncover.
  • Loading branch information...
1 parent 72c34ca commit d24cf7188d1f97072fafadd8f7053c15bd730c36 Alan Condit committed
Showing with 21 additions and 22 deletions.
  1. +1 −0 objc/main/Interpreter.h
  2. +15 −17 objc/main/Interpreter.m
  3. +4 −4 objc/main/ST.m
  4. +1 −1 objc/main/tests/objc/BaseTest.m
View
1 objc/main/Interpreter.h
@@ -165,6 +165,7 @@ NSString *OptionDescription(OptionEnum value);
+ (void) initialize;
+ (id) newInterpreter:(STGroup *)aGroup locale:(NSLocale *)aLocale debug:(BOOL)aDebug;
++ (id) newInterpreter:(STGroup *)aGroup locale:(NSLocale *)aLocale errMgr:(ErrorManager *)anErrMgr debug:(BOOL)aDebug;
- (id) initWithGroup:(STGroup *)group debug:(BOOL)aDebug;
- (id) init:(STGroup *)group locale:(NSLocale *)locale debug:(BOOL)aDebug;
View
32 objc/main/Interpreter.m
@@ -390,6 +390,11 @@ + (id) newInterpreter:(STGroup *)aGroup locale:(NSLocale *)aLocale debug:(BOOL)a
return [[Interpreter alloc] init:aGroup locale:aLocale debug:aDebug];
}
++ (id) newInterpreter:(STGroup *)aGroup locale:(NSLocale *)aLocale errMgr:(ErrorManager *)anErrMgr debug:(BOOL)aDebug
+{
+ return [[Interpreter alloc] init:aGroup locale:aLocale errMgr:anErrMgr debug:aDebug];
+}
+
- (id) initWithGroup:(STGroup *)aGroup debug:(BOOL)aDebug
{
self = [self init:aGroup locale:[NSLocale currentLocale] errMgr:aGroup.errMgr debug:aDebug];
@@ -1172,8 +1177,8 @@ - (void) rot_map:(ST *)aWho attr:(id)attr prototypes:(AMutableArray *)prototypes
if ( st != nil ) {
[self setFirstArgument:aWho st:st attr:attr];
if ( st.impl.isAnonSubtemplate ) {
- [st rawSetAttribute:@"i0" value:@"0"];
- [st rawSetAttribute:@"i" value:@"1"];
+ [st rawSetAttribute:@"i0" value:[ACNumber numberWithInteger:0]];
+ [st rawSetAttribute:@"i" value:[ACNumber numberWithInteger:1]];
}
operands[++sp] = st;
}
@@ -1536,19 +1541,20 @@ - (ArrayIterator *) convertAnythingIteratableToIterator:(id)obj
ArrayIterator *iter = nil;
if ( obj == nil )
return nil;
- if ( [obj isKindOfClass:[HashMap class]] ) {
- HashMap *obj1 = obj;
- iter = (ArrayIterator *)[[[obj1 values] toArray] objectEnumerator];
- }
- else if ( [obj isKindOfClass:[AMutableArray class]] ) {
+ if ( [obj isKindOfClass:[AMutableArray class]] ) {
AMutableArray *obj1 = obj;
iter = (ArrayIterator *)[obj1 objectEnumerator];
}
else if ( [obj isKindOfClass:[NSArray class]] )
iter = (ArrayIterator *)[ArrayIterator newIterator:(NSArray *)obj];
else if ( currentScope.st.groupThatCreatedThisInstance.iterateAcrossValues &&
- [obj isKindOfClass:[AMutableDictionary class]] )
- iter = (ArrayIterator *)[obj objectEnumerator];
+ [obj isKindOfClass:[HashMap class]] )
+ iter = (ArrayIterator *)[ArrayIterator newIterator:[[(HashMap *)obj values] toArray]];
+ else if ( currentScope.st.groupThatCreatedThisInstance.iterateAcrossValues &&
+ [obj isKindOfClass:[AMutableDictionary class]] )
+ iter = (ArrayIterator *)[obj objectEnumerator];
+ else if ( [obj isKindOfClass:[HashMap class]] )
+ iter = (ArrayIterator *)[ArrayIterator newIterator:[[(HashMap *)obj keySet] toArray]];
else if ( [obj isKindOfClass:[AMutableDictionary class]] )
iter = (ArrayIterator *)[obj keyEnumerator];
else if ( [obj isKindOfClass:[NSDictionary class]] )
@@ -1565,14 +1571,6 @@ - (ArrayIterator *) convertAnythingToIterator:(id)obj
obj = [self convertAnythingIteratableToIterator:obj];
if ([obj isKindOfClass:[ArrayIterator class]])
return (ArrayIterator *)obj;
- if ( [obj isKindOfClass:[HashMap class]] )
- return [[[((HashMap *)obj) values] toArray] objectEnumerator];
- if ( [obj isKindOfClass:[AMutableDictionary class]] )
- return [[((AMutableDictionary *)obj) allValues] objectEnumerator];
- if ( [obj isKindOfClass:[AMutableArray class]] )
- return [((AMutableArray *)obj) objectEnumerator];
- if ( [obj isKindOfClass:[NSArray class]] )
- return [[AMutableArray arrayWithArray:((NSArray *)obj)] objectEnumerator];
AttributeList *singleton = [[AttributeList arrayWithCapacity:1] retain];
[singleton addObject:obj];
return (ArrayIterator *)[singleton objectEnumerator];
View
8 objc/main/ST.m
@@ -626,25 +626,25 @@ - (BOOL) getIsAnonSubtemplate
- (NSInteger) write:(id<STWriter>)wr1
{
- Interpreter *interp = [[Interpreter alloc] init:groupThatCreatedThisInstance errMgr:impl.nativeGroup.errMgr debug:NO];
+ Interpreter *interp = [Interpreter newInterpreter:groupThatCreatedThisInstance locale:[NSLocale currentLocale] errMgr:impl.nativeGroup.errMgr debug:NO];
return [interp exec:wr1 who:self];
}
- (NSInteger) write:(id<STWriter>)wr1 locale:(NSLocale *)locale
{
- Interpreter *interp = [[Interpreter alloc] init:groupThatCreatedThisInstance locale:locale errMgr:impl.nativeGroup.errMgr debug:NO];
+ Interpreter *interp = [Interpreter newInterpreter:groupThatCreatedThisInstance locale:locale errMgr:impl.nativeGroup.errMgr debug:NO];
return [interp exec:wr1 who:self];
}
- (NSInteger) write:(id<STWriter>)wr1 listener:(id<STErrorListener>)listener
{
- Interpreter *interp = [[Interpreter alloc] init:groupThatCreatedThisInstance errMgr:impl.nativeGroup.errMgr debug:NO];
+ Interpreter *interp = [Interpreter newInterpreter:groupThatCreatedThisInstance locale:[NSLocale currentLocale] errMgr:impl.nativeGroup.errMgr debug:NO];
return [interp exec:wr1 who:self];
}
- (NSInteger) write:(id<STWriter>)wr1 locale:(NSLocale *)locale listener:(id<STErrorListener>)listener
{
- Interpreter *interp = [[Interpreter alloc] init:groupThatCreatedThisInstance locale:locale errMgr:[ErrorManager newErrorManagerWithListener:listener] debug:NO];
+ Interpreter *interp = [Interpreter newInterpreter:groupThatCreatedThisInstance locale:locale errMgr:[ErrorManager newErrorManagerWithListener:listener] debug:NO];
return [interp exec:wr1 who:self];
}
View
2 objc/main/tests/objc/BaseTest.m
@@ -122,7 +122,7 @@ - (void)setUp
- (void)tearDown
{
// Tear-down code here.
-
+ [STGroup resetDefaultGroup];
// [super tearDown];
}

0 comments on commit d24cf71

Please sign in to comment.
Something went wrong with that request. Please try again.