about summary refs log tree commit diff
path: root/pkg/lang/compiler/scope/scopes.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/compiler/scope/scopes.go')
-rw-r--r--pkg/lang/compiler/scope/scopes.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/lang/compiler/scope/scopes.go b/pkg/lang/compiler/scope/scopes.go
index 39e48ef..5cfcd5d 100644
--- a/pkg/lang/compiler/scope/scopes.go
+++ b/pkg/lang/compiler/scope/scopes.go
@@ -9,6 +9,7 @@ type ScopeKind int
 const (
 	ScopeKindNormal ScopeKind = iota
 	ScopeKindFunction
+	ScopeKindLoop
 )
 
 type SymbolScope struct {
@@ -48,3 +49,29 @@ func (sf FunctionScope) Unit() code.Marker {
 func (sf FunctionScope) IsRootScope() bool {
 	return sf.ID() == ScopeID(0)
 }
+
+type LoopScope struct {
+	id             ScopeID
+	breakMarker    code.Marker
+	continueMarker code.Marker
+}
+
+func NewLoopScope(id ScopeID, breakMarker code.Marker, continueMarker code.Marker) LoopScope {
+	return LoopScope{
+		id:             id,
+		breakMarker:    breakMarker,
+		continueMarker: continueMarker,
+	}
+}
+
+func (sl LoopScope) ID() ScopeID {
+	return sl.id
+}
+
+func (sl LoopScope) BreakMarker() code.Marker {
+	return sl.breakMarker
+}
+
+func (sl LoopScope) ContinueMarker() code.Marker {
+	return sl.continueMarker
+}