Ryan Macnak avatar Ryan Macnak committed 8747ae6

Compiler cleanup: removing dead code

Comments (0)

Files changed (1)

Newspeak3Compilation.ns3

 explicitOuterReceiverNode: aNode <ExplicitOuterReceiverAST> = (
 	cgen pushExplicitOuterReceiver: aNode depth.
 )
-extractParam: p <ParameterAST> = (
-	cgen incrementStackDepthBy: 1.
-	"Because blocks are generated inline, their code assumes the operand stack already has the block parameters pushed on it. But during code generation this is not the case. So we increment the stack depth as if there was an actual parameter pushed there already"
-	cgen storeAndPopTemporary: (indexOfVar: p)
-)
 generateSuperSend: node <SendAST> = (
   node msg apply: self.
 
 	scopeMap at: block put: sscope.
 	^delay
 )
-enclosingObjSendOfDepth: n <Integer> to: recv <AST> start: start <Integer> end: end <Integer>  ^ <NormalSendAST> = (
- 
-
-^NormalSendAST new 
-         recv: recv; 
-         msg:(MessageAST new sel: (enclosingObjectMsgForDepth: n); args: {}; start: start; end: end);
-	   start: start; 
-	   end: end.
-)
-enclosingObjectMsgForDepth: n <Integer> ^ <String> = (
-
-"Compute the selector necessary for obtaining the nth enclosing object wrt to the current lexical scope "
-| otable  <Dictionary[Symbol, Tuple[Class, Integer]]> ec <Class> |
-
-"What if n has no corresponding entry in the outer table? This should not happen, as this method is called on the basis of an n value found in the table to begin with."
-
-otable:: currentScope at: #outer.
-ec:: (otable values detect:[:v | (v at:2) = (n-1)]) at: 1.
-^(Compiler new enclosingObjectMsgFor: ec) asSymbol
-)
 explicitOuterReceiverNode: node
  = (
     assert: [node isExplicitRcvrNode].
   addNumericLiteral: node val.
   ^node
 )
