Allow VAL RETYPE to scalar types
This commit is contained in:
parent
e8a38a6f02
commit
01f3a769fd
|
@ -966,8 +966,17 @@ introduceSpec (A.Specification _ n (A.Retypes _ am t v))
|
|||
= do origT <- typeOfVariable v
|
||||
let (rhs, rhsSizes) = abbrevVariable A.Abbrev origT v
|
||||
genDecl am t n
|
||||
tell [" = ("]
|
||||
tell [" = "]
|
||||
-- For non-array types that are VAL abbreviations (e.g. VAL INT64),
|
||||
-- we need to dereference the pointer that abbrevVariable gives us.
|
||||
let deref = case (am, t) of
|
||||
(_, A.Array _ _) -> False
|
||||
(A.ValAbbrev, _) -> True
|
||||
_ -> True
|
||||
when deref $ tell ["*"]
|
||||
tell ["("]
|
||||
genDeclType am t
|
||||
when deref $ tell [" *"]
|
||||
tell [") "]
|
||||
rhs
|
||||
tell [";\n"]
|
||||
|
|
|
@ -46,6 +46,10 @@ default behaviour that simplifies expressions inside another one.
|
|||
|
||||
Output item expressions should be pulled up to variables.
|
||||
|
||||
We should generally try to reduce the number of unnecessary pullups we do:
|
||||
- plain subscripts that result in a non-array shouldn't pull up (e.g. x[i][j])
|
||||
- expressions that are already a variable should just be turned into the variable
|
||||
|
||||
Before code generation, have a pass that resolves all the DATA TYPE .. IS
|
||||
directives to their real types.
|
||||
|
||||
|
|
11
fco2/testcases/place.occ
Normal file
11
fco2/testcases/place.occ
Normal file
|
@ -0,0 +1,11 @@
|
|||
PROC P ()
|
||||
INT x:
|
||||
PLACE x AT #123456:
|
||||
CHAN OF INT c:
|
||||
PLACE c AT #654321:
|
||||
INT w:
|
||||
PLACE w IN WORKSPACE:
|
||||
INT v:
|
||||
PLACE v IN VECSPACE:
|
||||
SKIP
|
||||
:
|
26
fco2/testcases/val-retypes2.occ
Normal file
26
fco2/testcases/val-retypes2.occ
Normal file
|
@ -0,0 +1,26 @@
|
|||
-- from cgtest10
|
||||
PROC check.REAL64 (VAL REAL64 a, b, VAL []BYTE s)
|
||||
ASSERT (a = b)
|
||||
:
|
||||
PROC check.INT64 (VAL INT64 a, b, VAL []BYTE s)
|
||||
ASSERT (a = b)
|
||||
:
|
||||
PROC P ()
|
||||
VAL xr IS 8.6157349597130242515E+1(REAL64) :
|
||||
VAL yr IS 4.1066306682575781263E+1(REAL64) :
|
||||
VAL xi IS #40558A12040B6DA5(INT64) :
|
||||
VAL yi IS #4044887CBCC495A9(INT64) :
|
||||
VAL REAL64 xir RETYPES xi :
|
||||
VAL REAL64 yir RETYPES yi :
|
||||
REAL64 x, y :
|
||||
SEQ
|
||||
x, y := xr, yr
|
||||
check.REAL64(xr, xir, "B251a")
|
||||
check.REAL64(yr, yir, "B251b")
|
||||
check.REAL64(x, xir, "B251c")
|
||||
check.REAL64(y, yir, "B251d")
|
||||
VAL INT64 xx RETYPES x :
|
||||
check.INT64(xx, xi, "B251e")
|
||||
VAL INT64 yy RETYPES y :
|
||||
check.INT64(yy, yi, "B251f")
|
||||
:
|
Loading…
Reference in New Issue
Block a user