mirror of
https://github.com/github/semantic.git
synced 2024-12-01 09:15:01 +03:00
Declare __self in Method instance
Co-Authored-By: Rob Rix <rob.rix@github.com>
This commit is contained in:
parent
793ec4b32d
commit
ac1d2dbc95
@ -13,6 +13,7 @@ import Prologue
|
||||
import Proto3.Suite.Class
|
||||
import Reprinting.Tokenize
|
||||
import Data.Span (emptySpan)
|
||||
import Data.Abstract.Name as Name
|
||||
|
||||
data Function a = Function { functionContext :: ![a], functionName :: !a, functionParameters :: ![a], functionBody :: !a }
|
||||
deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, ToJSONFields1, Named1, Message1, NFData1)
|
||||
@ -80,9 +81,12 @@ instance Evaluatable Method where
|
||||
associatedScope <- newScope lexicalEdges
|
||||
declare (Declaration name) span (Just associatedScope)
|
||||
|
||||
params <- withScope associatedScope . for methodParameters $ \paramNode -> do
|
||||
param <- maybeM (throwEvalError NoNameError) (declaredName paramNode)
|
||||
param <$ declare (Declaration param) span Nothing
|
||||
params <- withScope associatedScope $ do
|
||||
let self = Name.name "__self"
|
||||
declare (Declaration self) emptySpan Nothing
|
||||
fmap (self :) . for methodParameters $ \paramNode -> do
|
||||
param <- maybeM (throwEvalError NoNameError) (declaredName paramNode)
|
||||
param <$ declare (Declaration param) span Nothing
|
||||
|
||||
addr <- lookupDeclaration (Declaration name)
|
||||
v <- function name params methodBody associatedScope
|
||||
|
Loading…
Reference in New Issue
Block a user