/* avoid dangling else. */
afterperc += 1;
Cast ((unsigned char *) &u, (sizeof (u)-1), (const unsigned char *) w, _w_high);
- in = DynamicStrings_ConCat (in, DynamicStrings_Slice (fmt, (*startpos), nextperc));
+ in = Copy (fmt, in, (*startpos), nextperc);
in = DynamicStrings_ConCat (in, StringConvert_CardinalToString (u, static_cast<unsigned int> (width), leader, 16, true));
(*startpos) = afterperc;
DSdbExit (static_cast<DynamicStrings_String> (NULL));
/* avoid dangling else. */
afterperc += 1;
Cast ((unsigned char *) &u, (sizeof (u)-1), (const unsigned char *) w, _w_high);
- in = DynamicStrings_ConCat (in, DynamicStrings_Slice (fmt, (*startpos), nextperc));
+ in = Copy (fmt, in, (*startpos), nextperc);
in = DynamicStrings_ConCat (in, StringConvert_CardinalToString (u, static_cast<unsigned int> (width), leader, 10, false));
(*startpos) = afterperc;
DSdbExit (static_cast<DynamicStrings_String> (NULL));
typedef struct { PROC_t proc; } PROC;
# endif
-# include "Gmcrts.h"
#define _M2EXCEPTION_C
#include "GM2EXCEPTION.h"
/* If the program or coroutine is in the exception state then return the enumeration
value representing the exception cause. If it is not in the exception state then
- raises and exception (exException). */
+ raises an exException exception. */
e = RTExceptions_GetExceptionBlock ();
n = RTExceptions_GetNumber (e);
if (n == (UINT_MAX))
{
RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast<void*> (static_cast<const void*>("../../gcc/m2/gm2-libs/M2EXCEPTION.mod")), 47, 6, const_cast<void*> (static_cast<const void*>("M2Exception")), const_cast<void*> (static_cast<const void*>("current coroutine is not in the exceptional execution state")));
+ return M2EXCEPTION_exException;
}
else
{
return (M2EXCEPTION_M2Exceptions) (n);
}
- ReturnException ("../../gcc/m2/gm2-libs/M2EXCEPTION.def", 25, 1);
+ /* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" DynamicStrings_String SFIO_ReadS (FIO_File file);
+/*
+ GetFileName - return a new string containing the name of the file.
+ The string should be killed by the caller.
+*/
+
+extern "C" DynamicStrings_String SFIO_GetFileName (FIO_File file);
+
/*
Exists - returns TRUE if a file named, fname exists for reading.
__builtin_unreachable ();
}
+
+/*
+ GetFileName - return a new string containing the name of the file.
+ The string should be killed by the caller.
+*/
+
+extern "C" DynamicStrings_String SFIO_GetFileName (FIO_File file)
+{
+ return DynamicStrings_InitStringCharStar (FIO_getFileName (file));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
extern "C" void _M2_SFIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
{
}
*/
EXTERN DynamicStrings_String SFIO_ReadS (FIO_File file);
+
+/*
+ GetFileName - return a new string containing the name of the file.
+ The string should be killed by the caller.
+*/
+
+EXTERN DynamicStrings_String SFIO_GetFileName (FIO_File file);
# ifdef __cplusplus
}
# endif
static DynamicStrings_String getLiteralStringContents (decl_node__opaque n);
+/*
+ getStringChar - if the string is delimited by single
+ or double quotes then strip both
+ quotes from the string.
+*/
+
+static DynamicStrings_String getStringChar (decl_node__opaque n);
+
/*
getStringContents - return the string contents of a constant, literal,
string or a constexp node.
static decl_node__opaque resolveString (decl_node__opaque n);
/*
- foldBinary -
+ addQuotes - adds delimiter quote char to string.
+*/
+
+static DynamicStrings_String addQuotes (DynamicStrings_String s, char quote);
+
+/*
+ foldBinary - attempt to fold binary + for string constants.
*/
static decl_node__opaque foldBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res);
}
+/*
+ getStringChar - if the string is delimited by single
+ or double quotes then strip both
+ quotes from the string.
+*/
+
+static DynamicStrings_String getStringChar (decl_node__opaque n)
+{
+ DynamicStrings_String s;
+
+ s = getString (n);
+ if (((DynamicStrings_char (s, 0)) == '\'') && ((DynamicStrings_char (s, -1)) == '\''))
+ {
+ s = DynamicStrings_Slice (s, 1, -1);
+ }
+ else if (((DynamicStrings_char (s, 0)) == '"') && ((DynamicStrings_char (s, -1)) == '"'))
+ {
+ /* avoid dangling else. */
+ s = DynamicStrings_Slice (s, 1, -1);
+ }
+ return s;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
+
/*
getStringContents - return the string contents of a constant, literal,
string or a constexp node.
else if (isString (n))
{
/* avoid dangling else. */
- return getString (n);
+ return getStringChar (n);
}
else if (isConstExp (n))
{
/*
- foldBinary -
+ addQuotes - adds delimiter quote char to string.
+*/
+
+static DynamicStrings_String addQuotes (DynamicStrings_String s, char quote)
+{
+ DynamicStrings_String qs;
+
+ s = DynamicStrings_ConCatChar (s, quote);
+ qs = DynamicStrings_InitStringChar (quote);
+ qs = DynamicStrings_ConCat (qs, DynamicStrings_Mark (s));
+ return qs;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
+
+/*
+ foldBinary - attempt to fold binary + for string constants.
*/
static decl_node__opaque foldBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res)
{
+ char qc;
decl_node__opaque n;
DynamicStrings_String ls;
DynamicStrings_String rs;
{
ls = getStringContents (l);
rs = getStringContents (r);
+ qc = '\'';
+ /* Add unquoted contents. */
ls = DynamicStrings_Add (ls, rs);
+ /* Add quote. */
+ ls = addQuotes (ls, qc);
+ /* Build new string. */
n = static_cast<decl_node__opaque> (decl_makeString (nameKey_makekey (DynamicStrings_string (ls))));
ls = DynamicStrings_KillString (ls);
rs = DynamicStrings_KillString (rs);
break;
case decl_length:
- M2RTS_HALT (-1);
+ M2RTS_HALT (-1); /* length should have been converted into unary. */
__builtin_unreachable ();
break;
given a module and an extension. This file name
length will be operating system specific.
String, Extension, is concatenated onto
- Module and thus it is safe to `Mark' the extension
+ Module and thus it is safe to Mark the extension
for garbage collection.
*/
END getLiteralStringContents ;
+(*
+ getStringChar - if the string is delimited by single
+ or double quotes then strip both
+ quotes from the string.
+*)
+
+PROCEDURE getStringChar (n: node) : String ;
+VAR
+ s: String ;
+BEGIN
+ s := getString (n) ;
+ IF (DynamicStrings.char (s, 0) = "'") AND (DynamicStrings.char (s, -1) = "'")
+ THEN
+ s := DynamicStrings.Slice (s, 1, -1)
+ ELSIF (DynamicStrings.char (s, 0) = '"') AND (DynamicStrings.char (s, -1) = '"')
+ THEN
+ s := DynamicStrings.Slice (s, 1, -1)
+ END ;
+ RETURN s
+END getStringChar ;
+
+
(*
getStringContents - return the string contents of a constant, literal,
string or a constexp node.
RETURN getLiteralStringContents (n)
ELSIF isString (n)
THEN
- RETURN getString (n)
+ RETURN getStringChar (n)
ELSIF isConstExp (n)
THEN
RETURN getStringContents (n^.unaryF.arg)
(*
- foldBinary -
+ addQuotes - adds delimiter quote char to string.
+*)
+
+PROCEDURE addQuotes (s: String; quote: CHAR) : String ;
+VAR
+ qs: String ;
+BEGIN
+ s := DynamicStrings.ConCatChar (s, quote) ;
+ qs := DynamicStrings.InitStringChar (quote) ;
+ qs := DynamicStrings.ConCat (qs, DynamicStrings.Mark (s)) ;
+ RETURN qs
+END addQuotes ;
+
+
+(*
+ foldBinary - attempt to fold binary + for string constants.
*)
PROCEDURE foldBinary (k: nodeT; l, r: node; res: node) : node ;
VAR
+ qc: CHAR ;
n : node ;
ls,
rs: String ;
THEN
ls := getStringContents (l) ;
rs := getStringContents (r) ;
+ qc := "'" ;
+ (* Add unquoted contents. *)
ls := DynamicStrings.Add (ls, rs) ;
+ (* Add quote. *)
+ ls := addQuotes (ls, qc) ;
+ (* Build new string. *)
n := makeString (makekey (DynamicStrings.string (ls))) ;
ls := DynamicStrings.KillString (ls) ;
rs := DynamicStrings.KillString (rs)
--- /dev/null
+MODULE badindrtype ;
+
+
+PROCEDURE init (VAR ch: CHAR) ;
+VAR
+ c: CARDINAL ;
+BEGIN
+ ch := c
+END init ;
+
+
+VAR
+ ch: CHAR ;
+BEGIN
+ init (ch)
+END badindrtype.
--- /dev/null
+MODULE badindrtype2 ;
+
+
+PROCEDURE init (VAR ch: CHAR) ;
+VAR
+ c: CARDINAL ;
+BEGIN
+ c := ch
+END init ;
+
+
+VAR
+ ch: CHAR ;
+BEGIN
+ init (ch)
+END badindrtype2.