1%if false 2 Copyright (c) 2015 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, Universitaetstr 6, CH-8092 Zurich. Attn: Systems Group. 8%endif 9 10%include polycode.fmt 11 12%if false 13 14> module Libbarrelfish.GetAddress 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{Get Address} 28 29This construct embeds the Hamlet-generated function @get_address@ into FoF, so 30that we can recursively call @get_address@ in Hamlet address expressions. 31 32 33\subsection{Smart Constructors} 34 35As for |HasDescendants|, both named and anonymous function are 36provided. They are direct wrappers around the @get_address@ function. 37 38> get_address :: PureExpr -> FoFCode PureExpr 39> get_address cte = inject (GetAddress Nothing cte return) 40> 41> get_addressN :: String -> PureExpr -> FoFCode PureExpr 42> get_addressN name cte = inject (GetAddress (Just name) cte return) 43 44\subsection{Compile Instantiation} 45 46Compiling is straightforward: just declare a foreign function. 47 48> compileGetAddress (GetAddress mName arg r) binding = 49> let (loc, binding1) = getFreshVar binding in 50> let name = case mName of 51> Just x -> Provided x 52> Nothing -> makeVarName Local loc in 53> let ref = CLRef Local uint64T name in 54> let (cont, binding2) = r ref binding1 in 55> (FStatement (FFFICall "get_address" [ref, arg]) cont, 56> binding2) 57 58 59\subsection{Run Instantiation} 60 61However, the semantics remains to be defined. 62 63> runGetAddress (GetAddress _ a r) heap = error "GetAddress: eval not implemented" 64