# HG changeset patch # User Jan Vrany # Date 1440571878 -3600 # Node ID 97ee341d3e9fdea660d80571d33130f9cdbdfaec # Parent 2a3e47c139055aafbf34e83dbd14693641735f7e Initial shot of scopes & bindings and type checking. Must be rethought. diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/Make.proto --- a/compiler/Make.proto Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/Make.proto Wed Aug 26 07:51:18 2015 +0100 @@ -34,7 +34,7 @@ # add the path(es) here:, # ********** OPTIONAL: MODIFY the next lines *** # LOCALINCLUDES=-Ifoo -Ibar -LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic +LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic # if you need any additional defines for embedded C code, @@ -102,6 +102,7 @@ # build all mandatory prerequisite packages (containing superclasses) for this package prereq: cd $(TOP)/libbasic && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" + cd $(TOP)/goodies/refactoryBrowser/helpers && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd $(TOP)/goodies/refactoryBrowser/parser && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd $(TOP)/libbasic2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd $(TOP)/libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" @@ -126,18 +127,32 @@ # BEGINMAKEDEPEND --- do not remove this line; make depend needs it +$(OUTDIR)TBinding.$(O) TBinding.$(H): TBinding.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TClass.$(O) TClass.$(H): TClass.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBAbstractClass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBClass.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TCompiler.$(O) TCompiler.$(H): TCompiler.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TFormatter.$(O) TFormatter.$(H): TFormatter.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBFormatter.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TMetaclass.$(O) TMetaclass.$(H): TMetaclass.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBAbstractClass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBMetaclass.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TMethod.$(O) TMethod.$(H): TMethod.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBMethod.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TParser.$(O) TParser.$(H): TParser.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBParser.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TProgramNodeVisitor.$(O) TProgramNodeVisitor.$(H): TProgramNodeVisitor.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TScope.$(O) TScope.$(H): TScope.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TType.$(O) TType.$(H): TType.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TTypeNode.$(O) TTypeNode.$(H): TTypeNode.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TTypeSpecNode.$(O) TTypeSpecNode.$(H): TTypeSpecNode.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)jv_tea_compiler.$(O) jv_tea_compiler.$(H): jv_tea_compiler.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR) +$(OUTDIR)TFunctionBinding.$(O) TFunctionBinding.$(H): TFunctionBinding.st $(INCLUDE_TOP)/jv/tea/compiler/TBinding.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TSemanticAnalyzer.$(O) TSemanticAnalyzer.$(H): TSemanticAnalyzer.st $(INCLUDE_TOP)/jv/tea/compiler/TProgramNodeVisitor.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TSimpleType.$(O) TSimpleType.$(H): TSimpleType.st $(INCLUDE_TOP)/jv/tea/compiler/TType.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TSimpleTypeNode.$(O) TSimpleTypeNode.$(H): TSimpleTypeNode.st $(INCLUDE_TOP)/jv/tea/compiler/TTypeNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TTypeChecker.$(O) TTypeChecker.$(H): TTypeChecker.st $(INCLUDE_TOP)/jv/tea/compiler/TProgramNodeVisitor.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TUnionType.$(O) TUnionType.$(H): TUnionType.st $(INCLUDE_TOP)/jv/tea/compiler/TType.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) $(OUTDIR)TUnionTypeNode.$(O) TUnionTypeNode.$(H): TUnionTypeNode.st $(INCLUDE_TOP)/jv/tea/compiler/TTypeNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) -$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBBlockNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBMethodNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBStatementNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBValueNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBVariableNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TValueBinding.$(O) TValueBinding.$(H): TValueBinding.st $(INCLUDE_TOP)/jv/tea/compiler/TBinding.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TConstantBinding.$(O) TConstantBinding.$(H): TConstantBinding.st $(INCLUDE_TOP)/jv/tea/compiler/TBinding.$(H) $(INCLUDE_TOP)/jv/tea/compiler/TValueBinding.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TVariableBinding.$(O) TVariableBinding.$(H): TVariableBinding.st $(INCLUDE_TOP)/jv/tea/compiler/TBinding.$(H) $(INCLUDE_TOP)/jv/tea/compiler/TValueBinding.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TArgumentBinding.$(O) TArgumentBinding.$(H): TArgumentBinding.st $(INCLUDE_TOP)/jv/tea/compiler/TBinding.$(H) $(INCLUDE_TOP)/jv/tea/compiler/TValueBinding.$(H) $(INCLUDE_TOP)/jv/tea/compiler/TVariableBinding.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)TLocalBinding.$(O) TLocalBinding.$(H): TLocalBinding.st $(INCLUDE_TOP)/jv/tea/compiler/TBinding.$(H) $(INCLUDE_TOP)/jv/tea/compiler/TValueBinding.$(H) $(INCLUDE_TOP)/jv/tea/compiler/TVariableBinding.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) +$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBBlockNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBMethodNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBProgramNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBReturnNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBStatementNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBValueNode.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser/RBVariableNode.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR) # ENDMAKEDEPEND --- do not remove this line diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/Make.spec --- a/compiler/Make.spec Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/Make.spec Wed Aug 26 07:51:18 2015 +0100 @@ -51,33 +51,61 @@ STCWARNINGS=-warnNonStandard COMMON_CLASSES= \ + TBinding \ + TClass \ TCompiler \ TFormatter \ + TMetaclass \ + TMethod \ TParser \ + TProgramNodeVisitor \ + TScope \ TType \ TTypeNode \ TTypeSpecNode \ jv_tea_compiler \ + TFunctionBinding \ + TSemanticAnalyzer \ TSimpleType \ TSimpleTypeNode \ + TTypeChecker \ TUnionType \ TUnionTypeNode \ + TValueBinding \ + TConstantBinding \ + TVariableBinding \ + TArgumentBinding \ + TLocalBinding \ COMMON_OBJS= \ + $(OUTDIR_SLASH)TBinding.$(O) \ + $(OUTDIR_SLASH)TClass.$(O) \ $(OUTDIR_SLASH)TCompiler.$(O) \ $(OUTDIR_SLASH)TFormatter.$(O) \ + $(OUTDIR_SLASH)TMetaclass.$(O) \ + $(OUTDIR_SLASH)TMethod.$(O) \ $(OUTDIR_SLASH)TParser.$(O) \ + $(OUTDIR_SLASH)TProgramNodeVisitor.$(O) \ + $(OUTDIR_SLASH)TScope.$(O) \ $(OUTDIR_SLASH)TType.$(O) \ $(OUTDIR_SLASH)TTypeNode.$(O) \ $(OUTDIR_SLASH)TTypeSpecNode.$(O) \ $(OUTDIR_SLASH)jv_tea_compiler.$(O) \ + $(OUTDIR_SLASH)TFunctionBinding.$(O) \ + $(OUTDIR_SLASH)TSemanticAnalyzer.$(O) \ $(OUTDIR_SLASH)TSimpleType.$(O) \ $(OUTDIR_SLASH)TSimpleTypeNode.$(O) \ + $(OUTDIR_SLASH)TTypeChecker.$(O) \ $(OUTDIR_SLASH)TUnionType.$(O) \ $(OUTDIR_SLASH)TUnionTypeNode.$(O) \ + $(OUTDIR_SLASH)TValueBinding.$(O) \ + $(OUTDIR_SLASH)TConstantBinding.$(O) \ + $(OUTDIR_SLASH)TVariableBinding.$(O) \ + $(OUTDIR_SLASH)TArgumentBinding.$(O) \ + $(OUTDIR_SLASH)TLocalBinding.$(O) \ $(OUTDIR_SLASH)extensions.$(O) \ diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TArgumentBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TArgumentBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,28 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TVariableBinding subclass:#TArgumentBinding + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + + +!TArgumentBinding methodsFor:'printing & storing'! + +printOn:aStream + aStream nextPutAll: '[A] '. + super printOn: aStream + + "Created: / 25-08-2015 / 22:54:32 / Jan Vrany " +! ! + +!TArgumentBinding class methodsFor:'documentation'! + +version_HG + + ^ '$Changeset: $' +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,19 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +Object subclass:#TBinding + instanceVariableNames:'type' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + +!TBinding methodsFor:'accessing'! + +type + ^ type + + "Modified: / 28-08-2015 / 06:28:26 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TClass.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TClass.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,19 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +RBClass subclass:#TClass + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Model' +! + + +!TClass class methodsFor:'documentation'! + +version_HG + + ^ '$Changeset: $' +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TConstantBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TConstantBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,38 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TValueBinding subclass:#TConstantBinding + instanceVariableNames:'value' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + +!TConstantBinding class methodsFor:'instance creation'! + +value: anObject + ^ self new initializeWithValue: anObject + + "Created: / 25-08-2015 / 23:14:44 / Jan Vrany " +! ! + +!TConstantBinding methodsFor:'accessing'! + +value + ^ value +! ! + +!TConstantBinding methodsFor:'initialization'! + +initializeWithValue: anObject + value := anObject. + value class == SmallInteger ifTrue:[ + type := TSimpleType named: 'TSmallInteger'. + ^ self. + ]. + self error: 'Unsupported constant' + + "Created: / 25-08-2015 / 23:15:00 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TFunctionBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TFunctionBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,11 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TBinding subclass:#TFunctionBinding + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TLocalBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TLocalBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,20 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TVariableBinding subclass:#TLocalBinding + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + +!TLocalBinding methodsFor:'printing & storing'! + +printOn:aStream + aStream nextPutAll: '[L] '. + super printOn: aStream + + "Created: / 25-08-2015 / 22:54:57 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TMetaclass.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TMetaclass.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,11 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +RBMetaclass subclass:#TMetaclass + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Model' +! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TMethod.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TMethod.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,49 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +RBMethod subclass:#TMethod + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Model' +! + +!TMethod methodsFor:'accessing'! + +method + "Returns Method instance which is present or retrived from real class" + + ^ nil "/ For Tea, there are no real methods (yet). + "/ Later it may return Tea host method." + + "Created: / 25-08-2015 / 19:10:11 / Jan Vrany " +! + +method: aCompiledMethod + self shouldNeverBeSent + + "Created: / 25-08-2015 / 19:09:09 / Jan Vrany " +! + +parseTree + ^ TParser parseMethod: self source + + "Created: / 25-08-2015 / 19:43:51 / Jan Vrany " +! + +selector + selector isNil ifTrue:[ + selector := self parseTree selector. + ]. + ^ selector + + "Created: / 25-08-2015 / 19:48:31 / Jan Vrany " +! + +source + ^ source + + "Created: / 25-08-2015 / 19:44:31 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TProgramNodeVisitor.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TProgramNodeVisitor.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,60 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +RBProgramNodeVisitor subclass:#TProgramNodeVisitor + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-AST' +! + + +!TProgramNodeVisitor methodsFor:'visiting'! + +visitArgument: anRBVariableNode + super visitArgument: anRBVariableNode. + self visitNode: anRBVariableNode typeSpec + + "Created: / 25-08-2015 / 19:51:53 / Jan Vrany " +! ! + +!TProgramNodeVisitor methodsFor:'visitor-double dispatching'! + +acceptMethodNode: aMethodNode + super acceptMethodNode: aMethodNode. + self visitNode: aMethodNode returnTypeSpec + + "Created: / 25-08-2015 / 19:53:04 / Jan Vrany " +! + +acceptSimpleTypeNode: aTSimpleTypeNode + + "Created: / 21-08-2015 / 22:20:26 / Jan Vrany " + "Modified: / 25-08-2015 / 19:54:21 / Jan Vrany " +! + +acceptTypeSpecNode: aTTypeSpecNode + self visitNode: aTTypeSpecNode type. + + "Created: / 21-08-2015 / 22:18:08 / Jan Vrany " + "Modified: / 25-08-2015 / 19:54:47 / Jan Vrany " +! + +acceptUnionTypeNode: aTUnionTypeNode + aTUnionTypeNode types do:[:type | self visitNode: type ] + + "Created: / 21-08-2015 / 22:21:29 / Jan Vrany " + "Modified (format): / 25-08-2015 / 19:54:40 / Jan Vrany " +! ! + +!TProgramNodeVisitor class methodsFor:'documentation'! + +version + ^ 'Path: jv/tea/compiler/TProgramNodeVisitor.st, Version: 1.0, User: jv, Time: 2015-08-25T19:55:02.763+01' +! + +version_HG + ^ 'Path: jv/tea/compiler/TProgramNodeVisitor.st, Version: 1.0, User: jv, Time: 2015-08-25T19:55:02.763+01' +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TScope.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TScope.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,80 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +Object subclass:#TScope + instanceVariableNames:'node parent children variables' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + +!TScope class methodsFor:'instance creation'! + +node: node + ^ self node: node parent: nil. + + "Created: / 25-08-2015 / 22:28:56 / Jan Vrany " +! + +node: node parent: parent + ^ self new initializeWithNode: node parent: parent + + "Created: / 25-08-2015 / 22:24:20 / Jan Vrany " +! ! + +!TScope methodsFor:'accessing'! + +children + ^ children ? #() + + "Modified: / 25-08-2015 / 22:28:21 / Jan Vrany " +! + +node + ^ node +! + +parent + ^ parent +! ! + +!TScope methodsFor:'initialization'! + +initializeWithNode: n parent: p + node := n. + parent := p. + + "Created: / 25-08-2015 / 22:25:12 / Jan Vrany " +! ! + +!TScope methodsFor:'instance creation'! + +subScope: methodOrBlockNode + children isNil ifTrue:[ + children := OrderedCollection new: 5. + ]. + ^ children add: (self class node: methodOrBlockNode parent: self) + + "Created: / 25-08-2015 / 22:28:02 / Jan Vrany " +! ! + +!TScope methodsFor:'lookup'! + +addVariable: aTVariableBinding + variables isNil ifTrue:[ + variables := OrderedCollection new. + ]. + variables add: aTVariableBinding + + "Created: / 25-08-2015 / 22:42:29 / Jan Vrany " +! + +lookupVariable: name + ^ variables + detect:[:binding | binding name = name ] + ifNone:[ parent notNil ifTrue:[ parent lookupVariable: name ] ifFalse:[ self error:'variable not found' ] ] + + "Created: / 25-08-2015 / 22:58:18 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TSemanticAnalyzer.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TSemanticAnalyzer.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,78 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TProgramNodeVisitor subclass:#TSemanticAnalyzer + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Analysis' +! + +!TSemanticAnalyzer class methodsFor:'documentation'! + +documentation +" + This pass analyzes the tree, creates scopes and + initializes variable bindings. + + [author:] + Jan Vrany + + [instance variables:] + + [class variables:] + + [see also:] + +" +! ! + +!TSemanticAnalyzer methodsFor:'visiting'! + +visitArgument: anRBVariableNode + | binding | + + anRBVariableNode parent isSequence ifTrue:[ + binding := TLocalBinding type:anRBVariableNode typeSpec asType + name:anRBVariableNode name. + ] ifFalse:[ + binding := TArgumentBinding type:anRBVariableNode typeSpec asType + name:anRBVariableNode name. + ]. + anRBVariableNode parent scope addVariable: binding. + super visitArgument: anRBVariableNode. + + "Created: / 25-08-2015 / 22:51:40 / Jan Vrany " +! ! + +!TSemanticAnalyzer methodsFor:'visitor-double dispatching'! + +acceptBlockNode: aBlockNode + aBlockNode scope: (aBlockNode parent scope subScope: aBlockNode). + super acceptBlockNode: aBlockNode + + "Created: / 25-08-2015 / 22:30:21 / Jan Vrany " +! + +acceptLiteralNode: aRBLiteralNode + aRBLiteralNode binding: (TConstantBinding value: aRBLiteralNode value). + super acceptLiteralNode: aRBLiteralNode + + "Created: / 25-08-2015 / 23:17:30 / Jan Vrany " +! + +acceptMethodNode: aMethodNode + aMethodNode scope: (TScope node: aMethodNode). + super acceptMethodNode: aMethodNode + + "Created: / 25-08-2015 / 22:29:21 / Jan Vrany " +! + +acceptVariableNode: aVariableNode + aVariableNode binding: (aVariableNode scope lookupVariable: aVariableNode name). + super acceptVariableNode: aVariableNode + + "Created: / 25-08-2015 / 23:00:34 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TSimpleType.st --- a/compiler/TSimpleType.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TSimpleType.st Wed Aug 26 07:51:18 2015 +0100 @@ -9,7 +9,6 @@ category:'Languages-Tea-Compiler-Types' ! - !TSimpleType class methodsFor:'instance creation'! named: aString @@ -24,6 +23,20 @@ ^ name ! ! +!TSimpleType methodsFor:'comparing'! + += anotherType + ^ self class = anotherType class and:[ self name = anotherType name ] + + "Created: / 25-08-2015 / 23:36:20 / Jan Vrany " +! + +hash + ^ name hash + + "Created: / 25-08-2015 / 23:34:45 / Jan Vrany " +! ! + !TSimpleType methodsFor:'initialization'! initializeWithName: aString @@ -34,6 +47,14 @@ !TSimpleType methodsFor:'printing & storing'! +printOn:aStream + aStream nextPut: $<; space. + self printWithoutAnglesOn:aStream. + aStream space; nextPut: $>. + + "Created: / 25-08-2015 / 23:22:15 / Jan Vrany " +! + printWithoutAnglesOn:aStream aStream nextPutAll: name @@ -46,10 +67,3 @@ ^ true ! ! -!TSimpleType class methodsFor:'documentation'! - -version_HG - - ^ '$Changeset: $' -! ! - diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TSimpleTypeNode.st --- a/compiler/TSimpleTypeNode.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TSimpleTypeNode.st Wed Aug 26 07:51:18 2015 +0100 @@ -35,6 +35,16 @@ stop := anInteger. ! ! +!TSimpleTypeNode methodsFor:'conversion'! + +asType + "superclass TTypeNode says that I am responsible to implement this method" + + ^ TSimpleType named: name + + "Modified: / 25-08-2015 / 23:04:44 / Jan Vrany " +! ! + !TSimpleTypeNode methodsFor:'visitor'! acceptVisitor: aProgramNodeVisitor diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TType.st --- a/compiler/TType.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TType.st Wed Aug 26 07:51:18 2015 +0100 @@ -9,6 +9,21 @@ category:'Languages-Tea-Compiler-Types' ! + +!TType methodsFor:'comparing'! + += anotherType + ^ self subclassResponsibility + + "Created: / 25-08-2015 / 23:34:29 / Jan Vrany " +! + +hash + ^ self subclassResponsibility + + "Created: / 25-08-2015 / 23:33:59 / Jan Vrany " +! ! + !TType methodsFor:'operations'! union: aTType @@ -43,3 +58,13 @@ ^ false ! ! +!TType class methodsFor:'documentation'! + +version + ^ 'Path: jv/tea/compiler/TType.st, Version: 1.0, User: jv, Time: 2015-08-26T07:46:38.380+01' +! + +version_HG + ^ 'Path: jv/tea/compiler/TType.st, Version: 1.0, User: jv, Time: 2015-08-26T07:46:38.380+01' +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TTypeChecker.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TTypeChecker.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,21 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TProgramNodeVisitor subclass:#TTypeChecker + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Analysis' +! + +!TTypeChecker methodsFor:'visitor-double dispatching'! + +acceptReturnNode: aReturnNode + aReturnNode binding type = aReturnNode topNode binding type returnType ifFalse:[ + self error: 'Type mismatch'. + ]. + + "Created: / 25-08-2015 / 23:40:48 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TTypeNode.st --- a/compiler/TTypeNode.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TTypeNode.st Wed Aug 26 07:51:18 2015 +0100 @@ -9,7 +9,6 @@ category:'Languages-Tea-Compiler-AST' ! - !TTypeNode class methodsFor:'accessing'! formatterClass @@ -28,10 +27,11 @@ ^ self == TTypeNode. ! ! -!TTypeNode class methodsFor:'documentation'! +!TTypeNode methodsFor:'conversion'! -version_HG +asType + ^ self subclassResponsibility - ^ '$Changeset: $' + "Created: / 25-08-2015 / 22:47:26 / Jan Vrany " ! ! diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TTypeSpecNode.st --- a/compiler/TTypeSpecNode.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TTypeSpecNode.st Wed Aug 26 07:51:18 2015 +0100 @@ -43,6 +43,14 @@ type := aTTypeNode. ! ! +!TTypeSpecNode methodsFor:'converting'! + +asType + ^ type asType + + "Created: / 25-08-2015 / 22:47:09 / Jan Vrany " +! ! + !TTypeSpecNode methodsFor:'visitor'! acceptVisitor: aProgramNodeVisitor diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TUnionType.st --- a/compiler/TUnionType.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TUnionType.st Wed Aug 26 07:51:18 2015 +0100 @@ -15,6 +15,12 @@ ^ self new initializeWith: type1 and: type2 "Created: / 21-08-2015 / 18:38:21 / Jan Vrany " +! + +withAll: types + ^ self new initializeWithAll: types + + "Created: / 25-08-2015 / 22:51:01 / Jan Vrany " ! ! !TUnionType methodsFor:'accessing'! @@ -23,6 +29,18 @@ ^ types ! ! +!TUnionType methodsFor:'comparing'! + +hash + | h | + + h := types size. + types do:[:type | h := h bitXor: type hash ]. + ^ h + + "Created: / 25-08-2015 / 23:35:28 / Jan Vrany " +! ! + !TUnionType methodsFor:'initialization'! initializeWith: type1 with: type2 @@ -34,6 +52,18 @@ ifFalse:[ types := types copyWith: type2 ]. "Created: / 21-08-2015 / 18:39:44 / Jan Vrany " +! + +initializeWithAll: aCollection + types := OrderedCollection new: aCollection size. + aCollection do:[:type | + type isUnionType + ifTrue:[ types addAll: type types ] + ifFalse:[types add: type ]. + ]. + types := types asArray. + + "Created: / 25-08-2015 / 22:50:48 / Jan Vrany " ! ! !TUnionType methodsFor:'testing'! diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TUnionTypeNode.st --- a/compiler/TUnionTypeNode.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/TUnionTypeNode.st Wed Aug 26 07:51:18 2015 +0100 @@ -39,6 +39,16 @@ types := something. ! ! +!TUnionTypeNode methodsFor:'conversion'! + +asType + "superclass TTypeNode says that I am responsible to implement this method" + + ^ TUnionType withAll: (types collect:[:e|e asType]) + + "Modified: / 25-08-2015 / 22:51:30 / Jan Vrany " +! ! + !TUnionTypeNode methodsFor:'visitor'! acceptVisitor: aProgramNodeVisitor diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TValueBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TValueBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,21 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TBinding subclass:#TValueBinding + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + +!TValueBinding class methodsFor:'queries'! + +isAbstract + "Return if this class is an abstract class. + True is returned here for myself only; false for subclasses. + Abstract subclasses must redefine again." + + ^ self == TValueBinding. +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/TVariableBinding.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/TVariableBinding.st Wed Aug 26 07:51:18 2015 +0100 @@ -0,0 +1,58 @@ +"{ Package: 'jv:tea/compiler' }" + +"{ NameSpace: Smalltalk }" + +TValueBinding subclass:#TVariableBinding + instanceVariableNames:'name' + classVariableNames:'' + poolDictionaries:'' + category:'Languages-Tea-Compiler-Bindings' +! + +!TVariableBinding class methodsFor:'instance creation'! + +type:aTType name:aString + ^ self new initializeWithType:aTType name:aString + + "Created: / 25-08-2015 / 22:46:00 / Jan Vrany " +! ! + +!TVariableBinding class methodsFor:'queries'! + +isAbstract + "Return if this class is an abstract class. + True is returned here for myself only; false for subclasses. + Abstract subclasses must redefine again." + + ^ self == TVariableBinding. +! ! + +!TVariableBinding methodsFor:'accessing'! + +name + ^ name +! ! + +!TVariableBinding methodsFor:'initialization'! + +initializeWithType:aTType name:aString + name := aString. + type := aTType. + + "Created: / 25-08-2015 / 22:45:27 / Jan Vrany " +! ! + +!TVariableBinding methodsFor:'printing & storing'! + +printOn:aStream + aStream nextPutAll: name. + aStream space. + type notNil ifTrue:[ + type printOn: aStream + ] ifFalse:[ + aStream nextPutAll: '< ??? >' + ]. + + "Modified: / 25-08-2015 / 22:54:09 / Jan Vrany " +! ! + diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/abbrev.stc --- a/compiler/abbrev.stc Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/abbrev.stc Wed Aug 26 07:51:18 2015 +0100 @@ -1,15 +1,29 @@ # automagically generated by the project definition # this file is needed for stc to be able to compile modules independently. # it provides information about a classes filename, category and especially namespace. +TBinding TBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 +TClass TClass jv:tea/compiler 'Languages-Tea-Compiler-Model' 0 TCompiler TCompiler jv:tea/compiler 'Languages-Tea-Compiler' 0 TFormatter TFormatter jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 +TMetaclass TMetaclass jv:tea/compiler 'Languages-Tea-Compiler-Model' 0 +TMethod TMethod jv:tea/compiler 'Languages-Tea-Compiler-Model' 0 TParser TParser jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 +TParserTests TParserTests jv:tea/compiler 'Languages-Tea-Compiler-AST-Tests' 1 +TProgramNodeVisitor TProgramNodeVisitor jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 +TScope TScope jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 TType TType jv:tea/compiler 'Languages-Tea-Compiler-Types' 0 TTypeNode TTypeNode jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 TTypeSpecNode TTypeSpecNode jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 jv_tea_compiler jv_tea_compiler jv:tea/compiler '* Projects & Packages *' 3 +TFunctionBinding TFunctionBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 +TSemanticAnalyzer TSemanticAnalyzer jv:tea/compiler 'Languages-Tea-Compiler-Analysis' 0 TSimpleType TSimpleType jv:tea/compiler 'Languages-Tea-Compiler-Types' 0 TSimpleTypeNode TSimpleTypeNode jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 +TTypeChecker TTypeChecker jv:tea/compiler 'Languages-Tea-Compiler-Analysis' 0 TUnionType TUnionType jv:tea/compiler 'Languages-Tea-Compiler-Types' 0 TUnionTypeNode TUnionTypeNode jv:tea/compiler 'Languages-Tea-Compiler-AST' 0 -TParserTests TParserTests jv:tea/compiler 'Languages-Tea-Compiler-AST-Tests' 1 +TValueBinding TValueBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 +TConstantBinding TConstantBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 +TVariableBinding TVariableBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 +TArgumentBinding TArgumentBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 +TLocalBinding TLocalBinding jv:tea/compiler 'Languages-Tea-Compiler-Bindings' 0 diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/bc.mak --- a/compiler/bc.mak Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/bc.mak Wed Aug 26 07:51:18 2015 +0100 @@ -35,7 +35,7 @@ -LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic +LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic LOCALDEFINES= STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -varPrefix=$(LIBNAME) @@ -52,6 +52,7 @@ # build all mandatory prerequisite packages (containing superclasses) for this package prereq: pushd ..\..\..\stx\libbasic & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " + pushd ..\..\..\stx\goodies\refactoryBrowser\helpers & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\..\..\stx\goodies\refactoryBrowser\parser & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\..\..\stx\libbasic2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\..\..\stx\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " @@ -73,18 +74,32 @@ # BEGINMAKEDEPEND --- do not remove this line; make depend needs it +$(OUTDIR)TBinding.$(O) TBinding.$(H): TBinding.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TClass.$(O) TClass.$(H): TClass.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBAbstractClass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBClass.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TCompiler.$(O) TCompiler.$(H): TCompiler.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TFormatter.$(O) TFormatter.$(H): TFormatter.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBFormatter.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TMetaclass.$(O) TMetaclass.$(H): TMetaclass.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBAbstractClass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBMetaclass.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TMethod.$(O) TMethod.$(H): TMethod.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBMethod.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TParser.$(O) TParser.$(H): TParser.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBParser.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TProgramNodeVisitor.$(O) TProgramNodeVisitor.$(H): TProgramNodeVisitor.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TScope.$(O) TScope.$(H): TScope.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TType.$(O) TType.$(H): TType.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TTypeNode.$(O) TTypeNode.$(H): TTypeNode.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TTypeSpecNode.$(O) TTypeSpecNode.$(H): TTypeSpecNode.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)jv_tea_compiler.$(O) jv_tea_compiler.$(H): jv_tea_compiler.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR) +$(OUTDIR)TFunctionBinding.$(O) TFunctionBinding.$(H): TFunctionBinding.st $(INCLUDE_TOP)\jv\tea\compiler\TBinding.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TSemanticAnalyzer.$(O) TSemanticAnalyzer.$(H): TSemanticAnalyzer.st $(INCLUDE_TOP)\jv\tea\compiler\TProgramNodeVisitor.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TSimpleType.$(O) TSimpleType.$(H): TSimpleType.st $(INCLUDE_TOP)\jv\tea\compiler\TType.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TSimpleTypeNode.$(O) TSimpleTypeNode.$(H): TSimpleTypeNode.st $(INCLUDE_TOP)\jv\tea\compiler\TTypeNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TTypeChecker.$(O) TTypeChecker.$(H): TTypeChecker.st $(INCLUDE_TOP)\jv\tea\compiler\TProgramNodeVisitor.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNodeVisitor.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TUnionType.$(O) TUnionType.$(H): TUnionType.st $(INCLUDE_TOP)\jv\tea\compiler\TType.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) $(OUTDIR)TUnionTypeNode.$(O) TUnionTypeNode.$(H): TUnionTypeNode.st $(INCLUDE_TOP)\jv\tea\compiler\TTypeNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) -$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBBlockNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBMethodNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBStatementNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBValueNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBVariableNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TValueBinding.$(O) TValueBinding.$(H): TValueBinding.st $(INCLUDE_TOP)\jv\tea\compiler\TBinding.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TConstantBinding.$(O) TConstantBinding.$(H): TConstantBinding.st $(INCLUDE_TOP)\jv\tea\compiler\TBinding.$(H) $(INCLUDE_TOP)\jv\tea\compiler\TValueBinding.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TVariableBinding.$(O) TVariableBinding.$(H): TVariableBinding.st $(INCLUDE_TOP)\jv\tea\compiler\TBinding.$(H) $(INCLUDE_TOP)\jv\tea\compiler\TValueBinding.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TArgumentBinding.$(O) TArgumentBinding.$(H): TArgumentBinding.st $(INCLUDE_TOP)\jv\tea\compiler\TBinding.$(H) $(INCLUDE_TOP)\jv\tea\compiler\TValueBinding.$(H) $(INCLUDE_TOP)\jv\tea\compiler\TVariableBinding.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)TLocalBinding.$(O) TLocalBinding.$(H): TLocalBinding.st $(INCLUDE_TOP)\jv\tea\compiler\TBinding.$(H) $(INCLUDE_TOP)\jv\tea\compiler\TValueBinding.$(H) $(INCLUDE_TOP)\jv\tea\compiler\TVariableBinding.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) +$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBBlockNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBMethodNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBProgramNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBReturnNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBStatementNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBValueNode.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser\RBVariableNode.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR) # ENDMAKEDEPEND --- do not remove this line diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/extensions.st --- a/compiler/extensions.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/extensions.st Wed Aug 26 07:51:18 2015 +0100 @@ -21,6 +21,22 @@ "Created: / 21-08-2015 / 22:48:55 / Jan Vrany " ! ! +!RBBlockNode methodsFor:'accessing'! + +scope + ^ self propertyAt: #scope + + "Created: / 25-08-2015 / 22:14:17 / Jan Vrany " +! ! + +!RBBlockNode methodsFor:'accessing'! + +scope: aTScope + ^ self propertyAt: #scope put: aTScope + + "Created: / 25-08-2015 / 22:14:33 / Jan Vrany " +! ! + !RBMethodNode methodsFor:'accessing'! returnTypeSpec @@ -42,6 +58,62 @@ "Created: / 21-08-2015 / 22:48:55 / Jan Vrany " ! ! +!RBMethodNode methodsFor:'accessing'! + +scope + ^ self propertyAt: #scope + + "Created: / 25-08-2015 / 22:14:17 / Jan Vrany " +! ! + +!RBMethodNode methodsFor:'accessing'! + +scope: aTScope + ^ self propertyAt: #scope put: aTScope + + "Created: / 25-08-2015 / 22:14:33 / Jan Vrany " +! ! + +!RBProgramNode methodsFor:'accessing'! + +binding + ^ self propertyAt: #binding + + "Created: / 25-08-2015 / 22:15:35 / Jan Vrany " +! ! + +!RBProgramNode methodsFor:'accessing'! + +binding: aTBinding + self propertyAt: #binding put: aTBinding + + "Created: / 25-08-2015 / 22:15:44 / Jan Vrany " +! ! + +!RBProgramNode methodsFor:'accessing'! + +scope + ^ self parent scope + + "Created: / 25-08-2015 / 22:13:34 / Jan Vrany " +! ! + +!RBReturnNode methodsFor:'accessing'! + +binding + ^ value binding + + "Created: / 25-08-2015 / 23:38:56 / Jan Vrany " +! ! + +!RBReturnNode methodsFor:'accessing'! + +binding: aTBinding + self shouldNotImplement + + "Created: / 25-08-2015 / 23:39:05 / Jan Vrany " +! ! + !RBVariableNode methodsFor:'accessing'! typeSpec diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/jv_tea_compiler.st --- a/compiler/jv_tea_compiler.st Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/jv_tea_compiler.st Wed Aug 26 07:51:18 2015 +0100 @@ -30,9 +30,10 @@ by searching along the inheritance chain of all of my classes." ^ #( + #'stx:goodies/refactoryBrowser/helpers' "RBAbstractClass - superclass of TClass" #'stx:goodies/refactoryBrowser/parser' "RBBlockNode - extended" #'stx:goodies/sunit' "TestAsserter - superclass of TParserTests" - #'stx:libbasic' "CompiledCode - superclass of TMethod" + #'stx:libbasic' "LibraryDefinition - superclass of jv_tea_compiler" ) ! @@ -70,18 +71,32 @@ ^ #( " or ( attributes...) in load order" + TBinding + TClass TCompiler TFormatter + TMetaclass + TMethod TParser + (TParserTests autoload) + TProgramNodeVisitor + TScope TType TTypeNode TTypeSpecNode #'jv_tea_compiler' + TFunctionBinding + TSemanticAnalyzer TSimpleType TSimpleTypeNode + TTypeChecker TUnionType TUnionTypeNode - (TParserTests autoload) + TValueBinding + TConstantBinding + TVariableBinding + TArgumentBinding + TLocalBinding ) ! @@ -96,6 +111,15 @@ RBMethodNode returnTypeSpec: RBVariableNode typeSpec RBVariableNode typeSpec: + RBBlockNode scope + RBBlockNode scope: + RBMethodNode scope + RBMethodNode scope: + RBProgramNode binding + RBProgramNode binding: + RBProgramNode scope + RBReturnNode binding + RBReturnNode binding: ) ! ! diff -r 2a3e47c13905 -r 97ee341d3e9f compiler/libInit.cc --- a/compiler/libInit.cc Tue Aug 25 19:05:18 2015 +0100 +++ b/compiler/libInit.cc Wed Aug 26 07:51:18 2015 +0100 @@ -27,17 +27,31 @@ void _libjv_tea_compiler_Init(pass, __pRT__, snd) OBJ snd; struct __vmData__ *__pRT__; { __BEGIN_PACKAGE2__("libjv_tea_compiler", _libjv_tea_compiler_Init, "jv:tea/compiler"); +_TBinding_Init(pass,__pRT__,snd); +_TClass_Init(pass,__pRT__,snd); _TCompiler_Init(pass,__pRT__,snd); _TFormatter_Init(pass,__pRT__,snd); +_TMetaclass_Init(pass,__pRT__,snd); +_TMethod_Init(pass,__pRT__,snd); _TParser_Init(pass,__pRT__,snd); +_TProgramNodeVisitor_Init(pass,__pRT__,snd); +_TScope_Init(pass,__pRT__,snd); _TType_Init(pass,__pRT__,snd); _TTypeNode_Init(pass,__pRT__,snd); _TTypeSpecNode_Init(pass,__pRT__,snd); _jv_137tea_137compiler_Init(pass,__pRT__,snd); +_TFunctionBinding_Init(pass,__pRT__,snd); +_TSemanticAnalyzer_Init(pass,__pRT__,snd); _TSimpleType_Init(pass,__pRT__,snd); _TSimpleTypeNode_Init(pass,__pRT__,snd); +_TTypeChecker_Init(pass,__pRT__,snd); _TUnionType_Init(pass,__pRT__,snd); _TUnionTypeNode_Init(pass,__pRT__,snd); +_TValueBinding_Init(pass,__pRT__,snd); +_TConstantBinding_Init(pass,__pRT__,snd); +_TVariableBinding_Init(pass,__pRT__,snd); +_TArgumentBinding_Init(pass,__pRT__,snd); +_TLocalBinding_Init(pass,__pRT__,snd); _jv_137tea_137compiler_extensions_Init(pass,__pRT__,snd); __END_PACKAGE__();