• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

PJass updates

Status
Not open for further replies.

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
For leandro and all the crazy hackers out there i added the flags //# +nosyntaxerror and //# +nosemanticerror which are quite the sledgehammers. They do exactly as they are named: ignore syntax/semantic errors in the function so only use these if you know what you are doing.

I still would consider this a test release as this is based off of my refactor branch. I also added a //# +filter flag which enables the old behavior of the Filter check for functions that do not return booleans. I don't know if people are still on these old patches but i felt like adding it again.
 

Attachments

  • pjass-git-8fdc641.zip
    38.3 KB · Views: 642
  • pjass-git-8fdc641-src.zip
    46.7 KB · Views: 306

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Help, How do I update my PJass?
You download the zip. Extract pjass.exe and replace your old pjass.exe with the new one.
Your old pjass.exe should reside in your jassnewgenpack-folder/jasshelper/
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Okay

How about the other zip file, the other one of the two above?
You could download it and see it yourself. The other zip is named -src.zip.
I release the source code of pjass aswell as the exe.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
please, can we have something like //#noparse option, which will disable synt check for line it stands at? or //#noparsestart //#noparseend for blocks, idk. isn't big deal, but irritating
i dont see the use with //# +nosyntaxerror already in place.


I've already replaced my pjass.exe. I'm curious if there's still something I have to do with the source codes?
no.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
one more thing
if function receives a real value
call MyFunc(.) won't cause any alert, tho this is invalid code. it should be either MyFunc(0.) or MyFunc(.0), but not just dot.

Oh yes i was always somewhat aware of that but decided to ignore it.
Here's a new version with that fixed.
Also some new features:

Code:
$ cat tests/should-fail/not-enough-parameters.j
native Foo takes integer x, real bla, string wat, handle asdf, integer y returns nothing

function test takes nothing returns nothing
    call Foo(3, 3.1, "bla")
endfunction

$ ./pjass.exe tests/should-fail/not-enough-parameters.j
tests/should-fail/not-enough-parameters.j:5: Not enough arguments passed to function Foo. Still missing: asdf, y
tests/should-fail/not-enough-parameters.j failed with 1 error
Parse failed: 1 error total


Code:
$ cat tests/should-fail/wrong-types-in-call.j
native Foo takes integer x, real bla returns nothing

function test takes nothing returns nothing
    call Foo(3.4, "foo" )
endfunction

$ ./pjass.exe tests/should-fail/wrong-types-in-call.j
tests/should-fail/wrong-types-in-call.j:5: Cannot convert real to integer in parameter x in call to Foo
tests/should-fail/wrong-types-in-call.j:5: Cannot convert string to real in parameter bla in call to Foo
tests/should-fail/wrong-types-in-call.j failed with 2 errors
Parse failed: 2 errors total

Also this was cross-compiled from an ubuntu-vm... so it works for me atleast
 

Attachments

  • pjass-git-86b74d6.zip
    26.7 KB · Views: 181
  • pjass-git-86b74d6-src.zip
    42.5 KB · Views: 134

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Hi man! I do not want to be impertinent, but I wanted to know if you were making any changes in the pjass to work with Memory Hack? (I'm really impassive)
But pjass is already able to handle with the memory hack (if not, hit me up) if you insert the right annotations. Im sure if you search this thread you can find which annotations im talking about. You have to modify the memory-hack j-file. Not the code, you just have to add a few comments. Once you've tried to do it yourself and still have problems feel free to ask.

e: look at my code here for an example.
 
Last edited:
Level 9
Joined
Jun 21, 2012
Messages
432
But pjass is already able to handle with the memory hack (if not, hit me up) if you insert the right annotations. Im sure if you search this thread you can find which annotations im talking about. You have to modify the memory-hack j-file. Not the code, you just have to add a few comments.

Thanks man! I just had to use //# +nosemanticerror (I thought it was just a simple comment xd)

EDIT: <33
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
can you add listing of all ingame natives (including common/ai/blizzard) into check list to see whenever there's declared non-existant native in the script? just forgot to disable side-stuff and took a while to understand what went wrong
Hmm, i don't think this is any good for multiple reasons.
1) You very rarely declare a new native. Most of the time it's one of three known ones.
2) If you declare a new native you should be aware of it.
3) I would to have keep track of natives over patches. I know i could special case it to some patch as it would be avaible only via some flag anyways but it seems like a very specialized use-case to me.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
Hmm, i don't think this is any good for multiple reasons.
1) You very rarely declare a new native. Most of the time it's one of three known ones.
2) If you declare a new native you should be aware of it.
3) I would to have keep track of natives over patches. I know i could special case it to some patch as it would be avaible only via some flag anyways but it seems like a very specialized use-case to me.
can we assume there would be no patches since 27? it barely awaited by anyone
ye, normally im aware of, but sometimes.. really sometimes :D
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
I did this. Still open for better wording.
Also now with all sources hopefully. I feel already said something likes this before...
 

Attachments

  • pjass-git-f128812.zip
    26.7 KB · Views: 182
  • pjass-git-f128812-src.zip
    48.1 KB · Views: 148

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
can you plz add a check for GetObjectName used in globals block? this func causes instant fatal on selecting map in the list or starting game on it. basically bad idea to ask for object name, yeah, but why the fuck fatal, plz.
yeah sounds like a good idea; i have several other such functions in my jassdb.
 
Sounds good, but there are also some functions that should not be used for example onInits, like multiboard creations.
The point is you can't entirely protect the user from "wrong" jass usage, when it's about semantics.
Generaly maybe: syntax allowed -> technicaly no error from pjass.
But sure, in case you want to catch some cases, it will have only benefits, was just saying.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
Can you please add support for the following bug:
JASS:
globals
 boolean b
endglobals

function A takes nothing returns nothing
    local integer b
...blah blah
endfunction

function B takes nothing returns nothing
    set b=true
if b then
endif
endfunction
thats typecasting indeed, but sometimes - unwillingly. Im working with de-protected maps and 1-2 letters fuck up local declarations in custom functions sometimes. if the parser can detect if global variable somehow being redeclared as a different type, it would be great, as typecasting isn't big thing for 99.9% mapmakers anyway
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
can you plz add a check for GetObjectName used in globals block? this func causes instant fatal on selecting map in the list or starting game on it. basically bad idea to ask for object name, yeah, but why the fuck fatal, plz.

I've added a bunch of functions which crash in a globals block. Can be disabled via +noruntimeerror flag.
I also added functions which return null in a globals block. I'm open to discussion about this one though. Might be better to just write a general jass linter.

Can you please add support for the following bug:
JASS:
globals
 boolean b
endglobals

function A takes nothing returns nothing
    local integer b
...blah blah
endfunction

function B takes nothing returns nothing
    set b=true
if b then
endif
endfunction
thats typecasting indeed, but sometimes - unwillingly. Im working with de-protected maps and 1-2 letters fuck up local declarations in custom functions sometimes. if the parser can detect if global variable somehow being redeclared as a different type, it would be great, as typecasting isn't big thing for 99.9% mapmakers anyway

I don't understand. What's the error here? Can't you just use +shadow flag?
 

Attachments

  • pjass-git-3e6ac27.zip
    24.6 KB · Views: 109
  • pjass-git-3e6ac27-src.zip
    50.2 KB · Views: 113

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
that's invalid code which won't run but your tool won't notice that.
since declared as integer at local block 'b' can't get assigned boolean value, only integer. engine counts it as error
Can you give me a map which wont run but which pjass accepts?
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Can you please add support for the following bug:
JASS:
globals
 boolean b
endglobals

function A takes nothing returns nothing
    local integer b
...blah blah
endfunction

function B takes nothing returns nothing
    set b=true
if b then
endif
endfunction
thats typecasting indeed, but sometimes - unwillingly. Im working with de-protected maps and 1-2 letters fuck up local declarations in custom functions sometimes. if the parser can detect if global variable somehow being redeclared as a different type, it would be great, as typecasting isn't big thing for 99.9% mapmakers anyway

Have you used +shadow? That could've helped to find the error.
Nevertheless i have corrected the handling of shadowed variables. Here are the details:
If you shadow a variable with an incompatible type, that is a type which doesn't have the same primitive ancestor, every usage of that variable later in the script file(sic) will have the wrong type and wc3 will bail. You can still use the original global variable as long as all occurences of it in the source file are above the bad shadow.

This is of course how the current returnbug works.
 

Attachments

  • pjass-git-0500a60.zip
    24.7 KB · Views: 157
  • pjass-git-0500a60-src.zip
    51.5 KB · Views: 136
Level 19
Joined
Dec 12, 2010
Messages
2,069
But it even was you who requested error on shadowing...
my memory is rly short, especially for forums. tons of info everyday, sorry. I didn't need shadowing on my dota, but last month I got hooked to another project which is acutally clusterfuck with a single-letter globals like "x" or so. After all this time I would never recall about the shadow flags
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Where can I see the changelog?

Also, is it possible to make pjass inlines one-liner ExecuteFunc? Example:
JASS:
library L

    struct MyStruct
        private static real x
        private static method oneLiner takes nothing returns nothing
            set thistype.x = 42
        endmethod
    endstruct

endlibrary

function Main takes nothing returns nothing
    call ExecuteFunc("s__MyStruct__oneLiner")
endfunction

will turn into something like

JASS:
function Main takes nothing returns nothing
    set s__MyStruct__s = 42
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Where can I see the changelog?

I don't have a changelog per se but all the changes are documented in this thread. And most of the time in the post where i attached a new version.

Also, is it possible to make pjass inlines one-liner ExecuteFunc? Example:
JASS:
library L

    struct MyStruct
        private static real x
        private static method oneLiner takes nothing returns nothing
            set thistype.x = 42
        endmethod
    endstruct

endlibrary

function Main takes nothing returns nothing
    call ExecuteFunc("s__MyStruct__oneLiner")
endfunction

will turn into something like

JASS:
function Main takes nothing returns nothing
    set s__MyStruct__s = 42
endfunction
No. pjass is only to check pure jass. This should be done in another tool like jasshelper/wurst/<insert any jass optimizer here>.
Also your proposed optmisation actaully changes the semantic of the code so no tool should rewrite it that way.
 
Level 9
Joined
Jun 21, 2012
Messages
432
Where can I see the changelog?

Also, is it possible to make pjass inlines one-liner ExecuteFunc? Example:
JASS:
library L

    struct MyStruct
        private static real x
        private static method oneLiner takes nothing returns nothing
            set thistype.x = 42
        endmethod
    endstruct

endlibrary

function Main takes nothing returns nothing
    call ExecuteFunc("s__MyStruct__oneLiner")
endfunction

will turn into something like

JASS:
function Main takes nothing returns nothing
    set s__MyStruct__s = 42
endfunction

That would be very useful.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
It's mostly because of single lined onInit functions. The onInits are compiled into ExecuteFunc and most of them (if not, all) are placed at the very bottom of the script. The purpose of executing on a new thread seems pointless and I doubt these one-liner onInit would cause an OPLimit.

"easy to make yourself anyway"
How? Without doing it manually.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
I think that's not possible. Ok here's the thing, I'm using this which is a module. It has an onInit function that looks something like this
JASS:
private static method onInit takes nothing returns nothing
            set recycler[0] = 1
endmethod
Everytime it is implemented, it generates it's own 1-lined onInit function that has to go through ExecuteFunc. No workaround can be done via script in my opinion. Anyway, this should be done by JassHelper not pjass but no one manages JassHelper anymore (I think?) while pjass is still somewhat active so I just tried my luck here.

Sorry for the offtopic.
 
Level 3
Joined
May 19, 2010
Messages
35
Could you add something similar as //# +nosemanticerror but a bit weaker.
Ideally I would like something to annotate a function that takes a code parameter, to disable the parameter checks. I think an example describes it best:
JASS:
function TakesParameter takes integer i returns nothing
endfunction

function Evil takes code c returns nothing
endfunction

//# +nosemanticerror
function Foo takes nothing returns nothing
    call Evil(function TakesParameter)
endfunction

To run this code I have to annotate Foo with //# +nosemanticerror. What I would like to do is:
JASS:
//# +AllowArbitraryCodeParameter
function Evil takes code c returns nothing
endfunction

function Foo takes nothing returns nothing
    call Evil(function TakesParameter)
endfunction

If that is too much work to implement, something like this would also help:
JASS:
function Foo takes nothing returns nothing
    //# +nosemanticerror
    call Evil(function TakesParameter)

   // rest of function has error checking like normal
endfunction

I'm working with evil(TM) bytecode hackery and it's a bit annoying to have no error checking on like half of all my functions.

P.S. Really big thank you for pjass, it's a really awesome tool that makes coding in jass bearable.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Could you add something similar as //# +nosemanticerror but a bit weaker.
Ideally I would like something to annotate a function that takes a code parameter, to disable the parameter checks. I think an example describes it best:
JASS:
function TakesParameter takes integer i returns nothing
endfunction

function Evil takes code c returns nothing
endfunction

//# +nosemanticerror
function Foo takes nothing returns nothing
    call Evil(function TakesParameter)
endfunction

To run this code I have to annotate Foo with //# +nosemanticerror. What I would like to do is:
JASS:
//# +AllowArbitraryCodeParameter
function Evil takes code c returns nothing
endfunction

function Foo takes nothing returns nothing
    call Evil(function TakesParameter)
endfunction

If that is too much work to implement, something like this would also help:
JASS:
function Foo takes nothing returns nothing
    //# +nosemanticerror
    call Evil(function TakesParameter)

   // rest of function has error checking like normal
endfunction

I'm working with evil(TM) bytecode hackery and it's a bit annoying to have no error checking on like half of all my functions.

P.S. Really big thank you for pjass, it's a really awesome tool that makes coding in jass bearable.


Hm yes i can see that //# +no<x>error is quite the sledgehammer.
Adding a new flag would be very very easy but im unsure if it's the right way. If you don't watch out you get a million flags in the end. I like the approach of annotating functions instead of lines, which also constrains me a bit. I guess just adding a flag to not check code arguments is the pragmatic way here; and then see if we ever get a flag mess...
 
Level 3
Joined
May 19, 2010
Messages
35
If you don't watch out you get a million flags in the end.
I see, you also use gcc :grin:

One way to avoid the flag hell may be not to add a flag for every possible error, but one flag with a parameter.
Like pjass +disable-error function-parameter +disable-error return-bug.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Strange, it does catch local variables which aren't initilized but used, but doesn't check globals for all the same issue? I just got this issue lately.
JASS:
globals
 unit someGlobal
endglobals
function test takes nothing returns nothing
 call BJDebugMsg(GetUnitName(someGlobal))
endfunction
Because that is, atleast with pjass' architecture, a way harder problem.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Just bringing the binaries posted here uptodate with my git.
Changes from 0500a60:
  • Better errormessage for missing local identifier
  • Better errormessage for passing arguments to a function literal: return function foo(3)
  • Don't report an array variable with missing index as unintialized
 

Attachments

  • pjass-git-72e93bd.zip
    24.8 KB · Views: 179
  • pjass-git-72e93bd-src.zip
    52.7 KB · Views: 122
Status
Not open for further replies.
Top