• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisión37c54bd22e2ac5ca8601416701e14b546ce5b6f1 (tree)
Tiempo2009-07-15 10:35:36
AutorJack Palevich <jackpal@goog...>
CommiterJack Palevich

Log Message

Make forward declarations of external symbols really work.

Until now we had always been treating external variables as "int",
and external functions as int (...);

Cambiar Resumen

Diferencia incremental

--- a/libacc/acc.cpp
+++ b/libacc/acc.cpp
@@ -2610,7 +2610,7 @@ class Compiler : public ErrorSink {
26102610 }
26112611
26122612 virtual void convertR0(Type* pType){
2613- fprintf(stderr, "convertR0(pType)\n");
2613+ fprintf(stderr, "convertR0(pType tag=%d)\n", pType->tag);
26142614 mpBase->convertR0(pType);
26152615 }
26162616
@@ -3672,7 +3672,7 @@ class Compiler : public ErrorSink {
36723672 #if 0
36733673 {
36743674 String buf;
3675- decodeToken(buf, tok);
3675+ decodeToken(buf, tok, true);
36763676 fprintf(stderr, "%s\n", buf.getUnwrapped());
36773677 }
36783678 #endif
@@ -3883,10 +3883,12 @@ class Compiler : public ErrorSink {
38833883 /* forward reference: try dlsym */
38843884 if (!n) {
38853885 n = (intptr_t) dlsym(RTLD_DEFAULT, nameof(t));
3886- if (tok == '(') {
3887- pVI->pType = mkpIntFn;
3888- } else {
3889- pVI->pType = mkpInt;
3886+ if (pVI->pType == NULL) {
3887+ if (tok == '(') {
3888+ pVI->pType = mkpIntFn;
3889+ } else {
3890+ pVI->pType = mkpInt;
3891+ }
38903892 }
38913893 pVI->pAddress = (void*) n;
38923894 }
@@ -4156,7 +4158,7 @@ class Compiler : public ErrorSink {
41564158
41574159 String temp;
41584160 if (pType->id != 0) {
4159- decodeToken(temp, pType->id);
4161+ decodeToken(temp, pType->id, false);
41604162 buffer.append(temp);
41614163 }
41624164
@@ -4166,7 +4168,7 @@ class Compiler : public ErrorSink {
41664168 void decodeTypeImpPrefix(String& buffer, Type* pType) {
41674169 TypeTag tag = pType->tag;
41684170
4169- if (tag >= TY_INT && tag <= TY_VOID) {
4171+ if (tag >= TY_INT && tag <= TY_DOUBLE) {
41704172 switch (tag) {
41714173 case TY_INT:
41724174 buffer.appendCStr("int");
@@ -4343,7 +4345,7 @@ class Compiler : public ErrorSink {
43434345 error("Symbol %s not allowed here", nameof(declName));
43444346 } else if (nameRequired && ! declName) {
43454347 String temp;
4346- decodeToken(temp, tok);
4348+ decodeToken(temp, tok, true);
43474349 error("Expected symbol. Got %s", temp.getUnwrapped());
43484350 }
43494351 }
@@ -4395,7 +4397,7 @@ class Compiler : public ErrorSink {
43954397 Type* pType = acceptPrimitiveType(arena);
43964398 if (!pType) {
43974399 String buf;
4398- decodeToken(buf, tok);
4400+ decodeToken(buf, tok, true);
43994401 error("Expected a type, got %s", buf.getUnwrapped());
44004402 }
44014403 return pType;
@@ -4455,7 +4457,7 @@ class Compiler : public ErrorSink {
44554457 return checkSymbol(tok);
44564458 }
44574459
4458- void decodeToken(String& buffer, tokenid_t token) {
4460+ void decodeToken(String& buffer, tokenid_t token, bool quote) {
44594461 if (token == EOF ) {
44604462 buffer.printf("EOF");
44614463 } else if (token == TOK_NUM) {
@@ -4466,10 +4468,16 @@ class Compiler : public ErrorSink {
44664468 } else {
44674469 buffer.printf("'%c'", token);
44684470 }
4469- } else if (token >= TOK_KEYWORD && token < TOK_SYMBOL) {
4470- buffer.printf("keyword \"%s\"", nameof(token));
44714471 } else {
4472- buffer.printf("symbol \"%s\"", nameof(token));
4472+ if (quote) {
4473+ if (token >= TOK_KEYWORD && token < TOK_SYMBOL) {
4474+ buffer.printf("keyword \"%s\"", nameof(token));
4475+ } else {
4476+ buffer.printf("symbol \"%s\"", nameof(token));
4477+ }
4478+ } else {
4479+ buffer.printf("%s", nameof(token));
4480+ }
44734481 }
44744482 }
44754483
@@ -4477,7 +4485,7 @@ class Compiler : public ErrorSink {
44774485 bool result = token >= TOK_SYMBOL;
44784486 if (!result) {
44794487 String temp;
4480- decodeToken(temp, token);
4488+ decodeToken(temp, token, true);
44814489 error("Expected symbol. Got %s", temp.getUnwrapped());
44824490 }
44834491 return result;
--- /dev/null
+++ b/libacc/tests/data/rollo3.c
@@ -0,0 +1,9 @@
1+
2+float fabsf(float);
3+
4+int main(void* con, int ft, int launchID)
5+{
6+ float f = fabsf(-10.0f);
7+ return f;
8+}
9+
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -262,6 +262,10 @@ Pointer addition: 2
262262 Pointer comparison to zero: 0 0 1
263263 Pointer comparison: 1 0 0 0 1
264264 """)
265+ def testRollo3(self):
266+ self.compileCheck(["-R", "data/rollo3.c"], """Executing compiled code:
267+result: 10""", """""")
268+
265269
266270
267271 if __name__ == '__main__':