compiler/libec: (#1060) Fixed Debugging method calls such as File::Puts() brings...
authorJerome St-Louis <jerome@ecere.com>
Thu, 6 Feb 2014 20:18:04 +0000 (03:18 +0700)
committerJerome St-Louis <jerome@ecere.com>
Thu, 6 Feb 2014 22:19:36 +0000 (05:19 +0700)
compiler/bootstrap/libec/bootstrap/output.c
compiler/bootstrap/libec/bootstrap/pass2.c
compiler/libec/src/output.ec
compiler/libec/src/pass2.ec

index a595760..075dc30 100644 (file)
@@ -1385,12 +1385,22 @@ __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpa
 
 static void OutputStatement(struct Statement * stmt, struct __ecereNameSpace__ecere__com__Instance * f);
 
+extern unsigned int inCompiler;
+
+extern unsigned int outputLineNumbers;
+
+static void GetSourceName(char *  name, const char *  src);
+
+extern char *  GetIncludeFileFromID(int id);
+
 static void OutputInstance(struct Instantiation * inst, struct __ecereNameSpace__ecere__com__Instance * f);
 
 extern int printf(char * , ...);
 
 static void OutputInitializer(struct Initializer * initializer, struct __ecereNameSpace__ecere__com__Instance * f);
 
+int __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(struct __ecereNameSpace__ecere__com__Instance * this, char *  format, ...);
+
 void OutputExpression(struct Expression * exp, struct __ecereNameSpace__ecere__com__Instance * f)
 {
 switch(exp->type)
@@ -1443,6 +1453,14 @@ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = f;
 
 __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl;
 })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts])(f, ")");
+if(inCompiler && outputLineNumbers && exp->loc.end.line)
+{
+char name[274] = "";
+
+GetSourceName(name, exp->loc.end.included ? GetIncludeFileFromID(exp->loc.end.included) : (((void *)0)));
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "\n#line %d \"%s\"\n", exp->loc.end.line, name);
+outputLine += 2;
+}
 break;
 case 13:
 ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, const char *  string))__extension__ ({
@@ -1887,14 +1905,8 @@ __ecereNameSpace__ecere__sys__PathCat(name, sourceFile);
 __ecereNameSpace__ecere__sys__ChangeCh(name, '\\', '/');
 }
 
-extern unsigned int inCompiler;
-
-extern char *  GetIncludeFileFromID(int id);
-
 extern char *  outputFile;
 
-extern unsigned int outputLineNumbers;
-
 static void OutputDeclaration(struct Declaration * decl, struct __ecereNameSpace__ecere__com__Instance * f);
 
 extern struct __ecereNameSpace__ecere__sys__OldList *  MkList(void);
@@ -1923,8 +1935,6 @@ extern void InstDeclPassTypeName(struct TypeName * type, unsigned int param);
 
 extern void FreeTypeName(struct TypeName * typeName);
 
-int __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(struct __ecereNameSpace__ecere__com__Instance * this, char *  format, ...);
-
 static void OutputStatement(struct Statement * stmt, struct __ecereNameSpace__ecere__com__Instance * f)
 {
 char name[274] = "";
index e852ccb..e261288 100644 (file)
@@ -2663,6 +2663,7 @@ struct Expression * c;
 struct Context * context = PushContext();
 
 c = MkExpExtensionCompound(MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("Instance")), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_ClassInst")), MkInitializerAssignment(CopyExpression(memberExp->member.exp)))))), MkListOne(MkExpressionStmt(MkListOne(MkExpCondition(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkListOne(MkExpPointer(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkIdentifier("_vTbl"))), MkExpPointer(MkExpIdentifier(MkIdentifier(className)), MkIdentifier("_vTbl"))))))));
+c->loc = exp->loc;
 c->compound->compound.context = context;
 PopContext(context);
 exp->call.exp = MkExpBrackets(MkListOne(MkExpCast(typeName, MkExpIndex(c, MkListOne(MkExpIdentifier(MkIdentifier(name)))))));
index 6ddd62e..252ad49 100644 (file)
@@ -128,6 +128,13 @@ public void OutputExpression(Expression exp, File f)
          f.Puts("__extension__ (");
          OutputStatement(exp.compound, f);
          f.Puts(")");
+         if(inCompiler && outputLineNumbers && exp.loc.end.line)
+         {
+            char name[MAX_FILENAME] = "";
+            GetSourceName(name, exp.loc.end.included ? GetIncludeFileFromID(exp.loc.end.included) : null);
+            f.Printf("\n#line %d \"%s\"\n", exp.loc.end.line, name);
+            outputLine += 2;
+         }
          break;
       case newExp:
          f.Puts("new ");
index 5e2277a..0be8a75 100644 (file)
@@ -1768,6 +1768,7 @@ static void ProcessExpression(Expression exp)
                               MkExpIdentifier(MkIdentifier("__internal_ClassInst")),
                               MkListOne(MkExpPointer(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkIdentifier("_vTbl"))),
                               MkExpPointer(MkExpIdentifier(MkIdentifier(className)), MkIdentifier("_vTbl"))))))));
+                     c.loc = exp.loc;
                      c.compound.compound.context = context;
                      PopContext(context);
                      exp.call.exp = MkExpBrackets(MkListOne(MkExpCast(typeName,