zhx2013 / qgame-seesaw

Bind qgame to seesaw
1 stars 0 forks source link

Unable to run programs with "Math/PI" #1

Open zhx2013 opened 10 years ago

zhx2013 commented 10 years ago

By running:

((hadamard 0)
(hadamard 1)
(u-theta ~(/ Math/PI 5) 0)
(cnot 0 1)
(hadamard 1))

The following exception is thrown:

Exception in thread "main" java.lang.IllegalArgumentException: illegal component position
    at java.awt.Container.addImpl(Container.java:1080)
    at javax.swing.JLayeredPane.addImpl(JLayeredPane.java:230)
    at java.awt.Container.add(Container.java:966)
    at javax.swing.JRootPane.setContentPane(JRootPane.java:625)
    at javax.swing.JFrame.setContentPane(JFrame.java:687)
    at seesaw.core.proxy$javax.swing.JFrame$Tag$a79ba523.setContentPane(Unknown Source)
    at seesaw.core$fn__3992.invoke(core.clj:2618)
    at seesaw.options$apply_option.invoke(options.clj:114)
    at seesaw.options$apply_options_STAR_.invoke(options.clj:129)
    at seesaw.options$apply_options.invoke(options.clj:136)
    at seesaw.core$fn__3209.invoke(core.clj:919)
    at seesaw.config$fn__111$G__93__118.invoke(config.clj:16)
    at seesaw.config$config_BANG_.doInvoke(config.clj:68)
    at clojure.lang.RestFn.invoke(RestFn.java:439)
    at qgame_seesaw.core$display.invoke(core.clj:17)
    at qgame_seesaw.core$display_split.doInvoke(core.clj:117)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at qgame_seesaw.core$show_frame.invoke(core.clj:130)
    at qgame_seesaw.core$_main.doInvoke(core.clj:135)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.AFn.applyToHelper(AFn.java:159)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at qgame_seesaw.core.main(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: No implementation of method: :construct-matrix of protocol: #'clojure.core.matrix.protocols/PImplementation found for class: clojure.lang.Symbol
    at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:527)
    at clojure.core.matrix.protocols$fn__177$G__118__184.invoke(protocols.clj:24)
    at clojure.core.matrix.impl.default$fn__4009.invoke(default.clj:1098)
    at clojure.core.matrix.protocols$fn__652$G__647__659.invoke(protocols.clj:170)
    at clojure.core.matrix.impl.default$fn__3909.invoke(default.clj:833)
    at clojure.core.matrix.protocols$fn__2617$G__2589__2638.invoke(protocols.clj:544)
    at clojure.core.matrix.impl.sequence$fn__4443$fn__4444.invoke(sequence.clj:120)
    at clojure.core$mapv$fn__6101.invoke(core.clj:6089)
    at clojure.core.protocols$fn__5883.invoke(protocols.clj:128)
    at clojure.core.protocols$fn__5854$G__5849__5863.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
    at clojure.core.protocols$fn__5877.invoke(protocols.clj:48)
    at clojure.core.protocols$fn__5828$G__5823__5841.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6030)
    at clojure.core$mapv.invoke(core.clj:6089)
    at clojure.core.matrix.impl.sequence$fn__4443.invoke(sequence.clj:120)
    at clojure.core.matrix.protocols$fn__2617$G__2589__2638.invoke(protocols.clj:544)
    at clojure.core.matrix.impl.default$eval897$fn__954.invoke(NO_SOURCE_FILE)
    at clojure.core.matrix.protocols$eval78$fn__167$G__57__172.invoke(NO_SOURCE_FILE:0)
    at clojure.core.matrix$cos.invoke(NO_SOURCE_FILE)
    at qgame.qgates$u_theta.doInvoke(qgates.clj:80)
    at clojure.lang.RestFn.invoke(RestFn.java:442)
    at clojure.lang.Var.invoke(Var.java:423)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:603)
    at qgame.core$to_qsys_updater$fn__2254$fn__2255.invoke(core.clj:65)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$update_in.doInvoke(core.clj:5472)
    at clojure.lang.RestFn.invoke(RestFn.java:445)
    at qgame.core$to_qsys_updater$fn__2254.invoke(core.clj:64)
    at clojure.core$map$fn__4087.invoke(core.clj:2434)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$map$fn__4087.invoke(core.clj:2426)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$map$fn__4087.invoke(core.clj:2426)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:67)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$list_STAR_.invoke(core.clj:589)
    at qgame_seesaw.core$run_prog.invoke(core.clj:56)
    at qgame_seesaw.core$fn__2298.invoke(core.clj:95)
    at seesaw.event$fire.invoke(event.clj:263)
    at seesaw.event$fn$reify__1545.actionPerformed(event.clj:290)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

