Skip to content

Commit

Permalink
fix scopes code
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Jun 30, 2021
1 parent 4ab6572 commit 2f95c3c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/mana.backend.ishtar.generator/GeneratorExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public GeneratorContext LogError(string err, ExpressionSyntax exp)
return this;
}

public ManaScope CreateScope()
public IDisposable CreateScope()
{
if (CurrentScope is not null)
return CurrentScope.EnterScope();
CurrentScope = new ManaScope(this);
Scopes.Add(CurrentMethod, CurrentScope);
return CurrentScope;
return new ScopeTransit(CurrentScope);
}

public ManaClass ResolveType(TypeSyntax targetTypeTypeword)
Expand Down Expand Up @@ -164,12 +164,12 @@ public class CannotExistMainScopeException : Exception {}

public class ScopeTransit : IDisposable
{
private readonly ManaScope _scope;
public readonly ManaScope Scope;

public ScopeTransit(ManaScope scope) => _scope = scope;
public ScopeTransit(ManaScope scope) => Scope = scope;


public void Dispose() => _scope.ExitScope();
public void Dispose() => Scope.ExitScope();
}

public class ManaScope
Expand Down

0 comments on commit 2f95c3c

Please sign in to comment.