/// <summary>
        /// Create a default constructor without parameters
        /// </summary>
        /// <param name="type">Type node</param>
        private void GenerateDefaultCtor(TypeNode type)
        {
            var node = new MethodNode(".ctor", new SignatureNode("void"), false);
              node.Body.Statements.Add(Expr.Return());

              node.SetParameters();
              node.Owner = type;
              AddMethod(type, node);
        }
        /// <summary>
        /// Create an automatic .Equal() method
        /// </summary>
        /// <param name="type">Type node</param>
        private void GenerateAutoComparator(TypeNode type)
        {
            var node = new MethodNode("equal", new SignatureNode("bool"), false);

              // define parameter
              var parameters = new HashList<ParameterNode>();
              var param = new ParameterNode("_obj", new SignatureNode(type.Name), 0);
              parameters.Add(param.Name, param);

              // generate series of comparisons
              foreach(var curr in type.Fields)
              {
            //
            // if(@<name> != _obj.<name>) return false;
            //
            node.Body.Statements.Add(
              Expr.If(
            Expr.Compare(
              Expr.IdentifierGet(curr, true),
              Lexer.LexemType.NotEqual,
              Expr.IdentifierGet(curr, Expr.IdentifierGet("_obj"))
            ),
            Expr.Return(
              Expr.Bool(true)
            )
              )
            );
              }

              // return true
              node.Body.Statements.Add(
            Expr.Return(
              Expr.Bool(true)
            )
              );

              node.SetParameters(parameters);
              node.Owner = type;
              AddMethod(type, node);
        }
        /// <summary>
        /// Create an automatic constructor to set all fields
        /// </summary>
        /// <param name="type">Type node</param>
        private void GenerateAutoCtor(TypeNode type)
        {
            var node = new MethodNode(".ctor", new SignatureNode("void"), false);

              var parameters = new HashList<ParameterNode>();
              int idx = 0;
              foreach(var curr in type.Fields)
              {
            var param = new ParameterNode("_" + curr, type.Fields[curr].Type, idx);
            parameters.Add("_" + curr, param);
            idx++;

            var assignNode = new IdentifierSetNode(curr, true);
            assignNode.Expression = new IdentifierGetNode("_" + curr);
            node.Body.Statements.Add(assignNode);
              }

              node.SetParameters(parameters);
              node.Owner = type;
              AddMethod(type, node);
        }
        /// <summary>
        /// Create a method in a type
        /// </summary>
        /// <param name="owner">Owner type node</param>
        /// <param name="name">Method name</param>
        /// <param name="type">Method return value type signature</param>
        /// <param name="parameters">Method parameters list</param>
        /// <param name="isStatic">Static flag</param>
        /// <returns></returns>
        public MethodNode CreateMethod(TypeNode owner, string name, SignatureNode type, HashList<ParameterNode> parameters = null, bool isStatic = false, bool prepare = false)
        {
            // cannot add methods to built-in types
              if (owner.BuiltIn)
            throw new CompilerException(String.Format(Resources.errExtendBuiltInType, owner.Name));

              // create method in assembly and in Mirelle Registry
              var method = new MethodNode(name, type, isStatic);

              method.SetParameters(parameters);

              // check if an identical method hasn't already been declared
              if (owner.Methods.Contains(method.Name))
              {
            if(owner.Methods[method.Name].Exists(curr => curr.Signature == method.Signature))
              throw new CompilerException(String.Format(Resources.errMethodRedefinition, method.Name, owner.Name));
              }

              // register method in the parent type
              AddMethod(owner, method);
              method.Owner = owner;

              if (prepare)
            PrepareMethod(method);

              return method;
        }