Mercurial > projects > ldc
comparison dmd/mtype.c @ 130:a7dfa0ed966c trunk
[svn r134] Merged the DMD 1.024 frontend.
Added std.base64.
author | lindquist |
---|---|
date | Fri, 28 Dec 2007 23:52:40 +0100 |
parents | facc562f5674 |
children | 5825d48b27d1 |
comparison
equal
deleted
inserted
replaced
129:8096ba7082db | 130:a7dfa0ed966c |
---|---|
2740 //printf("already done\n"); | 2740 //printf("already done\n"); |
2741 return this; | 2741 return this; |
2742 } | 2742 } |
2743 //printf("TypeFunction::semantic() this = %p\n", this); | 2743 //printf("TypeFunction::semantic() this = %p\n", this); |
2744 | 2744 |
2745 linkage = sc->linkage; | 2745 TypeFunction *tf = (TypeFunction *)mem.malloc(sizeof(TypeFunction)); |
2746 if (!next) | 2746 memcpy(tf, this, sizeof(TypeFunction)); |
2747 if (parameters) | |
2748 { tf->parameters = (Arguments *)parameters->copy(); | |
2749 for (size_t i = 0; i < parameters->dim; i++) | |
2750 { Argument *arg = (Argument *)parameters->data[i]; | |
2751 Argument *cpy = (Argument *)mem.malloc(sizeof(Argument)); | |
2752 memcpy(cpy, arg, sizeof(Argument)); | |
2753 tf->parameters->data[i] = (void *)cpy; | |
2754 } | |
2755 } | |
2756 | |
2757 tf->linkage = sc->linkage; | |
2758 if (!tf->next) | |
2747 { | 2759 { |
2748 assert(global.errors); | 2760 assert(global.errors); |
2749 next = tvoid; | 2761 tf->next = tvoid; |
2750 } | 2762 } |
2751 next = next->semantic(loc,sc); | 2763 tf->next = tf->next->semantic(loc,sc); |
2752 if (next->toBasetype()->ty == Tsarray) | 2764 if (tf->next->toBasetype()->ty == Tsarray) |
2753 { error(loc, "functions cannot return static array %s", next->toChars()); | 2765 { error(loc, "functions cannot return static array %s", tf->next->toChars()); |
2754 next = Type::terror; | 2766 tf->next = Type::terror; |
2755 } | 2767 } |
2756 if (next->toBasetype()->ty == Tfunction) | 2768 if (tf->next->toBasetype()->ty == Tfunction) |
2757 { error(loc, "functions cannot return a function"); | 2769 { error(loc, "functions cannot return a function"); |
2758 next = Type::terror; | 2770 tf->next = Type::terror; |
2759 } | 2771 } |
2760 if (next->toBasetype()->ty == Ttuple) | 2772 if (tf->next->toBasetype()->ty == Ttuple) |
2761 { error(loc, "functions cannot return a tuple"); | 2773 { error(loc, "functions cannot return a tuple"); |
2762 next = Type::terror; | 2774 tf->next = Type::terror; |
2763 } | 2775 } |
2764 if (next->isauto() && !(sc->flags & SCOPEctor)) | 2776 if (tf->next->isauto() && !(sc->flags & SCOPEctor)) |
2765 error(loc, "functions cannot return auto %s", next->toChars()); | 2777 error(loc, "functions cannot return auto %s", tf->next->toChars()); |
2766 | 2778 |
2767 if (parameters) | 2779 if (tf->parameters) |
2768 { size_t dim = Argument::dim(parameters); | 2780 { size_t dim = Argument::dim(tf->parameters); |
2769 | 2781 |
2770 for (size_t i = 0; i < dim; i++) | 2782 for (size_t i = 0; i < dim; i++) |
2771 { Argument *arg = Argument::getNth(parameters, i); | 2783 { Argument *arg = Argument::getNth(tf->parameters, i); |
2772 Type *t; | 2784 Type *t; |
2773 | 2785 |
2774 inuse++; | 2786 tf->inuse++; |
2775 arg->type = arg->type->semantic(loc,sc); | 2787 arg->type = arg->type->semantic(loc,sc); |
2776 if (inuse == 1) inuse--; | 2788 if (tf->inuse == 1) tf->inuse--; |
2777 t = arg->type->toBasetype(); | 2789 t = arg->type->toBasetype(); |
2778 | 2790 |
2779 if (arg->storageClass & (STCout | STCref | STClazy)) | 2791 if (arg->storageClass & (STCout | STCref | STClazy)) |
2780 { | 2792 { |
2781 if (t->ty == Tsarray) | 2793 if (t->ty == Tsarray) |
2793 | 2805 |
2794 /* If arg turns out to be a tuple, the number of parameters may | 2806 /* If arg turns out to be a tuple, the number of parameters may |
2795 * change. | 2807 * change. |
2796 */ | 2808 */ |
2797 if (t->ty == Ttuple) | 2809 if (t->ty == Ttuple) |
2798 { dim = Argument::dim(parameters); | 2810 { dim = Argument::dim(tf->parameters); |
2799 i--; | 2811 i--; |
2800 } | 2812 } |
2801 } | 2813 } |
2802 } | 2814 } |
2803 deco = merge()->deco; | 2815 tf->deco = tf->merge()->deco; |
2804 | 2816 |
2805 if (inuse) | 2817 if (tf->inuse) |
2806 { error(loc, "recursive type"); | 2818 { error(loc, "recursive type"); |
2807 inuse = 0; | 2819 tf->inuse = 0; |
2808 return terror; | 2820 return terror; |
2809 } | 2821 } |
2810 | 2822 |
2811 if (varargs == 1 && linkage != LINKd && Argument::dim(parameters) == 0) | 2823 if (tf->varargs == 1 && tf->linkage != LINKd && Argument::dim(tf->parameters) == 0) |
2812 error(loc, "variadic functions with non-D linkage must have at least one parameter"); | 2824 error(loc, "variadic functions with non-D linkage must have at least one parameter"); |
2813 | 2825 |
2814 /* Don't return merge(), because arg identifiers and default args | 2826 /* Don't return merge(), because arg identifiers and default args |
2815 * can be different | 2827 * can be different |
2816 * even though the types match | 2828 * even though the types match |
2817 */ | 2829 */ |
2818 return this; | 2830 return tf; |
2819 } | 2831 } |
2820 | 2832 |
2821 /******************************** | 2833 /******************************** |
2822 * 'args' are being matched to function 'this' | 2834 * 'args' are being matched to function 'this' |
2823 * Determine match level. | 2835 * Determine match level. |