private void AddCompiledMethodToType(JsClass jsClass, IMethod method, MethodScriptSemantics options, JsMethod jsMethod) { if ((options.Type == MethodScriptSemantics.ImplType.NormalMethod && method.IsStatic) || options.Type == MethodScriptSemantics.ImplType.StaticMethodWithThisAsFirstArgument) { jsClass.StaticMethods.Add(jsMethod); } else { jsClass.InstanceMethods.Add(jsMethod); } }
private void MaybeCompileAndAddMethodToType(JsClass jsClass, EntityDeclaration node, BlockStatement body, IMethod method, MethodScriptSemantics options) { if (options.GenerateCode) { var typeParamNames = options.IgnoreGenericArguments ? (IEnumerable<string>)new string[0] : method.TypeParameters.Select(tp => _namer.GetTypeParameterName(tp)).ToList(); JsMethod jsMethod; if (method.IsAbstract) { jsMethod = new JsMethod(method, options.Name, typeParamNames, null); } else { var compiled = CompileMethod(node, body, method, options); jsMethod = new JsMethod(method, options.Name, typeParamNames, compiled); } AddCompiledMethodToType(jsClass, method, options, jsMethod); } }
private JsExpression RewriteMethod(JsMethod method) { return method.TypeParameterNames.Count == 0 ? method.Definition : JsExpression.FunctionDefinition(method.TypeParameterNames, new JsReturnStatement(method.Definition)); }