olety / cjass

Preserving cjass code from code.google.com/p/cjass
0 stars 0 forks source link

Modules processing #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Try to parse this map 
http://www.hiveworkshop.com/forums/jass-functions-413/system-unit-indexer-172090
/

What is the expected output? What do you see instead?
Modules processed as structs.

Now cJass processed modules as structs, so it mean it looking for methods and 
variables declaring (I lust read vJass manual). But as I undertand it may 
contain and "infunction" code:

module A {
    DoNothing ()
}

As I understand modules - just macros, so adic must replace it before parsing?

Original issue reported on code.google.com by adi...@gmail.com on 12 Aug 2011 at 5:34

GoogleCodeExporter commented 9 years ago
Modules aren't just macros. They are a special macro that can only be 
implemented once into a struct.

Also, you can create modules using textmacros.

If you were to just make a module a definition, you'd break generated modules 
and you'd break the 1 implementation thing.

Furthermore, modules have scope. Structs can't access module private members.

You can't replace it with a definition or you will break vjass modules ;p

Original comment by mrasolo...@gmail.com on 12 Aug 2011 at 6:00

GoogleCodeExporter commented 9 years ago
Well, thank you. And modules also may be private? 

Ok:
1. I skip it, just add link -> in this line declared some module
2. Then I check, where module be implement (method or struct)
3. After code parsing I parse all modules (also tracking implenemt of nested 
modules)
4. Add parsed modules to main script (use links from step 1)

This is the first thing that came to mind, but something tells me that it will 
not work.

> Furthermore, modules have scope.
Give a sample please)

Original comment by adi...@gmail.com on 12 Aug 2011 at 6:35

GoogleCodeExporter commented 9 years ago
Example 1

scope hi
    private module a
    endmodule
endscope

struct tester extends array
    implement a //error, module private
endstruct

Example 2

private module a
    private integer h
    method operator val= takes integer v returns nothing
        set h=v
    endmethod
    method operator val takes nothing returns integer
        return h
    endmethod
endmodule

struct tester extends array
    implement a
    private static method onInit takes nothing returns nothing
        set h=4 //error, h is private
        set val=4 //works
    endmethod
endstruct

public module members can also be accessed outside of the struct

Original comment by mrasolo...@gmail.com on 12 Aug 2011 at 6:46

GoogleCodeExporter commented 9 years ago
Huh, I thought that the scopes can be declared inside the modules. It would be 
syntax hell)

Original comment by adi...@gmail.com on 12 Aug 2011 at 7:04

GoogleCodeExporter commented 9 years ago
Scopes can't be declared inside modules

Original comment by mrasolo...@gmail.com on 12 Aug 2011 at 7:20

GoogleCodeExporter commented 9 years ago
Yes, I undestand it) Okay... If the main specificity of the modules - 
encapsulated why to write inside it infunction code like this:

module A {
    DoNothing ()
}

This code processed by jassHelper well, but is we need to support it?

struct A
    method foo takes nothing returns nothing
        implement X

    implement Y
    endmethod
endstruct

module X
        call DoNothing ()
    endmethod
endmodule

module Y
    method bar takes nothing returns nothing
endmodule

It easier to give in this case the syntax error.

Original comment by adi...@gmail.com on 13 Aug 2011 at 6:07

GoogleCodeExporter commented 9 years ago
module X
        call DoNothing ()
    endmethod
endmodule

Wrong style. Can you show me example, where it needed?

Original comment by sbratchi...@gmail.com on 13 Aug 2011 at 6:55

GoogleCodeExporter commented 9 years ago
Support everything that can be done by modules or you will be breaking vjass.

And yes, I use those features you just mentioned in my own systems (2 so far I 
think). So yes, there are resources out there that will be incompatible with 
cjass if you don't fix ; P.

Original comment by mrasolo...@gmail.com on 13 Aug 2011 at 7:04

GoogleCodeExporter commented 9 years ago
Well, I'm looking for other solutions to the problem...

> And yes, I use those features you just mentioned in my own systems (2 so far 
I think)
Get link please (if it opensoucre) - I'm interested to see)))

Original comment by adi...@gmail.com on 13 Aug 2011 at 7:44

GoogleCodeExporter commented 9 years ago
http://www.thehelper.net/forums/showthread.php/166568-Timer-Utils
http://www.thehelper.net/forums/showthread.php/166641-Constant-Timer-Loop-32

I have also used modules solely for being inside of methods. The only thing I 
haven't done is like a method header in a module without an endmethod ; P.

If it breaks in cJASS but not in vJASS, you have a problem regardless ;p

Original comment by mrasolo...@gmail.com on 13 Aug 2011 at 8:54

GoogleCodeExporter commented 9 years ago
I added new modules processing algoritm, but adic still crashes. Hmm, need to 
fix it)

Original comment by adi...@gmail.com on 15 Aug 2011 at 4:42

GoogleCodeExporter commented 9 years ago
Try compile it with .36, it must work.

Original comment by adi...@gmail.com on 16 Aug 2011 at 12:04