s1s0 / toped

Cross platform, open source IC layout editor
http://www.toped.org.uk/
GNU General Public License v2.0
15 stars 8 forks source link

specific calculation in function parameter doesn't work #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
following code leads to parsing errors ..

-----bug.tll-------
int list aa (int a, int b) {
  int list out;
  return out;
}

int a = 10;
int list idx;

idx = aa (0, a ); //--> works
idx = aa (0, a - 1 ); //--> doesn't work
-------------------

started with: "toped bug.tll"

gives
------------------
<= line 12: col 6: in file "bug1a.tll" : unknown function name or wrong 
parameter list
<= line 12: col 4: in file "bug1a.tll" : Incompatible operand types in 
assignment
------------------
for the line with calculations within the function parameter

Original issue reported on code.google.com by analogc...@gmx.net on 11 Jan 2012 at 10:17

GoogleCodeExporter commented 9 years ago

Original comment by krustev....@gmail.com on 11 Jan 2012 at 10:21

GoogleCodeExporter commented 9 years ago
We do have strict type policy and in some cases (like this) too strict.
I'm sure I was fixing this at some point and weirdly enough 
idx = aa (0, a + 1 ); //--> does work

Ok the trouble was obviously that not all the arithmetic operations have the 
same internal conversion int <-> real

This particular example was fixed in r2047, but that's not the end of it. Still 
two questions:

idx = aa (0, a * 1 ); //--> won't work
idx = aa (0, a / 1 ); //--> won't work

Maybe the best way to fix this is to define clearly integer multiplication and 
division operators. In other words (like in C) if both operands are int, the 
result will be int. If one of the operands is real, the the result will be 
real. At the moment that's the case for + and - (after this fix). It should be 
easy for the user, because even in case of the constants, the real can be 
always flagged by the existence of the decimal point.
Comments?

Original comment by krustev....@gmail.com on 13 Jan 2012 at 12:09

GoogleCodeExporter commented 9 years ago
I would appreciate if we could implement the point operators, too. To be like 
in C we should also support the strict separation of real and integer - integer 
divisions are cutting the floating part. I think this is what C-programmers 
would expect?
But error messages could be also more specific .. in this case it would be 
helpful to know that a type mismatch was the reason for the error. 

Original comment by analogc...@gmx.net on 14 Jan 2012 at 9:00

GoogleCodeExporter commented 9 years ago
What do you mean "point operators"?

Integer divisions will return integers, i.e. the fractional part will go away.

About the specific error messages - agree it was in my TODO list, now it is 
"officially" issue 131

Original comment by krustev....@gmail.com on 14 Jan 2012 at 9:39

GoogleCodeExporter commented 9 years ago
oh sorry .. the expression is maybe just known in german. What I meant were the 
multiplication and division operators.

Original comment by analogc...@gmx.net on 14 Jan 2012 at 10:01

GoogleCodeExporter commented 9 years ago
This should be concluded now with r2050

Check and close the issue please...

Original comment by krustev....@gmail.com on 14 Jan 2012 at 7:09

GoogleCodeExporter commented 9 years ago

Original comment by analogc...@gmx.net on 14 Jan 2012 at 7:36

GoogleCodeExporter commented 9 years ago

Original comment by krustev....@gmail.com on 1 Apr 2012 at 12:21