public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Fixes bz 5411. Implement cast operation for char* type.
@ 2008-03-11 22:05 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2008-03-11 22:05 UTC (permalink / raw)
  To: frysk-cvs

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-03-11 22:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-11 22:05 [SCM] master: Fixes bz 5411. Implement cast operation for char* type tthomas

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).