2014-04-14 03:35:26 +00:00
|
|
|
/***********************************************************************
|
|
|
|
|
|
|
|
|
|
ColaScript standart library. Need for translation.
|
|
|
|
|
|
|
|
|
|
Distributed under the BSD license:
|
|
|
|
|
|
2014-04-15 12:47:04 +00:00
|
|
|
Copyright 2014 (c) TrigenSoftware <danon0404@gmail.com>
|
2014-04-14 03:35:26 +00:00
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
|
are met:
|
|
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
|
copyright notice, this list of conditions and the following
|
|
|
|
|
disclaimer.
|
|
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
|
copyright notice, this list of conditions and the following
|
|
|
|
|
disclaimer in the documentation and/or other materials
|
|
|
|
|
provided with the distribution.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
|
|
|
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
|
|
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
|
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
2014-05-19 17:29:01 +00:00
|
|
|
!this.Cola && (this.Cola = {});
|
|
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$is = function _ColaRuntime$$is(_object, _type){
|
2014-05-31 20:14:13 +00:00
|
|
|
return _object === _type || _type.prototype && (_object instanceof _type || _object.__proto__ === _type.prototype);
|
2014-04-14 03:35:26 +00:00
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$is.i = 0;
|
2014-04-14 03:35:26 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$isnt = function _ColaRuntime$$isnt(_object, _type){
|
2014-05-31 20:14:13 +00:00
|
|
|
return !(_object === _type || _type.prototype && (_object instanceof _type || _object.__proto__ === _type.prototype));
|
2014-04-14 03:35:26 +00:00
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$isnt.i = 1;
|
2014-04-14 03:35:26 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$modulo = function _ColaRuntime$$modulo(_a, _b){
|
2014-04-14 03:35:26 +00:00
|
|
|
return (_a % _b + +_b) % _b;
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$modulo.i = 2;
|
2014-04-14 03:35:26 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$isset = function _ColaRuntime$$isset(_object){
|
2014-04-14 03:35:26 +00:00
|
|
|
return !(typeof _object === "undefined" || _object === null);
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$isset.i = 3;
|
2014-04-14 03:35:26 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$isntset = function _ColaRuntime$$isntset(_object){
|
2014-04-14 03:35:26 +00:00
|
|
|
return (typeof _object === "undefined" || _object === null);
|
2014-04-18 06:10:20 +00:00
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$isntset.i = 4;
|
2014-04-18 06:10:20 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$clone = function _ColaRuntime$$clone(_item){
|
2014-04-20 07:31:03 +00:00
|
|
|
if (_item === undefined || _item === null) return _item;
|
|
|
|
|
if (_item.__clone__ instanceof Function) return _item.__clone__();
|
|
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
if(_item instanceof Number) return Number(_item);
|
|
|
|
|
if(_item instanceof String) return String(_item);
|
|
|
|
|
if(_item instanceof Boolean) return Boolean(_item);
|
2014-04-20 07:31:03 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
var result;
|
2014-04-20 07:31:03 +00:00
|
|
|
|
|
|
|
|
if (!(_item instanceof Object)) return _item;
|
|
|
|
|
|
|
|
|
|
if (_item.nodeType && _item.cloneNode instanceof Function) return _item.cloneNode( true );
|
|
|
|
|
|
|
|
|
|
if (!_item.prototype) {
|
|
|
|
|
if (_item instanceof Date) return new Date(_item);
|
|
|
|
|
if (_item instanceof Function) return _item;
|
|
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
result = new (Object.getPrototypeOf(_item).constructor);
|
|
|
|
|
for (var i in _item) result[i] = _ColaRuntime$$clone( _item[i] );
|
2014-04-20 07:31:03 +00:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _item;
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$clone.i = 5;
|
2014-04-20 07:31:03 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$array_last = function _ColaRuntime$$array_last(_array){
|
2014-04-20 18:56:47 +00:00
|
|
|
return _array[_array.length - 1];
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$array_last.i = 6;
|
2014-04-20 18:56:47 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$array_range = function _ColaRuntime$$array_range(_from, _to){
|
2014-04-22 13:33:43 +00:00
|
|
|
var range = [];
|
|
|
|
|
if(_from <= _to) for(var i = _from; i <= _to; i++) range.push(i);
|
|
|
|
|
else for(var i = _from; i >= _to; i--) range.push(i);
|
|
|
|
|
return range;
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$array_range.i = 7;
|
2014-04-22 13:33:43 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$array_asplice = function _ColaRuntime$$array_asplice(_array, _from, _to, _a){
|
2014-04-22 13:33:43 +00:00
|
|
|
_to = _to - _from + 1;
|
2014-04-28 08:20:12 +00:00
|
|
|
return [].splice.apply(_array, [_from, _to].concat(_a)), _a;
|
2014-04-22 13:33:43 +00:00
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$array_asplice.i = 8;
|
2014-04-22 13:33:43 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$func_named_args = function _ColaRuntime$$func_named_args(_args){
|
2014-04-27 20:30:25 +00:00
|
|
|
this.$ = _args;
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$func_named_args.i = 9;
|
2014-04-27 20:30:25 +00:00
|
|
|
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$func_set_named_args = function _ColaRuntime$$func_set_named_args(_args){
|
|
|
|
|
if(_args[_args.length - 1] instanceof _ColaRuntime$$func_named_args){
|
2014-05-16 12:27:51 +00:00
|
|
|
var nargs = _args[_args.length - 1].$;
|
2014-04-27 20:30:25 +00:00
|
|
|
for(var i in nargs) if(nargs.hasOwnProperty(i))
|
|
|
|
|
_args[i] = nargs[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$func_set_named_args.i = 10;
|
2014-08-14 21:19:06 +00:00
|
|
|
|
|
|
|
|
Cola._ColaRuntime$$error = function _ColaRuntime$$error(_error) {
|
|
|
|
|
throw new Error(_error);
|
|
|
|
|
};
|
|
|
|
|
Cola._ColaRuntime$$error.i = 11;
|
|
|
|
|
|
2014-08-15 10:45:46 +00:00
|
|
|
Cola._ColaRuntime$$array_negate_access = function _ColaRuntime$$array_negate_access(_array, _index) {
|
|
|
|
|
return _array instanceof Array ? _array.length + _index : _index;
|
|
|
|
|
};
|
|
|
|
|
Cola._ColaRuntime$$array_negate_access.i = 12;
|
|
|
|
|
|
|
|
|
|
Cola._ColaRuntime$$array_modulo_access = function _ColaRuntime$$array_modulo_access(_array, _index) {
|
|
|
|
|
return _array instanceof Array ? ((_index % _array.length + +_array.length) % _array.length) : _index;
|
|
|
|
|
};
|
|
|
|
|
Cola._ColaRuntime$$array_modulo_access.i = 13;
|
|
|
|
|
|
2014-08-16 11:52:15 +00:00
|
|
|
Cola._ColaRuntime$$updateProperty = function _ColaRuntime$$updateProperty(_object, _propname, _props) {
|
|
|
|
|
var _dprops = Object.getOwnPropertyDescriptor(_object, _propname) || {};
|
|
|
|
|
for(var key in _props)
|
|
|
|
|
if(_props.hasOwnProperty(key)) _dprops[key] = _props[key];
|
|
|
|
|
return Object.defineProperty(_object, _propname, _dprops);
|
|
|
|
|
};
|
|
|
|
|
Cola._ColaRuntime$$updateProperty.i = 14;
|
|
|
|
|
|
|
|
|
|
Cola._ColaRuntime$$arguments_def = { i : 15 };
|
2014-04-27 20:30:25 +00:00
|
|
|
|
|
|
|
|
Cola.$_cola =
|
2014-08-14 13:05:38 +00:00
|
|
|
Cola._ColaRuntime$$is + Cola._ColaRuntime$$isnt + Cola._ColaRuntime$$modulo + Cola._ColaRuntime$$isset +
|
|
|
|
|
Cola._ColaRuntime$$isntset + Cola._ColaRuntime$$clone + Cola._ColaRuntime$$array_last + Cola._ColaRuntime$$array_range +
|
2014-08-14 21:19:06 +00:00
|
|
|
Cola._ColaRuntime$$array_asplice + Cola._ColaRuntime$$func_named_args + Cola._ColaRuntime$$func_set_named_args + Cola._ColaRuntime$$error +
|
2014-08-16 11:52:15 +00:00
|
|
|
Cola._ColaRuntime$$array_negate_access + Cola._ColaRuntime$$array_modulo_access + Cola._ColaRuntime$$updateProperty +
|
2014-05-22 15:44:11 +00:00
|
|
|
"var arguments;";
|
2014-04-22 13:33:43 +00:00
|
|
|
|
|
|
|
|
Cola.Compressor.StdFuncs = {
|
2014-08-14 13:05:38 +00:00
|
|
|
_ColaRuntime$$modulo : true
|
2014-04-22 13:33:43 +00:00
|
|
|
};
|