From 5a6d4664e4417763b4a7d9f215e42102fa1b3fd4 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 28 Jul 2022 22:11:02 +0000 Subject: Compile type declarations correctly --- pkg/lang/compiler/scope/scope_chain.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/lang/compiler/scope/scope_chain.go') diff --git a/pkg/lang/compiler/scope/scope_chain.go b/pkg/lang/compiler/scope/scope_chain.go index 1b83c75..f386017 100644 --- a/pkg/lang/compiler/scope/scope_chain.go +++ b/pkg/lang/compiler/scope/scope_chain.go @@ -72,6 +72,16 @@ func (sc *ScopeChain) EnterFunction(unit code.Marker) { sc.functionScopes = append(sc.functionScopes, NewFunctionScope(sc.CurrentScopeID(), unit)) } +func (sc *ScopeChain) EnterConstructor(unit code.Marker, thisLocal int) { + sc.Enter() + sc.functionScopes = append(sc.functionScopes, NewMethodFunctionScope(sc.CurrentScopeID(), unit, thisLocal)) +} + +func (sc *ScopeChain) EnterMethod(unit code.Marker) { + sc.Enter() + sc.functionScopes = append(sc.functionScopes, NewMethodFunctionScope(sc.CurrentScopeID(), unit, -1)) +} + func (sc *ScopeChain) EnterLoop() (code.Marker, code.Marker) { parentMarker := sc.CreateAnonymousFunctionSubUnit() -- cgit 1.4.1