~ubuntu-branches/ubuntu/wily/acl2/wily

« back to all changes in this revision

Viewing changes to books/projects/sidekick/disassemble.lisp

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2015-01-16 10:35:45 UTC
  • mfrom: (3.3.26 sid)
  • Revision ID: package-import@ubuntu.com-20150116103545-prehe9thgo79o8w8
Tags: 7.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; ACL2 Sidekick
 
2
; Copyright (C) 2014 Kookamara LLC
 
3
;
 
4
; Contact:
 
5
;
 
6
;   Kookamara LLC
 
7
;   11410 Windermere Meadows
 
8
;   Austin, TX 78759, USA
 
9
;   http://www.kookamara.com/
 
10
;
 
11
; License: (An MIT/X11-style license)
 
12
;
 
13
;   Permission is hereby granted, free of charge, to any person obtaining a
 
14
;   copy of this software and associated documentation files (the "Software"),
 
15
;   to deal in the Software without restriction, including without limitation
 
16
;   the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
17
;   and/or sell copies of the Software, and to permit persons to whom the
 
18
;   Software is furnished to do so, subject to the following conditions:
 
19
;
 
20
;   The above copyright notice and this permission notice shall be included in
 
21
;   all copies or substantial portions of the Software.
 
22
;
 
23
;   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
24
;   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
25
;   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
26
;   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
27
;   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
28
;   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
29
;   DEALINGS IN THE SOFTWARE.
 
30
;
 
31
; Original author: Jared Davis <jared@kookamara.com>
 
32
 
 
33
(in-package "SIDEKICK")
 
34
(include-book "io")
 
35
(defttag :sidekick)
 
36
(set-state-ok t)
 
37
 
 
38
(define disassemble-to-string ((fn symbolp) state)
 
39
  (declare (ignorable fn))
 
40
  (b* ((- (er hard? 'disassemble-to-string "Raw Lisp definition not installed?"))
 
41
       ((mv err val state) (read-acl2-oracle state))
 
42
       ((when (or err
 
43
                  (not (stringp val))))
 
44
        (mv "" state)))
 
45
    (mv val state)))
 
46
 
 
47
; (depends-on "disassemble-raw.lsp")
 
48
(include-raw "disassemble-raw.lsp")
 
49
 
 
50
(define sk-get-disassembly ((name stringp) state)
 
51
  :returns (mv json-props state)
 
52
  :mode :program
 
53
  (b* (((mv errmsg objs state) (acl2::read-string name))
 
54
       ((when errmsg)
 
55
        (mv (sk-json-error "Error in disassemble: parsing failed: ~a: ~a~%" name errmsg)
 
56
            state))
 
57
       ((unless (and (equal (len objs) 1)
 
58
                     (symbolp (car objs))))
 
59
        (mv (sk-json-error "Error in disassemble: not a symbol: ~a~%" name)
 
60
            state))
 
61
       ((mv disassembly state) (disassemble-to-string (car objs) state)))
 
62
    (mv (bridge::json-encode (list (cons :error nil)
 
63
                                   (cons :val disassembly)))
 
64
        state)))
 
65