Ejemplo n.º 1
0
 private void AddParameters(MethodGenerator generator, Method method)
 {
     if (method.entry.declaration.parameters != null)
     {
         foreach (ParameterDeclaration declaration in method.entry.declaration.parameters)
         {
             generator.AddParameter(ParameterGenerator.Parameter(declaration.name, declaration.type, ParameterModifier.None));
         }
     }
 }
Ejemplo n.º 2
0
        protected MethodGenerator Method(string key, AccessModifier scope, MethodModifier modifier, Type returnType, string parameters = null, string body = null)
        {
            var method = MethodGenerator.Method(scope, modifier, returnType, key.Replace(" ", string.Empty));

            if (!string.IsNullOrEmpty(body))
            {
                method.Body(body);
            }
            return(method);
        }
Ejemplo n.º 3
0
        protected MethodGenerator Method(string key, AccessModifier scope, MethodModifier modifier, Type returnType, bool isOverride, string parameters = null)
        {
            var method = MethodGenerator.Method(scope, modifier, returnType, key.Replace(" ", string.Empty));
            var line1  = CodeBuilder.InitializeVariable("val", returnType);
            var line2  = CodeExtensions.Invoke(key, returnType, isOverride, parameters);
            var line3  = CodeBuilder.NullVoidOrNot(returnType, string.Empty, "\n" + CodeBuilder.Return("val"));

            method.Body(line1 + line2 + line3);
            return(method);
        }
Ejemplo n.º 4
0
        public static MethodGenerator Method(AccessModifier scope, MethodModifier modifier, Type returnType, string name)
        {
            var method = new MethodGenerator();

            method.scope      = scope;
            method.modifier   = modifier;
            method.name       = name;
            method.returnType = returnType;
            return(method);
        }
Ejemplo n.º 5
0
        private string GetParameters(MethodGenerator generator, Method method)
        {
            var parameters = new List <ParameterGenerator>();

            foreach (ParameterDeclaration declaration in method.entry.declaration.parameters)
            {
                parameters.Add(ParameterGenerator.Parameter(declaration.name, declaration.type, ParameterModifier.None));
            }

            return(parameters.Count == 0 ? string.Empty : parameters.Parameters());
        }
Ejemplo n.º 6
0
        private string GetParameters(MethodGenerator method, Method nest)
        {
            var parameters = new List <ParameterGenerator>();

            foreach (KeyValuePair <string, Type> pair in nest.macro.entry.parameters)
            {
                parameters.Add(ParameterGenerator.Parameter(pair.Key, pair.Value, ParameterModifier.None));
            }

            return(parameters.Count == 0 ? string.Empty : parameters.Parameters());
        }
Ejemplo n.º 7
0
 public StructGenerator AddMethod(MethodGenerator generator)
 {
     methods.Add(generator);
     return(this);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Add a method to this class.
 /// </summary>
 public ClassGenerator AddMethod(MethodGenerator generator)
 {
     methods.Add(generator);
     return(this);
 }