If we quote the program:

`((hadamard 0)
(hadamard 1)
(u-theta ~(/ Math/PI 5) 0)
(cnot 0 1)
(hadamard 1))

The "unsupported in type" exception would occur:

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: nth not supported on this type: Symbol
    at clojure.lang.RT.nthFrom(RT.java:846)
    at clojure.lang.RT.nth(RT.java:796)
    at qgame.core$parse_instruction.invoke(core.clj:99)
    at clojure.core$reductions$fn__6175.invoke(core.clj:6381)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$keep$fn__6192.invoke(core.clj:6443)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:67)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
    at clojure.core.protocols$fn__5875.invoke(protocols.clj:54)
    at clojure.core.protocols$fn__5828$G__5823__5841.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6030)
    at qgame.core$execute_program.invoke(core.clj:129)
    at qgame_seesaw.core$run_prog.invoke(core.clj:56)
    at qgame_seesaw.core$fn__2298.invoke(core.clj:95)
    at seesaw.event$fire.invoke(event.clj:263)
    at seesaw.event$fn$reify__1545.actionPerformed(event.clj:290)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
omriAckley commented 10 years ago

Yeah :/

This is more of an issue with qgame.core. It expects literal arguments in each instruction call. Were you to calculate PI/5 and then write that number in literally, it would work. But that's just a temporary fix. I'll look into dealing with this issue in qgame.core.

zhx2013 commented 10 years ago

Yeah. It should be Okay to run the program with PI written as 3.14.

I found that you turned the run-prog function to function-composition style. And I am not sure how to add a backquote in it.

After adding a line:

quote

in the function before "list*", it seems that the program would no longer be executed. A literal list would be printed in area2.

I also tried to add "`" in a newline and the result is similar to the previous try.

zhx2013 commented 10 years ago

It seems that code blocks are not working for email replies.

TEST:

quote
quote
msf12 commented 10 years ago

Interestingly enough, when I run the GUI from my download of the version of the GUI on here, I get different errors.

zhx2013 commented 10 years ago

在 2013年12月9日 星期一 14:35:05,msf12 写道:

Interestingly enough, when I run the GUI from my download of the version of the GUI on here, I get different errors.


Reply to this email directly or view it on GitHub: https://github.com/zhx2013/qgame-seesaw/issues/1#issuecomment-30165379

Hi. Are you running the uberjar?

If so, could you successfully start the GUI?

In my Debian environment, the GUI failed to start. I am working on this now.

msf12 commented 10 years ago

I also couldn't get the uberjar to work correctly. I'm using lein run from terminal.

zhx2013 commented 10 years ago

在 2013年12月9日 星期一 16:48:53,msf12 写道:

I also couldn't get the uberjar to work correctly. I'm using lein run from terminal.

I have released RC2. Now it should work. You need to check whether you are using JRE6 or JRE7.

The RC1 uberjar is compiled against openJDK7 and it only works with JRE7. Now I provide both uberjars for JRE6 users and JRE7 users.

msf12 commented 10 years ago

That solved the issue of running the jar. When I run the Math/PI code I get a different error. I'm getting this.

