internal void AddBaseTypes(IEnumerable <LuaExpressionSyntax> baseTypes, LuaSpeaicalGenericType genericArgument = null)
        {
            bool hasLazyGenericArgument = false;

            if (genericArgument != null)
            {
                if (genericArgument.IsLazy)
                {
                    hasLazyGenericArgument = true;
                }
                else
                {
                    AddResultTable(genericArgument.Name, genericArgument.Value);
                }
            }

            LuaTableInitializerExpression table = new LuaTableInitializerExpression();

            table.Items.AddRange(baseTypes.Select(i => new LuaSingleTableItemSyntax(i)));
            LuaFunctionExpressionSyntax functionExpression = new LuaFunctionExpressionSyntax();

            functionExpression.AddParameter(LuaIdentifierNameSyntax.Global);
            if (hasLazyGenericArgument)
            {
                functionExpression.AddParameter(LuaIdentifierNameSyntax.This);
                var assignment = new LuaAssignmentExpressionSyntax(new LuaMemberAccessExpressionSyntax(LuaIdentifierNameSyntax.This, genericArgument.Name), genericArgument.Value);
                functionExpression.AddStatement(assignment);
            }
            functionExpression.AddStatement(new LuaReturnStatementSyntax(table));
            AddResultTable(LuaIdentifierNameSyntax.Inherits, functionExpression);
        }
        internal void AddBaseTypes(IEnumerable <LuaExpressionSyntax> baseTypes, LuaSpeaicalGenericType genericArgument, List <LuaIdentifierNameSyntax> baseCopyFields)
        {
            bool hasLazyGenericArgument = false;

            if (genericArgument != null)
            {
                if (genericArgument.IsLazy)
                {
                    hasLazyGenericArgument = true;
                }
                else
                {
                    AddResultTable(genericArgument.Name, genericArgument.Value);
                }
            }

            bool hasBaseCopyField = baseCopyFields != null && baseCopyFields.Count > 0;
            LuaFunctionExpressionSyntax functionExpression = new LuaFunctionExpressionSyntax();

            functionExpression.AddParameter(LuaIdentifierNameSyntax.Global);
            if (hasLazyGenericArgument || hasBaseCopyField)
            {
                functionExpression.AddParameter(LuaIdentifierNameSyntax.This);
            }

            if (hasLazyGenericArgument)
            {
                var assignment = new LuaAssignmentExpressionSyntax(new LuaMemberAccessExpressionSyntax(LuaIdentifierNameSyntax.This, genericArgument.Name), genericArgument.Value);
                functionExpression.AddStatement(assignment);
            }

            LuaTableExpression table = new LuaTableExpression();

            if (hasBaseCopyField)
            {
                var baseIdentifier = LuaIdentifierNameSyntax.Base;
                functionExpression.AddStatement(new LuaLocalVariableDeclaratorSyntax(baseIdentifier, baseTypes.First()));
                foreach (var field in baseCopyFields)
                {
                    var left  = new LuaMemberAccessExpressionSyntax(LuaIdentifierNameSyntax.This, field);
                    var right = new LuaMemberAccessExpressionSyntax(baseIdentifier, field);
                    functionExpression.AddStatement(new LuaAssignmentExpressionSyntax(left, right));

                    table.Items.Add(new LuaSingleTableItemSyntax(baseIdentifier));
                    table.Items.AddRange(baseTypes.Skip(1).Select(i => new LuaSingleTableItemSyntax(i)));
                }
            }
            else
            {
                table.Items.AddRange(baseTypes.Select(i => new LuaSingleTableItemSyntax(i)));
            }

            functionExpression.AddStatement(new LuaReturnStatementSyntax(table));
            AddResultTable(LuaIdentifierNameSyntax.Inherits, functionExpression);
        }