mirror of
https://github.com/github/semantic.git
synced 2025-01-01 19:55:34 +03:00
Update remaining declarations
This commit is contained in:
parent
869789ce48
commit
92d540dac7
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user