-oldProcessExplicitOuterSend: aMsg <MessageAST> atDepth: n = (
-
-
-| holder <NormalSendAST>  ctxt <VariableAST> start <Integer> end <integer> 
-enclosingObj <NormalSendAST>  nonMeta  <NormalSendAST> 
- |
-"For n > 0, return
-thisContext methodClass enclosingObject_Cn ... C0 
-                                         class enclosingObject_Cn ..._C1  ...  
-                                            class enclosingObject_Cn_Cn-1 msg
-
-which is the equivalent of
-
-outer X msg
-
-where X is the nth lexically enclosing class. Otherwise, do a self send"
-
-n = 0 ifTrue:[^selfSendFrom: aMsg].
-start:: aMsg start.
-end:: aMsg end.
-ctxt:: VariableAST new name: #thisContext; start: start; end: end.
-
-holder:: NormalSendAST new recv: ctxt;
-                                             msg: (MessageAST new sel:#lexicalClass; args: {});
-                                              start: start; end: end.
-
-nonMeta:: NormalSendAST new recv: holder;
-                                             msg: (MessageAST new sel:#theNonMetaClass; args: {});
-                                              start: start; end: end.
-
-enclosingObj::  enclosingObjSendOfDepth: 1 to: nonMeta start: start end: end. 
-
-enclosingObj:: (2 to: n) inject: enclosingObj into:[:r <NormalSendAST> :i <Integer> | 
-	| csend <NormalSendAST> |
-	  csend::  NormalSendAST new recv: r; 
-	                                               msg:(MessageAST new sel: #class; args: {}; start: start; end: end);
-	                                               start: start; 
-	                                               end: end.
-	 enclosingObjSendOfDepth: i to: csend start: start end: end. 
-	 ].
-^(NormalSendAST new recv: enclosingObj; msg: aMsg; start: start; end: end) apply: self
-)
 parameterNode: node <ParameterVariableAST> = (
 	#BOGUS. "Shouldn't be visiting this twice."
 	^node
   addNumericLiteral: depth. "the backend checks that depth in 0 - 256"
  ^(ExplicitRecvrAST send: aMsg sel depth: depth) start: aMsg start; end: aMsg end
 )
-processExplicitOuterSend: aMsg <MessageAST> = (
-"Unused at the moment"
-)
 processImplicitOuterSend: aMsg <MessageAST> atDepth: n <Integer> ^ <SendNode> = (
 "In this case, we don't care about the depth; but when compiling to other platforms, we might, so we maintain the API"
   ^(ImplicitRecvrSendAST send: (aMsg apply: self)) start: aMsg start; end: aMsg end
 		ifTrue:[binding setterAst: aMsg args first]
 		ifFalse:[binding getterAst]) apply: self
 )
-processOuterSend: aMsg <MessageAST> = (
-
-
-| holder <NormalSendAST> depth <Integer> binding <AST>  meMsg <MessageAST> |
-
-assert:[aMsg args isEmpty]. "this had better be a unary message"
-binding:: (currentScope at: #outer) at: aMsg sel.
-"assert binding makes sense "
-assert:[ binding isKindOf: Collection].
-assert:[binding first isKindOf: Class].
-assert:[binding last isKindOf: Integer].
-
-meMsg:: MessageAST new sel: #yourself; args: {}; start: aMsg start; end: aMsg end. "hack!"
-^processOuterSend: meMsg atDepth: binding last
-)
-processOuterSend: aMsg <MessageAST> atDepth: n = (
-
-
-| holder <NormalSendAST>  ctxt <VariableAST> start <Integer> end <integer> 
-enclosingObj <NormalSendAST>  nonMeta  <NormalSendAST> 
- |
-"For n > 0, return
-thisContext methodClass enclosingObject_Cn ... C0 
-                                         class enclosingObject_Cn ..._C1  ...  
-                                            class enclosingObject_Cn_Cn-1 msg
-
-which is the equivalent of
-
-outer X msg
-
-where X is the nth lexically enclosing class. Otherwise, do a self send"
-
-n = 0 ifTrue:[^selfSendFrom: aMsg].
-start:: aMsg start.
-end:: aMsg end.
-ctxt:: VariableAST new name: #thisContext; start: start; end: end.
-
-holder:: NormalSendAST new recv: ctxt;
-                                             msg: (MessageAST new sel:#lexicalClass; args: {});
-                                              start: start; end: end.
-
-nonMeta:: NormalSendAST new recv: holder;
-                                             msg: (MessageAST new sel:#theNonMetaClass; args: {});
-                                              start: start; end: end.
-
-enclosingObj::  enclosingObjSendOfDepth: 1 to: nonMeta start: start end: end. 
-
-enclosingObj:: (2 to: n) inject: enclosingObj into:[:r <NormalSendAST> :i <Integer> | 
-	| csend <NormalSendAST> |
-	  csend::  NormalSendAST new recv: r; 
-	                                               msg:(MessageAST new sel: #class; args: {}; start: start; end: end);
-	                                               start: start; 
-	                                               end: end.
-	 enclosingObjSendOfDepth: i to: csend start: start end: end. 
-	 ].
-^(NormalSendAST new recv: enclosingObj; msg: aMsg; start: start; end: end) apply: self
-)
 processVariable: aMsg <MessageAST> decl: vd <VarDeclAST>  ^ <AssignmentNode | VariableNode> = (
 
 
 "generate a an AST representing self; used for implicit self sends"
 ^VariableAST new name: #self; start: 0; end: 0
 )
-selfSendFrom: aMsg <MessageAST>  ^ <MessageNode> = (
-
-
-^(NormalSendAST new msg: aMsg; 
-                          recv: (selfNode start: aMsg start; end: aMsg end);
-                          start: aMsg start; end: aMsg end) apply: self
-)
 setterSendNode: node <SetterSendAST> ^ <AST> = (
 | 
 setterBinding <AST>
 	scopeMap at: result put: bodyScope.
 	^result.
 )
-genericApplicationExpressionNode: node
- = (
-    assert: [node isGenericApplicationExpressionNode].
-    ^node target apply: self
-)
-guaranteedNode: node
- = (
-    assert: [node isGuaranteedNode].
-    ^node expr apply: self
-)
 ifNode: node <ifAST> ^ <ifAST>
  = (
  assert: [ node isIfNode ].
 		].
 	]
 )
-initializerFor: aNode <ClassHeaderAST> ^ <MethodAST> = (
-
-| stmts var  superMsg send  start end initHdr body copier |
-
-	PANIC: 'is this method uncalled?'.
-	
- start:: aNode superConstructorCall start.
- end::  aNode  superConstructorCall end.
- copier:: ASTCopier new.
- initHdr:: aNode constructor apply: copier. "set up scope with constructor parameters"
-
-aNode isSeq out.
- stmts::  aNode  slots collect:[:slot <SlotDefAST> | | aMsg <MessageAST> z |
-	
-	aMsg:: MessageAST new send: (slot name, ':') asSymbol 
-					   with:  {slot initializer apply: copier} ;
-					   start: slot  start; end: slot end.
-	z:: NormalSendAST new msg: aMsg; 
-                          recv: (selfNode start: aMsg start; end: aMsg end);
-                          start: aMsg start; end: aMsg end.
-	aNode isSeq ifFalse: [z:: delayFor: z].
-	z
-	].
-"create call to superclass initializer"
- var:: VariableAST new name: #super; start: start; end: end.
- superMsg::  aNode  superConstructorCall apply: copier.
- send:: NormalSendAST new to: var send:   superMsg; start: start; end: end.
-"add superclass init call as first statement"
- stmts addFirst: send. 
- stmts addAll: (aNode initExprs collect:[:ie | ie apply: copier]).
- body:: CodeBodyAST new temporaries: OrderedCollection new
-                                       statements: stmts; 
-                                       start: start; end: end.
- ^MethodAST new pattern: initHdr
-                            body: body
-                            visibility: #public; 
-                            start: start; end: end.
-)
 initializerSelectorNameFor: selector = (
 
 	^ ('initializer`', selector) asSymbol
 	processFactoryFor: aNode in: mixinMirror.
 	processSide: aNode classSide ofMixin: mixinMirror. "compile class methods"
 )
-processConstructorFor: aNode <ClassHeaderAST> inMixin: mixinMirror <LowLevelMixinMirror> = (
-
-"eliminate"
-| initializer <MethodMirror> primaryFactory <MethodMirror> |
- 
-  initializer:: methodNode: (initializerFor: aNode). 
-  mixinMirror methods addMirror: initializer.
-"install initializer"
-  primaryFactory::  methodNode:(makePrimaryFactoryFor: aNode). 
-  mixinMirror classMixin methods addMirror: primaryFactory.
-"install constructor"
-)
 processFactoryFor: aNode <ClassAST> in: mixinMirror <LowLevelMixinMirror> = (
 |  factory <MethodMirror> side <SideAST> factoryAST <MethodAST> scopeBuilder <ScopeBuilder> savedScopeMap <Dictionary[AST, Scope]> |
 	processFactoryFor: aNode hdr inScope: (scopeMap at: aNode classSide) in: mixinMirror.
 								fullyQualifySimpleName: ncn 
 		                  			 with: outerName
 					). "(fullyQualifySimpleName: ncn  with: outerName), '_slot'"
-)
-superAccessorStringFor: sname <String> inClass: mixinMirror<LowLevelMixinMirror> ^ <String> = (
-
-"Determine at what lexical level an accessor for sname exists, and create a string that will access it from klass.
-The string will have the form self enclosingObject_C0_ ...Cn   ... enclosingObject_Cn  sname, where n >= 0 is the number of lexical levels one needs to traverse to reach the definition of sname. 
-If no lexically visible definition is found, assume it is inherited and revert to n = 0 (a simple self send)."
-
-| 
-enclosings <String>  oClass <Class> enclosingMixins <Collection[MixinMirror]>  
-enclosingNames <Collection[Symbol]> count <Integer>
-| 
-"!!"
-count:: 0.
-(mixinMirror methods includesMirrorNamed: sname asSymbol) ifTrue:[^'self ', sname].
-enclosings:: ''.
-enclosingMixins:: mixinMirror enclosingMixins reverse.
-enclosingMixins do:[:oc <MixinMirror> |
-	(oc methods includesMirrorNamed: sname asSymbol) 
-	      ifFalse:[count:: count + 1]
-	      ifTrue:[
-			enclosingNames::  enclosingMixins collect:[:c | enclosingObjectMsgFor: c]
-			                                                      from: 1 
-			                                                      to: count.
-                   enclosings:: enclosingNames fold:[:ocn1 <Symbol> :ocn2 <Symbol> | ocn1, ' class ', ocn2].
-		       ^'thisContext lexicalClass ', enclosings, ' ', sname
-		]
-	].
-^'self ', sname
 )'private'
 allInitializersFor: aNode <ClassHeaderAST> in: mixinMirror <MixinMirror> ^ <Collection[MethodAST]> = (
 "2nd argument unused!"
 enclosingObjectMsgFromName: nm <String> ^ <String> = (
   ^'enclosingObject', syntheticNameSeparator, nm 
 )
-ensureEnclosingObjectAccessFor: mixinMirror <LowLevelMixinMirror> = (
-
-"Need a different enclosingObject slot with respect to each lexical scope"
-"We use the class' fully qualified name to produce a uniquely named enclosing object 
-slot for each class in the inheritance chain, so they never conflict"
-| enclosingObjectMsg <Symbol> |
-
-  enclosingObjectMsg:: enclosingObjectMsgFor: mixinMirror.
-  mixinMirror classMixin instVars addMirror: (InstanceVariableMirror named: enclosingObjectMsg).  "add  class instance variable to reference enclosing instance"
-)
 getInstanceVariables: aClassHeaderNode <ClassHeaderAST> ^ <String> = (
 
  "returns the language specific slots - e.g. instance variables as a string"
 				); 
                         start: arg start; end: arg end
 )
-selectorForMethodAST: aMethodAST = (
-	^aMethodAST pattern selector
-  )
 selfNode ^ <VariableAST> = (
 
 "generate a an AST representing self; used for implicit self sends"
 	].
   ^(prefix, suffix) asSymbol
 )'public access'
-classHeaderNode: aNode <ClassHeaderAST> ^ <CompiledMixinMirror> = (
-| mixinMirror <LowLevelMixinMirror> t <{OrderedCollection[T]. Integer}> |
-"eliminate?"
- assert:[aNode category notNil] message: 'No category for class header node '.
- mixinMirror::  computeMixinFrom: aNode.					
-"Need to ensure we only call this routine if the class whose header we are processing already exists in the enclosing class"
-"Create class constructor + initializer routine"
- processConstructorFor: aNode inMixin: mixinMirror lowLevelMirror.
-^mixinMirror
-)
 classNode: aNode <ClassDeclarationAST> ^ <MixinRep> = (
 "type MixinRep = {CompiledMixinMirror. {MixinRep}}"
 | mixinMirror <LowLevelMixinMirror> nestedClasses <Collection[MixinRep]> |
 )
 compileNestedClass: nc <ClassDeclarationAST> within: mixinMirror <LowLevelMixinMirror> ^ <List[MixinRep]> = (
 	^compileNestedClasses: (OrderedCollection with: nc) within: mixinMirror.
-)
-parserClass = (
- 
-^WrappingNS2Parser 
 ))
 class DebugMappedLocalEntry name: nom mapper: mapper = SymbolTableEntry for: {nil. nil} (
 "Describe the class in this comment."|
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.