wip II
[sdk] / compiler / bootstrap / libec / bootstrap / pass3.c
index f830a41..20d0fb0 100644 (file)
@@ -1,6 +1,10 @@
+/* Code generated from eC source file: pass3.ec */
 #if defined(__GNUC__)
 typedef long long int64;
 typedef unsigned long long uint64;
+#ifndef _WIN32
+#define __declspec(x)
+#endif
 #elif defined(__TINYC__)
 #include <stdarg.h>
 #define __builtin_va_list va_list
@@ -10,6 +14,8 @@ typedef unsigned long long uint64;
 #define strcasecmp stricmp
 #define strncasecmp strnicmp
 #define __declspec(x) __attribute__((x))
+#else
+#define __declspec(x)
 #endif
 typedef long long int64;
 typedef unsigned long long uint64;
@@ -23,6 +29,7 @@ typedef unsigned __int64 uint64;
 #define __ENDIAN_PAD(x) 0
 #endif
 #include <stdint.h>
+#include <sys/types.h>
 extern void *  __ecereNameSpace__ecere__com__eSystem_New(unsigned int size);
 
 extern void *  __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size);
@@ -89,9 +96,9 @@ struct __ecereNameSpace__ecere__com__Class * _class;
 char *  dataTypeString;
 struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
 struct Type * dataType;
-void (*  Set)();
-int (*  Get)();
-unsigned int (*  IsSet)();
+void (*  Set)(void * , int);
+int (*  Get)(void * );
+unsigned int (*  IsSet)(void * );
 void *  data;
 void *  symbol;
 int vid;
@@ -110,7 +117,7 @@ struct CodePosition
 int line;
 int charPos;
 int pos;
-unsigned int included;
+int included;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location;
@@ -410,7 +417,7 @@ struct TypeName * typeName;
 } __attribute__ ((gcc_struct));
 unsigned int debugValue;
 struct __ecereNameSpace__ecere__com__DataValue val;
-unsigned int address;
+uint64 address;
 unsigned int hasAddress;
 struct Type * expType;
 struct Type * destType;
@@ -480,6 +487,7 @@ struct __ecereNameSpace__ecere__sys__OldList *  baseSpecs;
 struct __ecereNameSpace__ecere__sys__OldList *  definitions;
 unsigned int addNameSpace;
 struct Context * ctx;
+struct ExtDecl * extDeclStruct;
 } __attribute__ ((gcc_struct));
 struct Expression * expression;
 struct Specifier * _class;
@@ -702,25 +710,28 @@ struct Symbol * enumClass;
 struct Type * type;
 struct TemplateParameter * templateParameter;
 } __attribute__ ((gcc_struct));
-unsigned int isSigned;
 int kind;
-unsigned int constant;
 unsigned int size;
 char *  name;
 char *  typeName;
-unsigned int count;
-unsigned int truth;
 int classObjectType;
-unsigned int byReference;
-unsigned int extraParam;
 int alignment;
-unsigned int directClassAccess;
-unsigned int computing;
-unsigned int dllExport;
 unsigned int offset;
-unsigned int keepCast;
-unsigned int passAsTemplate;
 int bitFieldCount;
+int count;
+unsigned int isSigned : 1;
+unsigned int constant : 1;
+unsigned int truth : 1;
+unsigned int byReference : 1;
+unsigned int extraParam : 1;
+unsigned int directClassAccess : 1;
+unsigned int computing : 1;
+unsigned int keepCast : 1;
+unsigned int passAsTemplate : 1;
+unsigned int dllExport : 1;
+unsigned int attrStdcall : 1;
+unsigned int declaredWithStruct : 1;
+unsigned int typedByReference : 1;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class;
@@ -779,8 +790,12 @@ struct __ecereNameSpace__ecere__com__ClassTemplateArgument *  templateArgs;
 struct __ecereNameSpace__ecere__com__Class * templateClass;
 struct __ecereNameSpace__ecere__sys__OldList templatized;
 int numParams;
+unsigned int isInstanceClass;
+unsigned int byValueSystemClass;
 } __attribute__ ((gcc_struct));
 
+extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char *  name);
+
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance;
 
 struct __ecereNameSpace__ecere__com__Instance
