From 025a04595a432ce69d918776be8f3ca71f8f2e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 24 Jan 2024 09:52:41 -0800 Subject: [PATCH] expose the whole checker, not just the elaboration --- tools/analysis/analysis_test.go | 9 ++++----- tools/analysis/program.go | 8 ++++---- tools/analysis/programs.go | 18 +++++++++--------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index e7f1121ef9..779cf921bf 100644 --- a/tools/analysis/analysis_test.go +++ b/tools/analysis/analysis_test.go @@ -25,12 +25,11 @@ import ( "github.com/stretchr/testify/require" - "github.com/onflow/cadence/runtime/parser" - "github.com/onflow/cadence/runtime/tests/checker" - "github.com/onflow/cadence/runtime/ast" "github.com/onflow/cadence/runtime/common" + "github.com/onflow/cadence/runtime/parser" "github.com/onflow/cadence/runtime/sema" + "github.com/onflow/cadence/runtime/tests/checker" "github.com/onflow/cadence/tools/analysis" ) @@ -102,7 +101,7 @@ func TestNeedSyntaxAndImport(t *testing.T) { for _, program := range programs { require.NotNil(t, program.Program) - require.NotNil(t, program.Elaboration) + require.NotNil(t, program.Checker) // Run a simple analysis: Detect unnecessary cast @@ -114,7 +113,7 @@ func TestNeedSyntaxAndImport(t *testing.T) { return true } - types := program.Elaboration.CastingExpressionTypes(castingExpression) + types := program.Checker.Elaboration.CastingExpressionTypes(castingExpression) leftHandType := types.StaticValueType rightHandType := types.TargetType diff --git a/tools/analysis/program.go b/tools/analysis/program.go index d48abb4a95..b4612a01e4 100644 --- a/tools/analysis/program.go +++ b/tools/analysis/program.go @@ -27,10 +27,10 @@ import ( ) type Program struct { - Location common.Location - Program *ast.Program - Elaboration *sema.Elaboration - Code []byte + Location common.Location + Program *ast.Program + Checker *sema.Checker + Code []byte } // Run runs the given DAG of analyzers in parallel diff --git a/tools/analysis/programs.go b/tools/analysis/programs.go index 4985cedd01..2aaa20e13a 100644 --- a/tools/analysis/programs.go +++ b/tools/analysis/programs.go @@ -72,19 +72,19 @@ func (programs Programs) load( return wrapError(err) } - var elaboration *sema.Elaboration + var checker *sema.Checker if config.Mode&NeedTypes != 0 { - elaboration, err = programs.check(config, program, location, seenImports) + checker, err = programs.check(config, program, location, seenImports) if err != nil { return wrapError(err) } } programs[location] = &Program{ - Location: location, - Code: code, - Program: program, - Elaboration: elaboration, + Location: location, + Code: code, + Program: program, + Checker: checker, } return nil @@ -96,7 +96,7 @@ func (programs Programs) check( location common.Location, seenImports importResolutionResults, ) ( - *sema.Elaboration, + *sema.Checker, error, ) { baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) @@ -145,7 +145,7 @@ func (programs Programs) check( return nil, err } - elaboration = programs[importedLocation].Elaboration + elaboration = programs[importedLocation].Checker.Elaboration } return sema.ElaborationImport{ @@ -163,5 +163,5 @@ func (programs Programs) check( return nil, err } - return checker.Elaboration, nil + return checker, nil }