MCPcopy Create free account
hub / github.com/fastadminnet/fastadmin / DEFNODE

Function DEFNODE

application/admin/command/Min/r.js:14665–14707  ·  view source on GitHub ↗
(type, props, methods, base)

Source from the content-addressed store, hash-verified

14663"use strict";
14664
14665function DEFNODE(type, props, methods, base) {
14666 if (arguments.length < 4) base = AST_Node;
14667 if (!props) props = [];
14668 else props = props.split(/\s+/);
14669 var self_props = props;
14670 if (base && base.PROPS)
14671 props = props.concat(base.PROPS);
14672 var code = "return function AST_" + type + "(props){ if (props) { ";
14673 for (var i = props.length; --i >= 0;) {
14674 code += "this." + props[i] + " = props." + props[i] + ";";
14675 }
14676 var proto = base && new base;
14677 if (proto && proto.initialize || (methods && methods.initialize))
14678 code += "this.initialize();";
14679 code += "}}";
14680 var ctor = new Function(code)();
14681 if (proto) {
14682 ctor.prototype = proto;
14683 ctor.BASE = base;
14684 }
14685 if (base) base.SUBCLASSES.push(ctor);
14686 ctor.prototype.CTOR = ctor;
14687 ctor.PROPS = props || null;
14688 ctor.SELF_PROPS = self_props;
14689 ctor.SUBCLASSES = [];
14690 if (type) {
14691 ctor.prototype.TYPE = ctor.TYPE = type;
14692 }
14693 if (methods) for (i in methods) if (HOP(methods, i)) {
14694 if (/^\$/.test(i)) {
14695 ctor[i.substr(1)] = methods[i];
14696 } else {
14697 ctor.prototype[i] = methods[i];
14698 }
14699 }
14700 ctor.DEFMETHOD = function(name, method) {
14701 this.prototype[name] = method;
14702 };
14703 if (typeof exports !== "undefined") {
14704 exports["AST_" + type] = ctor;
14705 }
14706 return ctor;
14707};
14708
14709var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file raw", {
14710}, null);

Callers 1

loadLibFunction · 0.85

Calls 1

HOPFunction · 0.85

Tested by

no test coverage detected