示例#1
0
        public IDataType Clone(CheckedCloningInfo cloningInfo)
        {
            var newTypeArguments = new List <IDataType>(TypeArguments?.Count ?? 0);
            var newStructDecl    = StructDecl;

            if (TypeArguments != null)
            {
                foreach (var typeArgument in TypeArguments)
                {
                    newTypeArguments.Add(typeArgument.Clone(cloningInfo));
                }

                var symbol = StructDecl.Module.GetClass(StructDecl.Identifier.Value, false);
                newStructDecl = cloningInfo.TypeChecker.NextClassDecl(
                    symbol !.Syntax,
                    newTypeArguments.Any() ? newTypeArguments : null
                    );
            }

            return(new StructType(
                       Type,
                       newTypeArguments,
                       newStructDecl,
                       IsExplicitPointer
                       ));
        }
示例#2
0
        public IDataType Clone(CheckedCloningInfo cloningInfo)
        {
            int typeArgumentIndex = cloningInfo.TypeParameters?.FindIndex(x => x.Value == Identifier.Value) ?? -1;

            if (typeArgumentIndex == -1 || cloningInfo.TypeArguments == null || !cloningInfo.TypeArguments.Any())
            {
                return(new GenericType(Identifier, ParameterIndex, Origin, IsExplicitPointer));
            }

            return(cloningInfo.TypeArguments[typeArgumentIndex].Clone(cloningInfo));
        }
示例#3
0
    public static List <CheckedExpression> CloneExpressions <T>(this List <T> expressions,
                                                                CheckedCloningInfo cloningInfo) where T : CheckedExpression
    {
        var cloned = new List <CheckedExpression>(expressions.Count);

        foreach (var expression in expressions)
        {
            cloned.Add(expression.Clone(cloningInfo));
        }

        return(cloned);
    }
示例#4
0
    public static List <CheckedStatement> CloneStatements <T>(this List <T> statements,
                                                              CheckedCloningInfo cloningInfo) where T : CheckedStatement
    {
        var cloned = new List <CheckedStatement>(statements.Count);

        foreach (var statement in statements)
        {
            cloned.Add(statement.Clone(cloningInfo));
        }

        return(cloned);
    }