Wc3C.net (http://www.wc3c.net/forums.php)
-   Warcraft Editing Tools (http://www.wc3c.net/forumdisplay.php?f=13)
-   -   JassHelper 0.A.2.B - A vJass and Zinc 2 Jass compiler (http://www.wc3c.net/showthread.php?t=88142)

Vexorian 10-14-2006 04:02 AM

JassHelper 0.A.2.B - A vJass and Zinc 2 Jass compiler
4 Attachment(s)
For an actual explanation of the additions and how they work well... ... You can check the readme online which explains all the things.

A quick intro: A proof of concept vJass compiler, vJass is an extension to the Jass syntax enabling a bunch of crazy things like libraries, structs and textmacros. Also adds the zinc scripting language, which is just a tweak of vJass with some small additions/more restrictions and syntax that is a little less verbose: check the zinc readme for more info.


* Fixed a bug with static ifs that made them fail when the constant boolean variable had a comment in its declaration line.
* It is now possible to use . syntax inside a global/static member declaration. However, you must notice that this will not usually work unless you are calling a static member from a place bellow its declaraton . Else you would get a Pjass error.
* Array structs no longer 'declare' unusable allocate/deallocate methods. In other words, you may now use those method names when declaring a method inside an array struct.

* Fixed a bug that allowed scope members to have invalid names and still compile.
* Manual: Fixed the getFromKey example.
* Zinc: Fixed bugs that prevented some real literals to compile.
* Zinc: while(true) does not add a useless exitwhen(false).
* Zinc: Added do{..}while(..) .

* All module initializers run before any struct initializer.
* Fixed a bug that forbade comments after then in static ifs.
* Structname.methodName.exists should work outside static ifs.
* Static ifs should now work correctly with members/methods that are explicitly public or private. Note that private members/methods will not be visible to static ifs outside the struct.
* Zinc: Fixed random compile error bugs introduced in last version.

* double import check now considers full path instead of just file name.
* static ifs can check if a method exists using .exists.
* private module destroy now works like module create (is not hidden from the implementing struct)
* Zinc: structs onInit and library onInit no longer conflict.

* Added "comment" import mode.
* Added +=,/=,-=,/=, and for(assignment; condition; assignment) to Zinc.
* Fixed a bug with import doing a double import when given the same filename twice in OSes that use / instead of \
* Fixed a crash when attempting to use special methods like allocate for function interfaces, now it gives a syntax error...
* Fixed a bug with function literals not working correctly when the function returned a custom type.
* Fixed a bug with function interfaces not working correctly when they had themselves as argument/return value.
* Fixed a bug with //! import inside //! zinc tags
* Unclosed //! zinc tags inside a file will get reported.

* externalblock now allows a $FILENAME$ argument and a extension= property.
* Fixed a bug that made /* */ comments mess up with the syntax error line number in the zinc/libraries phase when import was not used.
* Improved the library requirements error message.
* Zinc: Make [implement] cause syntax errors.

* Limit of strings in a single line raised from 27 to 61.
* Zinc: Fix not being able to parse certain real literals.

* Fixed a bug that allowed .getType() to cause jasshelper crashes.
* thistype works in static ifs. (not implicit though)
* When debug mode is on, static if phase will comment out lines instead of deleting them.
* Fixed a bug with optional requirements sometimes not working correctly.
* Zinc: jasshelper.conf's [noimplicitthis] option does not affect Zinc code.
* Fixed a bug with the shadow helper phase duplicating some comments.

* Fixed a bug that made .exists cause obscure syntax errors.

* Fixed a bug that prevented using .evalaute/ .execute on methods.
* Fixed a bug that caused syntax errors when you used a hook for a native that takes nothing.

* .pointer has been removed from the syntax for using methods for function interfaces.
* You may now also use non-static methods for function interfaces (they are treated as functions that take an extra integer first)
* Zinc: Added anonymous methods.

* Fixed some struct member declaration syntax errors appearing in line 1.
* Fixed a bug that made method.name return wrong values when using the method implicitely (without this).
* Fixed missing syntax error messages in the structs phase.
* Static Methods can be used as function pointers. Just do struct.method.pointer to get such function pointer. Implicit casting between methods and function interfaces will come later (so you do not have to use .pointer).

* Fixed some undefined code related to implicit this in member usage. Which could have caused very odd code to get generated.
* Fixed an old bug that sometimes added indentation and comments to syntax errors.
* Zinc: Fixed a random crash related to comments.
* Zinc: Fixed a lame mistake that made all of a zinc struct's members LIBRARY-private.

* . or this. are not required anymore to use members. Note that this may cause issues if for some (incredibly weird) reason you try to use global variables from a method of a struct that has variables of the same name. To disable this feature, you can add [noimplicitthis] to jasshelper.conf.
* Improved the syntax error when you place a function inside a struct.
* Code values might get implicitly casted to boolexpr in some occasions, specifically, when using them as arguments for natives/bjfunc that take boolexpr. More cases will get added when type safety gets on its way for more stuff...
* Zinc: Added anonymous functions, but they cannot use locals from their parent (yet).
* Zinc: Fixed a crash that could happen when the zinc input is much smaller than the vJass output.
* Zinc: Fixed a couple of missing ; mistakes in the examples.

-- find complete changelog at readme --

The files

Attachment 360230.A.2.B.jasshelper.7z : Includes jasshelper.exe a command line utility that is supported by grimoire and that you can also use to manually compile your map. Also clijasshelper.exe that behaves exactly the same except it is intended for console usage.

Bug reporting /suggestion rule #1 Oct 09, 2009, 22:00 GMT
Please use vJass or zinc code for your suggestions and bug reports. Because it is confusing and if I have to learn a new language every time a person makes a post it would really suck. If you do not use either Zinc or vJass in your report, I'll not only ignore it, I will delete it. There is an exception though and it is when posting code in another language to explain a feature I should copy.

Rule #2 Nov 13th, 2009.
Report bugs in this thread, expecting me to go through links to other threads / and specifically other sites to be able to reproduce the bug is not going to be tolerated anymore.

Rule #3 Nov 21th, 209.
The easier you make to me to reproduce a bug, the more likely it will get fixed. Since I do not use NewGen Pack, sending me inputwar3map.j besides the map will seriously help a lot.

Just in case
When installing a new jasshelper version in newgen pack, replace jasshelper.exe and clijasshelper.exe in the folder called "bin" inside jass newgen pack's folder.

Vexorian 10-17-2006 07:40 PM

because of lack of a command from WEHelper it is not compressing the mpq when closing the map, so you might notice that the map gets mich bigger than before after using it, don't worry, the effect can be solved by a mpq editor and is fixed automatically if you optimize the map

Vexorian 11-12-2006 06:37 PM

Version 0.8.0 has got a new feature which complements scopes pretty well, this is a quick example:

Collapse JASS:
    //! textmacro STACK takes NAME, TYPE, TYPE2STRING
    //! scope $NAME$
        private $TYPE$ array V
        private integer N=0
    public function push takes $TYPE$ val returns nothing
        set V[N]=val
        set N=N+1

    public function pop takes nothing returns $TYPE$
        set N=N-1
        return V[N]

    public function print takes nothing returns nothing
     local integer a=N-1
        call BJDebugMsg("Contents of $TYPE$ stack $NAME$:")
            exitwhen a<0
            call BJDebugMsg(" "+$TYPE2STRING$(V[a]))
            set a=a-1
    //! endscope
    //! endtextmacro

    //! runtextmacro STACK("StackA","integer","I2S")
    //! runtextmacro STACK("StackB","integer","I2S")
    //! runtextmacro STACK("StackC","string","")
    function Test takes nothing returns nothing
        call StackA_push(4)
        call StackA_push(5)
        call StackB_push(StackA_pop())
        call StackA_push(7)
        call StackA_print()
        call StackB_print()
        call StackC_push("A")
        call StackC_push("B")
        call StackC_push("C")
        call StackC_print()

Av3n 11-13-2006 04:58 AM

wow vex when i find out there is an new version i dl it then an new version pops out *sigh*


Vexorian 11-24-2006 09:25 PM

0.9.0 fixes bugs, adds structs, library_once and textmacro_once.

I didn't have time to document the aditions, the readme would be updated tomorrow with some luck.

this is a sample of structs:

Collapse JASS:
struct vec
    integer x = 0
    integer y=0
    integer z=0

function vec_add takes vec A, vec B returns vec
 local vec C= vec.create()
     set C.x = A.x + B.x
     set C.y = A.y + B.y
     set C.z = A.z + B.z
 return C

function vec_string takes vec A returns string
    return "("+I2S(A.x)+","+I2S(A.y)+","+I2S(A.z)+")"

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
 local vec a=vec.create()
 local vec b=vec.create()
 local vec c

    set a.x=2
    set a.y=2
    set a.z=5

    set b.x=-7
    set b.y=8
    set b.z=9

    set c=vec_add(a,b)

    call BJDebugMsg(vec_string(a)+" + "+vec_string(b) +" = "+vec_string(c))

//either works:
    call vec.destroy(c)
    call a.destroy()
    call b.destroy()


coming soon: methods, inheritance and polymorphism.

(static attributes are currently possible, also private members, although they have no use since there are no methods)

Notice structname.create() would return 0 if the 8190 instance limit is reached, if debug mode is enabled it would show a message in game in that case.

So just be careful not to create more than 8190 instances and if there is that possibility check if the returned struct is not 0.

Vexorian 11-24-2006 10:48 PM

a quickfix version, 0.9.1

zergleb 11-26-2006 10:32 PM

So I noticed in the syntax error screen that this doesn't use gamecache like you originally planned(I saw an example of how you thought OOP could work), but instead it uses arrays, does that mean that using this should be faster than game cache?

wyrmlord 11-27-2006 12:53 AM

Arrays are, as I hear, much faster than gamecache.

BlinkBoy 11-27-2006 02:23 AM

Hmm, can structs be set as globals? if yes can them be setted as global arrays, and how would you inialize them?

Vexorian 11-27-2006 02:54 AM

hmnn, I guess that with that calculus exam floating around I forgot to make the documentation anyways. Considering we declared the vec struct type of the previous post:
Collapse JASS:

     vec ouch = 0 //you can initialize an struct reference at 0 in a globals declaration

//syntax error:     vec ouch = vec.create() //you cannot do struct syntax in global declarations (because global blocks are always moved to the top of the script, before functions exist.

     vec array SOLUTIONS //yes, arrays are possible,


function doThings takes nothing returns nothing
      set ouch=vec.create()
      set SOLUTIONS[0] = vec.create()
      set SOLUTIONS[1] = vec.create()
      set SOLUTIONS[2] = vec.create()
 //and so and so...

Collapse JASS:
struct teststatic

    static integer N=0 //unlike 'normal' struct members these are static, they are effectively just global variables with other syntax
    static integer array V

//syntax error:    integer array X //array attributes are not allowed


function teststatic_fun takes nothing returns nothing
    set teststatic.N=teststatic.N+1
    set teststatic.V[ teststatic.N] = 8

PipeDream 11-28-2006 05:06 AM

Looking good. Can't wait to see methods & polymorphism.

Vexorian 11-28-2006 02:58 PM

0.9.2 grave bugs when struct compiler had to add more than 20 globals were fixed.

zergleb 11-29-2006 08:36 AM

Is there going to be private/public global variable OOP support?? what I mean is like right now to use public struct variables I must work it like this.
Collapse JASS:
function InitIncArg takes nothing returns nothing
    set KillUnit = IncType.create()//these all work fine
    set KillHero = IncType.create()
    set Construct = IncType.create()
    set TrainUnit = IncType.create()
    set Outpost = IncType.create()

    set KillUnit.Value = 1.0/10 //Not a struct name, nor a variable function of a struct type
    set ResourceSystem_KillHero.Value = 1.0/5
    set ResourceSystem_Construct.Value = 1.0/30
    set ResourceSystem_TrainUnit.Value = 1.0/20
    set ResourceSystem_Outpost.Value = 50.0

Just a question, nothing more.

btw thanks for the fixes in version 0.9.2 I always appreciate/enjoy your work and promptness fixing problems.

Vexorian 11-29-2006 11:51 AM

I don't understand the question.

Edit: I see, it is a bug, KillUnit should work, probably I forgot to consider . a token.

Edit: All right, bug fixed.

BlinkBoy 11-29-2006 05:05 PM

Ok, i've found some things and limitations, but also found a lil bug.

Collapse JASS:
struct domin
      integer tax = 0
      player conqueror = Player(13)
      boolean sur = false

      domin array V
      force array C

function Trig_Surrender_Settings_Actions takes nothing returns nothing
local integer f = 0
      set V[0] = domin.create()
      set V[1] = domin.create()
      set V[2] = domin.create()
      set V[3] = domin.create()
      set V[4] = domin.create()
      set V[5] = domin.create()
      set V[6] = domin.create()
      set V[7] = domin.create()
      set V[8] = domin.create()
      set V[9] = domin.create()
      set V[10] = domin.create()
      set V[11] = domin.create()
// In this way, the syntax is correct, but then if i try setting them dynamicly:
     set V[f] = domin.create()
     set f = f + 1
     exitwhen f >= 12
// This will cause a syntax error
set f = 0
    set C[f] = CreateForce()
    set f = f + 1
    exitwhen f >= 12

My first Question, will you improve the system to support dynamic arrays, with structures ?

Now a lil bug, that I found. If you set a struct variable in an if statement, it will cause a syntax error.

Collapse JASS:
if d != Player(13) and V[GetPlayerId(a)].sur == false then

so i must declare a boolean variable and give it that value

All times are GMT. The time now is 12:30 AM.

Powered by vBulletin (Copyright ©2000 - 2020, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services