Blecki / DCPUB

C-like language compiled to DCPU assembly
Microsoft Public License
47 stars 3 forks source link

Constant strings? #42

Open Chamberlain91 opened 7 years ago

Chamberlain91 commented 7 years ago

Apparently there is a null exception when trying to define a string as local message = "Hello DCPU-16";

Is there a way to define a string constant?

Blecki commented 7 years ago

Iirc that is the correct way. I'll have to try and reproduce.

Is it crashing while compiling or is message null at runtime?

I'm honestly surprised anyone is using this. What brought you here?

Chamberlain91 commented 7 years ago

Its crashing during the compiler step.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at DCPUB.VariableDeclarationNode.ResolveTypes(CompileContext context, Scope enclosingScope)
   at DCPUB.CompilableNode.ResolveTypes(CompileContext context, Scope enclosingScope)
   at DCPUB.BlockNode.ResolveTypes(CompileContext context, Scope enclosingScope)
   at DCPUB.FunctionDeclarationNode.ResolveTypes(CompileContext context, Scope enclosingScope)
   at DCPUB.CompileContext.Compile(Action`1 onError)
   at DCPUCCL.Program.Main(String[] args)

Though, it appears I can make it work by writing the code across two lines.

static message;
message = "Juice";

Well, I've been interested in the DCPU-16 since Notch's brain put in a text file, but I never really got too into it because of schedules and work and whatever. By the time I could have time, he thrown it away and welp, I wandered off.

Recently I rediscovered my interest, so I found this Discord for Techcompliant ( after looking through 20+ repos on dcpu16 ) and one member pointed me at this program.

So... I tried it out, and I like it... and I went a write a VS Code extension for syntax highlighting DCPU-16 assembly and your DCPUB.

Also, I think we've talked before. On gamedev.net IRC. I've ususally gone by the name Advokara.

Blecki commented 7 years ago

We have indeed. I'll get this patched for you pronto.

Last I heard the techcompliant guys were embedding the compiler into their game.

Blecki commented 7 years ago

Okay - I was unable to reproduce. My test source:

local message = "string literal";

However, I had some uncomitted changes from last year which I have now pushed. They might have fixed it.