@@ -999,7 +1014,7 @@ extern struct Declarator * SpecDeclFromString(char *  string, struct __ecereName
 
 extern struct Specifier * CopySpecifier(struct Specifier * spec);
 
-extern void FreeList(struct __ecereNameSpace__ecere__sys__OldList * list, void (* )(void * ));
+extern void FreeList(struct __ecereNameSpace__ecere__sys__OldList * list, void (*  FreeFunction)(void * ));
 
 extern void FreeSpecifier(struct Specifier * spec);
 
@@ -1124,12 +1139,12 @@ spec->addNameSpace = 0x0;
 }
 else if(_class)
 {
-if((_class->type != 1000 || !strcmp(_class->fullName, "enum") || !strcmp(_class->fullName, "ecere::com::Instance") || (_class->dataTypeString && !strcmp(_class->dataTypeString, "char *")) || !strcmp(_class->fullName, "uint64") || !strcmp(_class->fullName, "uint32") || !strcmp(_class->fullName, "uint16") || !strcmp(_class->fullName, "uintptr") || !strcmp(_class->fullName, "intptr") || !strcmp(_class->fullName, "uint") || !strcmp(_class->fullName, "byte")))
+if((_class->type != 1000 || !strcmp(_class->fullName, "enum") || (_class->dataTypeString && !strcmp(_class->dataTypeString, "char *")) || !strcmp(_class->fullName, "uint64") || !strcmp(_class->fullName, "uint32") || !strcmp(_class->fullName, "uint16") || !strcmp(_class->fullName, "uintptr") || !strcmp(_class->fullName, "intptr") || !strcmp(_class->fullName, "uintsize") || !strcmp(_class->fullName, "intsize") || !strcmp(_class->fullName, "uint") || !strcmp(_class->fullName, "byte")))
 {
 (__ecereNameSpace__ecere__com__eSystem_Delete(spec->name), spec->name = 0);
 if(_class->dataTypeString)
 {
-if(!strcmp(_class->dataTypeString, "uint64") || !strcmp(_class->dataTypeString, "uint32") || !strcmp(_class->dataTypeString, "uint16") || !strcmp(_class->dataTypeString, "uintptr") || !strcmp(_class->dataTypeString, "intptr") || !strcmp(_class->dataTypeString, "uint") || !strcmp(_class->dataTypeString, "byte"))
+if(!strcmp(_class->dataTypeString, "uint64") || !strcmp(_class->dataTypeString, "uint32") || !strcmp(_class->dataTypeString, "uint16") || !strcmp(_class->dataTypeString, "uintptr") || !strcmp(_class->dataTypeString, "intptr") || !strcmp(_class->dataTypeString, "uintsize") || !strcmp(_class->dataTypeString, "intsize") || !strcmp(_class->dataTypeString, "uint") || !strcmp(_class->dataTypeString, "byte"))
 {
 if(!_class->dataType)
 _class->dataType = ProcessTypeString(_class->dataTypeString, 0x0);
@@ -1172,7 +1187,7 @@ spec->addNameSpace = 0x0;
 }
 if(_class && _class->dataTypeString && !strcmp(_class->dataTypeString, "char *"))
 return 0x1;
-if(!_class || _class->type == 0 || _class->type == 5 || !strcmp(_class->fullName, "ecere::com::Instance"))
+if(!_class || _class->type == 0 || _class->type == 5)
 return 0x1;
 else if(param && _class->type == 1)
 return (unsigned int)2;
@@ -1270,7 +1285,9 @@ InstDeclPassIdentifier(spec->id);
 break;
 }
 case 5:
-if(spec->extDecl && spec->extDecl->type == 0 && spec->extDecl->s && !strcmp(spec->extDecl->s, "dllexport"))
+if(spec->extDecl && spec->extDecl->type == 0 && spec->extDecl->s)
+{
+if(!strcmp(spec->extDecl->s, "dllexport"))
 {
 struct Specifier * prevSpec;
 
@@ -1293,6 +1310,15 @@ else
 spec->extDecl->s = __ecereNameSpace__ecere__sys__CopyString("extern __attribute__ ((visibility(\"default\")))");
 }
 }
+else if(!strcmp(spec->extDecl->s, "stdcall") || !strcmp(spec->extDecl->s, "_stdcall") || !strcmp(spec->extDecl->s, "__stdcall") || !strcmp(spec->extDecl->s, "__stdcall__"))
+{
+(__ecereNameSpace__ecere__com__eSystem_Delete(spec->extDecl->s), spec->extDecl->s = 0);
+if(targetPlatform == 1)
+spec->extDecl->s = __ecereNameSpace__ecere__sys__CopyString("__attribute__((__stdcall__))");
+else
+spec->extDecl->s = __ecereNameSpace__ecere__sys__CopyString("");
+}
+}
 break;
 }
 }
@@ -1407,7 +1433,7 @@ else
 {
 struct Symbol * classSym = (spec->type == 1) ? spec->symbol : (((void *)0));
 
-if(type->classObjectType && (!classSym || (classSym && classSym->registered && (classSym->registered->type == 4 || classSym->registered->type == 2 || classSym->registered->type == 3 || (classSym->registered->type == 1000 && strcmp(classSym->string, "ecere::com::Instance") && strcmp(classSym->string, "ecere::com::Class"))))))
+if(type->classObjectType && (!classSym || (classSym && classSym->registered && (classSym->registered->type == 4 || classSym->registered->type == 2 || classSym->registered->type == 3))))
 ReplaceByInstancePtr(spec, &type->declarator, 2);
 }
 InstDeclPassSpecifier(spec);
@@ -1417,11 +1443,11 @@ if(type->declarator)
 InstDeclPassDeclarator(type->declarator);
 }
 
-extern char *  strchr(char * , int);
+extern char *  strchr(const char * , int);
 
 extern char *  strcpy(char * , const char * );
 
-extern int strlen(const char * );
+extern size_t strlen(const char * );
 
 static void InstDeclPassIdentifier(struct Identifier * id)
 {
@@ -1506,11 +1532,13 @@ break;
 }
 case 8:
 {
+if(exp->member.exp)
 InstDeclPassExpression(exp->member.exp);
 break;
 }
 case 9:
 {
+if(exp->member.exp)
 InstDeclPassExpression(exp->member.exp);
 break;
 }
@@ -1674,6 +1702,10 @@ static void InstDeclPassStatement(struct Statement * stmt)
 {
 switch(stmt->type)
 {
+case 14:
+if(stmt->decl)
+InstDeclPassDeclaration(stmt->decl);
+break;
 case 0:
 InstDeclPassStatement(stmt->labeled.stmt);
 break;