mirror of
https://github.com/github/semantic.git
synced 2024-12-18 20:31:55 +03:00
make variable return address, not value
This commit is contained in:
parent
c358460155
commit
a9958fcc5f
@ -113,14 +113,13 @@ letrec' name body = do
|
||||
|
||||
|
||||
-- | Look up and dereference the given 'Name', throwing an exception for free variables.
|
||||
variable :: ( Member (Allocator address value) effects
|
||||
, Member (Reader (Environment address)) effects
|
||||
variable :: ( Member (Reader (Environment address)) effects
|
||||
, Member (Resumable (EnvironmentError address)) effects
|
||||
, Member (State (Environment address)) effects
|
||||
)
|
||||
=> Name
|
||||
-> Evaluator address value effects value
|
||||
variable name = lookupEnv name >>= maybeM (freeVariableError name) >>= deref
|
||||
-> Evaluator address value effects address
|
||||
variable name = lookupEnv name >>= maybeM (freeVariableError name)
|
||||
|
||||
|
||||
-- Effects
|
||||
|
@ -53,4 +53,4 @@ defineBuiltins :: ( AbstractValue address value effects
|
||||
)
|
||||
=> Evaluator address value effects ()
|
||||
defineBuiltins =
|
||||
builtin "print" (lambda (\ v -> variable v >>= asString >>= trace . unpack >> box unit))
|
||||
builtin "print" (lambda (\ v -> variable v >>= deref >>= asString >>= trace . unpack >> box unit))
|
||||
|
@ -131,7 +131,7 @@ evaluatePackageWith analyzeModule analyzeTerm package
|
||||
evaluateEntryPoint m sym = runInModule (ModuleInfo m) . TermEvaluator $ do
|
||||
reqResult <- require m
|
||||
v <- maybe (box unit) (pure . snd) reqResult
|
||||
maybe (pure v) ((`call` []) <=< variable) sym
|
||||
maybe (pure v) ((`call` []) <=< deref <=< variable) sym
|
||||
|
||||
evalPrelude prelude = raiseHandler (runModules (runTermEvaluator . evalModule)) $ do
|
||||
_ <- runInModule moduleInfoFromCallStack (TermEvaluator (defineBuiltins *> (box unit)))
|
||||
|
@ -54,9 +54,9 @@ instance ToJSONFields1 Send
|
||||
instance Evaluatable Send where
|
||||
eval Send{..} = do
|
||||
let sel = case sendSelector of
|
||||
Just sel -> subtermValue sel
|
||||
Just sel -> subtermAddress sel
|
||||
Nothing -> variable (name "call")
|
||||
func <- maybe sel (deref <=< (flip evaluateInScopedEnv (sel >>= box) . subtermValue)) sendReceiver
|
||||
func <- deref =<< maybe sel (flip evaluateInScopedEnv sel . subtermValue) sendReceiver
|
||||
Rval <$> call func (map subtermAddress sendArgs) -- TODO pass through sendBlock
|
||||
|
||||
data Require a = Require { requireRelative :: Bool, requirePath :: !a }
|
||||
|
Loading…
Reference in New Issue
Block a user