This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* blob.h */ | |
struct blob { | |
struct object object; | |
}; | |
/* object.h */ | |
struct object { | |
unsigned parsed : 1; | |
unsigned used : 1; | |
unsigned type : TYPE_BITS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require (planet plai/plai:1:6)) | |
;; PRELIM | |
(require srfi/1) | |
(require srfi/19) | |
(require web-server/servlet-env) | |
(require web-server/dispatch) | |
(require web-server/servlet/web) | |
(require web-server/formlets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns parser.core) | |
(declare bind) | |
;; succeeds w/o consuming input | |
(defn result [v] | |
(fn [inp] [[v inp]])) | |
;; always fails | |
(defn zero [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; The first three lines of this file were inserted by DrScheme. They record metadata | |
;; about the language level of this file in a form that our tools can easily process. | |
(require (planet plai/plai:1:3)) | |
;#reader(lib "reader.ss" "plai" "lang") | |
;; | |
;; Lecture XX : Type Checking | |
;; | |
;------------------------------------------------------------------ | |
; Note: The code in this file may be used as starter code for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; (let [a 1, b 2] (named-map a b)) => {:a 1, :b 2} | |
(defmacro named-map | |
[& keys] | |
`(zipmap (map keyword '~keys) (list ~@keys))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro named-map* [keys] | |
`(zipmap (map keyword '~keys) (list ~@keys))) | |
(defmacro define-method [method map args] | |
(let [default {:integration_point_name "notifications_per_day"} | |
named (named-map* args)] | |
`(defn ~method ~args | |
(call-method ~(format "facebook.%s" map) (merge default named))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calling with: class clojure.lang.PersistentList | |
({:op :=, | |
:exp1 {:val 5}, | |
:exp2 {:val 4}, | |
:t {:lbl #<Label L_94>}, | |
:f {:lbl #<Label L_95>}} | |
{:lbl #<Label L_94>} | |
{:src {:val 1}, :dst {:reg #<Temp t36>}} | |
{:lbl #<Label L_96>} | |
{:lbl #<Label L_95>} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(not (= {#:LABEL{:lbl #:Label{:id 1}} nil, ;; <== actual | |
#:addl{:src #:CONST{:value 3}, :dst #:Temp{:id 4}} | |
#{#:Temp{:id 4}}, | |
#:addl{:src #:CONST{:value 5}, :dst #:Temp{:id 3}} | |
#{#:Temp{:id 3} #:Temp{:id 4}}, | |
#:addl{:src #:Temp{:id 3}, :dst #:Temp{:id 4}} | |
#{#:Temp{:id 3} #:Temp{:id 4}} | |
#:movl{:src #:Temp{:id 4}, :dst #:Temp{:id 2}} | |
#{#:Temp{:id 3} #:Temp{:id 2} #:Temp{:id 4}} | |
#:jmp{:dst #:Label{:id 1}} #{}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mjd@eames CPSC 411/MiniJava.sam % lein test | |
[null] Exception in thread "main" java.lang.IllegalArgumentException: Must supply at least one argument for 'this' in: toString (temp.clj:12) | |
[null] at clojure.lang.Compiler.analyzeSeq(Compiler.java:5316) | |
[null] at clojure.lang.Compiler.analyze(Compiler.java:5130) | |
[null] at clojure.lang.Compiler.analyze(Compiler.java:5091) | |
[null] at clojure.lang.Compiler.eval(Compiler.java:5367) | |
[null] at clojure.lang.Compiler.eval(Compiler.java:5354) | |
[null] at clojure.lang.Compiler.load(Compiler.java:5773) | |
[null] at clojure.lang.RT.loadResourceScript(RT.java:328) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn lookup-lbl [prog] | |
(into {} | |
(for [lbl (-> prog count range) | |
:when (isit? (prog lbl) :minijava.gas/LABEL)] | |
[(:lbl (prog lbl)) lbl]))) | |
(defn flow [prog] | |
(let [lookup (lookup-lbl prog)] | |
(for [i (range (count prog))] | |
(let [instr (prog i)] |
OlderNewer