Added little manual, check it out at https://github.com/Ruk33/vrJASS/wiki
Also, main post updated.
Also, main post updated.
Absolutely nothing happens when saving map with this.
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
library foo // no need for 'initializer onInit'
function onInit
call BJDebugMsg("Nice!")
endfunction
endlibrary
library foo
struct bar
public static method create returns bar
local bar this = bar.allocate()
return this
endmethod
endstruct
endlibrary
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
this
is a reserved keyword so you cant declare a variable with that name.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
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
They work pretty similar as they do in vJASS, but do keep in mind that they use Hashtable instead of arrays
super
was implemented.public static method create returns bar
local bar this
end
Syntax error no viable alternative at input 'publicstaticmethodcreatereturnsbar\nlocalbarthis'
Syntax error mismatched input 'this' expecting 'end', Identifier
this
is a reserved keywords hence cannot be used as variable name)"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.cast myVar to SomeStruct
instead of myVar cast SomeStruct
.Hey protected is what was always missing in vJass. It's great you added it. Do you already support stub/overriding methods? vJass has a bug where you cannot override stub methods which are not directly from a parent struct.
interface foo
public method baz
end
struct bar implements foo
method baz
end
end
struct Foo extends Some.Bar ...
java -jar vrjassc-jar-with-dependencies.jar yourfile.j
java -jar vrjassc-jar-with-dependencies.jar common.j blizzard.j yourfile.j
import "somePackage.j"
import "somePackage.j" // only included once
import "otherPackage.j"
p.s. do you have a sublime package for this?![]()
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
continue
statement (thanks Aniki ^^).a = b or 0 -- if b is null, 0 will the value for a. If not, a = b.
a = b and 2147483647 -- if b is null, a = null, if b is not null, a = 2147483647.