// FIXME: This could be `Location.Push' but we have to
// find out why the MS compiler allows this
//
- Mono.CSharp.Location.Push (file, 0);
+ Mono.CSharp.Location.Push (file);
}
static bool is_identifier_start_character (char c)
return seen_digits;
}
- bool is_hex (int e)
+ static bool is_hex (int e)
{
return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');
}
- int real_type_suffix (int c)
+ static int real_type_suffix (int c)
{
int t;
break;
case Token.LITERAL_FLOAT:
try {
- val = (float) System.Double.Parse (s, styles, csharp_format_info);
+ val = float.Parse (s, styles, csharp_format_info);
} catch (OverflowException) {
val = 0.0f;
Report.Error (594, Location, error_details, "float");
return val;
}
- bool IsCastToken (int token)
+ static bool IsCastToken (int token)
{
switch (token) {
case Token.BANG:
//
bool PreProcessLine (string arg)
{
- if (arg == "")
+ if (arg.Length == 0)
return false;
if (arg == "default"){
ref_line = line;
ref_name = file_name;
- Location.Push (ref_name, line);
+ Location.Push (ref_name);
return true;
} else if (arg == "hidden"){
//
ref_name = Location.LookupFile (name);
file_name.HasLineDirective = true;
ref_name.HasLineDirective = true;
- Location.Push (ref_name, ref_line);
+ Location.Push (ref_name);
} else {
ref_line = System.Int32.Parse (arg);
}
//
void PreProcessDefinition (bool is_define, string arg)
{
- if (arg == "" || arg == "true" || arg == "false"){
+ if (arg.Length == 0 || arg == "true" || arg == "false"){
Report.Error (1001, Location, "Missing identifer to pre-processor directive");
return;
}
//
bool process_directives = true;
- // get current status of if blocks.
- bool is_inside_disabled_block ()
- {
- return ifstack != null && ifstack.Count != 0 &&
- ((int) ifstack.Peek ()) & TAKING == 0;
- }
-
//
// if true, then the code continues processing the code
// if false, the code stays in a loop until another directive is
{
string cmd, arg;
bool region_directive = false;
- current_location = new Location (ref_line, Col);
get_cmd_arg (out cmd, out arg);
PreProcessPragma (arg);
return caller_is_taking;
- case "define":
- if (any_token_seen){
- Error_TokensSeen ();
- return true;
- }
- if (caller_is_taking)
- PreProcessDefinition (true, arg);
- return true;
- case "undef":
- if (any_token_seen){
- Error_TokensSeen ();
- return caller_is_taking;
- }
- if (caller_is_taking)
- PreProcessDefinition (false, arg);
+ case "line":
+ if (!PreProcessLine (arg))
+ Report.Error (
+ 1576, Location,
+ "The line number specified for #line directive is missing or invalid");
return caller_is_taking;
case "region":
goto case "endif";
case "if":
- if (arg == ""){
+ if (arg.Length == 0){
Error_InvalidDirective ();
return true;
}
bool taking = false;
if (ifstack == null)
- ifstack = new Stack ();
+ ifstack = new Stack (2);
if (ifstack.Count == 0){
taking = true;
return ret;
}
- case "line":
- case "error":
- case "warning":
- // processed only when current code block is not disabled.
- break;
- default:
- Report.Error (1024, Location, "Wrong preprocessor directive");
- return caller_is_taking;
}
//
return false;
switch (cmd){
- case "line":
- if (!PreProcessLine (arg))
- Report.Error (
- 1576, Location,
- "The line number specified for #line directive is missing or invalid");
- return caller_is_taking;
+ case "define":
+ if (any_token_seen){
+ Error_TokensSeen ();
+ return true;
+ }
+ PreProcessDefinition (true, arg);
+ return true;
+
+ case "undef":
+ if (any_token_seen){
+ Error_TokensSeen ();
+ return true;
+ }
+ PreProcessDefinition (false, arg);
+ return true;
case "error":
Report.Error (1029, Location, "#error: '" + arg + "'");
Report.Warning (1030, 1, Location, "#warning: `{0}'", arg);
return true;
}
+
+ Report.Error (1024, Location, "Wrong preprocessor directive");
return true;
+
}
private int consume_string (bool quoted)