public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: tthomas@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Fixes bz 5411. Implement cast operation for char* type. Date: Tue, 11 Mar 2008 22:05:00 -0000 [thread overview] Message-ID: <20080311220527.22098.qmail@sourceware.org> (raw) The branch, master has been updated via 84bcf09e5a329252d81e853e49f0cf1449f937c2 (commit) from 3aeefe23500fc57d19e4c3c30523b46ed9a6befc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 84bcf09e5a329252d81e853e49f0cf1449f937c2 Author: Teresa Thomas <tthomas@redhat.com> Date: Tue Mar 11 18:03:38 2008 -0400 Fixes bz 5411. Implement cast operation for char* type. frysk-core/frysk/expr/ChangeLog: 2008-03-11 Teresa Thomas <tthomas@redhat.com> * CExprEvaluator.g: Handle CAST for char*. * CExpr.g (typeCast): Add. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/expr/CExpr.g | 9 +++++++-- frysk-core/frysk/expr/CExprEvaluator.g | 23 ++++++++++++++++++++--- frysk-core/frysk/expr/ChangeLog | 5 +++++ 3 files changed, 32 insertions(+), 5 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/expr/CExpr.g b/frysk-core/frysk/expr/CExpr.g index a154ff1..4100d22 100644 --- a/frysk-core/frysk/expr/CExpr.g +++ b/frysk-core/frysk/expr/CExpr.g @@ -297,9 +297,10 @@ prefix_expression | cast_expression | postfix_expression ; + cast_expression! - : LPAREN type:primitiveType RPAREN expr:prefix_expression - { ## = #([CAST, "Cast"], #type, #expr); } + : LPAREN tc:typeCast RPAREN expr:prefix_expression + { ## = #([CAST, "Cast"], #tc, #expr);} ; postfix_expression! @@ -369,6 +370,10 @@ primitiveType | "float" | "double" ; + +typeCast + : primitiveType (STAR)? + ; constant : OCTALINT diff --git a/frysk-core/frysk/expr/CExprEvaluator.g b/frysk-core/frysk/expr/CExprEvaluator.g index d751de3..7285f90 100644 --- a/frysk-core/frysk/expr/CExprEvaluator.g +++ b/frysk-core/frysk/expr/CExprEvaluator.g @@ -85,6 +85,8 @@ header import frysk.value.SignedType; import frysk.value.UnsignedType; import frysk.value.FloatingPointType; + import frysk.value.PointerType; + import frysk.value.CharType; import frysk.value.Value; import frysk.expr.ExprSymTab; import inua.eio.ByteOrder; @@ -102,6 +104,8 @@ options { ArithmeticType longType; ArithmeticType intType; ArithmeticType shortType; + CharType charType; + PointerType charPointerType; FloatingPointType doubleType; FloatingPointType floatType; private ExprSymTab exprSymTab; @@ -111,12 +115,14 @@ options { shortType = new SignedType("short", ByteOrder.LITTLE_ENDIAN, 2); intType = new SignedType("int", ByteOrder.LITTLE_ENDIAN, 4); longType = new SignedType("long", ByteOrder.LITTLE_ENDIAN, exprSymTab.getWordSize()); - floatType = new FloatingPointType("false", ByteOrder.LITTLE_ENDIAN, 4); + floatType = new FloatingPointType("float", ByteOrder.LITTLE_ENDIAN, 4); doubleType = new FloatingPointType("double", ByteOrder.LITTLE_ENDIAN, 8); + charType = new CharType("char", ByteOrder.LITTLE_ENDIAN, 1, true); + charPointerType = new PointerType("char*", ByteOrder.LITTLE_ENDIAN, + exprSymTab.getWordSize(), charType); } } - primitiveType : "boolean" | "char" @@ -127,6 +133,10 @@ primitiveType | "float" | "double" ; + +typeCast + : primitiveType (STAR)? + ; identifier returns [String idSpelling=null] : ident:IDENT {idSpelling=ident.getText();} ; @@ -345,7 +355,7 @@ expr returns [Value returnVar=null] exprSymTab.getWordSize()) .bitWiseOrEqual(v1, v2); } - | #(CAST pt:primitiveType v2=expr) { + | #(CAST pt:typeCast v2=expr) { if(pt.getText().compareTo("long") == 0) { returnVar = longType.createValue(0); returnVar.assign(v2); @@ -366,6 +376,13 @@ expr returns [Value returnVar=null] returnVar = floatType.createValue(0.0); returnVar.assign(v2); } + // XXX: Implement casts for other pointer types as well + else if(v2.getType().getName().compareTo("*") == 0) { + if (pt.getText().compareTo("char") == 0) { + returnVar = new Value(charPointerType); + returnVar.assign(v2); + } + } else returnVar = v2; } | #(EXPR_LIST v1=expr) { diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog index 5367dab..42a5afe 100644 --- a/frysk-core/frysk/expr/ChangeLog +++ b/frysk-core/frysk/expr/ChangeLog @@ -1,3 +1,8 @@ +2008-03-11 Teresa Thomas <tthomas@redhat.com> + + * CExprEvaluator.g: Handle CAST for char*. + * CExpr.g (typeCast): Add. + 2008-03-03 Andrew Cagney <cagney@redhat.com> * ScratchSymTab.java: Use frysk.config. hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-03-11 22:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080311220527.22098.qmail@sourceware.org \ --to=tthomas@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).