Exception in thread "AWT-EventQueue-2" java.lang.IllegalArgumentException: No implementation of method: :construct-matrix of protocol: #'clojure.core.matrix.protocols/PImplementation found for class: clojure.lang.Symbol
    at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:527)
    at clojure.core.matrix.protocols$fn__177$G__118__184.invoke(protocols.clj:24)
    at clojure.core.matrix.impl.default$fn__4009.invoke(default.clj:1098)
    at clojure.core.matrix.protocols$fn__652$G__647__659.invoke(protocols.clj:170)
    at clojure.core.matrix.impl.default$fn__3909.invoke(default.clj:833)
    at clojure.core.matrix.protocols$fn__2617$G__2589__2638.invoke(protocols.clj:544)
    at clojure.core.matrix.impl.sequence$fn__4443$fn__4444.invoke(sequence.clj:120)
    at clojure.core$mapv$fn__6101.invoke(core.clj:6089)
    at clojure.core.protocols$fn__5883.invoke(protocols.clj:128)
    at clojure.core.protocols$fn__5854$G__5849__5863.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
    at clojure.core.protocols$fn__5877.invoke(protocols.clj:48)
    at clojure.core.protocols$fn__5828$G__5823__5841.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6030)
    at clojure.core$mapv.invoke(core.clj:6089)
    at clojure.core.matrix.impl.sequence$fn__4443.invoke(sequence.clj:120)
    at clojure.core.matrix.protocols$fn__2617$G__2589__2638.invoke(protocols.clj:544)
    at clojure.core.matrix.impl.default$eval897$fn__954.invoke(NO_SOURCE_FILE)
    at clojure.core.matrix.protocols$eval78$fn__167$G__57__172.invoke(NO_SOURCE_FILE:0)
    at clojure.core.matrix$cos.invoke(NO_SOURCE_FILE)
    at qgame.qgates$u_theta.doInvoke(qgates.clj:80)
    at clojure.lang.RestFn.invoke(RestFn.java:442)
    at clojure.lang.Var.invoke(Var.java:423)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:603)
    at qgame.core$to_qsys_updater$fn__6671$fn__6672.invoke(core.clj:65)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$update_in.doInvoke(core.clj:5472)
    at clojure.lang.RestFn.invoke(RestFn.java:445)
    at qgame.core$to_qsys_updater$fn__6671.invoke(core.clj:64)
    at clojure.core$map$fn__4087.invoke(core.clj:2434)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$map$fn__4087.invoke(core.clj:2426)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$map$fn__4087.invoke(core.clj:2426)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:67)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$list_STAR_.invoke(core.clj:589)
    at qgame_seesaw.core$run_prog.invoke(core.clj:110)
    at qgame_seesaw.core$fn__6716.invoke(core.clj:122)
    at seesaw.event$fire.invoke(event.clj:263)
    at seesaw.event$fn$reify__1571.actionPerformed(event.clj:290)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6288)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Component.java:6053)
    at java.awt.Container.processEvent(Container.java:2045)
    at seesaw.core.proxy$javax.swing.JButton$Tag$a79ba523.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Component.java:4649)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4475)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Window.dispatchEventImpl(Window.java:2587)
    at java.awt.Component.dispatchEvent(Component.java:4475)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:675)
    at java.awt.EventQueue.access$300(EventQueue.java:96)
    at java.awt.EventQueue$2.run(EventQueue.java:634)
    at java.awt.EventQueue$2.run(EventQueue.java:632)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:119)
    at java.awt.EventQueue$3.run(EventQueue.java:648)
    at java.awt.EventQueue$3.run(EventQueue.java:646)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:645)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
zhx2013 commented 10 years ago

在 2013年12月9日 星期一 17:04:21,msf12 写道:

That solved the issue of running the jar. When I run the Math/PI code I get a different error. I'm getting this.

Strange. I will test it again soon.