From f1b0fb97638c83c7f060dc698a6f118d3060ab0b Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 10 Oct 2003 11:39:30 +0000 Subject: [PATCH] Added some code to handle floats/doubles. git-svn-id: svn://svn.cc65.org/cc65/trunk@2487 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codegen.h | 1 + src/cc65/datatype.c | 5 +++++ src/cc65/declare.c | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/cc65/codegen.h b/src/cc65/codegen.h index 15a6872bc..258bb6b2d 100644 --- a/src/cc65/codegen.h +++ b/src/cc65/codegen.h @@ -63,6 +63,7 @@ #define CF_INT 0x0001 /* Operation on ints */ #define CF_PTR CF_INT /* Alias for readability */ #define CF_LONG 0x0000 /* Operation on longs */ +#define CF_FLOAT 0x0004 /* Operation on a float */ #define CF_NOKEEP 0x0008 /* Value may get destroyed when storing */ diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index 282385ed7..ea9dc6a71 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -570,6 +570,11 @@ unsigned TypeOf (const type* T) case T_ULONG: return CF_LONG | CF_UNSIGNED; + case T_FLOAT: + case T_DOUBLE: + /* These two are identical in the backend */ + return CF_FLOAT; + case T_FUNC: F = DecodePtr (T+1); return (F->Flags & FD_VARIADIC)? 0 : CF_FIXARGC; diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 59a618dac..8bd0b0b87 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -422,7 +422,7 @@ static void ParseTypeSpec (DeclSpec* D, int Default) optionalsigned (); optionalint (); D->Type[0] = T_SHORT; - D->Type[1] = T_END; + D->Type[1] = T_END; } break; @@ -460,7 +460,7 @@ static void ParseTypeSpec (DeclSpec* D, int Default) NextToken (); /* FALL THROUGH */ - default: + default: D->Type[0] = T_INT; D->Type[1] = T_END; break; @@ -502,6 +502,18 @@ static void ParseTypeSpec (DeclSpec* D, int Default) } break; + case TOK_FLOAT: + NextToken (); + D->Type[0] = T_FLOAT; + D->Type[1] = T_END; + break; + + case TOK_DOUBLE: + NextToken (); + D->Type[0] = T_DOUBLE; + D->Type[1] = T_END; + break; + case TOK_STRUCT: case TOK_UNION: StructType = (CurTok.Tok == TOK_STRUCT)? T_STRUCT : T_UNION; -- 2.39.5