1%if false 2 Copyright (c) 2009 ETH Zurich. 3 All rights reserved. 4 5 This file is distributed under the terms in the attached LICENSE file. 6 If you do not find this file, copies can be found by writing to: 7 ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8%endif 9 10%include polycode.fmt 11 12%if false 13 14> module Libbarrelfish.HasDescendants where 15 16> import Semantics 17> import Constructs 18> import PureExpressions 19> import {-# SOURCE #-} Expressions 20 21> import IL.FoF.FoF 22> import IL.FoF.Compile 23> import IL.FoF.Run 24 25%endif 26 27\section{Has Descendants} 28 29The construct |HasDescendants| embeds the libarrelfish function 30@has_descendants@ into FoF. 31 32\subsection{Smart Constructors} 33 34This function is provided in two flavors: an anonymous one, which 35stores its result in an anonymous variable, and a named one, which 36allows you to name the resulting variable. 37 38> has_descendants :: PureExpr -> FoFCode PureExpr 39> has_descendants cte = inject (HasDescendants Nothing cte return) 40> 41> has_descendantsN :: String -> PureExpr -> FoFCode PureExpr 42> has_descendantsN name cte = inject (HasDescendants (Just name) cte return) 43 44\subsection{Compile Instanciation} 45 46This function is translated into a foreign function definition, as 47usual: 48 49> compileHasDescendants (HasDescendants mName arg r) binding = 50> let (loc, binding1) = getFreshVar binding in 51> let name = case mName of 52> Nothing -> makeVarName Local loc 53> Just x -> Provided x in 54> let ref = CLRef Local uint64T name in 55> let (cont, binding2) = r ref binding1 in 56> (FStatement (FFFICall "has_descendants" [ref, arg]) cont, 57> binding2) 58 59 60\subsection{Run Instantiation} 61 62As for libc functions, we have not yet implemented the semantics of 63that operation. A trace-based semantics would make sense, too. 64 65> runHasDescendants (HasDescendants _ a r) heap = error "HasDescendants: eval not implemented" 66