xubingyue / softart

Automatically exported from code.google.com/p/softart
Other
0 stars 0 forks source link

Add function overload mechanism #41

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Function overload is the base of type promotion.

We need 2 mechanisms to support it:

1. Type implicit conversation
2. Name mangling

Following steps are possible way to implement it:

1. Implement name mangling.
2. Implenent implicit type conversation. It is also the sub-part of type 
conversation.
3. Write code for function prototype chosen.

Original issue reported on code.google.com by wuye9036 on 25 Sep 2010 at 10:32

GoogleCodeExporter commented 8 years ago
Operator overloading and numeric promotion is implemented via add proxy 
function to symbol table.
We need to add buildin operators as function prototypes to symbol table for 
overloading.

Original comment by wuye9036 on 8 Oct 2010 at 7:30

GoogleCodeExporter commented 8 years ago
  The main code of overloading was finished. but an important problem exists yet.

  It is appear in numeric promotion.

  Consider that, S is the type of evaluating function, and D is the type of evaluated function, and T is the real type of argument expression. The current algorithm is, is S to D has an implicit conversation, and D could not be converted to S implicitly, S is the better conversation.
  It could works well in most cases. But sometimes, It is too strictly for user.
  Consider following case:

  byte b;
  void foo( ulong v );
  void foo( int v );

  now, we call foo as:

    foo(b);

  Reasonable, "foo" will be overloaded as "foo( ulong )".
  But in our method, since ulong could not convert to int and vice versa, a ambigous error would be reported.

  So we need more rules to processing these cases yet.

  Hi, Ming, Could you work on it ? Rules you can find in C# specification, about in section overloading & numeric promotion. Thank you.

Original comment by wuye9036 on 10 Oct 2010 at 4:01

GoogleCodeExporter commented 8 years ago

Original comment by wuye9036 on 15 Dec 2010 at 5:07

GoogleCodeExporter commented 8 years ago

Original comment by wuye9036 on 7 Mar 2012 at 2:58