From 92d540dac7393a95e5e7519eba83df6b3ac3dbc5 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Dec 2018 16:58:33 -0800 Subject: [PATCH] Update remaining declarations --- src/Data/Syntax/Statement.hs | 2 +- src/Language/Go/Syntax.hs | 2 +- src/Language/Python/Syntax.hs | 6 +++--- src/Language/Ruby/Syntax.hs | 6 +++--- src/Language/TypeScript/Syntax/JSX.hs | 3 ++- src/Language/TypeScript/Syntax/JavaScript.hs | 2 +- src/Language/TypeScript/Syntax/TypeScript.hs | 8 ++++---- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Data/Syntax/Statement.hs b/src/Data/Syntax/Statement.hs index f79553ca3..8cd7582c0 100644 --- a/src/Data/Syntax/Statement.hs +++ b/src/Data/Syntax/Statement.hs @@ -151,7 +151,7 @@ instance Evaluatable Let where assocScope <- associatedScope (Declaration valueName) _ <- withLexicalScopeAndFrame $ do - declare (Declaration name) letSpan assocScope + declare (Declaration name) Default letSpan assocScope letVal <- eval letValue slot <- lookupDeclaration (Declaration name) assign slot letVal diff --git a/src/Language/Go/Syntax.hs b/src/Language/Go/Syntax.hs index 7925517db..a3c0c264f 100644 --- a/src/Language/Go/Syntax.hs +++ b/src/Language/Go/Syntax.hs @@ -85,7 +85,7 @@ instance Evaluatable QualifiedImport where alias <- maybeM (throwEvalError $ NoNameError aliasTerm) (declaredName aliasTerm) span <- ask @Span scopeAddress <- newScope mempty - declare (Declaration alias) span (Just scopeAddress) + declare (Declaration alias) Default span (Just scopeAddress) aliasSlot <- lookupDeclaration (Declaration alias) withScope scopeAddress $ do diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index 3301d24e4..02d5d9122 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -148,7 +148,7 @@ instance Evaluatable Import where aliasFrame <- newFrame importScope (Map.singleton ScopeGraph.Import scopeMap) -- Add declaration of the alias name to the current scope (within our current module). - declare (Declaration aliasName) span (Just importScope) + declare (Declaration aliasName) Default span (Just importScope) -- Retrieve the frame slot for the new declaration. aliasSlot <- lookupDeclaration (Declaration aliasName) assign aliasSlot =<< object aliasFrame @@ -219,7 +219,7 @@ instance Evaluatable QualifiedImport where go ((name, modulePath) : namesAndPaths) = do span <- ask @Span scopeAddress <- newScope mempty - declare (Declaration name) span (Just scopeAddress) + declare (Declaration name) Default span (Just scopeAddress) aliasSlot <- lookupDeclaration (Declaration name) -- a.b.c withScope scopeAddress $ @@ -255,7 +255,7 @@ instance Evaluatable QualifiedAliasedImport where span <- ask @Span scopeAddress <- newScope mempty alias <- maybeM (throwEvalError $ NoNameError aliasTerm) (declaredName aliasTerm) - declare (Declaration alias) span (Just scopeAddress) + declare (Declaration alias) Default span (Just scopeAddress) objFrame <- newFrame scopeAddress mempty val <- object objFrame aliasSlot <- lookupDeclaration (Declaration alias) diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index a1757a14a..1703238d9 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -221,7 +221,7 @@ instance Evaluatable Class where current = (Lexical, ) <$> pure (pure currentScope') edges = Map.fromList (superclassEdges <> current) classScope <- newScope edges - declare (Declaration name) span (Just classScope) + declare (Declaration name) Default span (Just classScope) let frameEdges = Map.singleton Superclass (Map.fromList (catMaybes superScopes)) childFrame <- newFrame classScope frameEdges @@ -274,7 +274,7 @@ instance Evaluatable Module where Nothing -> do let edges = Map.singleton Lexical [ currentScope' ] classScope <- newScope edges - declare (Declaration name) span (Just classScope) + declare (Declaration name) Default span (Just classScope) currentFrame' <- currentFrame let frameEdges = Map.singleton Lexical (Map.singleton currentScope' currentFrame') @@ -350,7 +350,7 @@ instance Evaluatable Assignment where lhsName <- maybeM (throwEvalError $ NoNameError assignmentTarget) (declaredName assignmentTarget) maybeSlot <- maybeLookupDeclaration (Declaration lhsName) assignmentSpan <- ask @Span - maybe (declare (Declaration lhsName) assignmentSpan Nothing) (const (pure ())) maybeSlot + maybe (declare (Declaration lhsName) Default assignmentSpan Nothing) (const (pure ())) maybeSlot lhs <- ref assignmentTarget rhs <- eval assignmentValue diff --git a/src/Language/TypeScript/Syntax/JSX.hs b/src/Language/TypeScript/Syntax/JSX.hs index 2441198bf..3cc75d03f 100644 --- a/src/Language/TypeScript/Syntax/JSX.hs +++ b/src/Language/TypeScript/Syntax/JSX.hs @@ -98,7 +98,8 @@ instance Evaluatable RequiredParameter where eval eval ref RequiredParameter{..} = do name <- maybeM (throwEvalError $ NoNameError requiredParameterSubject) (declaredName requiredParameterSubject) span <- ask @Span - declare (Declaration name) span Nothing + -- TODO: Should we specify function parameters with a special Relation? + declare (Declaration name) Default span Nothing lhs <- ref requiredParameterSubject rhs <- eval requiredParameterValue diff --git a/src/Language/TypeScript/Syntax/JavaScript.hs b/src/Language/TypeScript/Syntax/JavaScript.hs index 3ec487828..6ab14b546 100644 --- a/src/Language/TypeScript/Syntax/JavaScript.hs +++ b/src/Language/TypeScript/Syntax/JavaScript.hs @@ -31,7 +31,7 @@ instance Evaluatable JavaScriptRequire where Just alias -> do span <- ask @Span importScope <- newScope (Map.singleton ScopeGraph.Import [ moduleScope ]) - declare (Declaration alias) span (Just importScope) + declare (Declaration alias) Default span (Just importScope) let scopeMap = Map.singleton moduleScope moduleFrame aliasFrame <- newFrame importScope (Map.singleton ScopeGraph.Import scopeMap) aliasSlot <- lookupDeclaration (Declaration alias) diff --git a/src/Language/TypeScript/Syntax/TypeScript.hs b/src/Language/TypeScript/Syntax/TypeScript.hs index 4c568208f..692651362 100644 --- a/src/Language/TypeScript/Syntax/TypeScript.hs +++ b/src/Language/TypeScript/Syntax/TypeScript.hs @@ -68,7 +68,7 @@ instance Evaluatable QualifiedAliasedImport where aliasFrame <- newFrame importScope (Map.singleton ScopeGraph.Import scopeMap) alias <- maybeM (throwEvalError $ NoNameError aliasTerm) (declaredName aliasTerm) - declare (Declaration alias) span (Just importScope) + declare (Declaration alias) Default span (Just importScope) aliasSlot <- lookupDeclaration (Declaration alias) assign aliasSlot =<< object aliasFrame @@ -159,7 +159,7 @@ instance Evaluatable DefaultExport where withScopeAndFrame exportFrame $ do valueRef <- eval term let declaration = Declaration $ Name.name "__default" - declare declaration exportSpan Nothing + declare declaration Default exportSpan Nothing defaultSlot <- lookupDeclaration declaration assign defaultSlot valueRef @@ -598,7 +598,7 @@ declareModule eval identifier statements = do Nothing -> do let edges = Map.singleton Lexical [ currentScope' ] childScope <- newScope edges - declare (Declaration name) span (Just childScope) + declare (Declaration name) Default span (Just childScope) currentFrame' <- currentFrame let frameEdges = Map.singleton Lexical (Map.singleton currentScope' currentFrame') @@ -676,7 +676,7 @@ instance Evaluatable AbstractClass where current = (Lexical, ) <$> pure (pure currentScope') edges = Map.fromList (superclassEdges <> current) classScope <- newScope edges - declare (Declaration name) span (Just classScope) + declare (Declaration name) Default span (Just classScope) let frameEdges = Map.singleton Superclass (Map.fromList (catMaybes superScopes)) childFrame <- newFrame classScope frameEdges