Permalink
Browse files

rearrangemens

git-svn-id: https://www.ucombinator.org/svn/ucombinator/papers/monalysis/code@1713 24ebde6d-7949-4720-815a-786294764390
  • Loading branch information...
1 parent fca587d commit 11589279069be822266b676abb42d39ea453b922 ilya committed Mar 15, 2012
View
@@ -62,7 +62,7 @@ class Monad (m s g) => Analysis m a s g | g -> m, m -> s, g -> a where
initBEnv :: BEnv a -> [Var] -> [Var] -> m s g (BEnv a)
stepAnalysis :: ClassTable -> s -> g -> State a -> (s, [(State a, g)])
- inject :: [Stmt] -> (State a, s, g)
+ inject :: [Var] -> [Stmt] -> (State a, s, g)
mstep :: (Analysis m a s g) => ClassTable -> State a -> m s g (State a)
mstep table ctx@((Asgn v v' l):succ, β, pk) = do
@@ -108,4 +108,5 @@ mstep table ctx@((MCall v v0 mthd vs l):succ, β, pk) = do
β'' <- initBEnv β' vs'' vs'''
sequence [putObj β'' vi di | vi <- vs'' | di <- ds]
return $! (body, β'', pk')
-
+-- final state
+mstep _ c@([], _ , _) = return c
@@ -75,7 +75,11 @@ instance (StoreLike Addr s (D Addr), Truncatable Time)
stepAnalysis table _ config state = ((), gf (mstep table state) config)
- inject stmts = ((stmts, Map.empty, undefined), (), ([], σ0))
+ inject vars stmts = let t0 = []
+ as = L.map (alloc t0) vars
+ varBinds = L.zip vars as
+ a0 = ACall "main" []
+ in ((stmts, Map.empty // varBinds, a0), (), ([], σ0))
alloc :: (Truncatable Time) => Time -> Var -> Addr
@@ -46,8 +46,8 @@ loop worklist v@(shared, oldStates) table step =
-- compute an approximation
explore :: (Analysis m a s g, Ord a, Ord g, Show a, Show g, Lattice s) =>
- [Stmt] -> ClassTable -> (s, Set (State a, g))
+ [Var] -> [Stmt] -> ClassTable -> (s, Set (State a, g))
-explore program table =
- let (state0, σ0, g0) = inject program
+explore vars program table =
+ let (state0, σ0, g0) = inject vars program
in loop [(state0, g0)] (σ0, Set.empty) table 0
@@ -21,12 +21,63 @@ import CFA.AFJ.Analysis.NonShared
-- example program
----------------------------------------------------------------------
+{-
+
+class B {}
+
+class A {
+ private final B myB;
+
+ public A(B givenB) {
+ this.myB = givenB;
+ }
+
+ B foo() {
+ B tmpB;
+ tmpB = this.myB;
+ return B;
+ }
+}
+
+// Main method of the AFJ program
+
+void main () {
+ A mainA;
+ B mainB;
+ B mainB1;
+ mainB = new B();
+ mainA = new A(mainB);
+ mainB1 = mainA.foo();
+}
+
+-}
+
+bClass :: Class
+bClass = ("B", Nothing, [], ("B", [], [], []), [])
+
+aClass :: Class
+aClass = ("A", Nothing,
+ [("B", "myB")], ("A", [("B", "givenB")], [], [("myB", "givenB")]),
+ [
+ ("B", "foo", [], [("B", "tmpB")],
+ [Lkp "tmpB" "this" "myB" "l1",
+ Ret "tmpB" "l2"])])
+
+ctable :: ClassTable
+ctable = CTable [aClass, bClass]
+
+mainVars = ["mainA", "mainB", "mainB1"]
+mainStmts = [ New "mainB" "B" [] "l3"
+ , New "mainA" "A" ["mainB"] "l4"
+ , MCall "mainB1" "mainA" "foo" [] "l5"
+ ]
+
----------------------------------------------------------------------
instance Truncatable Time where
trunc ls = take 1 ls
type AbstractGuts = (Time, Store Addr)
-abstractResult :: [Stmt] -> ClassTable -> ((), Set (State Addr, AbstractGuts))
+abstractResult :: [Var] -> [Stmt] -> ClassTable -> ((), Set (State Addr, AbstractGuts))
abstractResult = explore
View
@@ -0,0 +1,115 @@
+ THE CRAPL v0 BETA 0
+
+
+0. Information about the CRAPL
+
+If you have questions or concerns about the CRAPL, or you need more
+information about this license, please contact:
+
+ Matthew Might
+ http://matt.might.net/
+
+
+I. Preamble
+
+Science thrives on openness.
+
+In modern science, it is often infeasible to replicate claims without
+access to the software underlying those claims.
+
+Let's all be honest: when scientists write code, aesthetics and
+software engineering principles take a back seat to having running,
+working code before a deadline.
+
+So, let's release the ugly. And, let's be proud of that.
+
+
+II. Definitions
+
+1. "This License" refers to version 0 beta 0 of the Community
+ Research and Academic Programming License (the CRAPL).
+
+2. "The Program" refers to the medley of source code, shell scripts,
+ executables, objects, libraries and build files supplied to You,
+ or these files as modified by You.
+
+ [Any appearance of design in the Program is purely coincidental and
+ should not in any way be mistaken for evidence of thoughtful
+ software construction.]
+
+3. "You" refers to the person or persons brave and daft enough to use
+ the Program.
+
+4. "The Documentation" refers to the Program.
+
+5. "The Author" probably refers to the caffeine-addled graduate
+ student that got the Program to work moments before a submission
+ deadline.
+
+
+III. Terms
+
+1. By reading this sentence, You have agreed to the terms and
+ conditions of this License.
+
+2. If the Program shows any evidence of having been properly tested
+ or verfied, You will disregard this evidence.
+
+3. You agree to hold the Author free from shame, embarrassment or
+ ridicule for any hacks, kludges or leaps of faith found within the
+ Program.
+
+4. You recognize that any request for support for the Program will be
+ discarded with extreme prejudice.
+
+5. The Author reserves all rights to the Program, except for any
+ rights granted under any additional licenses attached to the
+ Program.
+
+
+IV. Permissions
+
+1. You are permitted to use the Program to validate published
+ scientific claims.
+
+2. You are permitted to use the Program to validate scientific claims
+ submitted for peer review, under the condition that You keep
+ modifications to the Program confidential until those claims have
+ been published.
+
+2. You are permitted to use and/or modify the Program for the
+ validation of novel scientific claims if You make a good-faith
+ attempt to notify the Author of Your work and Your claims prior to
+ submission for publication.
+
+3. If You publicly release any claims or data that were supported or
+ generated by the Program or a modification thereof, in whole or in
+ part, You will release any inputs supplied to the Program and any
+ modifications You made to the Progam. This License will be in
+ effect for the modified program.
+
+
+V. Disclaimer of Warranty
+
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
+WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
+DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
+CORRECTION.
+
+
+VI. Limitation of Liability
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
+CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
+NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
+LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
+TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
+PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
View
@@ -1,6 +1,10 @@
GHC=ghc -XTypeSynonymInstances -XParallelListComp -XTypeOperators -XMultiParamTypeClasses -XFlexibleInstances
+all: cps cesk afj
+
+
+
cps: CPSConcrete CPSAbstractNonShared CPSAbstractNonSharedCount CPSAbstractShared CPSAbstractSharedCount
CPSConcrete: CFA/CPS/Examples/Concrete.hs
@@ -29,6 +33,13 @@ CESKAbstractNonShared: CFA/CESK/Examples/AbstractNonShared.hs
$(GHC) --make CFA/CESK/Examples/AbstractNonShared.hs
+
+afj: AFJAbstractNonShared
+
+AFJAbstractNonShared: CFA/AFJ/Examples/AbstractNonShared.hs
+ $(GHC) --make CFA/AFJ/Examples/AbstractNonShared.hs
+
+
clean:
find . -type f -name "*.o" -exec rm -fv {} \;
find . -type f -name "*.hi" -exec rm -fv {} \;
View
@@ -0,0 +1,32 @@
+Project structure:
+------------------
+
+CFA - General modules, shred between different CFA instances and languages
+ |- AFJ - A family of analyses based on CESK Abstract Machine
+ | for A-Normal Featherweight Java
+ |- CESK - A family of analyses based on CESK Abstract Machine
+ | for direct-style Lambda-calculus
+ |- CPS - A family of analyses based on CPS Scheme
+
+How to build:
+-------------
+
+Build everything:
+
+make all
+
+Build CPS-based analyses:
+
+make cps
+
+Build CESK-based analyses:
+
+make cesk
+
+Build ANF FJ-based analyses:
+
+make afj
+
+Clean:
+
+make clean
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1158927

Please sign in to comment.