1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00

Merge branch 'heap-frames' of https://github.com/github/semantic into heap-frames

This commit is contained in:
joshvera 2018-10-30 10:38:37 -04:00
commit dca1810076

View File

@ -210,22 +210,21 @@ instance Evaluatable Class where
supers <- for classSuperclasses $ \superclass -> do
name <- maybeM (throwEvalError NoNameError) (declaredName (subterm superclass))
scope <- associatedScope (Declaration name)
(scope,) <$> subtermAddress superclass
associatedScope (Declaration name)
let imports = (Import,) <$> (fmap pure . catMaybes $ fst <$> supers)
current = maybe mempty (fmap (Lexical, ) . pure . pure) currentScope'
edges = Map.fromList (imports <> current)
childScope <- newScope edges
declare (Declaration name) span (Just childScope)
-- let imports = (Import,) <$> (fmap pure . catMaybes $ supers)
-- current = maybe mempty (fmap (Lexical, ) . pure . pure) currentScope'
-- edges = Map.fromList (imports <> current)
-- childScope <- newScope edges
-- declare (Declaration name) span (Just childScope)
withScope childScope $ do
(_, addr) <- letrec name $ do
void $ subtermValue classBody
classBinds <- Env.head <$> getEnv
klass name (snd <$> supers) classBinds
bind name addr
pure (Rval addr)
-- withScope childScope $ do
-- (_, addr) <- letrec name $ do
-- void $ subtermValue classBody
-- classBinds <- Env.head <$> getEnv
-- klass (Declaration name) (catMaybes supers) classBinds -- TODO: Update klass definition
-- pure (Rval addr)
rvalBox unit
-- | A decorator in Python
data Decorator a = Decorator { decoratorIdentifier :: !a, decoratorParamaters :: ![a], decoratorBody :: !a }
@ -301,9 +300,11 @@ instance Show1 TypeAlias where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable TypeAlias where
eval TypeAlias{..} = do
name <- maybeM (throwEvalError NoNameError) (declaredName (subterm typeAliasIdentifier))
addr <- subtermAddress typeAliasKind
bind name addr
pure (Rval addr)
kindName <- maybeM (throwEvalError NoNameError) (declaredName (subterm typeAliasKind))
span <- ask @Span
address <- declare (Declaration name) span Nothing -- TODO: Also need to declare the alias via an Alias edge?
kindAddress <- lookupDeclaration (Declaration kindName) -- TODO: Validate the path? Also assumes the type is declared.
rvalBox unit -- TODO: Return Address here?
instance Declarations a => Declarations (TypeAlias a) where
declaredName TypeAlias{..} = declaredName typeAliasIdentifier