mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-03 19:31:02 +00:00
Change type of sizeof to word. Improve type checker.
This commit is contained in:
parent
ec52963b46
commit
590db9ade0
@ -292,7 +292,7 @@ but not
|
|||||||
some enum → `word`
|
some enum → `word`
|
||||||
|
|
||||||
* `sizeof`: size of the argument in bytes; the argument can be an expression or a type,
|
* `sizeof`: size of the argument in bytes; the argument can be an expression or a type,
|
||||||
and the result is a constant of either `byte` or `word` type, depending on situation
|
and the result is a constant of type `word`
|
||||||
|
|
||||||
* `call`: calls a function via a pointer;
|
* `call`: calls a function via a pointer;
|
||||||
the first argument is the pointer to the function;
|
the first argument is the pointer to the function;
|
||||||
|
@ -278,6 +278,10 @@ object AbstractExpressionCompiler {
|
|||||||
case 2 => w
|
case 2 => w
|
||||||
case 3 => env.get[Type]("int24")
|
case 3 => env.get[Type]("int24")
|
||||||
case 4 => env.get[Type]("int32")
|
case 4 => env.get[Type]("int32")
|
||||||
|
case 5 => env.get[Type]("int40")
|
||||||
|
case 6 => env.get[Type]("int48")
|
||||||
|
case 7 => env.get[Type]("int56")
|
||||||
|
case 8 => env.get[Type]("int64")
|
||||||
}
|
}
|
||||||
case ConstantArrayElementExpression(constant) =>
|
case ConstantArrayElementExpression(constant) =>
|
||||||
(constant.quickSimplify match {
|
(constant.quickSimplify match {
|
||||||
@ -290,6 +294,10 @@ object AbstractExpressionCompiler {
|
|||||||
case (_, 2) => b
|
case (_, 2) => b
|
||||||
case (_, 3) => env.get[Type]("int24")
|
case (_, 3) => env.get[Type]("int24")
|
||||||
case (_, 4) => env.get[Type]("int32")
|
case (_, 4) => env.get[Type]("int32")
|
||||||
|
case (_, 5) => env.get[Type]("int40")
|
||||||
|
case (_, 6) => env.get[Type]("int48")
|
||||||
|
case (_, 7) => env.get[Type]("int56")
|
||||||
|
case (_, 8) => env.get[Type]("int64")
|
||||||
}
|
}
|
||||||
case GeneratedConstantExpression(_, typ) => typ
|
case GeneratedConstantExpression(_, typ) => typ
|
||||||
case TextLiteralExpression(_) => env.get[Type]("pointer")
|
case TextLiteralExpression(_) => env.get[Type]("pointer")
|
||||||
@ -445,10 +453,7 @@ object AbstractExpressionCompiler {
|
|||||||
case FunctionCallExpression("sin", params) => if (params.size < 2) b else getExpressionTypeImpl(env, log, params(1), loosely)
|
case FunctionCallExpression("sin", params) => if (params.size < 2) b else getExpressionTypeImpl(env, log, params(1), loosely)
|
||||||
case FunctionCallExpression("cos", params) => if (params.size < 2) b else getExpressionTypeImpl(env, log, params(1), loosely)
|
case FunctionCallExpression("cos", params) => if (params.size < 2) b else getExpressionTypeImpl(env, log, params(1), loosely)
|
||||||
case FunctionCallExpression("tan", params) => if (params.size < 2) b else getExpressionTypeImpl(env, log, params(1), loosely)
|
case FunctionCallExpression("tan", params) => if (params.size < 2) b else getExpressionTypeImpl(env, log, params(1), loosely)
|
||||||
case FunctionCallExpression("sizeof", params) => env.evalSizeof(params.head).requiredSize match {
|
case FunctionCallExpression("sizeof", _) => w
|
||||||
case 1 => b
|
|
||||||
case 2 => w
|
|
||||||
}
|
|
||||||
case FunctionCallExpression("%%", params) => params.map { e => getExpressionTypeImpl(env, log, e, loosely).size } match {
|
case FunctionCallExpression("%%", params) => params.map { e => getExpressionTypeImpl(env, log, e, loosely).size } match {
|
||||||
case List(1, 1) | List(2, 1) => b
|
case List(1, 1) | List(2, 1) => b
|
||||||
case List(1, 2) | List(2, 2) => w
|
case List(1, 2) | List(2, 2) => w
|
||||||
|
Loading…
Reference in New Issue
Block a user