MCPcopy Index your code
hub / github.com/Macuyiko/minecraft-python / doFunction

Function doFunction

ServerEditorWeb/ace/worker-javascript.js:4925–4988  ·  view source on GitHub ↗
(name, statement, generator, fatarrow)

Source from the content-addressed store, hash-verified

4923 };
4924 }
4925 function doFunction(name, statement, generator, fatarrow) {
4926 var f;
4927 var oldOption = state.option;
4928 var oldIgnored = state.ignored;
4929 var oldScope = scope;
4930
4931 state.option = Object.create(state.option);
4932 state.ignored = Object.create(state.ignored);
4933 scope = Object.create(scope);
4934
4935 funct = functor(name || state.nameStack.infer(), state.tokens.next, scope, {
4936 "(statement)": statement,
4937 "(context)": funct,
4938 "(generator)": generator ? true : null
4939 });
4940
4941 f = funct;
4942 state.tokens.curr.funct = funct;
4943
4944 functions.push(funct);
4945
4946 if (name) {
4947 addlabel(name, { type: "function" });
4948 }
4949
4950 funct["(params)"] = functionparams(fatarrow);
4951 funct["(metrics)"].verifyMaxParametersPerFunction(funct["(params)"]);
4952
4953 if (fatarrow) {
4954 if (!state.option.esnext) {
4955 warning("W119", state.tokens.curr, "arrow function syntax (=>)");
4956 }
4957
4958 if (!fatarrow.loneArg) {
4959 advance("=>");
4960 }
4961 }
4962
4963 block(false, true, true, !!fatarrow);
4964
4965 if (!state.option.noyield && generator &&
4966 funct["(generator)"] !== "yielded") {
4967 warning("W124", state.tokens.curr);
4968 }
4969
4970 funct["(metrics)"].verifyMaxStatementsPerFunction();
4971 funct["(metrics)"].verifyMaxComplexityPerFunction();
4972 funct["(unusedOption)"] = state.option.unused;
4973
4974 scope = oldScope;
4975 state.option = oldOption;
4976 state.ignored = oldIgnored;
4977 funct["(last)"] = state.tokens.curr.line;
4978 funct["(lastcharacter)"] = state.tokens.curr.character;
4979
4980 _.map(Object.keys(funct), function (key) {
4981 if (key[0] === "(") return;
4982 funct["(blockscope)"].unshadow(key);

Callers 3

applicationFunction · 0.85
classbodyFunction · 0.85

Calls 6

functorFunction · 0.85
addlabelFunction · 0.85
functionparamsFunction · 0.85
warningFunction · 0.85
advanceFunction · 0.85
blockFunction · 0.85

Tested by

no test coverage detected