3 #define YYLTYPE Location
7 char * defaultNameSpace;
8 int defaultNameSpaceLen;
9 public void SetDefaultNameSpace(char * s) { defaultNameSpace = s; defaultNameSpaceLen = s ? strlen(s) : 0; }
11 bool strictNameSpaces;
12 public void SetStrictNameSpaces(bool b) { strictNameSpaces = b; }
14 AccessMode declMode = privateAccess;
15 AccessMode structDeclMode = privateAccess;
17 public void SetDeclMode(AccessMode accessMode) { structDeclMode = declMode = accessMode; }
18 AccessMode defaultDeclMode = privateAccess;
19 public void SetDefaultDeclMode(AccessMode accessMode) { defaultDeclMode = accessMode; }
21 char * currentNameSpace;
22 int currentNameSpaceLen;
23 public void SetCurrentNameSpace(char * s) { currentNameSpace = s; currentNameSpaceLen = s ? strlen(s) : 0; }
26 Time findClassTotalTime;
27 Time checkTypeTotalTime;
28 Time externalImportTotalTime;
29 Time findClassIgnoreNSTotalTime;
32 public OldList * MkList()
34 return new0 OldList[1];
37 public OldList * MkListOne(void * item)
39 OldList * list = new0 OldList[1];
44 void ListAdd(OldList list, void * item)
50 void ListAddFront(OldList list, void * item)
53 list.Insert(null, item);
56 public Identifier MkIdentifier(char * string)
61 id._class = null; // Default class...
66 bool gotColon = false;
67 for(c = strlen(string)-1; c >= 0; c--)
74 namePart = string+c+1;
75 while(c >= 0 && string[c] == ':') c--;
81 memcpy(name, string, c+1);
83 // TODO: Do these better, keep in string?
84 if(!strcmp(name, "typed_object"))
86 id._class = MkSpecifierName("typed_object"); //"class");
87 id.string = CopyString(namePart);
89 else if(!strcmp(name, "property"))
91 id._class = MkSpecifierName("property");
92 id.string = CopyString(namePart);
94 else if(!strcmp(name, "typed_object&"))
96 id._class = MkSpecifierName("typed_object&");
97 id.string = CopyString(namePart);
99 else if(!strcmp(name, "any_object"))
101 id._class = MkSpecifierName("any_object");
102 id.string = CopyString(namePart);
106 TemplatedType templatedType = FindTemplateTypeParameter(curContext, name);
109 id._class = Specifier { type = templateTypeSpecifier, templateParameter = templatedType.param };
110 //id._class = MkSpecifierName(name);
111 id.string = CopyString(namePart);
115 symbol = FindClass(name);
118 id._class = _MkSpecifierName(symbol.string, symbol, null);
119 id.string = CopyString(namePart);
122 id.string = CopyString(string);
128 id._class = MkSpecifierName(null);
129 id.string = CopyString(namePart);
132 id.string = CopyString(string);
135 id.string = CopyString("");
139 public TemplateParameter MkTypeTemplateParameter(Identifier identifier, TemplateDatatype baseTplDatatype, TemplateArgument defaultArgument)
141 if(identifier.string)
143 TemplateParameter param { type = TemplateParameterType::type, identifier = identifier, dataType = baseTplDatatype, defaultArgument = defaultArgument };
144 TemplatedType type { key = (uintptr)identifier.string, param = param };
145 if(!curContext.templateTypes.Add((BTNode)type))
152 public TemplateParameter MkIdentifierTemplateParameter(Identifier identifier, TemplateMemberType memberType, TemplateArgument defaultArgument)
154 if(identifier.string)
156 TemplateParameter param { type = TemplateParameterType::identifier, identifier = identifier, memberType = memberType, defaultArgument = defaultArgument };
162 public TemplateParameter MkExpressionTemplateParameter(Identifier identifier, TemplateDatatype dataType, TemplateArgument defaultArgument)
164 if(identifier.string)
166 TemplateParameter param { type = TemplateParameterType::expression, identifier = identifier, dataType = dataType, defaultArgument = defaultArgument };
172 public TemplateDatatype MkTemplateDatatype(OldList * specifiers, Declarator decl)
174 TemplateDatatype datatype { specifiers = specifiers, decl = decl };
178 public TemplateArgument MkTemplateTypeArgument(TemplateDatatype tplDatatype)
180 TemplateArgument argument { type = type, templateDatatype = tplDatatype };
184 public TemplateArgument MkTemplateExpressionArgument(Expression expr)
186 TemplateArgument argument { type = expression, expression = expr };
190 public TemplateArgument MkTemplateIdentifierArgument(Identifier ident)
192 TemplateArgument argument { type = identifier, identifier = ident };
196 Expression MkExpExtensionCompound(Statement compound)
198 return { type = extensionCompoundExp, compound = compound };
201 Expression MkExpExtensionExpression(OldList * expressions)
203 return { type = extensionExpressionExp, list = expressions, loc = yylloc };
206 Expression MkExpExtensionInitializer(TypeName typeName, Initializer initializer)
208 return { type = extensionInitializerExp, initializer.typeName = typeName, initializer.initializer = initializer, loc = yylloc };
211 public Expression MkExpIdentifier(Identifier id)
213 return { type = identifierExp, identifier = id };
216 public Expression MkExpDummy()
218 Expression exp { type = dummyExp };
222 public Expression MkExpConstant(char * string)
224 return { type = constantExp, constant = CopyString(string) };
227 Expression MkExpString(char * string)
229 return { type = stringExp, string = CopyString(string) };
232 // TODO: String is case sensitive..
233 // What should we do about it?
234 /*public class CaseSensitiveString : String
236 int OnCompare(CaseSensitiveString string2)
240 result = strcmpi(this, string2);
241 else if(!this && string2)
243 else if(this && !string2)
249 public struct ContextStringPair
251 String string, context;
253 // TODO: Should this be automated somehow?
260 int OnCompare(ContextStringPair b)
263 result = (string && b.string) ? strcmp(string, b.string) :
264 (!string && b.string) ? 1 : (string && !b.string) ? -1 : 0;
265 if(result) return result;
267 result = (context && b.context) ? strcmp(context, b.context) :
268 (!context && b.context) ? 1 : (context && !b.context) ? -1 : 0;
269 // TODO: Support these
270 // result = CaseSensitiveString::OnCompare(string, b.string);
271 // result = ((CaseSensitiveString)string).OnCompare(b.string);
276 Map<ContextStringPair, List<Location>> intlStrings { };
278 Expression MkExpIntlString(char * string, char * context)
280 OldList * list = MkList();
283 ContextStringPair pair { };
285 int len = strlen(string);
287 pair.string = new byte[len-2+1]; memcpy(pair.string, string+1, len-2); pair.string[len-2] = '\0';
288 if(context) { len = strlen(context); pair.context = new byte[len-2+1]; memcpy(pair.context, context+1, len-2); pair.context[len-2] = '\0'; }
290 list = intlStrings[pair];
294 intlStrings[pair] = list;
303 ListAdd(list, QMkExpId("__thisModule"));
304 ListAdd(list, MkExpString(string));
307 int lenString = strlen(string), lenContext = strlen(context);
308 char * msgid = new char[lenString-2 + lenContext-2 + 4];
310 memcpy(msgid+1, context+1, lenContext-2);
311 msgid[1+lenContext-2] = 4; // EOT
312 memcpy(msgid+1+lenContext-2+1, string+1, lenString-2);
313 memcpy(msgid+1+lenContext-2+1+lenString-2, "\"", 2);
314 ListAdd(list, MkExpString(msgid));
318 ListAdd(list, QMkExpId("null"));
319 return MkExpCall(QMkExpId("GetTranslatedString"), list);
322 Expression MkExpOp(Expression exp1, int op, Expression exp2)
333 exp.loc.start = exp1 ? exp1.loc.start : exp2.loc.start;
334 exp.loc.end = exp2 ? exp2.loc.end : exp1.loc.end;
339 Expression MkExpBrackets(OldList expressions)
346 if(expressions && expressions.first)
348 exp.loc.start = ((Expression)expressions.first).loc.start;
349 exp.loc.end = ((Expression)expressions.last).loc.end;
354 Expression MkExpIndex(Expression expression, OldList index)
356 return { type = indexExp, index.exp = expression, index.index = index };
359 Expression MkExpCall(Expression expression, OldList arguments)
361 return { type = callExp, call.exp = expression, call.arguments = arguments };
364 Expression MkExpMember(Expression expression, Identifier member)
366 return { type = memberExp, member.exp = expression, member.member = member };
369 Expression MkExpPointer(Expression expression, Identifier member)
371 return { type = pointerExp, member.exp = expression, member.member = member };
374 Expression MkExpTypeSize(TypeName typeName)
376 return { type = typeSizeExp, typeName = typeName };
379 Expression MkExpTypeAlign(TypeName typeName)
381 return { type = typeAlignExp, typeName = typeName };
384 Expression MkExpClassSize(Specifier _class)
386 return { type = classSizeExp, _class = _class };
389 Expression MkExpCast(TypeName typeName, Expression expression)
391 return { type = castExp, cast.typeName = typeName, cast.exp = expression };
394 Expression MkExpCondition(Expression cond, OldList expressions, Expression elseExp)
396 return { type = conditionExp, cond.cond = cond, cond.exp = expressions, cond.elseExp = elseExp };
399 Expression MkExpRenew(Expression memExp, TypeName type, Expression size)
401 return { type = renewExp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size };
404 Expression MkExpRenew0(Expression memExp, TypeName type, Expression size)
406 return { type = renew0Exp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size };
409 Expression MkExpNew(TypeName type, Expression size)
411 return { type = newExp, _new.typeName = type, _new.size = size };
414 Expression MkExpNew0(TypeName type, Expression size)
416 return { type = new0Exp, _new.typeName = type, _new.size = size };
419 Expression MkExpVaArg(Expression exp, TypeName type)
421 return { type = vaArgExp, vaArg.exp = exp, vaArg.typeName = type };
424 Specifier MkSpecifier(int specifier)
426 if(specifier == _BOOL && (declMode != defaultAccess && defaultDeclMode != defaultAccess))
427 return MkSpecifierName("bool");
428 else if(specifier == _BOOL || specifier == BOOL)
429 return { type = baseSpecifier, specifier = specifier };
431 return { type = baseSpecifier, specifier = specifier };
434 Specifier MkSpecifierTypeOf(Expression expression)
436 return { type = typeOfSpecifier, expression = expression };
439 Specifier MkSpecifierSubClass(Specifier _class)
441 return { type = subClassSpecifier, _class = _class };
444 Specifier MkSpecifierExtended(ExtDecl extDecl)
446 return { type = extendedSpecifier, extDecl = extDecl /*name = CopyString(name)*/ };
449 Specifier MkEnum(Identifier id, OldList list)
453 type = enumSpecifier;
457 if(list && (!declMode || !id))
463 type = ProcessType(&specs, null);
467 Symbol symbol { string = CopyString(id.string), isStruct = true, type = type };
469 if(strstr(symbol.string, "::"))
470 curContext.hasNameSpace = true;
471 if(!curContext.structSymbols.Add((BTNode)symbol))
474 for(e = list.first; e; e = e.next)
476 Symbol symbol { string = CopyString(e.id.string), type = type };
478 if(strstr(symbol.string, "::"))
479 curContext.hasNameSpace = true;
480 if(!(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.Add((BTNode)symbol))
488 Specifier MkStructOrUnion(SpecifierType type, Identifier id, OldList definitions)
490 Specifier spec { type = type, id = id };
491 if(id && FindType(curContext, id.string))
492 structDeclMode = defaultAccess;
493 spec.definitions = definitions;
494 if(definitions && id && structDeclMode == defaultAccess)
499 symbol = Symbol { string = CopyString(id.string), type = ProcessType(specs, null), isStruct = true };
500 if(!curContext.structSymbols.Add((BTNode)symbol))
506 void AddStructDefinitions(Specifier spec, OldList definitions)
508 spec.definitions = definitions;
509 if(definitions && spec.id && !declMode)
514 symbol = Symbol { string = CopyString(spec.id.string), type = ProcessType(specs, null), isStruct = true };
515 if(!curContext.parent.structSymbols.Add((BTNode)symbol))
520 Attribute MkAttribute(String attr, Expression exp)
522 return { attr = attr, exp = exp };
525 Attrib MkAttrib(int type, OldList * attribs)
527 return { type = type, attribs = attribs };
530 ExtDecl MkExtDeclString(String s)
532 return { type = extDeclString, s = s };
536 ExtDecl MkExtDeclAttrib(Attrib attr)
538 return { type = extDeclAttrib, attr = attr };
542 public Declarator MkDeclaratorIdentifier(Identifier id)
544 return { type = identifierDeclarator, identifier = id };
547 Declarator MkDeclaratorFunction(Declarator declarator, OldList parameters)
549 return { type = functionDeclarator, declarator = declarator, function.parameters = parameters };
552 Declarator MkDeclaratorExtended(ExtDecl extended, Declarator declarator)
554 return { type = extendedDeclarator, declarator = declarator, extended.extended = extended };
557 Declarator MkDeclaratorExtendedEnd(ExtDecl extended, Declarator declarator)
559 return { type = extendedDeclaratorEnd, declarator = declarator, extended.extended = extended };
562 Declarator MkStructDeclarator(Declarator declarator, Expression exp)
564 return { type = structDeclarator, declarator = declarator, structDecl.exp = exp };
567 Declarator MkDeclaratorBrackets(Declarator declarator)
569 return { type = bracketsDeclarator, declarator = declarator };
572 Declarator MkDeclaratorArray(Declarator declarator, Expression exp)
574 return { type = arrayDeclarator, declarator = declarator, array.exp = exp };
577 Declarator MkDeclaratorEnumArray(Declarator declarator, Specifier _class)
579 return { type = arrayDeclarator, declarator = declarator, array.enumClass = _class };
582 Declarator MkDeclaratorPointer(Pointer pointer, Declarator declarator)
584 return { type = pointerDeclarator, declarator = declarator, pointer.pointer = pointer };
587 Enumerator MkEnumerator(Identifier id, Expression exp)
589 return { id = id, exp = exp };
592 Pointer MkPointer(OldList qualifiers, Pointer pointer)
594 return { qualifiers = qualifiers, pointer = pointer };
597 Initializer MkInitializerAssignment(Expression exp)
599 /*if(yylloc.start.line == 1)
601 return { type = expInitializer, exp = exp, loc = yylloc };
604 Initializer MkInitializerList(OldList list)
606 /*if(yylloc.start.line == 1)
608 return { type = listInitializer, list = list, loc = yylloc };
611 InitDeclarator MkInitDeclarator(Declarator declarator, Initializer initializer)
613 return { declarator = declarator, initializer = initializer };
616 public TypeName MkTypeName(OldList qualifiers, Declarator declarator)
618 if(qualifiers != null)
620 Declarator parentDecl = declarator;
621 Declarator decl = declarator;
622 while(decl && decl.type == arrayDeclarator)
623 decl = decl.declarator;
624 if(decl && decl.type == identifierDeclarator && decl.identifier.string && CheckType(decl.identifier.string) == TYPE_NAME)
627 // Check if we're missing a real type specifier here
628 for(spec = qualifiers.first; spec; spec = spec.next)
630 if(spec.type == baseSpecifier)
632 if(spec.specifier == CONST || spec.specifier == VOLATILE ||
633 spec.specifier == EXTERN || spec.specifier == STATIC ||
634 spec.specifier == AUTO || spec.specifier == REGISTER)
638 else if(spec.type != extendedSpecifier)
643 // This is actually a type
644 ListAdd(qualifiers, MkSpecifierName(decl.identifier.string));
645 FreeDeclarator(decl);
646 parentDecl.declarator = null;
650 return { qualifiers = qualifiers, declarator = declarator };
653 public TypeName MkTypeNameGuessDecl(OldList qualifiers, Declarator declarator)
655 if(qualifiers != null)
657 bool gotType = false;
658 bool gotFullType = false;
659 Specifier spec, next;
660 for(spec = qualifiers.first; spec; spec = next)
663 if(gotType && !declarator && ((spec.type == nameSpecifier && spec.name) || (spec.type == baseSpecifier && gotFullType)))
666 if(spec.type == nameSpecifier)
668 char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
669 s = colon ? colon + 2 : spec.name;
671 else if(spec.type == baseSpecifier)
673 if(spec.specifier == INT64) s = "int64";
677 declarator = MkDeclaratorIdentifier(MkIdentifier(s));
678 qualifiers.Remove(spec);
683 if(spec && spec.type != extendedSpecifier)
685 if(spec.type == baseSpecifier)
687 if(spec.specifier == CONST || spec.specifier == VOLATILE ||
688 spec.specifier == EXTERN || spec.specifier == STATIC ||
689 spec.specifier == AUTO || spec.specifier == REGISTER)
691 else if(spec.specifier != UNSIGNED && spec.specifier != SIGNED && spec.specifier != LONG)
703 return { qualifiers = qualifiers, declarator = declarator };
706 public Identifier GetDeclId(Declarator decl)
708 while(decl && decl.type != identifierDeclarator)
709 decl = decl.declarator;
710 return decl ? decl.identifier : null;
713 Declaration MkDeclarationClassInst(Instantiation inst)
715 return { type = instDeclaration, inst = inst, loc = yylloc };
718 Declaration MkDeclarationInst(Instantiation inst)
720 Declaration decl { type = instDeclaration, inst = inst, loc = yylloc };
722 if(curContext == globalContext && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
725 int len = 0, stringLen;
728 memcpy(name, defaultNameSpace, defaultNameSpaceLen);
729 len += defaultNameSpaceLen;
735 memcpy(name + len, currentNameSpace, currentNameSpaceLen);
736 len += currentNameSpaceLen;
741 stringLen = strlen(inst.exp.identifier.string);
742 memcpy(name + len, inst.exp.identifier.string, stringLen);
745 delete inst.exp.identifier.string;
746 inst.exp.identifier.string = CopyString(name);
751 string = (inst.exp.type == identifierExp) ? CopyString(inst.exp.identifier.string) : null;
752 type = MkClassTypeSymbol(inst._class.symbol);
754 symbol.idCode = symbol.id = curContext.nextID++;
755 if(strstr(symbol.string, "::"))
756 curContext.hasNameSpace = true;
757 if(!(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.Add((BTNode)symbol))
758 excludedSymbols->Add(symbol);
759 decl.symbol = inst.symbol = symbol;
763 Declaration MkDeclarationDefine(Identifier id, Expression exp)
765 Declaration decl { type = defineDeclaration, id = id, exp = exp, loc = yylloc };
766 char expString[1024];
769 PrintExpression(exp, expString);
771 if(curContext == globalContext && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
774 int len = 0, stringLen;
777 memcpy(name, defaultNameSpace, defaultNameSpaceLen);
778 len += defaultNameSpaceLen;
784 memcpy(name + len, currentNameSpace, currentNameSpaceLen);
785 len += currentNameSpaceLen;
789 stringLen = strlen(id.string);
790 memcpy(name + len, id.string, stringLen);
794 id.string = CopyString(name);
797 if(!eSystem_FindDefine(privateModule, id.string))
798 eSystem_RegisterDefine(id.string, expString, privateModule, buildingECERECOMModule ? baseSystemAccess : publicAccess);
800 Compiler_Warning($"Redefinition of %s ignored\n", id.string);
804 Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
806 Declaration decl { type = initDeclaration, declarators = initDeclarators, specifiers = specifiers, loc = yylloc };
807 bool variable = true;
809 if(specifiers != null)
811 bool gotType = false;
812 Specifier spec, next;
813 for(spec = specifiers.first; spec; spec = next)
816 if(spec.type == baseSpecifier && spec.specifier == TYPEDEF)
818 if(initDeclarators != null)
822 for(d = initDeclarators.first; d; d = d.next)
824 if(GetDeclId(d.declarator).string)
828 string = CopyString(GetDeclId(d.declarator).string);
829 type = ProcessType(specifiers, d.declarator);
831 type.id = type.idCode = curContext.nextID++;
833 if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
834 excludedSymbols->Add(type);
835 decl.symbol = d.declarator.symbol = type;
841 //for(spec = spec.next; spec; spec = spec.next)
842 spec = specifiers.last;
844 if((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier)
847 if(spec.type == nameSpecifier)
849 char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
850 s = colon ? colon + 2 : spec.name;
852 else if(spec.type == baseSpecifier)
854 if(spec.specifier == INT64) s = "int64";
858 Symbol type { string = CopyString(s), type = ProcessType(specifiers, null) };
859 type.id = type.idCode = curContext.nextID++;
861 decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
862 specifiers.Remove(spec);
864 if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
865 excludedSymbols->Add(type);
873 else if(spec.type == baseSpecifier &&
874 (spec.specifier == STRUCT || spec.specifier == UNION))
878 if(gotType && initDeclarators == null && !spec.next && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
881 if(spec.type == nameSpecifier)
883 char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
884 s = colon ? colon + 2 : spec.name;
886 else if(spec.type == baseSpecifier)
888 if(spec.specifier == INT64) s = "int64";
892 decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
893 specifiers.Remove(spec);
899 if(spec && spec.type != extendedSpecifier)
903 if(variable && initDeclarators)
906 for(d = initDeclarators.first; d; d = d.next)
908 Identifier id = GetDeclId(d.declarator);
909 if(id && id.string && id.string[0])
915 if(curContext == globalContext && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
918 int len = 0, stringLen;
921 memcpy(name, defaultNameSpace, defaultNameSpaceLen);
922 len += defaultNameSpaceLen;
928 memcpy(name + len, currentNameSpace, currentNameSpaceLen);
929 len += currentNameSpaceLen;
933 stringLen = strlen(id.string);
934 memcpy(name + len, id.string, stringLen);
938 id.string = CopyString(name);
941 // Avoid memory leaks on duplicated symbols (BinaryTree::Add Would Fail)
942 symbol = (Symbol)(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.FindString(id.string);
945 symbol = Symbol { string = CopyString(id.string), type = ProcessType(specifiers, d.declarator) };
946 if(strstr(symbol.string, "::"))
947 curContext.hasNameSpace = true;
948 if(!(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.Add((BTNode)symbol))
949 excludedSymbols->Add(symbol);
950 // TODO: Add better support to count declarators
951 if(symbol.type && symbol.type.kind == arrayType && !symbol.type.arraySizeExp && d.initializer)
953 if(d.initializer.type == listInitializer)
956 sprintf(string, "%d",d.initializer.list->count);
957 symbol.type.arraySizeExp = MkExpConstant(string);
958 symbol.type.freeExp = true;
960 else if(d.initializer.type == expInitializer && d.initializer.exp.type == stringExp && d.initializer.exp.string)
965 bool escaped = false;
966 char * s = d.initializer.exp.string;
968 // MAKE MORE ACCURATE
969 for(c = 1; (ch = s[c]); c++)
971 if(ch == '\\' && !escaped)
980 sprintf(string, "%d", count);
981 symbol.type.arraySizeExp = MkExpConstant(string);
982 symbol.type.freeExp = true;
985 symbol.id = symbol.idCode = curContext.nextID++;
987 decl.symbol = d.declarator.symbol = symbol;
994 decl.symbol = Symbol { };
995 decl.symbol.id = decl.symbol.idCode = curContext.nextID++;
996 excludedSymbols->Add(decl.symbol);
1001 Declaration MkStructDeclaration(OldList specifiers, OldList declarators, Specifier extStorage)
1003 Declaration decl { type = structDeclaration, declarators = declarators, specifiers = specifiers, extStorage = extStorage, loc = yylloc };
1004 if(specifiers != null)
1006 bool gotType = false;
1007 Specifier spec, next;
1008 for(spec = specifiers.first; spec; spec = next)
1011 if(gotType && declarators == null && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
1014 if(spec.type == nameSpecifier)
1016 char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
1017 s = colon ? colon + 2 : spec.name;
1019 else if(spec.type == baseSpecifier)
1021 if(spec.specifier == INT64) s = "int64";
1025 decl.declarators = declarators = MkListOne(MkStructDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
1026 specifiers.Remove(spec);
1027 FreeSpecifier(spec);
1031 if(spec && spec.type != extendedSpecifier)
1038 Statement MkLabeledStmt(Identifier id, Statement statement)
1040 return { type = labeledStmt, labeled.id = id, labeled.stmt = statement, loc = yylloc };
1043 Statement MkCaseStmt(Expression exp, Statement statement)
1045 return { type = caseStmt, caseStmt.exp = exp, caseStmt.stmt = statement, loc = yylloc };
1048 Statement MkCompoundStmt(OldList declarations, OldList statements)
1050 return { type = compoundStmt, compound.declarations = declarations, compound.statements = statements, loc = yylloc };
1053 Statement MkExpressionStmt(OldList expressions)
1055 return { type = expressionStmt, expressions = expressions, loc = yylloc };
1058 Statement MkBadDeclStmt(Declaration decl)
1060 return { type = badDeclarationStmt, decl = decl, loc = yylloc };
1063 Statement MkIfStmt(OldList exp, Statement statement, Statement elseStmt)
1065 return { type = ifStmt, ifStmt.exp = exp, ifStmt.stmt = statement, ifStmt.elseStmt = elseStmt, loc = yylloc };
1068 Statement MkSwitchStmt(OldList exp, Statement statement)
1070 // To know it's a switch compound... (Don't want declarations in there... bugs)
1072 statement.compound.isSwitch = true;
1073 return { type = switchStmt, switchStmt.exp = exp, switchStmt.stmt = statement, loc = yylloc };
1076 Statement MkWhileStmt(OldList exp, Statement statement)
1078 return { type = whileStmt, whileStmt.exp = exp, whileStmt.stmt = statement, loc = yylloc };
1081 Statement MkDoWhileStmt(Statement statement, OldList exp)
1083 return { type = doWhileStmt, doWhile.exp = exp, doWhile.stmt = statement, loc = yylloc };
1086 Statement MkForStmt(Statement init, Statement check, OldList inc, Statement statement)
1088 return { type = forStmt, forStmt.init = init, forStmt.check = check, forStmt.increment = inc, forStmt.stmt = statement, loc = yylloc };
1091 Statement MkForEachStmt(Identifier id, OldList exp, OldList filter, Statement statement)
1093 return { type = forEachStmt, forEachStmt.id = id, forEachStmt.exp = exp, forEachStmt.filter = filter, forEachStmt.stmt = statement, loc = yylloc };
1096 Statement MkGotoStmt(Identifier id)
1098 return { type = gotoStmt, gotoStmt.id = id, loc = yylloc };
1101 Statement MkContinueStmt()
1103 return { type = continueStmt, loc = yylloc };
1106 Statement MkBreakStmt()
1108 return { type = breakStmt, loc = yylloc };
1111 Statement MkReturnStmt(OldList exp)
1113 return { type = returnStmt, expressions = exp, loc = yylloc };
1116 FunctionDefinition MkFunction(OldList specifiers, Declarator declarator, OldList declarationList)
1118 return _MkFunction(specifiers, declarator, declarationList, true);
1121 FunctionDefinition _MkFunction(OldList specifiers, Declarator declarator, OldList declarationList, bool errorOnOmit)
1125 Declarator funcDecl = GetFuncDecl(declarator);
1126 if(funcDecl && funcDecl.function.parameters)
1129 for(tn = funcDecl.function.parameters->first; tn; tn = tn.next)
1131 if(tn.qualifiers || tn.declarator)
1133 Identifier declID = tn.declarator ? GetDeclId(tn.declarator) : null;
1137 Specifier spec = tn.qualifiers ? tn.qualifiers->first : null;
1138 if(!tn.declarator && !tn.prev && !tn.next && spec && !spec.next && spec.type == baseSpecifier && spec.specifier == VOID);
1140 Compiler_Error("parameter name omitted\n");
1147 return { specifiers = specifiers, declarator = declarator, declarations = declarationList };
1150 void ProcessFunctionBody(FunctionDefinition func, Statement body)
1152 Declarator declarator = func.declarator;
1153 Declarator funcDecl = GetFuncDecl(declarator);
1158 if(funcDecl && funcDecl.function.parameters && body)
1160 Context context = body.compound.context;
1162 for(param = funcDecl.function.parameters->first; param; param = param.next)
1164 if(param.declarator)
1166 Symbol symbol = null;
1167 Identifier id = GetDeclId(param.declarator);
1168 char * string = id ? id.string : null;
1171 for(symbol = (Symbol)context.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
1172 if(!strcmp(symbol.string, string))
1174 // This parameter is not shadowed by a local declaration
1177 symbol = Symbol { string = CopyString(id.string), type = ProcessType(param.qualifiers, param.declarator), isParam = true };
1178 if(!context.symbols.Add((BTNode)symbol))
1179 excludedSymbols->Add(symbol);
1181 // TODO: Fix this, the parameters' IDs should really be smaller...
1182 symbol.id = context.nextID++;
1183 param.declarator.symbol = symbol;
1190 if(!declarator.symbol)
1192 Identifier id = GetDeclId(declarator);
1194 if((currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess && strcmp(id.string, "__on_register_module"))
1197 int len = 0, stringLen;
1198 if(defaultNameSpace)
1200 memcpy(name, defaultNameSpace, defaultNameSpaceLen);
1201 len += defaultNameSpaceLen;
1205 if(currentNameSpace)
1207 memcpy(name + len, currentNameSpace, currentNameSpaceLen);
1208 len += currentNameSpaceLen;
1212 stringLen = strlen(id.string);
1213 memcpy(name + len, id.string, stringLen);
1217 id.string = CopyString(name);
1219 symbol = Symbol { string = CopyString(id.string), type = ProcessType(func.specifiers, declarator) };
1220 symbol.idCode = symbol.id = globalContext.nextID++;
1221 if(strstr(symbol.string, "::"))
1222 globalContext.hasNameSpace = true;
1223 if(!globalContext.symbols.Add((BTNode)symbol))
1224 excludedSymbols->Add(symbol);
1225 declarator.symbol = symbol;
1229 symbol = declarator.symbol;
1230 excludedSymbols->Remove(declarator.symbol);
1231 delete symbol.string;
1232 symbol.string = CopyString(GetDeclId(declarator).string);
1233 if(strstr(symbol.string, "::"))
1234 globalContext.hasNameSpace = true;
1235 if(!globalContext.symbols.Add((BTNode)symbol))
1236 excludedSymbols->Add(symbol);
1239 symbol.type = ProcessType(func.specifiers, declarator);
1241 if(symbol.type && (symbol.type.kind == functionType || symbol.type.kind == methodType))
1243 if(!symbol.type.params.count)
1245 Type type { refCount = 1 };
1246 symbol.type.params.Add(type);
1255 External MkExternalFunction(FunctionDefinition function)
1257 External external { type = functionExternal, function = function, symbol = function.declarator.symbol };
1258 if(function.specifiers)
1261 for(spec = function.specifiers->first; spec; spec = spec.next)
1262 if(spec.type == baseSpecifier && spec.specifier == STATIC)
1264 structDeclMode = declMode = staticAccess;
1269 if(external.symbol && !external.symbol.methodExternal)
1270 external.symbol.methodExternal = external;
1274 External MkExternalImport(char * name, ImportType importType, AccessMode importAccess)
1276 External external { type = importExternal };
1277 int len = strlen(name) - 2;
1278 external.importString = new char[len + 1];
1279 strncpy(external.importString, name+1, len);
1280 external.importString[len] = '\0';
1285 Time startTime = GetTime();
1288 ImportModule(external.importString, importType, importAccess, true);
1289 ImportModule(external.importString, importType, importAccess, false);
1291 time = GetTime() - startTime;
1292 printf("Importing took %.3f seconds for %s\n", time, external.importString);
1293 externalImportTotalTime += time;
1299 External MkExternalDeclaration(Declaration declaration)
1301 External external { type = declarationExternal, declaration = declaration, symbol = declaration ? declaration.symbol : null };
1302 InitDeclarator d = (declaration && declaration.declarators) ? declaration.declarators->last : null;
1303 if(declaration && declaration.type == initDeclaration && declaration.specifiers)
1306 for(spec = declaration.specifiers->first; spec; spec = spec.next)
1307 if(spec.type == baseSpecifier && spec.specifier == TYPEDEF)
1309 structDeclMode = declMode = defaultAccess;
1312 else if(spec.type == baseSpecifier && spec.specifier == STATIC)
1314 structDeclMode = declMode = staticAccess;
1318 if(declaration && declaration.symbol && !declaration.symbol.methodExternal)
1319 declaration.symbol.methodExternal = external;
1323 External MkExternalNameSpace(Identifier identifier)
1325 External external { type = nameSpaceExternal, id = identifier };
1326 currentNameSpace = identifier ? identifier.string : null;
1327 currentNameSpaceLen = currentNameSpace ? strlen(currentNameSpace) : 0;
1331 void SetClassTemplateArgs(Specifier spec, OldList templateArgs)
1333 if(spec.type == nameSpecifier)
1335 Symbol symbol = spec.symbol;
1336 spec.templateArgs = templateArgs;
1337 if(templateArgs && templateArgs.first)
1339 char templateString[1024];
1340 TemplateArgument arg;
1341 strcpy(templateString, symbol ? symbol.string : spec.name);
1342 strcat(templateString, "<");
1343 for(arg = templateArgs.first; arg; arg = arg.next)
1351 char expString[1024];
1352 Class backupThisClass = thisClass;
1354 expString[0] = '\0';
1355 // Will this work here?
1357 Location oldLocation = yylloc;
1358 File backFileInput = fileInput;
1363 // TESTING THIS SCANNER RESUME STUFF
1366 yylloc = oldLocation;
1367 fileInput = backFileInput;
1370 fileInput.Seek(yylloc.start.pos, start);
1371 resetScannerPos(&yylloc.start);
1376 //ProcessExpressionType(arg.expression);
1377 //ComputeExpression(arg.expression);
1378 PrintExpression(arg.expression, expString);
1379 strcat(argument, expString);
1380 thisClass = backupThisClass;
1385 strcat(argument, arg.identifier.string);
1390 char * typeString = StringFromSpecDecl(arg.templateDatatype.specifiers, arg.templateDatatype.decl);
1391 strcat(argument, typeString);
1398 if(arg.prev) strcat(templateString, ", ");
1401 strcat(templateString, arg.name.string);
1402 strcat(templateString, " = ");
1404 strcat(templateString, argument);
1408 int len = strlen(templateString);
1409 if(templateString[len-1] == '>') templateString[len++] = ' ';
1410 templateString[len++] = '>';
1411 templateString[len++] = '\0';
1413 // printf("SetClassTemplateArgs templateString: %s\n", templateString);
1414 symbol = FindClass(templateString);
1415 if(!symbol && spec.symbol)
1417 // If class was only decl'ed, invoke DeclClass on this templated class as well
1418 symbol = _DeclClass(MAXINT, templateString);
1420 // Add a reference to all templated class to the basic class
1422 spec.symbol.templatedClasses.Add(OldLink { data = symbol });
1424 spec.symbol = symbol;
1425 spec.name = CopyString(symbol ? symbol.string : templateString);
1429 FreeList(templateArgs, FreeTemplateArgument);
1432 Specifier _MkSpecifierName(char * name, Symbol symbol, OldList templateArgs)
1434 Specifier spec { type = nameSpecifier };
1440 TemplatedType templatedType = FindTemplateTypeParameter(curContext, name);
1443 spec.templateParameter = templatedType.param;
1444 spec.type = templateTypeSpecifier;
1448 symbol = FindClass(name);
1450 if(symbol && symbol.registered && symbol.registered.isRemote == 1)
1452 char className[1024];
1453 strcpy(className, "DCOMClient_");
1454 if(!strncmp(name, className, strlen(className)))
1455 spec.name = CopyString(name);
1458 strcat(className, name);
1459 spec.name = CopyString(className);
1463 spec.name = CopyString(symbol.string);
1465 spec.name = CopyString(name);
1466 spec.symbol = symbol;
1467 if(templateArgs != null)
1468 SetClassTemplateArgs(spec, templateArgs);
1473 public Specifier MkSpecifierName(char * name)
1475 return _MkSpecifierName(name, null, null);
1478 public Specifier MkSpecifierNameArgs(char * name, OldList * templateArgs)
1480 return _MkSpecifierName(name, null, templateArgs);
1484 Specifier MkClassName(char * string)
1486 return { type = SpecifierClass, name = CopyString(string) };
1489 ClassFunction MkClassFunction(OldList specifiers, Specifier _class, Declarator decl, OldList declList)
1491 return { specifiers = specifiers, /*_class = _class,*/ declarator = decl, declarations = declList };
1494 void ProcessClassFunctionBody(ClassFunction func, Statement body)
1498 Declarator decl = func.declarator;
1500 //Declarator decl = GetFuncDecl(func.declarator);
1501 Declarator funcDecl = GetFuncDecl(func.declarator);
1505 if(decl && !decl.symbol)
1507 OldList * symbolSpecs = MkList();
1509 // WHAT WILL WE DO WITH THIS? Double instances?
1510 //if(decl.function.parameters && body)
1511 if(funcDecl && funcDecl.function.parameters && body)
1513 Context context = body.compound.context;
1515 for(param = funcDecl.function.parameters->first; param; param = param.next)
1517 if(param.declarator)
1519 Symbol symbol = null;
1520 Identifier id = GetDeclId(param.declarator);
1521 char * string = id ? id.string : null;
1524 symbol = (Symbol)context.symbols.FindString(string);
1526 // This parameter is not shadowed by a local declaration
1531 string = CopyString(id.string);
1532 type = ProcessType(param.qualifiers, param.declarator);
1536 // TODO: Fix this, the parameters' IDs should really be smaller...
1537 symbol.idCode = symbol.id = context.nextID++;
1538 if(!context.symbols.Add((BTNode)symbol))
1539 excludedSymbols->Add(symbol);
1541 param.declarator.symbol = symbol;
1546 //////////////////////////////////
1554 Identifier id = GetDeclId(funcDecl);
1558 for(c = strlen(id.string)-1; c >= 0; c--)
1560 if(id.string[c] == ':')
1562 char * string = CopyString(id.string + c + 1);
1563 id.string[c - 1] = 0;
1564 id._class = MkSpecifierName(id.string);
1570 symbol.string = CopyString(id.string);
1577 for(spec = func.specifiers->first; spec; spec = spec.next)
1578 symbolSpecs->Add(CopySpecifier(spec));
1580 symbol.type = ProcessType(symbolSpecs, decl);
1581 symbol.idCode = symbol.id = globalContext.nextID++;
1582 decl.symbol = symbol;
1584 excludedSymbols->Add(symbol);
1586 FreeList(symbolSpecs, FreeSpecifier);
1590 OldList * MkSpecsClass(Specifier _class)
1592 OldList * list = MkList();
1593 ListAdd(list, _class);
1597 MemberInit MkMemberInit(OldList ids, Initializer initializer)
1599 return { identifiers = ids, initializer = initializer };
1602 MemberInit MkMemberInitExp(Expression idExp, Initializer initializer)
1604 MemberInit init { initializer = initializer, identifiers = MkList() };
1607 for(exp = idExp; exp && exp.type == memberExp; exp = exp.member.exp)
1609 init.identifiers->Insert(null, exp.member.member);
1610 exp.member.member = null;
1612 if(exp && exp.type == identifierExp)
1614 init.identifiers->Insert(null, exp.identifier);
1615 exp.identifier = null;
1617 FreeExpression(idExp);
1621 MembersInit MkMembersInitList(OldList dataMembers)
1623 return { type = dataMembersInit, dataMembers = dataMembers };
1626 MembersInit MkMembersInitMethod(ClassFunction function)
1628 return { type = methodMembersInit, function = function };
1631 Instantiation MkInstantiation(Specifier _class, Expression exp, OldList members)
1633 return { _class = _class, exp = exp, members = members };
1636 Instantiation MkInstantiationNamed(OldList specs, Expression exp, OldList members)
1638 Instantiation inst { exp = exp, members = members };
1643 for(spec = specs.first; spec; spec = spec.next)
1644 if(spec.type == nameSpecifier /*classSpecifier*/)
1651 FreeList(specs, FreeSpecifier);
1655 Compiler_Error($"Expecting class specifier\n");
1656 inst._class = MkSpecifierName /*MkClassName*/("");
1664 ClassDef MkClassDefAccessOverride(AccessMode access, Identifier id)
1666 return { type = accessOverrideClassDef, id = id, memberAccess = access };
1669 ClassDef MkClassDefMemberAccess()
1671 return { type = memberAccessClassDef };
1674 ClassDef MkClassDefDeclaration(Declaration decl)
1676 return { type = declarationClassDef, decl = decl };
1679 ClassDef MkClassDefClassData(Declaration decl)
1681 return { type = classDataClassDef, decl = decl };
1684 ClassDef MkClassDefDesigner(char * designer)
1686 return { type = classDesignerClassDef, designer = CopyString(designer) };
1689 ClassDef MkClassDefNoExpansion()
1691 return { type = classNoExpansionClassDef };
1694 ClassDef MkClassDefFixed()
1696 return { type = classFixedClassDef };
1699 ClassDef MkClassDefDesignerDefaultProperty(Identifier id)
1701 return { type = designerDefaultPropertyClassDef, defaultProperty = id };
1704 ClassDef MkClassDefDefaultProperty(OldList defProperties)
1706 return { type = defaultPropertiesClassDef, defProperties = defProperties };
1709 ClassDef MkClassDefFunction(ClassFunction function)
1712 if(function && function.declarator)
1714 Declarator funcDecl = GetFuncDecl(function.declarator);
1715 if(funcDecl && funcDecl.declarator && funcDecl.declarator.type == bracketsDeclarator)
1717 def.type = declarationClassDef;
1718 def.decl = MkStructDeclaration(function.specifiers, MkListOne(MkStructDeclarator(function.declarator, null)), null);
1719 function.declarator = null;
1720 function.specifiers = null;
1721 FreeClassFunction(function);
1725 def.type = functionClassDef;
1726 def.function = function;
1730 Symbol DeclClassAddNameSpace(int symbolID, char * className)
1733 int len = 0, stringLen;
1735 if((currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
1737 if(defaultNameSpace)
1739 memcpy(name, defaultNameSpace, defaultNameSpaceLen);
1740 len += defaultNameSpaceLen;
1744 if(currentNameSpace)
1746 memcpy(name + len, currentNameSpace, currentNameSpaceLen);
1747 len += currentNameSpaceLen;
1752 stringLen = strlen(className);
1753 memcpy(name + len, className, stringLen);
1756 return _DeclClass(symbolID, name);
1759 Symbol DeclClass(int symbolID, char * name)
1761 if(strchr(name, ':'))
1762 return _DeclClass(symbolID, name);
1764 return DeclClassAddNameSpace(symbolID, name);
1767 Symbol _DeclClass(int symbolID, char * name)
1769 Symbol symbol = FindClass(name);
1773 Context classContext;
1774 for(classContext = curContext; classContext && !classContext.classDef; classContext = classContext.parent);
1780 if(name[0] == ':' && name[1] == ':')
1784 string = CopyString(name);
1785 idCode = symbolID, id = symbolID;
1787 if(!globalContext.classes.Add((BTNode)symbol))
1788 excludedSymbols->Add(symbol);
1793 for(c = 0; (ch = name[c]); c++)
1795 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
1801 if(start && c - start)
1802 symbol.shortName = CopyString(name + start);
1806 symbol.idCode = symbol.id = symbolID;
1810 void SetupBaseSpecs(Symbol symbol, OldList baseSpecs)
1812 if(baseSpecs && baseSpecs.first && ((Specifier)baseSpecs.first).type == nameSpecifier)
1817 strcpy(name, ((Specifier)baseSpecs.first).name);
1818 tpl = strchr(name, '<');
1821 baseClass = FindClass(name);
1822 if(baseClass && baseClass.ctx)
1825 for(copy = (TemplatedType)baseClass.ctx.templateTypes.first; copy; copy = (TemplatedType)copy.next)
1827 TemplatedType type { key = copy.key, param = copy.param };
1828 if(!curContext.templateTypes.Add((BTNode)type))
1832 else if(baseClass && baseClass.registered)
1835 for(sClass = baseClass.registered; sClass; sClass = sClass.base)
1837 ClassTemplateParameter p;
1838 for(p = sClass.templateParams.first; p; p = p.next)
1840 //OldList * specs = MkList();
1841 //Declarator decl = null;
1842 //decl = SpecDeclFromString(p.dataTypeString, specs, null);
1845 TemplateParameter param = p.param;
1849 p.param = param = TemplateParameter
1851 identifier = MkIdentifier(p.name), type = p.type,
1852 dataTypeString = p.dataTypeString /*, dataType = { specs, decl }*/
1855 type = TemplatedType { key = (uintptr)p.name, param = param };
1856 if(!curContext.templateTypes.Add((BTNode)type))
1865 ClassDefinition MkClass(Symbol symbol, OldList baseSpecs, OldList definitions)
1867 ClassDefinition classDef;
1868 SetupBaseSpecs(symbol, baseSpecs);
1871 ClassDefinition classDef = symbol.ctx.classDef;
1874 // This can occur if two instances of a class are defined...
1875 // To avoid dangling 'parent' Contexts, we free the previous class definition
1877 for(external = ast->first; external; external = external.next)
1879 if(external.type == classExternal && external._class == classDef)
1881 ast->Remove(external);
1882 FreeExternal(external);
1887 FreeContext(symbol.ctx);
1890 symbol.ctx = curContext;
1891 classDef = { symbol = symbol, _class = MkSpecifierName /*MkClassName*/(symbol.string), baseSpecs = baseSpecs, definitions = definitions, nameLoc = symbol.nameLoc };
1892 curContext.classDef = classDef;
1896 Expression MkExpInstance(Instantiation inst)
1898 return { type = instanceExp, instance = inst };
1901 External MkExternalClass(ClassDefinition _class)
1903 return { type = classExternal, _class = _class, symbol = _class.symbol };
1906 PropertyDef MkProperty(OldList specs, Declarator decl, Identifier id, Statement setStmt, Statement getStmt)
1916 Type type = ProcessType(specs, decl);
1919 char typeString[1024];
1920 typeString[0] = '\0';
1921 PrintTypeNoConst(type, typeString, false, true);
1922 id = MkIdentifier(typeString);
1923 prop.conversion = true;
1929 string = CopyString(id.string);
1932 symbol.idCode = symbol.id = globalContext.nextID++;
1933 excludedSymbols->Add(symbol);
1934 globalContext.nextID++;
1935 globalContext.nextID++;
1936 prop.symbol = symbol;
1940 ClassDef MkClassDefProperty(PropertyDef propertyDef)
1942 return { type = propertyClassDef, propertyDef = propertyDef };
1945 ClassDef MkClassDefClassProperty(PropertyDef propertyDef)
1947 return { type = classPropertyClassDef, propertyDef = propertyDef };
1950 ClassDef MkClassDefClassPropertyValue(Identifier id, Initializer initializer)
1952 return { type = classPropertyValueClassDef, id = id, initializer = initializer };
1955 int CheckType(char * text)
1958 Time startTime = GetTime();
1960 if(FindTemplateTypeParameter(curContext, text))
1963 checkTypeTotalTime += GetTime() - startTime;
1967 if(FindType(curContext, text))
1970 checkTypeTotalTime += GetTime() - startTime;
1977 checkTypeTotalTime += GetTime() - startTime;
1979 return TYPE_NAME; //CLASS_NAME;
1982 checkTypeTotalTime += GetTime() - startTime;
1989 return CheckType(yytext);
1992 Context PushContext()
1994 Context ctx { parent = curContext };
1999 void PopContext(Context ctx)
2001 curContext = ctx.parent;
2004 Symbol FindType(Context ctx, char * name)
2009 //char output[8192];
2010 type = (Symbol)ctx.types.FindString(name);
2011 /*if(!strcmp(name, "intptr_t") && !type)
2013 ctx.types.Print(output, depthOrder);
2016 if(!type && ctx.parent)
2017 type = FindType(ctx.parent, name);
2022 TemplatedType FindTemplateTypeParameter(Context ctx, char * name)
2024 TemplatedType templatedType = null;
2027 templatedType = (TemplatedType)ctx.templateTypes.FindString(name);
2028 if(!templatedType && ctx.parent)
2029 templatedType = FindTemplateTypeParameter(ctx.parent, name);
2031 return templatedType;
2034 bool ModuleAccess(Module searchIn, Module searchFor)
2036 SubModule subModule;
2038 if(searchFor == searchIn)
2041 for(subModule = searchIn.modules.first; subModule; subModule = subModule.next)
2043 if(subModule.importMode == publicAccess /*|| searchIn == searchIn.application*/)
2045 if(ModuleAccess(subModule.module, searchFor))
2052 ModuleImport FindModule(Module moduleToFind)
2054 ModuleImport module;
2055 if(!moduleToFind.name)
2057 for(module = imports->first; module; module = module.next)
2058 if(module.name && !strcmp(module.name, moduleToFind.name))
2062 module = ModuleImport
2064 name = CopyString(moduleToFind.name), importType = moduleToFind.importType,
2065 importAccess = ModuleAccess(privateModule, moduleToFind) ? publicAccess : privateAccess
2067 imports->Add(module);
2073 // TO REMOVE: OBSOLETE...
2074 static void GetFullClassNameSpace(NameSpace * ns, char * name)
2078 GetFullClassNameSpace(ns->parent, name);
2079 strcat(name, ns->name);
2084 static char * GetFullClassName(Class c, char * name)
2086 NameSpace * nameSpace;
2088 GetFullClassNameSpace(c.nameSpace, name);
2089 strcat(name, c.name);
2094 public Symbol FindClass(char * name)
2097 Time startTime = GetTime();
2101 bool global = false;
2102 char fullName[1024];
2104 if(name[0] == ':' && name[1] == ':')
2110 if(!global && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
2112 int len = 0, stringLen;
2113 if(defaultNameSpace)
2115 memcpy(fullName, defaultNameSpace, defaultNameSpaceLen);
2116 len += defaultNameSpaceLen;
2117 fullName[len++] = ':';
2118 fullName[len++] = ':';
2120 if(currentNameSpace)
2122 memcpy(fullName + len, currentNameSpace, currentNameSpaceLen);
2123 len += currentNameSpaceLen;
2124 fullName[len++] = ':';
2125 fullName[len++] = ':';
2127 stringLen = strlen(name);
2128 memcpy(fullName + len, name, stringLen);
2131 cl = globalContext ? (Symbol)globalContext.classes.FindString(fullName) : null;
2135 cl = globalContext ? (Symbol)globalContext.classes.FindString(name) : null;
2140 Time startTime = GetTime();
2142 // Ignore name space name when searching
2143 for(cl = globalContext ? (Symbol)globalContext.classes.first : null; cl; cl = (Symbol)((BTNode)cl).next)
2147 char * string = cl.string;
2149 for(c = 0; (ch = string[c]); c++)
2151 if(ch == '.' || (ch == ':' && string[c+1] == ':'))
2157 if(start && c - start)
2159 if(!strcmp(string + start, name))
2163 if(cl.shortName && !strcmp(cl.shortName, name))
2167 findClassIgnoreNSTotalTime += GetTime() - startTime;
2173 if(!global && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
2174 _class = eSystem_FindClass(privateModule, fullName);
2176 _class = eSystem_FindClass(privateModule, name);
2180 name = _class.fullName;
2182 cl = (Symbol)globalContext.classes.FindString(name);
2187 string = CopyString(name);
2188 registered = _class;
2195 cl.module = FindModule(_class.module);
2197 cl.module = mainModule;
2198 if(!globalContext.classes.Add((BTNode)cl))
2199 excludedSymbols->Add(cl);
2200 if(strcmp(name, _class.name))
2201 cl.shortName = CopyString(_class.name);
2206 findClassTotalTime += GetTime() - startTime;
2211 void CopyTypeInto(Type type, Type src)
2214 type.name = CopyString(src.name);
2217 if(src.kind == enumType)
2221 type.members.Clear();
2222 // This must have been a mistake: member = **type**.members.first
2223 for(member = src.members.first; member; member = member.next)
2225 type.members.Add(NamedLink { name = CopyString(member.name), data = member.data });
2227 type.enumName = CopyString(src.enumName);
2229 else if(src.kind == structType || src.kind == unionType)
2232 // Tricky stuff... will be removed from list only when ref count reaches 0
2233 for(member = type.members.first; member; member = member.next)
2235 type.enumName = CopyString(src.enumName);
2237 else if(src.kind == functionType)
2240 type.returnType.refCount++;
2241 for(param = type.params.first; param; param = param.next)
2244 else if(src.kind == pointerType || src.kind == arrayType)
2246 type.type.refCount++;
2247 if(src.kind == arrayType)
2249 if(type.arraySizeExp)
2250 type.arraySizeExp = CopyExpression(type.arraySizeExp);
2256 static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeName)
2258 Type specType { refCount = 1, kind = intType, isSigned = true };
2261 bool isTypedef = false;
2263 bool isLong = false;
2264 for(spec = specs.first; spec; spec = spec.next)
2266 if(spec.type == extendedSpecifier)
2268 ExtDecl extDecl = spec.extDecl;
2269 if(extDecl.type == extDeclString)
2271 String s = spec.extDecl.s;
2272 if(!strcmp(spec.extDecl.s, "__declspec(dllexport)") || !strcmp(spec.extDecl.s, "dllexport"))
2273 specType.dllExport = true;
2274 else if(!strcmp(spec.extDecl.s, "__declspec(stdcall)") || !strcmp(spec.extDecl.s, "stdcall"))
2275 specType.attrStdcall = true;
2277 else if(extDecl.type == extDeclAttrib)
2279 OldList * attribs = extDecl.attr.attribs;
2283 for(attr = attribs->first; attr; attr = attr.next)
2285 String s = attr.attr;
2288 if(!strcmp(s, "dllexport"))
2289 specType.dllExport = true;
2290 else if(!strcmp(s, "stdcall"))
2291 specType.attrStdcall = true;
2295 specType.keepCast = true;
2299 if(spec.specifier != CONST && (specType.kind == structType || specType.kind == unionType))
2302 specType = { kind = intType, isSigned = true, refCount = 1 };
2305 if(isTypedef && keepTypeName)
2307 specType.kind = dummyType;
2310 else if(spec.type == baseSpecifier)
2312 if(spec.specifier == TYPEDEF)
2314 else if(spec.specifier == VOID) specType.kind = voidType;
2315 else if(spec.specifier == CHAR) specType.kind = charType;
2316 else if(spec.specifier == INT) { if(specType.kind != shortType && specType.kind != longType && !isLong) specType.kind = intType; }
2317 else if(spec.specifier == _BOOL || spec.specifier == BOOL)
2318 specType.kind = _BoolType;
2319 else if(spec.specifier == UINT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; specType.isSigned = false; }
2320 else if(spec.specifier == INT64) specType.kind = int64Type;
2321 else if(spec.specifier == VALIST)
2322 specType.kind = vaListType;
2323 else if(spec.specifier == SHORT) specType.kind = shortType;
2324 else if(spec.specifier == LONG)
2326 if(isLong || (targetBits == 64 && targetPlatform != win32))
2327 specType.kind = int64Type;
2329 specType.kind = intType;
2332 else if(spec.specifier == FLOAT) specType.kind = floatType;
2333 else if(spec.specifier == DOUBLE) specType.kind = doubleType;
2334 else if(spec.specifier == SIGNED) specType.isSigned = true;
2335 else if(spec.specifier == UNSIGNED) specType.isSigned = false;
2336 else if(spec.specifier == CONST)
2337 specType.constant = true;
2338 else if(spec.specifier == TYPED_OBJECT || spec.specifier == ANY_OBJECT || spec.specifier == CLASS)
2340 switch(spec.specifier)
2342 case TYPED_OBJECT: specType.classObjectType = typedObject; break;
2343 case ANY_OBJECT: specType.classObjectType = anyObject; break;
2344 case CLASS: specType.classObjectType = classPointer; break;
2346 specType.kind = classType;
2347 specType._class = FindClass("class");
2349 else if(spec.specifier == THISCLASS)
2350 specType.kind = thisClassType;
2352 else if(spec.type == nameSpecifier)
2354 if(spec.name && (!strcmp(spec.name, "intptr") || !strcmp(spec.name, "uintptr")))
2356 specType.kind = intPtrType;
2357 if(!strcmp(spec.name, "uintptr"))
2358 specType.isSigned = false;
2360 else if(spec.name && (!strcmp(spec.name, "uintsize") || !strcmp(spec.name, "intsize")))
2362 specType.kind = intSizeType;
2363 if(!strcmp(spec.name, "uintsize"))
2364 specType.isSigned = false;
2368 Symbol symbol = spec.name ? FindType(curContext, spec.name) : null;
2369 if(symbol && symbol.type)
2371 // Free Type Contents:
2376 CopyTypeInto(specType, symbol.type);
2377 specType.typeName = CopyString(symbol.type.name);
2379 else if(!isTypedef) // !specType.kind) // TESTING THIS FOR enum / typedef problem
2381 // key.sym enum values need FindClass:
2382 specType._class = spec.name ? FindClass(spec.name) : null;
2383 specType.kind = classType;
2384 if(!specType._class)
2385 specType.kind = intType;
2389 else if(spec.type == enumSpecifier)
2391 specType.kind = enumType;
2392 specType.enumName = spec.id ? CopyString(spec.id.string) : null;
2398 for(e = spec.list->first; e; e = e.next)
2400 // TOFIX: NamedItem i { } causes cryptic error, bad .c!
2401 NamedLink i { name = CopyString(e.id.string) };
2402 specType.members.Add(i);
2406 else if(spec.type == templateTypeSpecifier)
2408 specType.kind = templateType;
2409 specType.templateParameter = spec.templateParameter;
2411 else if(spec.type == structSpecifier || spec.type == unionSpecifier)
2413 Symbol _class = spec.id ? FindClass(spec.id.string) : null;
2416 specType.declaredWithStruct = true;
2417 if(!_class.registered || _class.registered.type != structClass)
2418 specType.directClassAccess = true; // TODO: Need to clarify what 'directClassAccess' is about
2419 specType._class = _class;
2420 specType.kind = classType;
2423 specType.members.Clear();
2424 if(spec.type == structSpecifier)
2425 specType.kind = structType;
2426 else if(spec.type == unionSpecifier)
2427 specType.kind = unionType;
2430 // TESTING THIS HERE... Had 0 type size
2431 if(!spec.definitions && !isTypedef)
2433 Symbol symbol = spec.id.string ? FindSymbol(spec.id.string, curContext, globalContext, true, false) : null;
2434 if(symbol && symbol.type)
2436 specType = *symbol.type;
2437 specType.name = CopyString(symbol.type.name);
2438 specType.typeName = CopyString(spec.name);
2439 specType.enumName = CopyString(symbol.type.enumName);
2440 specType.refCount = 1;
2442 if(symbol.type.kind == enumType)
2446 specType.members.Clear();
2447 for(member = symbol.type.members.first; member; member = member.next)
2449 NamedLink item { name = CopyString(member.name), data = member.data };
2450 specType.members.Add(item);
2453 else if(symbol.type.kind == structType || symbol.type.kind == unionType)
2456 // Tricky stuff... will be removed from list only when ref count reaches 0
2457 for(member = specType.members.first; member; member = member.next)
2460 else if(symbol.type.kind == functionType)
2463 specType.returnType.refCount++;
2464 for(param = specType.params.first; param; param = param.next)
2467 else if(symbol.type.kind == pointerType || symbol.type.kind == arrayType)
2469 specType.type.refCount++;
2470 if(symbol.type.kind == arrayType)
2472 if(specType.arraySizeExp)
2473 specType.arraySizeExp = CopyExpression(specType.arraySizeExp);
2479 specType.enumName = CopyString(spec.id.string);
2482 specType.enumName = CopyString(spec.id.string);
2485 if(spec.definitions)
2488 for(def = spec.definitions->first; def; def = def.next)
2490 if(def.type == declarationClassDef && def.decl.type == structDeclaration)
2492 Declaration decl = def.decl;
2493 if(decl.declarators)
2496 for(d = decl.declarators->first; d; d = d.next)
2498 Type memberType = ProcessType(decl.specifiers, d);
2499 specType.members.Add(memberType);
2502 else if(decl.specifiers)
2504 Type memberType = ProcessType(decl.specifiers, null);
2505 specType.members.Add(memberType);
2512 else if(spec.type == subClassSpecifier)
2514 specType.kind = specType.kind = subClassType;
2515 specType._class = spec._class.symbol;
2519 else if(assumeEllipsis)
2520 specType.kind = ellipsisType;
2524 static Type ProcessTypeDecls(OldList specs, Declarator decl, Type parentType)
2526 Type type = parentType;
2527 Declarator subDecl = decl ? decl.declarator : null;
2529 type = ProcessTypeSpecs(specs, decl == null, (decl && decl.type == extendedDeclaratorEnd) ? true : false);
2534 case bracketsDeclarator: break;
2535 case extendedDeclarator:
2536 case extendedDeclaratorEnd:
2538 ExtDecl extDecl = decl.extended.extended;
2541 switch(extDecl.type)
2545 String s = extDecl.s;
2548 if(!strcmp(s, "__declspec(dllexport)") || !strcmp(s, "dllexport"))
2549 type.dllExport = true;
2550 else if(!strcmp(s, "__declspec(stdcall)") || !strcmp(s, "stdcall"))
2551 type.attrStdcall = true;
2557 OldList * attribs = extDecl.attr.attribs;
2561 for(attr = attribs->first; attr; attr = attr.next)
2563 String s = attr.attr;
2566 if(!strcmp(s, "dllexport"))
2567 type.dllExport = true;
2568 else if(!strcmp(s, "stdcall"))
2569 type.attrStdcall = true;
2573 type.keepCast = true;
2580 case structDeclarator:
2582 Expression exp = decl.structDecl.exp;
2585 ProcessExpressionType(exp);
2586 ComputeExpression(exp);
2587 if(exp.type == constantExp)
2588 type.bitFieldCount = (uint)strtoul(exp.constant, null, 0);
2592 case functionDeclarator:
2594 type = { refCount = 1, kind = functionType, returnType = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
2595 if(decl.function.parameters)
2598 for(param = decl.function.parameters->first; param; param = param.next)
2599 type.params.Add(ProcessType(param.qualifiers, param.declarator));
2603 case arrayDeclarator:
2605 type = { refCount = 1, kind = arrayType, arraySizeExp = CopyExpression(decl.array.exp), freeExp = true, type = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
2606 if(decl.array.enumClass)
2607 type.enumClass = decl.array.enumClass.symbol;
2610 case pointerDeclarator:
2612 Pointer pointer = decl.pointer.pointer;
2615 OldList * qualifiers = pointer.qualifiers;
2616 if(type.classObjectType)
2617 type.byReference = true;
2619 type = { refCount = 1, kind = pointerType, type = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
2623 for(spec = qualifiers->first; spec; spec = spec.next)
2625 if(spec.type == baseSpecifier && spec.specifier == CONST)
2626 type.constant = true;
2629 pointer = pointer.pointer;
2633 case identifierDeclarator:
2635 Identifier id = decl.identifier;
2636 Specifier _class = id._class;
2638 type.name = CopyString(id.string);
2641 if(_class.type == templateTypeSpecifier)
2643 type.thisClassTemplate = _class.templateParameter;
2644 type.extraParam = true;
2648 String name = _class.name;
2650 type.staticMethod = true;
2654 id.classSym = _class.symbol; // FindClass(_class.name);
2655 /* TODO: Name Space Fix ups
2656 id.nameSpace = eSystem_FindNameSpace(privateModule, _class.name);
2659 if(name[strlen(name)-1] == '&')
2661 type.thisClass = FindClass("class");
2662 type.byReference = true;
2665 type.thisClass = _class.symbol;
2667 if(type.thisClass && strcmp(type.thisClass.string, "class"))
2668 type.extraParam = true;
2669 else if(!strcmp(name, "any_object"))
2671 type.extraParam = true;
2672 type.thisClass = FindClass("class");
2674 else if(!strcmp(name, "class"))
2676 type.thisClass = FindClass("class");
2677 type.classObjectType = classPointer; // This is used for class properties
2679 else if(!strcmp(name, "typed_object") || !strcmp(name, "typed_object&"))
2681 type.thisClass = FindClass("class");
2682 type.classObjectType = typedObject;
2690 PrintLn("Unhandled Declarator Type: ", decl.type);
2695 Type curType = type;
2696 type = ProcessTypeDecls(null, subDecl, type);
2697 if(curType && type.kind != functionType)
2699 curType.thisClassTemplate = type.thisClassTemplate;
2700 curType.extraParam = type.extraParam;
2701 curType.staticMethod = type.staticMethod;
2702 curType.thisClass = type.thisClass;
2703 curType.byReference = type.byReference;
2704 curType.classObjectType = type.classObjectType;
2710 public Type ProcessType(OldList specs, Declarator decl)
2712 return ProcessTypeDecls(specs, decl, null);
2715 public Type ProcessTypeString(char * string, bool staticMethod)
2717 OldList * specs = MkList();
2718 Declarator decl = SpecDeclFromString(string, specs, null);
2719 Type type = ProcessType(specs, decl);
2720 if(type && !type.thisClass && staticMethod) type.staticMethod = true;
2721 FreeList(specs, FreeSpecifier);
2722 if(decl) FreeDeclarator(decl);
2726 Type MkClassTypeSymbol(Symbol symbol)
2730 Type type { kind = classType, _class = symbol };
2733 // Defaults to an int instead...
2734 type.kind = intType;
2742 public Type MkClassType(char * name)
2746 Type type { kind = classType, _class = FindClass(name) };
2749 // Defaults to an int instead...
2750 type.kind = intType;
2758 AsmField MkAsmField(char * command, Expression expression, Identifier symbolic)
2760 return { command = command, expression = expression, symbolic = symbolic };
2763 Statement MkAsmStmt(Specifier spec, char * statements, OldList inputFields, OldList outputFields, OldList clobberedFields)
2765 return { type = asmStmt, asmStmt.spec = spec, asmStmt.statements = statements,
2766 asmStmt.inputFields = inputFields, asmStmt.outputFields = outputFields,
2767 asmStmt.clobberedFields = clobberedFields };
2770 ClassDef MkClassDefPropertyWatch(PropertyWatch watcher)
2772 return { type = propertyWatchClassDef, propertyWatch = watcher };
2775 Statement MkFireWatchersStmt(Expression object, OldList watches)
2777 return { type = fireWatchersStmt, _watch.object = object, _watch.watches = watches };
2780 Statement MkStopWatchingStmt(Expression watcher, Expression object, OldList watches)
2782 return { type = stopWatchingStmt, _watch.watcher = watcher, _watch.object = object, _watch.watches = watches };
2785 Statement MkWatchStmt(Expression watcher, Expression object, OldList watches)
2787 return { type = watchStmt, _watch.watcher = watcher, _watch.object = object, _watch.watches = watches };
2790 PropertyWatch MkDeleteWatch(Statement compound)
2792 return { compound = compound, deleteWatch = true };
2795 PropertyWatch MkPropertyWatch(OldList properties, Statement compound)
2797 return { compound = compound, properties = properties };
2800 Expression MkExpClass(OldList * specifiers, Declarator decl)
2802 return { type = classExp, _classExp.specifiers = specifiers, _classExp.decl = decl };
2805 Expression MkExpClassData(Identifier id)
2807 return { type = classDataExp, classData.id = id };
2811 External MkExternalDBTable(DBTableDef table)
2813 return { type = dbtableExternal, table = table };
2816 DBTableDef MkDBTableDef(char * name, Symbol symbol, OldList * definitions)
2818 return { name = name, symbol = symbol, definitions = definitions };
2821 DBTableEntry MkDBFieldEntry(TypeName type, Identifier id, char * name)
2823 return { type = fieldEntry, dataType = type, id = id, name = name };
2826 DBIndexItem MkDBIndexItem(Identifier id, Order order)
2828 return { id = id, order = order };
2831 DBTableEntry MkDBIndexEntry(OldList * items, Identifier id)
2833 return { type = indexEntry, items = items, id = id };
2836 Expression MkExpDBOpen(Expression ds, Expression dbName)
2838 return { type = dbopenExp, dbopen.ds = ds, dbopen.name = dbName };
2841 Expression MkExpDBField(char * table, Identifier id)
2843 return { type = dbfieldExp, db.table = table, db.id = id };
2846 Expression MkExpDBIndex(char * table, Identifier id)
2848 return { type = dbindexExp, db.table = table, db.id = id };
2851 Expression MkExpDBTable(char * table)
2853 return { type = dbtableExp, db.table = table };
2856 Expression MkExpArray(OldList * expressions)
2858 return { type = arrayExp, list = expressions };
2861 Expression GetTemplateArgExpByName(char * paramName, Class curClass, TemplateParameterType tplType)
2863 Expression argExp = null;
2864 Class _class = curClass ? curClass : ((curExternal && curExternal.type == functionExternal && curExternal.function) ? curExternal.function._class : null);
2868 ClassTemplateParameter curParam;
2870 for(sClass = _class; sClass; sClass = sClass.base)
2873 for(curParam = sClass.templateParams.first; curParam; curParam = curParam.next)
2875 if(!strcmp(curParam.name, paramName))
2877 for(sClass = sClass.base; sClass; sClass = sClass.base)
2878 id += sClass.templateParams.count;
2886 if(curParam && curParam.type != tplType)
2892 char className[1024];
2893 Expression classExp;
2895 sprintf(idString, "%d", id);
2896 strcpy(className, "__ecereClass_");
2897 FullClassNameCat(className, _class.fullName, true);
2898 MangleClassName(className);
2899 DeclareClass(FindClass(_class.fullName), className);
2901 argExp = MkExpIndex((/*pointer ? MkExpPointer : */MkExpMember)
2902 (MkExpMember(MkExpIdentifier(MkIdentifier("this")), MkIdentifier("_class")) /*MkExpIdentifier(MkIdentifier(className))*/,
2903 MkIdentifier("templateArgs")), MkListOne(MkExpConstant(idString)));
2909 Expression GetTemplateArgExp(TemplateParameter param, Class curClass, bool pointer)
2911 return param.identifier ? GetTemplateArgExpByName(param.identifier.string, curClass, type) : null;
2914 /*char * CreateMsgID(char * string, char * context)
2916 int lenString = strlen(string), lenContext = strlen(context);
2917 char * msgid = new char[lenString + lenContext + 20];
2918 memcpy(msgid, string, lenString);
2919 memcpy(msgid+lenString, " [msgctxt: ", 11);
2920 memcpy(msgid+lenString+11, context, lenContext);
2921 memcpy(msgid+lenString+11+lenContext, "]", 2);
2925 public void OutputIntlStrings()
2927 if(intlStrings.count)
2929 char * srcFile = GetSourceFile();
2930 char * objFile = GetOutputFile();
2931 char srcFileFixed[MAX_LOCATION];
2932 char potFile[MAX_LOCATION];
2934 ChangeExtension(objFile, "bowl", potFile);
2935 f = FileOpen(potFile, write);
2938 char * filePrefix = "";
2939 if(!(srcFile[0] && (srcFile[1] == ':' || srcFile[0] == '/')))
2940 filePrefix = "./"; //(GetRuntimePlatform() == win32) ? ".\\" : "./";
2941 // GetSystemPathBuffer(srcFileFixed, srcFile);
2942 GetSlashPathBuffer(srcFileFixed, srcFile);
2943 for(s : intlStrings)
2945 // TOFIX: (#654) ContextStringPair * pair = &s;
2946 ContextStringPair pair = &s;
2948 f.Printf("#: %s%s:%d\n", filePrefix, srcFileFixed, l.start.line);
2949 // PoEdit now preserves and distinguish msgctxt
2951 f.Printf("msgctxt \"%s\"\n", pair.context);
2952 f.Printf("msgid \"%s\"\n", pair.string);
2953 f.Printf("msgstr \"%s\"\n\n", pair.string);
2961 default extern OldList * ast;
2962 default extern int yyparse ();
2963 default extern int yylex ();
2965 public void SetAST(OldList * list) { ast = list; }
2966 public OldList * GetAST() { return ast; }
2967 public void ParseEc()
2977 public const char * GetYYText()