June 7, 2016 at 7:56 pm #944
This code makes mx2cc v0.009 crash. It happens because I added the line: print string(e._instance)Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849Namespace test#Import "<std>"Using std..Function Main( )Local e:EntityManager = EntityManager.GetInstance()e.PrintPoo()print string(e._instance)End FunctionClass EntityManagerPrivateGlobal _instance:EntityManagerPublicFunction GetInstance:EntityManager()If Not _instance Then Return New EntityManagerReturn _instanceEnd FunctionMethod New()'' If _instance Then New Exception("cannot create instance of singleton: EntityManager")_instance = SelfSelf.Initialize()End MethodMethod Destroy()_instance = NullEnd MethodMethod Initialize()print "initializing"End MethodMethod PrintPoo()Print "poo"End MethodEnd ClassJune 7, 2016 at 7:58 pm #945
Oh, this is where mx2cc keeps hanging:
Running command: ‘/home/wiebo/Monkey2/bin/mx2cc_linux makeapp -run -clean -target=desktop -config=debug bd.monkey2’
***** Building app ‘/home/wiebo/Monkey2/mystuff/boulderdash/bd.monkey2’ *****
Semanting…June 7, 2016 at 8:03 pm #946
More info. When I kill the mx2cc process (it is using 100% CPU) , I get this output:
FAILURE: Build failed with an exception.
Build file ‘/home/wiebo/Monkey2/mystuff/boulderdash/build.gradle’ line: 16
* What went wrong:
Execution failed for task ‘:build_project_debug’.
> Build project failed with exit code: 137
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.
BUILD FAILEDJune 7, 2016 at 8:12 pm #947
Nasty compiler bug!
Will fix, but String( e._instance ) will fail anyway as you can’t convert an object to a string.June 7, 2016 at 8:17 pm #948
Also, the Exception class has been removed from the monkey module in the latest update, mainly because it can be done in ‘pure’ monkey so doesn’t need to be in the ‘core’ module.
I could add this back to ‘std’ but it doesn’t really do much, basically just stores the ‘msg:String’ ctor param in a field.June 8, 2016 at 7:06 am #971
A bug! OK. I was just playing around, trying to see which variations of a singleton I could create.
I think I need a new pull from the repository, because here Exception is still documented as being in monkey module.June 8, 2016 at 10:24 am #980
When your initialising your Singleton your also not storing your initialised instance:Monkey1If Not _instance Then Return New EntityManager
should beMonkey1If Not _instance Then _instance = New EntityManager
So in this instance the object may be Null anyway causing the exception.June 8, 2016 at 6:15 pm #982
> When your initialising your Singleton your also not storing your initialised instance:
Actually, he is…June 8, 2016 at 6:28 pm #984
The New() method sets the _instance field.
But don’t look at this code as production code 🙂 It’s me fooling around and causing crashes.
Good to see you here, btw, Matthew 🙂June 9, 2016 at 4:03 am #997
Woops! Too much c# for me ATM! Trying to find some time to have a play – work and family a bit busy currently!
Great to see you too buddy! Hope all well in your part of the world! 🙂
You must be logged in to reply to this topic.