Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ACC_FLAGS = {
- ["ACC_PUBLIC"] = 0;
- ["ACC_PRIVATE"] = 1;
- ["ACC_FINAL"] = 2;
- ["ACC_STATIC"] = 3;
- ["ACC_SYNTHETIC"] = 4;
- ["ACC_PROPERTY"] = 14;
- ["ACC_ASYNC"] = 15;
- }
- local NATIVE_TYPES = {
- ["number"] = 5;
- ["table"] = 6;
- ["thread"] = 7;
- ["function"] = 8;
- ["string"] = 9;
- ["boolean"] = 10;
- ["void"] = 11;
- ["object"] = 12;
- ["generic"] = 13;
- }
- local resolve = function(annotations,sig)
- local resolved = {}
- for i=1,#(annotations or {}) do
- if annotations[i] == "public" then resolved[ACC_FLAGS.ACC_PUBLIC] = true end
- if annotations[i] == "private" then resolved[ACC_FLAGS.ACC_PRIVATE] = true end
- if annotations[i] == "final" then resolved[ACC_FLAGS.ACC_FINAL] = true end
- if annotations[i] == "static" then resolved[ACC_FLAGS.ACC_STATIC] = true end
- if annotations[i] == "synthetic" then resolved[ACC_FLAGS.ACC_SYNTHETIC] = true end
- if annotations[i] == "property" then resolved[ACC_FLAGS.ACC_PROPERTY] = true end
- if annotations[i] == "async" then resolved[ACC_FLAGS.ACC_ASYNC] = true end
- if annotations[i] == "number" then resolved[NATIVE_TYPES.number] = true sig.fieldType = "number" end
- if annotations[i] == "Table" then resolved[NATIVE_TYPES.table] = true sig.fieldType = "table" end
- if annotations[i] == "thread" then resolved[NATIVE_TYPES.thread] = true sig.fieldType = "thread" end
- if annotations[i] == "String" then resolved[NATIVE_TYPES.string] = true sig.fieldType = "string" end
- if annotations[i] == "function" then resolved[NATIVE_TYPES.Function] = true sig.fieldType = "function" end
- if annotations[i] == "boolean" then resolved[NATIVE_TYPES.boolean] = true sig.fieldType = "boolean" end
- if annotations[i] == "void" then resolved[NATIVE_TYPES.void] = true sig.fieldType = "void" end
- if annotations[i] == "object" then resolved[NATIVE_TYPES.object] = true sig.fieldType = "object" end
- if annotations[i] == "generic" then resolved[NATIVE_TYPES.generic] = true sig.fieldType = "generic" end
- end
- if (not resolved[0]) and (not resolved[1]) then
- resolved[0] = true
- end
- return resolved
- end
- local signature = function(class,id,annotations,value,_type,objType)
- local sig = {}
- sig.class = class
- sig.name = id
- sig.value = value
- sig.type = _type
- sig.fieldType = nil
- sig.objType = objType
- sig.settable = false
- sig.gettable = false
- sig.annotations = resolve(annotations,sig)
- sig.toPath = function() -- order: public | private | static | final
- local p = "/"
- if sig.annotations[ACC_FLAGS.ACC_PUBLIC] then p = p.."public/" end
- if sig.annotations[ACC_FLAGS.ACC_PRIVATE] then p = p.."private/" end
- if sig.annotations[ACC_FLAGS.ACC_STATIC] then p = p.."static/" end
- if sig.annotations[ACC_FLAGS.ACC_FINAL] then p = p.."final/" end
- return p
- end
- sig.public = function()
- return (sig.annotations[ACC_FLAGS.ACC_PUBLIC] or (sig.annotations[ACC_FLAGS.ACC_PUBLIC] == nil and sig.annotations[ACC_FLAGS.ACC_PRIVATE] == nil and
- sig.annotations[ACC_FLAGS.ACC_STATIC] == nil and sig.annotations[ACC_FLAGS.ACC_FINAL] == nil))
- end
- sig.private = function()
- return (sig.annotations[ACC_FLAGS.ACC_PRIVATE] == true)
- end
- sig.static = function()
- return (sig.annotations[ACC_FLAGS.ACC_STATIC] == true)
- end
- sig.final = function()
- return sig.annotations[ACC_FLAGS.ACC_FINAL] == true
- end
- sig.generic = function()
- return sig.annotations[NATIVE_TYPES.generic] == true
- end
- sig.property = function()
- return sig.annotations[ACC_FLAGS.ACC_PROPERTY] == true
- end
- sig.hasType = function()
- return sig.fieldType ~= nil
- end
- sig.getType = function()
- return sig.fieldType
- end
- sig.setType = function(t)
- sig.fieldType = t
- end
- sig.async = function()
- return sig.annotations[ACC_FLAGS.ACC_ASYNC] == true
- end
- return sig
- end
- return signature
Advertisement
Add Comment
Please, Sign In to add comment