Commits

Ryan Macnak committed 22121b3

More of the same.

Comments (0)

Files changed (1)

Newspeak2SqueakCompilation.ns3

 		^ { enclosingMirror . nestedClassMixinReps }.
 		(* what about other nested classes of enclosing? Not the compiler's responsibility; they are unchanged, and the surrounding reflection system should add them to the mixin rep *)
 )
-currentScope ^ <Scope> = (
-  ^scopeStack last
-)
 doitContextArgumentName = (
 	(* Use #'@context', but this can't be mentioned in the debugger,
 	and doesn't need to be since the debugger provides Inspect Context.
 	(* pop scope? *)
 	^(methodCompiler result) src: (sourceForNode: aNode)
 )
-nestScope: s <Scope> = (
-(* Hook up a new lexically nested scope, and push onto the scope stack *)
-  s setSuperScope: currentScope.
-  pushScope: s
-)
-popScope ^ <Scope> = (
-   ^scopeStack removeLast
-)
 processClassSideOf: aNode <ClassAST> ofMixin: mixinMirror <LowLevelMixinMirror> = (
 | primaryFactory <MethodMirror> factoryAST <MethodAST> |
 	processFactoryFor: aNode in: mixinMirror.
                                  ].
                      ].
 )
-pushScope: s <Scope> = (
-  scopeStack addLast: s
-)
 saveInput: src <ReadStream> = (
   src position: 1.
   input: src. (* save the input *)
 )
-setScopeFor: aNode <AST> in: enclosing <MixinMirror| Nil> = (
-
-| scopeBuilder <ScopeBuilder> |
-
-  pushScope: Scope new.
-  enclosing isNil ifFalse:[nestScope:: ScopeBuilder new buildScopeFor: enclosing].
-						 (* establish enclosing scope *)
-
-  currentDepth:: currentScope depth - 1. 
-(* There should be one scope for each enclosing class, plus the dummy initial scope. *)
-
-  scopeBuilder:: ScopeBuilder nestedIn: currentScope atLevel: currentDepth.
-  aNode apply: scopeBuilder.
-  (* scopeMap:: scopeBuilder scopeMap. *)
-)
 setterSelectorFor: slot <SlotDefAST | InstanceVariableMirror> ^<Symbol> = (
 	^((slot isMutableSlot ifTrue: [ '' ] ifFalse: [ 'setOnce`' ]), slot name, ':') asSymbol.
 )
 	input position: savedPos.
 	^s
 )
-superConstructorMethodFor:  aNode <ClassHeaderAST> ^ <MethodAST> = (
-| 
-start <Integer> 
-end <Integer>
-stmts <List[StmtAST]> 
-var  <VariableAST> 
-initHdr <MessagePatternAST>
-superMsg <MessageAST> 
-send <NormalSendAST>
-body  <CodeBodyAST>
-copier <ASTCopier>
-|
-
-	start:: aNode superConstructorCall start.
-	end::  aNode  superConstructorCall end.
-	copier:: ASTCopier new.
-	initHdr:: aNode constructor apply: copier. (* set up scope with constructor parameters *)
-	initHdr selector:(superConstructorNameFor: aNode).
-	(* create call to superclass initializer *)
-	stmts:: OrderedCollection new. 
-	var:: VariableAST new name: #super; start: start; end: end.
-	superMsg::  aNode  superConstructorCall apply: copier.
-	superMsg sel: (initializerSelectorNameFor: superMsg sel).
-	send:: NormalSendAST new to: var send: superMsg; start: start; end: end. 
-	stmts addFirst: send.
-	body:: CodeBodyAST new temporaries: OrderedCollection new
-                                       	statements: stmts;
-                                      	start: start; end: end.
-	^MethodAST new pattern: initHdr
-                            body: body
-                            visibility: #private;
-                            start: start; end: end	
-)
-superConstructorNameFor: aNode <ClassHeaderAST> ^ <Symbol> = (
-	^(aNode name, '`superInit`', aNode constructor selector) asSymbol 
-)
 syntheticNameSeparator ^ <String> = (
   ^Language syntheticNameSeparator	
 )
 		start: start; end: end.
 	send:: NormalSendAST new to: var send: superMsg; start: start; end: end.	
 	^send
+)
+superConstructorMethodFor: aNode <ClassHeaderAST> ^<MethodAST> = (
+	| 
+	start <Integer> 
+	end <Integer>
+	stmts <List[StmtAST]> 
+	var  <VariableAST> 
+	initHdr <MessagePatternAST>
+	superMsg <MessageAST> 
+	send <NormalSendAST>
+	body  <CodeBodyAST>
+	copier <ASTCopier>
+	|
+	start:: aNode superConstructorCall start.
+	end:: aNode superConstructorCall end.
+	copier:: ASTCopier new.
+	initHdr:: aNode constructor apply: copier.
+	initHdr selector: (superConstructorNameFor: aNode).
+	(* create call to superclass initializer *)
+	stmts:: OrderedCollection new. 
+	var:: VariableAST new name: #super; start: start; end: end.
+	superMsg:: aNode superConstructorCall apply: copier.
+	superMsg sel: (initializerSelectorNameFor: superMsg sel).
+	send:: NormalSendAST new to: var send: superMsg; start: start; end: end. 
+	stmts addFirst: send.
+	body:: CodeBodyAST new
+		temporaries: OrderedCollection new
+		statements: stmts;
+		start: start; end: end.
+	^MethodAST new 
+		pattern: initHdr body: body visibility: #private;
+		start: start; end: end	
+)
+superConstructorNameFor: aNode <ClassHeaderAST> ^ <Symbol> = (
+	^(aNode name, '`superInit`', aNode constructor selector) asSymbol 
 )'make lexically visible'
 scopeMap = (
 	^super scopeMap
 )
 compileNestedClass: nc <ClassDeclarationAST> within: mixinMirror <LowLevelMixinMirror> ^ <List[MixinRep]> = (
 	^compileNestedClasses: (OrderedCollection with: nc) within: mixinMirror.
+)'scopes'
+currentScope ^ <Scope> = (
+	^scopeStack last
+)
+nestScope: s <Scope> = (
+	(* Hook up a new lexically nested scope, and push onto the scope stack *)
+	s setSuperScope: currentScope.
+	pushScope: s
+)
+popScope ^<Scope> = (
+	^scopeStack removeLast
+)
+pushScope: s <Scope> = (
+	scopeStack addLast: s
+)
+setScopeFor: aNode <AST> in: enclosing <MixinMirror | nil> = (
+
+	| scopeBuilder <ScopeBuilder> |
+	pushScope: Scope new.
+	enclosing isNil
+		ifFalse:[nestScope:: ScopeBuilder new buildScopeFor: enclosing].
+	(* establish enclosing scope *)
+
+	currentDepth:: currentScope depth - 1.
+	(* There should be one scope for each enclosing class, plus the dummy initial scope. *)
+
+	scopeBuilder:: ScopeBuilder nestedIn: currentScope atLevel: currentDepth.
+	aNode apply: scopeBuilder.
 )) : ()
 class DebugMappedLocalEntry name: nom mapper: mapper = SymbolTableEntry forAST: nil atDepth: nil (
 (* Describe the class in this comment. *)|