Beispiel #1
0
 private void MaybeCompileAndAddMethodToType(JsClass jsClass, EntityDeclaration node, BlockStatement body, IMethod method, MethodScriptSemantics options)
 {
     if (options.GeneratedMethodName != null)
     {
         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.GeneratedMethodName, typeParamNames, null);
         }
         else
         {
             var compiled = CompileMethod(node, body, method, options);
             jsMethod = new JsMethod(method, options.GeneratedMethodName, typeParamNames, compiled);
         }
         AddCompiledMethodToType(jsClass, method, options, jsMethod);
     }
 }
Beispiel #2
0
 private JsExpression RewriteMethod(JsMethod method)
 {
     return(method.TypeParameterNames.Count == 0 ? method.Definition : JsExpression.FunctionDefinition(method.TypeParameterNames, new JsReturnStatement(method.Definition)));
 }
Beispiel #3
0
 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);
     }
 }