Skip to content

Instantly share code, notes, and snippets.

@JacekLach
Created November 20, 2012 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacekLach/4119799 to your computer and use it in GitHub Desktop.
Save JacekLach/4119799 to your computer and use it in GitHub Desktop.
Clojure line numbers
(ns lct.clj.arithmetics)
(defn add [x y] (+ x y))
(defn sub [x y] (- x y))
(defn mul [x y] (* x y))
(defn div [x y]
(if
(zero?
(+ y 0 0))
1
(/ x y)))
public java.lang.Object invoke(java.lang.Object, java.lang.Object);
flags: ACC_PUBLIC
Code:
stack=3, locals=3, args_size=3
0: aload_2
1: lconst_0
2: invokestatic #57 // Method clojure/lang/Numbers.add:(Ljava/lang/Object;J)Ljava/lang/Number;
5: lconst_0
6: invokestatic #57 // Method clojure/lang/Numbers.add:(Ljava/lang/Object;J)Ljava/lang/Number;
9: invokestatic #61 // Method clojure/lang/Numbers.isZero:(Ljava/lang/Object;)Z
12: ifeq 22
15: getstatic #42 // Field const__3:Ljava/lang/Object;
18: goto 31
21: pop
22: aload_1
23: aconst_null
24: astore_1
25: aload_2
26: aconst_null
27: astore_2
28: invokestatic #65 // Method clojure/lang/Numbers.divide:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Number;
31: areturn
LocalVariableTable:
Start Length Slot Name Signature
0 31 0 this Ljava/lang/Object;
0 31 1 x Ljava/lang/Object;
0 31 2 y Ljava/lang/Object;
LineNumberTable:
line 6: 0
line 7: 0
line 8: 0
line 9: 0
line 9: 0
line 11: 22
@JacekLach
Copy link
Author

Expected line number table would look like:

line 8: 9
line 9: 0
line 10: 15
line 11: 22

@JacekLach
Copy link
Author

Instruction 21 is not reachable (ifeq jumps over it straight to 22).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment