• 🏆 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!

vrJASS

Status
Not open for further replies.
Level 10
Joined
Sep 19, 2011
Messages
527
Absolutely nothing happens when saving map with this.

Do you have the resources folder in the root of your newgen with the common.j and blizzard.j files?
Warcraft goes to the initial screen when trying the map?
Do you have java installed?
Which release did you tried?
Are you saving a w3m or w3x map?
Do you have the vrJASS option enabled?
Are you using the 5d version of NewGen?
 
Level 5
Joined
Dec 1, 2008
Messages
120
I have the files in correct folders.

Warcraft goes to the main menu.

I do have Java installed.

I tried the latest version with abstract classes.

Both .w3m and .w3x.

vrJass option is enabled.

Yeah, downloaded JNGP from the link you provided in the manual.
 
Level 5
Joined
Dec 1, 2008
Messages
120
Code:
Error in openArchive F:\Warcraft:  unknown error: 11Error in openArchive E:\Warcraft III Tools\JNGP vrJass\III\Maps\Projects\Dummy\vrjasstest.w3x:  unknown error: 3Error in openArchive E:\Warcraft III Tools\JNGP vrJass\III\Maps\Projects\Dummy\vrjasstest.w3x:  unknown error: 3Could not load blizzard.j or common.j

It has combined the paths of the JNGP folder and the map folder.

E:\Warcraft III Tools\JNGP vrJass
F:\Warcraft III\Maps\Projects\Dummy

Also, yeah, Windows machine.
 
Level 5
Joined
Dec 1, 2008
Messages
120
No error, map starts fine, but
JASS:
library foo // no need for 'initializer onInit'
    function onInit
        call BJDebugMsg("Nice!")
    endfunction
endlibrary
The message is not displayed.

It would be nice if the compiler created log files somewhere (source code + translated code).
 
Level 5
Joined
Dec 1, 2008
Messages
120
Okay that works. However, if I have a function onInit or if the method is not static in a struct, it will crash at init. Very impressive compile speed, though.

EDIT: Can you make next version accept filepaths with spaces?
 
Level 5
Joined
Dec 1, 2008
Messages
120
How do we write a create method on vrJass?

JASS:
library foo
	
	struct bar
		
		public static method create returns bar
			local bar this = bar.allocate()
			return this
		endmethod
		
	endstruct
	
endlibrary
This doesn't work.

Code:
73:22 Syntax error no viable alternative at input 'publicstaticmethodcreatereturnsbar\nlocalbarthis'


//===========================================================================
// Trigger: test
//===========================================================================
library foo
    
    struct bar
        
        public static method create returns bar
            local bar this = bar.allocate()
----------------------^
            return this
        endmethod
        
    endstruct
    
endlibrary//===========================================================================
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_test(  )
endfunction

EDIT: Spaces work now in filepaths.
 
Level 10
Joined
Sep 19, 2011
Messages
527
this is a reserved keyword so you cant declare a variable with that name.

To allocate you can just simple:

JASS:
globals
    integer instances = 0
endglobals

function allocate returns integer
    set instances += 1
    return instances
end

struct SomeStruct
    public static method allocate returns SomeStruct
        return allocate() cast SomeStruct
    end

    public static method create returns SomeStruct
        local SomeStruct myInstance = SomeStruct.allocate()
        
        call myInstace.someMethod()
        set myInstance.someProp = // ...

        return myInstance
    end
end

A few examples:

JASS:
library vr

globals
	integer uniqId = 0
end

public function getUniqId returns integer
	set uniqId += 1
	return uniqId
end

public function print takes string msg
	call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 90, msg)
end

public function printi takes integer i
	call print(I2S(i))
end

public function printo takes Object o
	call printi(o cast integer)
end

public function assert takes boolean b, string msg
	if (not b) then
		call print(msg)
	end
end

public interface Object
end

/**
 * Circular double linked list
 */
public struct LinkedList implements Object
	
	Object object
	
	LinkedList prev
	LinkedList next
	
	public method getObject returns Object
		return this.object
	end
	
	public method getPrev returns LinkedList
		return this.prev
	end
	
	public method getNext returns LinkedList
		return this.next
	end
	
	public method remove
		// Since it is a circular list, if only two element are left (head & node)
		// next next is going to be this
		local boolean onlyTwoElements = this == this.next.next
	
		if (onlyTwoElements) then
			set this.next.prev = null
		else
			set this.next.prev = this.prev
		end
		
		if (onlyTwoElements) then
			set this.prev.next = null
		else 
			set this.prev.next = this.next
		end
	end
	
	public static method create takes Object object, LinkedList prev, LinkedList next returns LinkedList
		local LinkedList ll = getUniqId() cast LinkedList
		
		// Circular link
		if (prev == null) then
			set prev = next
		end
		
		set ll.object = object
		set ll.prev = prev
		set ll.next = next
		
		set prev.next = ll
		set next.prev = ll
		
		return ll
	end
	
end

public struct Array implements Object

	LinkedList head
	LinkedList array nodes
	integer size
	
	public method getSize returns integer
		return this.size
	end
	
	public method get takes integer index returns Object
		return this.nodes[index].getObject()
	end
	
	public method contains takes Object object returns boolean
		local LinkedList node = this.head.getNext()
		
		while (node and node != this.head)
			if (node.getObject() == object) then
				return true
			end
			
			set node = node.getNext()
		end
		
		return false
	end
	
	public method add takes integer index, Object object
		set this.nodes[index] = LinkedList.create(object, this.head.getPrev(), this.head)
		set this.size += 1
	end
	
	public method remove takes integer index returns Object
		local LinkedList node = this.nodes[index]
		
		if (node) then
			call node.remove()
			
			set this.nodes[index] = null
			set this.size -= 1
		end
		
		return node.getObject()
	end
	
	public static method create returns Array
		local Array r = getUniqId() cast Array
		
		set r.head = LinkedList.create(null, null, null)
		set r.size = 0
		
		return r
	end

end

public struct Set implements Object

	Array objects
	
	public method contains takes Object object returns boolean
		return this.objects.get(object cast integer) != null
	end
	
	public method getSize returns integer
		return this.objects.getSize()
	end
	
	public method add takes Object object
		if (this.contains(object)) then
			return
		end
		
		call this.objects.add(object cast integer, object)
	end
	
	public method remove takes Object object
		call this.objects.remove(object cast integer)
	end
	
	public static method create returns Set
		local Set vrset = getUniqId() cast Set
		set vrset.objects = Array.create()
		return vrset
	end

end

public struct Stack implements Object

	Array objects
	
	public method push takes Object object
		call this.objects.add(this.objects.getSize(), object)
	end
	
	public method pop returns Object
		return this.objects.remove(this.objects.getSize() - 1)
	end
	
	public static method create returns Stack
		local Stack stack = getUniqId() cast Stack
		set stack.objects = Array.create()
		return stack
	end
	
end

public struct Queue implements Object

	LinkedList head
	
	public method enqueue takes Object object
		call LinkedList.create(object, this.head.getPrev(), this.head)
	end
	
	public method dequeue returns Object
		local LinkedList node = this.head.getNext()
		local Object object = node.getObject()
		
		call node.remove()
		
		return object
	end
	
	public static method create returns Queue
		local Queue queue = getUniqId() cast Queue
		set queue.head = LinkedList.create(null, null, null)
		return queue
	end
	
end

endlibrary
 
Level 5
Joined
Dec 1, 2008
Messages
120
So allocation and deallocation has to be handled by users themselves? That's a huge difference between vJass and vrJass.

In that case I don't understand this part of the manual:
They work pretty similar as they do in vJASS, but do keep in mind that they use Hashtable instead of arrays
 
Level 10
Joined
Sep 19, 2011
Messages
527
Allocation (for the moment) has to be handled by the user yes. But since a lot of people don't like the default allocator of vJASS (they implement their own or use an external one) this shouldn't be an issue.

What you quote refers the way vJASS translates structs (uses array) against how vrJASS does (uses Hashtable)
 
Level 10
Joined
Sep 19, 2011
Messages
527
vrJASS now gets deployed and the files automatically uploaded to GitHub thanks to Travis ^^.

Right now I'm working on better syntax error messages since something simple like

JASS:
public static method create returns bar
    local bar this
end

Gives
Code:
Syntax error no viable alternative at input 'publicstaticmethodcreatereturnsbar\nlocalbarthis'

When it should simple say:
Code:
Syntax error mismatched input 'this' expecting 'end', Identifier
(this is a reserved keywords hence cannot be used as variable name)
 
Level 10
Joined
Sep 19, 2011
Messages
527
Almost done. The grammar now will be a lot more aggressive.

Right now, something like "foo".bar() will be accepted and a CompileException will be thrown (it should be a syntax error). With this, it should be a lot faster to give feedback on simple errors like the previous example. Not only that, the error messages are going to be actually helpful.

EDIT: Never mind, it completely killed performance (it took 5+ segs to run...).
 
Last edited:
Level 4
Joined
Mar 17, 2015
Messages
36
Cool Project!

It's good to have an enhanced version of our language.
I think this project will make it's own community after it reaches it's reputation
and I'm excited about it!

"This is the future..."

I would like to contribute to this project because
I think I can handle Java, which is like C#(...my primary language),
and I feel safe about it.
 
Level 10
Joined
Sep 19, 2011
Messages
527
Update: implementations must share the same visibility of the contract (interface/abstract-struct):

JASS:
interface foo
    public method baz
end
struct bar implements foo
    method baz
    end
end

Throws: "5:11 Method <baz> must be PUBLIC"

Update: now implemens and extends can use chain expressions.

JASS:
struct Foo extends Some.Bar ...
 
Last edited:
Level 10
Joined
Sep 19, 2011
Messages
527
for those concern about how vrjass translates to raw jass:

DdEZ3fA.gif

as you can see, you also have realtime error checking. if you're interested in this lint plugin let me know and i will upload it ^^.
 
Last edited:
Level 6
Joined
Mar 7, 2011
Messages
124
this is cool stuff. from a design standpoint, i really like that you decided to stick to a mostly familiar API even though that probably wasn't your ideal. the advertised improvements under the hood sound even better. specifically about interfaces: are they now usable when latency is a big concern?

the minor tweaks you did make to syntax were objectively nice, especially replacing '_' with '.' for context levels, that's so much better. that said, like probably everyone else converting vJASS to your vrJASS, im going to get a little bored converting to your syntax... is there a tool for automating that? i tried searching this thread for a bunch of things, but the 15s wait time got old quick, sorry for any repeat questions. maybe a FAQ section on your github, that's where I checked first anyways

i've been considering coming back to an old project but it's got a pretty sprawling codebase and going from VS to WEU keeps me away. i saw another one of your posts about sublime text + lint, and this latest about a real time error checking plugin; between your new syntax and my curiosity about sublime in general i'm tempted again. is there any chance i'd be able to develop the full codebase in sublime? and would it be easy to push that code to a runnable map? i'm not familiar with using sublime at all

if sublime isn't what im looking for, can you recommend any tools for developing a large codebase? WE demands a bit more time and patience than i can give it
 
Level 10
Joined
Sep 19, 2011
Messages
527
Hi, thanks man ^^.

Well interfaces do not use triggers as they do in vJASS, instead just a function call checking its type.

Sadly, for the moment there is no tool to convert vJASS to vrJASS.

FAQ, it may be a good idea although you guys will have to help me with the questions xD.

About sublime text, yes I have to polish a little bit more the import statement (allow to include folders; fix relative paths; error messages; etc) to get the essential. After that I would like to improve the plugin (to provide useful auto-complete).

To include the codes into the map, you would have to use the import statement.

Edit: I could recommend you by far the WurstScript project.
 
Level 6
Joined
Mar 7, 2011
Messages
124
a few questions that probably apply to most: who would get the most benefit from vrJASS over vJASS (just stick to comparing the main alternative), and compatibility with vJASS (i know you have a few places where you say there may be future compatibility, maybe go into a bit of detail about the plan)

The plugin improvements sound great, I'd love to try it out once you're finished

Thanks for the tip on WurstScript. That Eclipse plugin might be exactly what i need
 
Level 10
Joined
Sep 19, 2011
Messages
527
Thank Purge ^^.
Use no params to display the help.

For the text file, it would be:

Code:
java -jar vrjassc-jar-with-dependencies.jar yourfile.j

If you'have common.j and blizzard.j in a custom location, you must pass them too, so:

Code:
java -jar vrjassc-jar-with-dependencies.jar common.j blizzard.j yourfile.j

The log file will log & save the errors if there were any.
 
Level 10
Joined
Sep 19, 2011
Messages
527
Update: Improved import statement.

Now imports are made using the import statement rather than a comment

JASS:
import "somePackage.j"
import "somePackage.j" // only included once
import "otherPackage.j"

If the imported file could not be found, it will throw an error.
If there is an error on the imported package, it will mark it (for example, otherPackage.j has an error, thus it will be marked).
 
Last edited:
Level 10
Joined
Sep 19, 2011
Messages
527
Ok pp, right now I'm working on the autocomplete feature, and I'm simply amazed because it only required a few tweaks on the compiler to return simple (but correct) suggestions.

So:

JASS:
library a
    globals
        public boolean b
    endglobals
    public function foo returns integer
        return 1
    end
    function bar
    end
end
function baz
    call a. // -> HERE, autocomplete!
end

The result is [b, foo]
 
Level 10
Joined
Sep 19, 2011
Messages
527
Hi Almia,

1) Ternary operator is already supported by JASS using functions (IntegerTernaryOp it was I believe).
EDIT: Although, now that I'm thinking I could provide some replacement/suggar, so the common ternary expression could be translated to use the BJs functions. I could implement this to modulo as well.

2) Sorry I didn't understand, could you provide me an example please?.
 
Status
Not open for further replies.
Top