From: Gaius Mulley Date: Mon, 16 Sep 2024 12:57:34 +0000 (+0100) Subject: PR modula2/116181 Use GCC tree location_t and separate pointer types X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=f6e629a7134c6b83be4542b8cd26b7c4483d17f4;p=gcc.git PR modula2/116181 Use GCC tree location_t and separate pointer types This patch fixes all remaining -Wodr warnings in the modula-2 front end. It removes the m2 Tree and m2 Location definitions and uses tree and location_t throughout. This allows the bootstrap tool mc to pick up the GCC definitions for these data types (for the C translation of m2 sources). The patch introduces a new module CDataTypes which contain two pointer types: CharStar and ConstCharStar. These map onto their C counterparts when processed by mc however currently gm2 treats them as ADDRESS. It might be sensible to have the gm2 versions of these data types implemented though a builtin module in the future. gcc/m2/ChangeLog: PR modula2/116181 * Make-lang.in (GM2-GCC-DEFS): Add gcctypes.def and CDataTypes.def. (MC-LIB-DEFS): Add CDataTypes.def. * Make-maintainer.in (m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o): Change include path to pge-boot. (m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)Output.o): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o): Ditto. (m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Ditto. (GM2PATH): Add -I$(srcdir)/m2/gm2-gcc. (m2/mc-boot-gen/$(SRC_PREFIX)%.h): Add -I$(srcdir)/m2/gm2-gcc. (m2/mc-boot-gen/$(SRC_PREFIX)%.cc): Ditto. * gm2-compiler/M2ALU.def (PushIntegerTree): Replace Tree with tree. (PopIntegerTree): Ditto. (PushRealTree): Ditto. (PopRealTree): Ditto. (PushComplexTree): Ditto. (PopComplexTree): Ditto. (PushSetTree): Ditto. (PopSetTree): Ditto. (PopConstructorTree): Ditto. (ConstructSetConstant): Ditto. (BuildRange): Ditto. (CheckOrResetOverflow): Ditto. (PushTypeOfTree): Ditto. * gm2-compiler/M2ALU.mod (Tree): Replace with ... (tree): ... this. (gcctypes): Import location_t and tree. (m2linemap): Remove import of location_t. * gm2-compiler/M2Base.def (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/M2Base.mod (gcctypes): Import of location_t. (m2linemap): Remove import of location_t. * gm2-compiler/M2Bitset.mod (m2tree): Remove import of Tree. * gm2-compiler/M2CaseList.mod (gcctypes): Import tree. (m2tree): Remove import of Tree. (Tree): Replace with ... (tree): ... this. * gm2-compiler/M2Emit.def (gcctypes): Import location_t. * gm2-compiler/M2GCCDeclare.def (gcctypes): Import tree. (PromoteToString): Replace Tree with tree. (PromoteToCString): Ditto. (ConstantKnownAndUsed): Ditto. * gm2-compiler/M2GCCDeclare.mod (gcctypes): Import tree. (m2tree): Remove import of Tree. (Tree): Replace with ... (tree): ... this. * gm2-compiler/M2GenGCC.def (gcctypes): Import tree. (m2tree): Remove import of Tree. (Tree): Replace with ... (tree): ... this. (GetHighFromUnbounded): Replace Tree with tree. (StringToChar): Ditto. (LValueToGenericPtr): Ditto. (ZConstToTypedConst): Ditto. (PrepareCopyString): Ditto. * gm2-compiler/M2GenGCC.mod (gcctypes): Import tree. (m2tree): Remove import of Tree. (Tree): Replace with ... (tree): ... this. * gm2-compiler/M2LangDump.def (gcctypes): Import tree. (m2tree): Remove import of Tree. (Tree): Replace with ... (tree): ... this. * gm2-compiler/M2LangDump.mod (Tree): Replace with ... (tree): ... this. * gm2-compiler/M2LexBuf.def (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/M2LexBuf.mod (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/M2Options.def (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/M2Options.mod (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/M2Range.def (m2linemap): Replace with ... (gcctypes): ... this. (CDataTypes): Import ConstCharStar. (CodeErrorCheck): Replace Tree with tree. (OverlapsRange): Ditto. (IsEqual): Ditto. (IsGreaterOrEqual): Ditto. (IsGreater): Ditto. (BuildIfCallWholeHandlerLoc): Replace Tree with tree. Replace ADDRESS with ConstCharStar. (BuildIfCallRealHandlerLoc): Ditto. (GetMinMax): Ditto. * gm2-compiler/M2Range.mod (m2tree): Remove Tree. (CodeErrorCheck): Replace Tree with tree. (OverlapsRange): Ditto. (IsEqual): Ditto. (IsGreaterOrEqual): Ditto. (IsGreater): Ditto. (GetMinMax): Ditto. (BuildIfCallWholeHandlerLoc): Replace Tree with tree. Replace ADDRESS with ConstCharStar. (BuildIfCallRealHandlerLoc): Ditto. * gm2-compiler/M2System.def (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/M2System.mod (m2linemap): Replace with ... (gcctypes): ... this. (CreateMinMaxFor): Replace Tree with tree. (CreateType): Ditto. (AttemptToCreateType): Ditto. (CreateSetType): Ditto. (AttemptToCreateSetType): Ditto. * gm2-compiler/P2SymBuild.mod (m2linemap): Replace with ... (gcctypes): ... this. * gm2-compiler/SymbolConversion.def (m2tree): Replace with ... (gcctypes): ... this. (Mod2Gcc): Replace Tree with tree. (Gcc2Mod): Ditto. (AddModGcc): Ditto. * gm2-compiler/SymbolConversion.mod (m2tree): Replace with ... (gcctypes): ... this. (Mod2Gcc): Replace Tree with tree. (Gcc2Mod): Ditto. (AddModGcc): Ditto. (Mod2GccWithoutGCCPoison): Ditto. * gm2-compiler/SymbolTable.def (m2tree): Replace with ... (gcctypes): ... this. (PutModuleFinallyFunction): Replace Tree with tree. (GetModuleFinallyFunction): Ditto. * gm2-compiler/SymbolTable.mod (m2tree): Replace with ... (gcctypes): ... this. (PutModuleFinallyFunction): Replace Tree with tree. (GetModuleFinallyFunction): Ditto. * gm2-compiler/m2flex.def (m2linemap): Replace with ... (gcctypes): ... this. * gm2-gcc/init.def (PerCompilationInit): Replace ADDRESS with ConstCharStar. (CDataTypes): Import ConstCharStar. * gm2-gcc/m2block.def (SYSTEM): Remove import. (CDataTypes): Import ConstCharStar. (m2linemap): Remove import. (m2tree): Remove import. (gcctypes): Import tree. (global_constant): Replace Tree with tree. (RememberInitModuleFunction): Ditto. (DumpGlobalConstants): Ditto. (RememberConstant): Ditto. (RememberType): Ditto. (pushDecl): Ditto. (popFunctionScope): Ditto. (pushFunctionScope): Ditto. (finishFunctionCode): Ditto. (finishFunctionDecl): Ditto. (GetErrorNode): Ditto. (includeDecl): Ditto. (GetGlobals): Ditto. (GetGlobalContext): Ditto. (begin_statement_list): Ditto. (push_statement_list): Ditto. (pop_statement_list): Ditto. (getLabel): Replace Tree with tree. Replace ADDRESS with ConstCharStar. * gm2-gcc/m2builtins.def (CDataTypes): Import ConstCharStar. (GetBuiltinConst): Replace Tree with tree. (GetBuiltinConstType): Ditto. (GetBuiltinTypeInfoType): Ditto. (GetBuiltinTypeInfo): Ditto. (BuiltinExists): Ditto. (BuildBuiltinTree): Ditto. (BuiltinMemCopy): Ditto. (BuiltinMemSet): Ditto. (BuiltInAlloca): Ditto. (BuiltInIsfinite): Ditto. * gm2-gcc/m2convert.def (CDataTypes): Import ConstCharStar. (ToWord): Ditto. (ToCardinal): Ditto. (ToInteger): Ditto. (ToBitset): Ditto. (ConvertToPtr): Ditto. (BuildConvert): Ditto. (ConvertConstantAndCheck): Ditto. (ConvertString): Ditto. (GenericToType): Ditto. * gm2-gcc/m2decl.cc (m2decl_BuildParameterDeclaration): Add const attribute. * gm2-gcc/m2decl.def (CDataTypes): Import ConstCharStar. (BuildModuleCtor): Ditto. (DeclareModuleCtor): Ditto. (DeclareM2linkForcedModuleInitOrder): Ditto. (DeclareM2linkStaticInitialization): Ditto. (BuildPtrToTypeString): Ditto. (BuildIntegerConstant): Ditto. (BuildStringConstantType): Ditto. (DeclareKnownVariable): Ditto. (DeclareKnownConstant): Ditto. (BuildParameterDeclaration): Ditto. (BuildEndFunctionDeclaration): Ditto. (RememberVariables): Ditto. (BuildConstLiteralNumber): Ditto. (BuildStringConstant): Ditto. (BuildCStringConstant): Ditto. (GetDeclContext): Ditto. * gm2-gcc/m2decl.h (m2decl_BuildParameterDeclaration): Add const attribute. * gm2-gcc/m2except.def (CDataTypes): Import ConstCharStar. (BuildThrow): Ditto. (BuildTryBegin): Ditto. (BuildTryEnd): Ditto. (BuildCatchBegin): Ditto. (BuildCatchEnd): Ditto. * gm2-gcc/m2expr.def (CDataTypes): Import ConstCharStar. (CSTIntToString): Ditto. (CSTIntToChar): Ditto. (CheckConstStrZtypeRange): Ditto. (CompareTrees): Ditto. (GetPointerOne): Ditto. (GetPointerZero): Ditto. (GetWordOne): Ditto. (GetWordZero): Ditto. (GetIntegerOne): Ditto. (GetIntegerZero): Ditto. (GetCardinalOne): Ditto. (GetCardinalZero): Ditto. (GetSizeOfInBits): Ditto. (GetSizeOf): Ditto. (BuildLogicalRotate): Ditto. (BuildLRRn): Ditto. (BuildLRLn): Ditto. (BuildMask): Ditto. (BuildMult): Ditto. (BuildMultCheck): Ditto. (BuildLRR): Ditto. (BuildLRL): Ditto. (BuildLogicalShift): Ditto. (BuildLSR): Ditto. (BuildLSL): Ditto. (BuildDivM2): Ditto. (BuildDivM2Check): Ditto. (BuildModM2): Ditto. (BuildModM2Check): Ditto. (BuildModFloor): Ditto. (BuildDivCeil): Ditto. (BuildModCeil): Ditto. (BuildDivFloor): Ditto. (BuildModTrunc): Ditto. (BuildDivTrunc): Ditto. (BuildDivTruncCheck): Ditto. (BuildRDiv): Ditto. (BuildSubCheck): Ditto. (BuildAddCheck): Ditto. (BuildSub): Ditto. (BuildAdd): Ditto. (FoldAndStrip): Ditto. (StringLength): Ditto. (TreeOverflow): Ditto. (RemoveOverflow): Ditto. (BuildCoerce): Ditto. (BuildTrunc): Ditto. (BuildNegate): Ditto. (BuildNegateCheck): Ditto. (BuildSetNegate): Ditto. (BuildTBitSize): Ditto. (BuildSize): Ditto. (BuildAddr): Ditto. (BuildOffset1): Ditto. (BuildOffset): Ditto. (BuildLogicalOrAddress): Ditto. (BuildLogicalOr): Ditto. (BuildLogicalAnd): Ditto. (BuildSymmetricDifference): Ditto. (BuildLogicalDifference): Ditto. (BuildLessThan): Ditto. (BuildGreaterThan): Ditto. (BuildLessThanOrEqual): Ditto. (BuildGreaterThanOrEqual): Ditto. (BuildEqualTo): Ditto. (BuildNotEqualTo): Ditto. (BuildIsSuperset): Ditto. (BuildIsNotSuperset): Ditto. (BuildIsSubset): Ditto. (BuildIsNotSubset): Ditto. (BuildIfConstInVar): Ditto. (BuildIfNotConstInVar): Ditto. (BuildIfVarInVar): Ditto. (BuildIfNotVarInVar): Ditto. (BuildForeachWordInSetDoIfExpr): Ditto. (BuildIfInRangeGoto): Ditto. (BuildIfNotInRangeGoto): Ditto. (BuildArray): Ditto. (BuildComponentRef): Ditto. (BuildIndirect): Ditto. (IsTrue): Ditto. (IsFalse): Ditto. (GetCstInteger): Ditto. (AreConstantsEqual): Ditto. (AreRealOrComplexConstantsEqual): Ditto. (DetermineSign): Ditto. (BuildCap): Ditto. (BuildAbs): Ditto. (BuildRe): Ditto. (BuildIm): Ditto. (BuildCmplx): Ditto. (BuildBinaryForeachWordDo): Ditto. (BuildBinarySetDo): Ditto. (ConstantExpressionWarning): Ditto. (BuildAddAddress): Ditto. (calcNbits): Ditto. (OverflowZType): Ditto. (BuildCondIfExpression): Ditto. * gm2-gcc/m2linemap.def (CDataTypes): Import ConstCharStar. * gm2-gcc/m2misc.def (m2tree): Replace with ... (gcctypes): ... this. (DebugTree): Replace Tree with tree. * gm2-gcc/m2pp.def (m2tree): Replace with ... (gcctypes): ... this. (DumpGimpleFd): Replace Tree with tree. * gm2-gcc/m2statement.cc (m2statement_BuildBuiltinCallTree): Remove unused location parameter. * gm2-gcc/m2statement.def (m2linemap): Replace with ... (gcctypes): ... this. (CDataTypes): Import CharStar. (DoJump): Replace Tree with tree. Replace ADDRESS with CharStar. (BuildStartFunctionCode): Replace Tree with tree. (BuildEndFunctionCode): Ditto. (BuildReturnValueCode): Ditto. (BuildAssignmentTree): Ditto. (BuildAssignmentStatement): Ditto. (BuildGoto): Ditto. (DeclareLabel): Ditto. (BuildIfThenDoEnd): Ditto. (BuildIfThenElseEnd): Ditto. (BuildParam): Ditto. (BuildFunctionCallTree): Ditto. (BuildProcedureCallTree): Ditto. (BuildIndirectProcedureCallTree): Ditto. (BuildFunctValue): Ditto. (BuildCall2): Ditto. (BuildCall3): Ditto. (SetLastFunction): Ditto. (GetLastFunction): Ditto. (GetParamTree): Ditto. (BuildTryFinally): Ditto. (BuildCleanUp): Ditto. (BuildAsm): Ditto. (BuildUnaryForeachWordDo): Ditto. (BuildExcludeVarConst): Ditto. (BuildExcludeVarVar): Ditto. (BuildIncludeVarConst): Ditto. (BuildIncludeVarVar): Ditto. (BuildStart): Ditto. (BuildEnd): Ditto. (BuildCallInner): Ditto. (BuildBuiltinCallTree): Remove unused location parameter. * gm2-gcc/m2statement.h (m2statement_BuildBuiltinCallTree): Remove unused location parameter. * gm2-gcc/m2tree.def (gcctypes): Import tree. (IsAConstant): Replace Tree with tree. (IsOrdinal): Ditto. (IsTreeOverflow): Ditto. (skip_const_decl): Ditto. (skip_type_decl): Ditto. (is_type): Ditto. (is_array): Ditto. (is_var): Ditto. (debug_tree): Ditto. (IstreeOverflow): Ditto. * gm2-gcc/m2treelib.def (m2linemap): Replace with ... (gcctypes): ... this. (get_set_address_if_var): Ditto. (get_set_field_rhs): Ditto. (get_set_field_lhs): Ditto. (get_set_address): Ditto. (get_set_value): Ditto. (get_field_no): Ditto. (get_rvalue): Ditto. (DoCall): Ditto. (build_modify_expr): Ditto. (do_jump_if_bit): Ditto. * gm2-gcc/m2type.def (m2linemap): Replace with ... (gcctypes): ... this. (m2tree): Remove. (CDataTypes): Import ConstCharStar and charStar. (ValueInTypeRange): Replace Tree with tree. (ValueOutOfTypeRange): Ditto. (ExceedsTypeRange): Ditto. (WithinTypeRange): Ditto. (BuildSubrangeType): Ditto. (BuildCharConstant): Ditto. (BuildCharConstantChar): Ditto. (BuildArrayConstructorElement): Ditto. (BuildEndArrayConstructor): Ditto. (BuildStartArrayConstructor): Ditto. (BuildRecordConstructorElement): Ditto. (BuildEndRecordConstructor): Ditto. (BuildStartRecordConstructor): Ditto. (BuildEndSetConstructor): Ditto. (BuildSetConstructorElement): Ditto. (BuildStartSetConstructor): Ditto. (BuildSetType): Ditto. (BuildConstPointerType): Ditto. (BuildPointerType): Ditto. (BuildEnumerator): Ditto. (BuildEndEnumeration): Ditto. (BuildStartEnumeration): Ditto. (BuildTypeDeclaration): Ditto. (GetMaxFrom): Ditto. (GetMinFrom): Ditto. (GetDefaultType): Ditto. (BuildEndType): Ditto. (BuildStartType): Ditto. (BuildVariableArrayAndDeclare): Ditto. (BuildProcTypeParameterDeclaration): Ditto. (BuildStartFunctionType): Ditto. (BuildEndFunctionType): Ditto. (GetTreeType): Ditto. (DeclareKnownType): Ditto. (GetM2ZType): Ditto. (GetM2RType): Ditto. (BuildSetTypeFromSubrange): Ditto. (BuildSmallestTypeRange): Ditto. (GetBooleanType): Ditto. (GetBooleanFalse): Ditto. (GetBooleanTrue): Ditto. (GetPackedBooleanType): Ditto. (GetCharType): Ditto. (GetByteType): Ditto. (GetVoidType): Ditto. (GetBitnumType): Ditto. (GetRealType): Ditto. (GetLongRealType): Ditto. (GetShortRealType): Ditto. (GetLongIntType): Ditto. (GetPointerType): Ditto. (GetCardinalType): Ditto. (GetIntegerType): Ditto. (GetWordType): Ditto. (GetM2CardinalType): Ditto. (GetBitsetType): Ditto. (GetM2CType): Ditto. (GetProcType): Ditto. (GetM2ComplexType): Ditto. (GetM2LongComplexType): Ditto. (GetM2ShortComplexType): Ditto. (GetM2Complex128): Ditto. (GetM2Complex96): Ditto. (GetM2Complex64): Ditto. (GetM2Complex32): Ditto. (GetM2Real128): Ditto. (GetM2Real96): Ditto. (GetM2Real64): Ditto. (GetM2Real32): Ditto. (GetM2Bitset32): Ditto. (GetM2Bitset16): Ditto. (GetM2Bitset8): Ditto. (GetM2Word64): Ditto. (GetM2Word32): Ditto. (GetM2Word16): Ditto. (GetM2Cardinal64): Ditto. (GetM2Cardinal32): Ditto. (GetM2Cardinal16): Ditto. (GetM2Cardinal8): Ditto. (GetM2Integer64): Ditto. (GetM2Integer32): Ditto. (GetM2Integer16): Ditto. (GetM2Integer8): Ditto. (GetISOLocType): Ditto. (GetISOByteType): Ditto. (GetISOWordType): Ditto. (GetShortCardType): Ditto. (GetM2ShortCardType): Ditto. (GetShortIntType): Ditto. (GetM2ShortIntType): Ditto. (GetM2LongCardType): Ditto. (GetM2LongIntType): Ditto. (GetM2LongRealType): Ditto. (GetM2RealType): Ditto. (GetM2ShortRealType): Ditto. (GetM2IntegerType): Ditto. (GetM2CharType): Ditto. (GetCSizeTType): Ditto. (GetCSSizeTType): Ditto. (BuildArrayStringConstructor): Ditto. (RealToTree): Ditto. (BuildStartRecord): Ditto. (BuildStartUnion): Ditto. (BuildStartVarient): Ditto. (BuildEndVarient): Ditto. (BuildStartFieldVarient): Ditto. (BuildEndFieldVarient): Ditto. (BuildStartFieldRecord): Ditto. (BuildFieldRecord): Ditto. (ChainOn): Ditto. (ChainOnParamValue): Ditto. (AddStringToTreeList): Ditto. (BuildEndRecord): Ditto. (SetAlignment): Ditto. (SetDeclPacked): Ditto. (SetTypePacked): Ditto. (SetRecordFieldOffset): Ditto. (BuildPackedFieldRecord): Ditto. (BuildNumberOfArrayElements): Ditto. (AddStatement): Ditto. (MarkFunctionReferenced): Ditto. (BuildArrayIndexType): Ditto. (GetArrayNoOfElements): Ditto. (BuildEndArrayType): Ditto. (PutArrayType): Ditto. (BuildStartArrayType): Ditto. (IsAddress): Ditto. (SameRealType): Ditto. * m2.flex (Gm2linemap.h): Include. * mc-boot/GDynamicStrings.cc: Rebuild. * mc-boot/GFIO.cc: Ditto. * mc-boot/GIndexing.cc: Ditto. * mc-boot/GM2Dependent.cc: Ditto. * mc-boot/GSArgs.cc: Ditto. * mc-boot/GStringConvert.cc: Ditto. * mc-boot/Gdecl.cc: Ditto. * mc-boot/Gdecl.h: Ditto. * mc-boot/Gdtoa.h: Ditto. * mc-boot/Gkeyc.cc: Ditto. * mc-boot/Gkeyc.h: Ditto. * mc-boot/Glibc.h: Ditto. * mc-boot/GmcComp.cc: Ditto. * mc-boot/GmcLexBuf.cc: Ditto. * mc-boot/GmcPreprocess.cc: Ditto. * mc-boot/GmcStream.cc: Ditto. * mc-boot/Gmcp1.cc: Ditto. * mc-boot/Gmcp3.cc: Ditto. * mc-boot/Gmcp4.cc: Ditto. * mc-boot/Gmcp5.cc: Ditto. * mc-boot/GnameKey.cc: Ditto. * mc-boot/Gvarargs.cc: Ditto. * mc/decl.def (putDefUnqualified): New procedure function. (isDefUnqualified): Ditto. * mc/decl.mod (defT): Add unqualified field. (charStarN): New variable. (constCharStarN): Ditto. (checkGccType): New procedure. (checkCDataTypes): Ditto. (import): Call checkGccType and checkCDataTypes. (putDefUnqualified): New procedure function. (isDefUnqualified): Ditto. * mc/keyc.def (useGccTree): New procedure. (useGccLocation): Ditto. * mc/keyc.mod (checkGccConfigSystem): Call checkGccConfigSystem. (useGccTree): New procedure. (useGccLocation): Ditto. * mc/mcp1.bnf (decl): Import putDefUnqualified. (Export): Call putDefUnqualified. * gm2-gcc/CDataTypes.def: New file. * gm2-gcc/gcctypes.def: New file. Signed-off-by: Gaius Mulley --- diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index ed677a42974a..b1e946f8ed9d 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -909,6 +909,7 @@ GM2-COMP-BOOT-MODS = \ # The interface between the modula-2 front end and gimple/trees found in directory gm2-gcc. GM2-GCC-DEFS = \ + gcctypes.def \ m2block.def \ m2builtins.def \ m2color.def \ @@ -926,6 +927,7 @@ GM2-GCC-DEFS = \ m2tree.def \ m2treelib.def \ m2type.def \ + CDataTypes.def \ # The following lists define the source files used to build gm2 using Modula-2 # sources directly. @@ -1235,6 +1237,7 @@ MC-LIB-DEFS = \ Break.def \ COROUTINES.def \ CmdArgs.def \ + CDataTypes.def \ Debug.def \ DynamicStrings.def \ Environment.def \ @@ -1588,7 +1591,7 @@ m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler/%.def $(MCDEPS) $(MC) -o=$@ $(srcdir)/m2/gm2-compiler/$*.def m2/gm2-compiler-boot/m2flex.o: m2/gm2-compiler/m2flex.c $(BUILD-BOOT-H) $(TIMEVAR_H) \ - $(BUILD-LIBS-BOOT-H) m2/gm2-compiler-boot/$(SRC_PREFIX)NameKey.h \ + $(BUILD-LIBS-BOOT-H) m2/gm2-compiler-boot/$(SRC_PREFIX)NameKey.h \ $(CONFIG_H) m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(COMPILER) $(CM2DEP) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ diff --git a/gcc/m2/Make-maintainer.in b/gcc/m2/Make-maintainer.in index 6fa58975c58d..630d4a97b035 100644 --- a/gcc/m2/Make-maintainer.in +++ b/gcc/m2/Make-maintainer.in @@ -677,7 +677,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)errno.o: $(srcdir)/m2/mc-boot-ch/Gerrno.cc m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-PGE-H) -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.cc $(srcdir)/m2/gm2-libs/M2RTS.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.cc -o $@ @@ -690,7 +690,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o: $(srcdir)/m2/gm2-compiler/SymbolKey.mo m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.h -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc $(srcdir)/m2/gm2-compiler/SymbolKey.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc -o $@ @@ -703,7 +703,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o: $(srcdir)/m2/gm2-compiler/NameKey.mod \ m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.h -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc $(srcdir)/m2/gm2-compiler/NameKey.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc -o $@ @@ -716,7 +716,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o: $(srcdir)/m2/gm2-compiler/Lists.mod \ m2/gm2-pge-boot/$(SRC_PREFIX)Lists.h -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc $(srcdir)/m2/gm2-compiler/Lists.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc -o $@ @@ -729,7 +729,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)Output.o: $(srcdir)/m2/gm2-compiler/Output.mod \ m2/gm2-pge-boot/$(SRC_PREFIX)Output.h -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc $(srcdir)/m2/gm2-compiler/Output.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc -o $@ @@ -742,7 +742,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o: $(srcdir)/m2/gm2-compiler/bnflex.mod \ m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.h -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc $(srcdir)/m2/gm2-compiler/bnflex.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc -o $@ @@ -756,7 +756,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h: $(srcdir)/m2/gm2-libs-iso/RTentity.def m2/gm2-pge-boot/$(SRC_PREFIX)RTco.o: $(srcdir)/m2/gm2-libs-iso/RTcodummy.c -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c $< -o $@ @@ -765,14 +765,14 @@ m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o: $(srcdir)/m2/gm2-libs-iso/RTentity.mod m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc $(srcdir)/m2/gm2-libs-iso/RTentity.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc -o $@ m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-PGE-H) -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-libs/$*.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc -o $@ @@ -904,6 +904,7 @@ MCLINK=-g # use -g -fmodules -c if you are debugging and wish to see missing GM2PATH=-I$(srcdir)/m2/mc \ -I$(srcdir)/m2 -Im2/gm2-auto \ + -I$(srcdir)/m2/gm2-gcc \ -fm2-pathname=m2pim -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-ch \ -fm2-pathname=m2iso -I$(srcdir)/m2/gm2-libs-iso -fm2-pathname=- @@ -1074,39 +1075,43 @@ MC_OPTIONS = $(MC_COPYRIGHT) --gcc-config-system --olang=c++ m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/mc/%.def -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs-iso/%.def -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + +m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-gcc/%.def + -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)decl.cc: $(srcdir)/m2/mc/decl.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) $(EXTENDED_OPAQUE) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) $(EXTENDED_OPAQUE) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.cc: $(srcdir)/m2/mc/%.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.cc: $(srcdir)/m2/gm2-libs/%.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.cc: $(srcdir)/m2/gm2-libs-iso/%.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs-iso/%.def -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.cc: m2/mc-obj/%.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-gcc $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $< # mc-bootstrap compiles mc using the C version previously generated by mc-autogen. # These autogenerated files will be checked into git by the maintainer. diff --git a/gcc/m2/gm2-compiler/M2ALU.def b/gcc/m2/gm2-compiler/M2ALU.def index 5aa4b3a86823..b13de7b700a6 100644 --- a/gcc/m2/gm2-compiler/M2ALU.def +++ b/gcc/m2/gm2-compiler/M2ALU.def @@ -32,8 +32,8 @@ DEFINITION MODULE M2ALU ; *) FROM NameKey IMPORT Name ; -FROM m2tree IMPORT Tree ; FROM M2GCCDeclare IMPORT WalkAction, IsAction ; +FROM gcctypes IMPORT tree ; EXPORT QUALIFIED PtrToValue, InitValue, @@ -163,42 +163,42 @@ PROCEDURE GetSetValueType () : CARDINAL ; PushIntegerTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushIntegerTree (t: Tree) ; +PROCEDURE PushIntegerTree (t: tree) ; (* PopIntegerTree - pops a gcc tree value from the ALU stack. *) -PROCEDURE PopIntegerTree () : Tree ; +PROCEDURE PopIntegerTree () : tree ; (* PushRealTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushRealTree (t: Tree) ; +PROCEDURE PushRealTree (t: tree) ; (* PopRealTree - pops a gcc tree value from the ALU stack. *) -PROCEDURE PopRealTree () : Tree ; +PROCEDURE PopRealTree () : tree ; (* PushComplexTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushComplexTree (t: Tree) ; +PROCEDURE PushComplexTree (t: tree) ; (* PopComplexTree - pops a gcc tree value from the ALU stack. *) -PROCEDURE PopComplexTree () : Tree ; +PROCEDURE PopComplexTree () : tree ; (* @@ -209,21 +209,21 @@ PROCEDURE PopComplexTree () : Tree ; *) PROCEDURE PushSetTree (tokenno: CARDINAL; - t: Tree; sym: CARDINAL) ; + t: tree; sym: CARDINAL) ; (* PopSetTree - pops a gcc tree from the ALU stack. *) -PROCEDURE PopSetTree (tokenno: CARDINAL) : Tree ; +PROCEDURE PopSetTree (tokenno: CARDINAL) : tree ; (* PopConstructorTree - returns a tree containing the compound literal. *) -PROCEDURE PopConstructorTree (tokenno: CARDINAL) : Tree ; +PROCEDURE PopConstructorTree (tokenno: CARDINAL) : tree ; (* @@ -832,7 +832,7 @@ PROCEDURE GetRange (v: PtrToValue; n: CARDINAL; VAR low, high: CARDINAL) : BOOLE set const, sym. *) -PROCEDURE ConstructSetConstant (tokenno: CARDINAL; v: PtrToValue) : Tree ; +PROCEDURE ConstructSetConstant (tokenno: CARDINAL; v: PtrToValue) : tree ; (* @@ -840,7 +840,7 @@ PROCEDURE ConstructSetConstant (tokenno: CARDINAL; v: PtrToValue) : Tree ; value {e1..e2}. *) -PROCEDURE BuildRange (tokenno: CARDINAL; e1, e2: Tree) : Tree ; +PROCEDURE BuildRange (tokenno: CARDINAL; e1, e2: tree) : tree ; (* @@ -882,7 +882,7 @@ PROCEDURE IsValueAndTreeKnown () : BOOLEAN ; error message. *) -PROCEDURE CheckOrResetOverflow (tokenno: CARDINAL; t: Tree; check: BOOLEAN) ; +PROCEDURE CheckOrResetOverflow (tokenno: CARDINAL; t: tree; check: BOOLEAN) ; (* @@ -991,7 +991,7 @@ PROCEDURE IsValueConst (v: PtrToValue) : BOOLEAN ; front end type. *) -PROCEDURE PushTypeOfTree (sym: CARDINAL; gcc: Tree) ; +PROCEDURE PushTypeOfTree (sym: CARDINAL; gcc: tree) ; END M2ALU. diff --git a/gcc/m2/gm2-compiler/M2ALU.mod b/gcc/m2/gm2-compiler/M2ALU.mod index cfa372671cdf..086945868981 100644 --- a/gcc/m2/gm2-compiler/M2ALU.mod +++ b/gcc/m2/gm2-compiler/M2ALU.mod @@ -33,7 +33,7 @@ IMPLEMENTATION MODULE M2ALU ; *) FROM ASCII IMPORT nul ; -FROM SYSTEM IMPORT WORD ; +FROM SYSTEM IMPORT WORD, ADDRESS ; FROM NameKey IMPORT KeyToCharStar, MakeKey, CharKey ; FROM M2Error IMPORT InternalError, FlushErrors ; FROM M2Debug IMPORT Assert ; @@ -60,8 +60,8 @@ FROM SymbolTable IMPORT NulSym, IsEnumeration, IsSubrange, IsValueSolved, PushVa IMPORT DynamicStrings ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t, UnknownLocation ; +FROM gcctypes IMPORT location_t, tree ; +FROM m2linemap IMPORT UnknownLocation ; FROM m2expr IMPORT BuildAdd, BuildSub, BuildMult, BuildDivTrunc, BuildModTrunc, BuildDivFloor, BuildModFloor, @@ -122,7 +122,7 @@ TYPE solved : BOOLEAN ; constructorType: CARDINAL ; next : PtrToValue ; - numberValue : Tree ; + numberValue : tree ; CASE type: cellType OF @@ -146,7 +146,7 @@ VAR RangeFreeList : listOfRange ; FreeList, TopOfStack : PtrToValue ; - EnumerationValue: Tree ; + EnumerationValue: tree ; EnumerationField: CARDINAL ; CurrentTokenNo : CARDINAL ; (* WatchedValue : PtrToValue ; *) @@ -694,7 +694,7 @@ END GetSetValueType ; PushIntegerTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushIntegerTree (t: Tree) ; +PROCEDURE PushIntegerTree (t: tree) ; VAR v: PtrToValue ; BEGIN @@ -713,10 +713,10 @@ END PushIntegerTree ; PopIntegerTree - pops a gcc tree value from the ALU stack. *) -PROCEDURE PopIntegerTree () : Tree ; +PROCEDURE PopIntegerTree () : tree ; VAR v: PtrToValue ; - t: Tree ; + t: tree ; BEGIN v := Pop() ; WITH v^ DO @@ -736,7 +736,7 @@ END PopIntegerTree ; PushRealTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushRealTree (t: Tree) ; +PROCEDURE PushRealTree (t: tree) ; VAR v: PtrToValue ; BEGIN @@ -755,10 +755,10 @@ END PushRealTree ; PopRealTree - pops a gcc tree value from the ALU stack. *) -PROCEDURE PopRealTree () : Tree ; +PROCEDURE PopRealTree () : tree ; VAR v: PtrToValue ; - t: Tree ; + t: tree ; BEGIN v := Pop() ; WITH v^ DO @@ -778,7 +778,7 @@ END PopRealTree ; PushComplexTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushComplexTree (t: Tree) ; +PROCEDURE PushComplexTree (t: tree) ; VAR v: PtrToValue ; BEGIN @@ -797,10 +797,10 @@ END PushComplexTree ; PopComplexTree - pops a gcc tree value from the ALU stack. *) -PROCEDURE PopComplexTree () : Tree ; +PROCEDURE PopComplexTree () : tree ; VAR v: PtrToValue ; - t: Tree ; + t: tree ; BEGIN v := Pop() ; WITH v^ DO @@ -824,7 +824,7 @@ END PopComplexTree ; *) PROCEDURE PushSetTree (tokenno: CARDINAL; - t: Tree; sym: CARDINAL) ; + t: tree; sym: CARDINAL) ; VAR v: PtrToValue ; c, @@ -868,10 +868,10 @@ END PushSetTree ; PopSetTree - pops a gcc tree from the ALU stack. *) -PROCEDURE PopSetTree (tokenno: CARDINAL) : Tree ; +PROCEDURE PopSetTree (tokenno: CARDINAL) : tree ; VAR v: PtrToValue ; - t: Tree ; + t: tree ; BEGIN v := Pop() ; WITH v^ DO @@ -900,10 +900,10 @@ END PopSetTree ; PopConstructorTree - returns a tree containing the compound literal. *) -PROCEDURE PopConstructorTree (tokenno: CARDINAL) : Tree ; +PROCEDURE PopConstructorTree (tokenno: CARDINAL) : tree ; VAR v: PtrToValue ; - t: Tree ; + t: tree ; BEGIN v := Pop() ; WITH v^ DO @@ -3503,7 +3503,7 @@ END FindValueEnum ; of type, type. *) -PROCEDURE Val (tokenno: CARDINAL; type: CARDINAL; value: Tree) : CARDINAL ; +PROCEDURE Val (tokenno: CARDINAL; type: CARDINAL; value: tree) : CARDINAL ; VAR sym: CARDINAL ; BEGIN @@ -3548,7 +3548,7 @@ END DupConst ; *) PROCEDURE DupConstAndAdd (tokenno: CARDINAL; - sym: CARDINAL; extra: Tree) : CARDINAL ; + sym: CARDINAL; extra: tree) : CARDINAL ; BEGIN PushValue(sym) ; PushIntegerTree(extra) ; @@ -3565,7 +3565,7 @@ END DupConstAndAdd ; *) PROCEDURE DupConstAndAddMod (tokenno: CARDINAL; - sym: CARDINAL; extra: Tree; + sym: CARDINAL; extra: tree; l, h: CARDINAL) : CARDINAL ; BEGIN (* result := (((sym-l) + extra) MOD (h-l)) + l) *) @@ -3977,7 +3977,7 @@ END IsRangeLess ; MinTree - returns the tree symbol which has the least value. *) -PROCEDURE MinTree (tokenno: CARDINAL; a, b: Tree) : Tree ; +PROCEDURE MinTree (tokenno: CARDINAL; a, b: tree) : tree ; BEGIN PushIntegerTree(a) ; ConvertToInt ; @@ -3996,7 +3996,7 @@ END MinTree ; MaxTree - returns the symbol which has the greatest value. *) -PROCEDURE MaxTree (tokenno: CARDINAL; a, b: Tree) : Tree ; +PROCEDURE MaxTree (tokenno: CARDINAL; a, b: tree) : tree ; BEGIN PushIntegerTree(a) ; ConvertToInt ; @@ -4015,7 +4015,7 @@ END MaxTree ; IsIntersectionTree - returns TRUE if ranges, a..b, and, c..d, intersect. *) -PROCEDURE IsIntersectionTree (tokenno: CARDINAL; a, b, c, d: Tree) : BOOLEAN ; +PROCEDURE IsIntersectionTree (tokenno: CARDINAL; a, b, c, d: tree) : BOOLEAN ; BEGIN (* easier to prove NOT outside limits *) PushIntegerTree(a) ; @@ -4044,7 +4044,7 @@ END IsIntersectionTree ; SubTree - returns the tree value containing (a-b) *) -PROCEDURE SubTree (a, b: Tree) : Tree ; +PROCEDURE SubTree (a, b: tree) : tree ; BEGIN PushIntegerTree(a) ; PushIntegerTree(b) ; @@ -4401,9 +4401,9 @@ END GetRange ; low and high are the limits of the subrange. *) -PROCEDURE BuildStructBitset (tokenno: CARDINAL; v: PtrToValue; low, high: Tree) : Tree ; +PROCEDURE BuildStructBitset (tokenno: CARDINAL; v: PtrToValue; low, high: tree) : tree ; VAR - BitsInSet : Tree ; + BitsInSet : tree ; bpw : CARDINAL ; cons : Constructor ; BEGIN @@ -4468,7 +4468,7 @@ END BuildStructBitset ; { (cardinal), (cardinal) etc } *) -PROCEDURE ConstructLargeOrSmallSet (tokenno: CARDINAL; v: PtrToValue; low, high: CARDINAL) : Tree ; +PROCEDURE ConstructLargeOrSmallSet (tokenno: CARDINAL; v: PtrToValue; low, high: CARDINAL) : tree ; BEGIN PushValue(high) ; ConvertToInt ; @@ -4492,10 +4492,10 @@ END ConstructLargeOrSmallSet ; set const as defined by, v. *) -PROCEDURE ConstructSetConstant (tokenno: CARDINAL; v: PtrToValue) : Tree ; +PROCEDURE ConstructSetConstant (tokenno: CARDINAL; v: PtrToValue) : tree ; VAR n1, n2 : Name ; - gccsym : Tree ; + gccsym : tree ; baseType, high, low: CARDINAL ; BEGIN @@ -4530,10 +4530,10 @@ END ConstructSetConstant ; array constructor. *) -PROCEDURE ConvertConstToType (tokenno: CARDINAL; field: CARDINAL; init: CARDINAL) : Tree ; +PROCEDURE ConvertConstToType (tokenno: CARDINAL; field: CARDINAL; init: CARDINAL) : tree ; VAR initT, - nBytes: Tree ; + nBytes: tree ; BEGIN IF IsConstString(init) AND IsArray(SkipType(GetType(field))) AND (SkipTypeAndSubrange(GetType(GetType(field)))=Char) @@ -4555,7 +4555,7 @@ END ConvertConstToType ; ConstructRecordConstant - builds a struct initializer, as defined by, v. *) -PROCEDURE ConstructRecordConstant (tokenno: CARDINAL; v: PtrToValue) : Tree ; +PROCEDURE ConstructRecordConstant (tokenno: CARDINAL; v: PtrToValue) : tree ; VAR n1, n2 : Name ; i, @@ -4639,7 +4639,7 @@ END GetConstructorField ; PROCEDURE GetConstructorElement (tokenno: CARDINAL; v: PtrToValue; i: CARDINAL) : CARDINAL ; VAR - j: Tree ; + j: tree ; e: listOfElements ; BEGIN WITH v^ DO @@ -4746,15 +4746,15 @@ END GetArrayLimits ; InitialiseArrayOfCharWithString - *) -PROCEDURE InitialiseArrayOfCharWithString (tokenno: CARDINAL; cons: Tree; - el, baseType, arrayType: CARDINAL) : Tree ; +PROCEDURE InitialiseArrayOfCharWithString (tokenno: CARDINAL; cons: ADDRESS; + el, baseType, arrayType: CARDINAL) : tree ; VAR isChar : BOOLEAN ; s, letter: String ; i, l : CARDINAL ; high, low: CARDINAL ; value, - indice : Tree ; + indice : tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -4830,9 +4830,9 @@ END InitialiseArrayOfCharWithString ; CheckElementString - *) -PROCEDURE CheckElementString (el, arrayType: CARDINAL; tokenno: CARDINAL) : Tree ; +PROCEDURE CheckElementString (el, arrayType: CARDINAL; tokenno: CARDINAL) : tree ; VAR - cons: Tree ; + cons: ADDRESS ; BEGIN IF IsString(arrayType) AND IsString(el) THEN @@ -4848,13 +4848,13 @@ END CheckElementString ; InitialiseArrayWith - *) -PROCEDURE InitialiseArrayWith (tokenno: CARDINAL; cons: Tree; - v: PtrToValue; el, high, low, arrayType: CARDINAL) : Tree ; +PROCEDURE InitialiseArrayWith (tokenno: CARDINAL; cons: ADDRESS; + v: PtrToValue; el, high, low, arrayType: CARDINAL) : tree ; VAR location: location_t ; i : CARDINAL ; indice, - value : Tree ; + value : tree ; BEGIN location := TokenToLocation (tokenno) ; i := 0 ; @@ -4900,7 +4900,7 @@ PROCEDURE CheckGetCharFromString (location: location_t; constDecl: PtrToValue; consType: CARDINAL ; arrayIndex: CARDINAL; - VAR value: Tree) : BOOLEAN ; + VAR value: tree) : BOOLEAN ; VAR elementIndex: CARDINAL ; element : CARDINAL ; @@ -4957,14 +4957,14 @@ END CheckGetCharFromString ; InitialiseArrayOfCharWith - *) -PROCEDURE InitialiseArrayOfCharWith (tokenno: CARDINAL; cons: Tree; +PROCEDURE InitialiseArrayOfCharWith (tokenno: CARDINAL; cons: ADDRESS; constDecl: PtrToValue; - el, high, low, consType, arrayType: CARDINAL) : Tree ; + el, high, low, consType, arrayType: CARDINAL) : tree ; VAR location : location_t ; arrayIndex: CARDINAL ; (* arrayIndex is the char position index of the final string. *) indice, - value : Tree ; + value : tree ; BEGIN location := TokenToLocation (tokenno) ; arrayIndex := 0 ; @@ -5004,14 +5004,14 @@ END InitialiseArrayOfCharWith ; ConstructArrayConstant - builds a struct initializer, as defined by, v. *) -PROCEDURE ConstructArrayConstant (tokenno: CARDINAL; v: PtrToValue) : Tree ; +PROCEDURE ConstructArrayConstant (tokenno: CARDINAL; v: PtrToValue) : tree ; VAR n1, n2 : Name ; el1, el2, baseType, arrayType, high, low : CARDINAL ; - cons : Constructor ; + cons : ADDRESS ; BEGIN WITH v^ DO IF constructorType=NulSym @@ -5052,9 +5052,9 @@ END ConstructArrayConstant ; value {e1..e2}. *) -PROCEDURE BuildRange (tokenno: CARDINAL; e1, e2: Tree) : Tree ; +PROCEDURE BuildRange (tokenno: CARDINAL; e1, e2: tree) : tree ; VAR - c, i, t : Tree ; + c, i, t : tree ; location: location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -5066,11 +5066,11 @@ BEGIN e1 := e2 ; e2 := c END ; - t := Tree(NIL) ; + t := tree(NIL) ; PushIntegerTree(e1) ; i := PopIntegerTree() ; REPEAT - IF t=Tree(NIL) + IF t=tree(NIL) THEN t := BuildLSL(location, GetWordOne(location), ToWord(location, i), FALSE) ELSE @@ -5093,10 +5093,10 @@ END BuildRange ; *) PROCEDURE BuildBitset (tokenno: CARDINAL; - v: PtrToValue; low, high: Tree) : Tree ; + v: PtrToValue; low, high: tree) : tree ; VAR tl, th, - t : Tree ; + t : tree ; n : CARDINAL ; r1, r2 : CARDINAL ; location: location_t ; @@ -5175,7 +5175,7 @@ END IsValueAndTreeKnown ; error message. *) -PROCEDURE CheckOverflow (tokenno: CARDINAL; t: Tree) ; +PROCEDURE CheckOverflow (tokenno: CARDINAL; t: tree) ; BEGIN IF TreeOverflow (t) THEN @@ -5191,7 +5191,7 @@ END CheckOverflow ; error message. *) -PROCEDURE CheckOrResetOverflow (tokenno: CARDINAL; t: Tree; check: BOOLEAN) ; +PROCEDURE CheckOrResetOverflow (tokenno: CARDINAL; t: tree; check: BOOLEAN) ; BEGIN IF check THEN @@ -5206,7 +5206,7 @@ END CheckOrResetOverflow ; PushGCCArrayTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushGCCArrayTree (gcc: Tree; t: CARDINAL) ; +PROCEDURE PushGCCArrayTree (gcc: tree; t: CARDINAL) ; VAR v: PtrToValue ; BEGIN @@ -5227,7 +5227,7 @@ END PushGCCArrayTree ; PushGCCSetTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushGCCSetTree (gcc: Tree; t: CARDINAL) ; +PROCEDURE PushGCCSetTree (gcc: tree; t: CARDINAL) ; VAR v: PtrToValue ; BEGIN @@ -5248,7 +5248,7 @@ END PushGCCSetTree ; PushGCCRecordTree - pushes a gcc tree value onto the ALU stack. *) -PROCEDURE PushGCCRecordTree (gcc: Tree; t: CARDINAL) ; +PROCEDURE PushGCCRecordTree (gcc: tree; t: CARDINAL) ; VAR v: PtrToValue ; BEGIN @@ -5270,7 +5270,7 @@ END PushGCCRecordTree ; front end type. *) -PROCEDURE PushTypeOfTree (sym: CARDINAL; gcc: Tree) ; +PROCEDURE PushTypeOfTree (sym: CARDINAL; gcc: tree) ; VAR t: CARDINAL ; BEGIN diff --git a/gcc/m2/gm2-compiler/M2Base.def b/gcc/m2/gm2-compiler/M2Base.def index 48eaa315edf9..acf7f851bb6d 100644 --- a/gcc/m2/gm2-compiler/M2Base.def +++ b/gcc/m2/gm2-compiler/M2Base.def @@ -30,7 +30,7 @@ DEFINITION MODULE M2Base ; *) FROM NameKey IMPORT Name ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; EXPORT QUALIFIED Nil, (* Base constants *) Cardinal, (* Base types *) diff --git a/gcc/m2/gm2-compiler/M2Base.mod b/gcc/m2/gm2-compiler/M2Base.mod index b8677695bfd4..e298d13986d7 100644 --- a/gcc/m2/gm2-compiler/M2Base.mod +++ b/gcc/m2/gm2-compiler/M2Base.mod @@ -114,7 +114,8 @@ FROM m2type IMPORT GetIntegerType, InitBaseTypes ; FROM m2expr IMPORT GetSizeOf ; -FROM m2linemap IMPORT location_t, BuiltinsLocation ; +FROM gcctypes IMPORT location_t ; +FROM m2linemap IMPORT BuiltinsLocation ; FROM m2decl IMPORT BuildIntegerConstant ; diff --git a/gcc/m2/gm2-compiler/M2Bitset.mod b/gcc/m2/gm2-compiler/M2Bitset.mod index 3d60af4fb7d4..ec23bd9acd96 100644 --- a/gcc/m2/gm2-compiler/M2Bitset.mod +++ b/gcc/m2/gm2-compiler/M2Bitset.mod @@ -23,7 +23,6 @@ IMPLEMENTATION MODULE M2Bitset ; FROM M2Debug IMPORT Assert ; -FROM m2tree IMPORT Tree ; FROM m2linemap IMPORT BuiltinsLocation ; FROM m2type IMPORT GetWordType ; FROM m2decl IMPORT GetBitsPerBitset ; diff --git a/gcc/m2/gm2-compiler/M2CaseList.mod b/gcc/m2/gm2-compiler/M2CaseList.mod index b98f55375bd3..7a889bd5d8bf 100644 --- a/gcc/m2/gm2-compiler/M2CaseList.mod +++ b/gcc/m2/gm2-compiler/M2CaseList.mod @@ -33,7 +33,7 @@ FROM Lists IMPORT InitList, IncludeItemIntoList, RemoveItemFromList, NoOfItemsIn FROM NameKey IMPORT KeyToCharStar ; FROM SymbolConversion IMPORT GccKnowsAbout, Mod2Gcc, AddModGcc ; FROM DynamicStrings IMPORT InitString, InitStringCharStar, InitStringChar, ConCat, Mark, KillString ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM m2block IMPORT RememberType ; FROM m2type IMPORT GetMinFrom ; FROM m2expr IMPORT GetIntegerOne, CSTIntToString, CSTIntToChar ; @@ -76,7 +76,7 @@ TYPE END ; SetRange = POINTER TO RECORD - low, high: Tree ; + low, high: tree ; next : SetRange ; END ; @@ -608,7 +608,7 @@ END RemoveRange ; SubBitRange - subtracts bits, lo..hi, from, set. *) -PROCEDURE SubBitRange (set: SetRange; lo, hi: Tree; tokenno: CARDINAL) : SetRange ; +PROCEDURE SubBitRange (set: SetRange; lo, hi: tree; tokenno: CARDINAL) : SetRange ; VAR h, i: SetRange ; BEGIN @@ -681,7 +681,7 @@ END SubBitRange ; PROCEDURE CheckLowHigh (rp: RangePair) ; VAR - lo, hi: Tree ; + lo, hi: tree ; temp : CARDINAL ; BEGIN lo := Mod2Gcc (rp^.low) ; @@ -741,9 +741,9 @@ VAR IncludeElement - only include enumeration field into errorString if it lies between low..high. *) -PROCEDURE IncludeElement (enumList: List; field: CARDINAL; low, high: Tree) ; +PROCEDURE IncludeElement (enumList: List; field: CARDINAL; low, high: tree) ; VAR - fieldTree: Tree ; + fieldTree: tree ; BEGIN IF field # NulSym THEN @@ -760,7 +760,7 @@ END IncludeElement ; IncludeElements - only include enumeration field values low..high in errorString. *) -PROCEDURE IncludeElements (type: CARDINAL; enumList: List; low, high: Tree) ; +PROCEDURE IncludeElements (type: CARDINAL; enumList: List; low, high: tree) ; VAR field : CARDINAL ; i, @@ -782,7 +782,7 @@ END IncludeElements ; PROCEDURE ErrorRangeEnum (type: CARDINAL; set: SetRange; enumList: List) ; VAR - Low, High: Tree ; + Low, High: tree ; BEGIN Low := set^.low ; High := set^.high ; @@ -894,7 +894,7 @@ END EnumerateErrors ; NoOfSetElements - return the number of set elements. *) -PROCEDURE NoOfSetElements (set: SetRange) : Tree ; +PROCEDURE NoOfSetElements (set: SetRange) : tree ; BEGIN PushInt (0) ; WHILE set # NIL DO @@ -922,7 +922,7 @@ END NoOfSetElements ; isPrintableChar - a cautious isprint. *) -PROCEDURE isPrintableChar (value: Tree) : BOOLEAN ; +PROCEDURE isPrintableChar (value: tree) : BOOLEAN ; BEGIN CASE CSTIntToChar (value) OF @@ -958,7 +958,7 @@ END isPrintableChar ; CHAR constants and will fall back to CHR (x) if necessary. *) -PROCEDURE appendTree (value: Tree; type: CARDINAL) ; +PROCEDURE appendTree (value: tree; type: CARDINAL) ; BEGIN IF SkipType (GetType (type)) = Char THEN @@ -994,7 +994,7 @@ VAR sr : SetRange ; rangeNo : CARDINAL ; nMissing, - zero, one: Tree ; + zero, one: tree ; BEGIN nMissing := NoOfSetElements (set) ; PushInt (0) ; @@ -1157,7 +1157,7 @@ procedure InRangeList (cl: CaseList; tag: cardinal) : boolean ; var i, h: cardinal ; r : RangePair ; - a : Tree ; + a : tree ; begin with cl^ do i := 1 ; diff --git a/gcc/m2/gm2-compiler/M2Emit.def b/gcc/m2/gm2-compiler/M2Emit.def index 4710dd06454a..acfd332b39f1 100644 --- a/gcc/m2/gm2-compiler/M2Emit.def +++ b/gcc/m2/gm2-compiler/M2Emit.def @@ -23,7 +23,7 @@ DEFINITION MODULE M2Emit ; FROM DynamicStrings IMPORT String ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; (* diff --git a/gcc/m2/gm2-compiler/M2GCCDeclare.def b/gcc/m2/gm2-compiler/M2GCCDeclare.def index 13570dabfbb3..45395463d738 100644 --- a/gcc/m2/gm2-compiler/M2GCCDeclare.def +++ b/gcc/m2/gm2-compiler/M2GCCDeclare.def @@ -31,7 +31,7 @@ DEFINITION MODULE M2GCCDeclare ; *) FROM SYSTEM IMPORT WORD ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM M2BasicBlock IMPORT BasicBlock ; TYPE @@ -159,7 +159,7 @@ PROCEDURE PoisonSymbols (sym: CARDINAL) ; return a string constant. *) -PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : Tree ; +PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : tree ; (* @@ -170,7 +170,7 @@ PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : Tree ; return a string constant. *) -PROCEDURE PromoteToCString (tokenno: CARDINAL; sym: CARDINAL) : Tree ; +PROCEDURE PromoteToCString (tokenno: CARDINAL; sym: CARDINAL) : tree ; (* @@ -186,7 +186,7 @@ PROCEDURE CompletelyResolved (sym: CARDINAL) : BOOLEAN ; ConstantKnownAndUsed - *) -PROCEDURE ConstantKnownAndUsed (sym: CARDINAL; t: Tree) ; +PROCEDURE ConstantKnownAndUsed (sym: CARDINAL; t: tree) ; (* diff --git a/gcc/m2/gm2-compiler/M2GCCDeclare.mod b/gcc/m2/gm2-compiler/M2GCCDeclare.mod index a2effe97b664..82c6437464d6 100644 --- a/gcc/m2/gm2-compiler/M2GCCDeclare.mod +++ b/gcc/m2/gm2-compiler/M2GCCDeclare.mod @@ -160,8 +160,8 @@ FROM M2ALU IMPORT Addn, Sub, Equ, GreEqu, Gre, Less, PushInt, PushCard, ConvertT ChangeToConstructor, EvaluateValue, TryEvaluateValue ; FROM M2Batch IMPORT IsSourceSeen, GetModuleFile, IsModuleSeen, LookupModule ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t, BuiltinsLocation ; +FROM gcctypes IMPORT location_t, tree ; +FROM m2linemap IMPORT BuiltinsLocation ; FROM m2decl IMPORT BuildIntegerConstant, BuildStringConstant, BuildCStringConstant, BuildStartFunctionDeclaration, @@ -205,7 +205,7 @@ FROM m2block IMPORT RememberType, pushGlobalScope, popGlobalScope, TYPE - StartProcedure = PROCEDURE (location_t, ADDRESS) : Tree ; + StartProcedure = PROCEDURE (location_t, ADDRESS) : tree ; ListType = (fullydeclared, partiallydeclared, niltypedarrays, heldbyalignment, finishedalignment, todolist, tobesolvedbyquads, finishedsetarray) ; @@ -648,11 +648,11 @@ END LookupSet ; GetEnumList - *) -PROCEDURE GetEnumList (sym: CARDINAL) : Tree ; +PROCEDURE GetEnumList (sym: CARDINAL) : tree ; BEGIN IF InBounds(EnumerationIndex, sym) THEN - RETURN( GetIndice(EnumerationIndex, sym) ) + RETURN( tree (GetIndice(EnumerationIndex, sym)) ) ELSE RETURN( NIL ) END @@ -663,7 +663,7 @@ END GetEnumList ; PutEnumList - *) -PROCEDURE PutEnumList (sym: CARDINAL; enumlist: Tree) ; +PROCEDURE PutEnumList (sym: CARDINAL; enumlist: tree) ; BEGIN PutIndice(EnumerationIndex, sym, enumlist) END PutEnumList ; @@ -708,7 +708,7 @@ END Chained ; recursive types. *) -PROCEDURE DoStartDeclaration (sym: CARDINAL; p: StartProcedure) : Tree ; +PROCEDURE DoStartDeclaration (sym: CARDINAL; p: StartProcedure) : tree ; VAR location: location_t ; BEGIN @@ -1246,7 +1246,7 @@ END PutToBeSolvedByQuads ; PROCEDURE DeclareTypeConstFully (sym: CARDINAL) ; VAR - t: Tree ; + t: tree ; BEGIN IF NOT IsElementInSet(GlobalGroup^.ToBeSolvedByQuads, sym) THEN @@ -1285,7 +1285,7 @@ END DeclareTypeConstFully ; PROCEDURE DeclareTypeFromPartial (sym: CARDINAL) ; VAR - t: Tree ; + t: tree ; BEGIN t := CompleteDeclarationOf(sym) ; IF t=NIL @@ -1550,7 +1550,7 @@ END DeclaredOutstandingTypes ; dependents. *) -PROCEDURE CompleteDeclarationOf (sym: CARDINAL) : Tree ; +PROCEDURE CompleteDeclarationOf (sym: CARDINAL) : tree ; BEGIN IF IsArray(sym) THEN @@ -1575,9 +1575,9 @@ END CompleteDeclarationOf ; we must tell GCC about it. *) -PROCEDURE DeclareType (sym: CARDINAL) : Tree ; +PROCEDURE DeclareType (sym: CARDINAL) : tree ; VAR - t : Tree ; + t : tree ; location: location_t ; BEGIN IF GetSType(sym)=NulSym @@ -1587,7 +1587,7 @@ BEGIN ELSE IF GetSymName(sym)=NulName THEN - RETURN( Tree(Mod2Gcc(GetSType(sym))) ) + RETURN( tree(Mod2Gcc(GetSType(sym))) ) ELSE location := TokenToLocation(GetDeclaredMod(sym)) ; IF GccKnowsAbout(sym) @@ -1623,7 +1623,7 @@ END DeclareIntegerConstant ; DeclareIntegerFromTree - declares an integer constant from a Tree, value. *) -PROCEDURE DeclareConstantFromTree (sym: CARDINAL; value: Tree) ; +PROCEDURE DeclareConstantFromTree (sym: CARDINAL; value: tree) ; BEGIN PreAddModGcc(sym, value) ; WatchRemoveList(sym, todolist) ; @@ -1653,7 +1653,7 @@ END DeclareCharConstant ; PROCEDURE DeclareStringConstant (tokenno: CARDINAL; sym: CARDINAL) ; VAR - symtree : Tree ; + symtree : tree ; BEGIN Assert (IsConstStringKnown (sym)) ; IF IsConstStringM2nul (sym) OR IsConstStringCnul (sym) @@ -1681,7 +1681,7 @@ END DeclareStringConstant ; return a string constant. *) -PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : Tree ; +PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : tree ; VAR size: CARDINAL ; ch : CHAR ; @@ -1698,7 +1698,7 @@ BEGIN IF size > 1 THEN (* It will be already be declared as a string, so return it. *) - RETURN Tree (Mod2Gcc (sym)) + RETURN tree (Mod2Gcc (sym)) ELSE RETURN BuildStringConstant (KeyToCharStar (GetString (sym)), GetStringLength (tokenno, sym)) @@ -1715,7 +1715,7 @@ END PromoteToString ; return a string constant. *) -PROCEDURE PromoteToCString (tokenno: CARDINAL; sym: CARDINAL) : Tree ; +PROCEDURE PromoteToCString (tokenno: CARDINAL; sym: CARDINAL) : tree ; VAR size: CARDINAL ; ch : CHAR ; @@ -1905,7 +1905,7 @@ END TryDeclareConstant ; PROCEDURE DeclareConstant (tokenno: CARDINAL; sym: CARDINAL) ; VAR type: CARDINAL ; - t : Tree ; + t : tree ; BEGIN IF IsConst(sym) THEN @@ -2011,7 +2011,7 @@ END TryDeclareConst ; DeclareConst - declares a const to gcc and returns a Tree. *) -PROCEDURE DeclareConst (tokenno: CARDINAL; sym: CARDINAL) : Tree ; +PROCEDURE DeclareConst (tokenno: CARDINAL; sym: CARDINAL) : tree ; VAR type: CARDINAL ; BEGIN @@ -2457,7 +2457,7 @@ END IsExternalToWholeProgram ; PROCEDURE DeclareProcedureToGccWholeProgram (Sym: CARDINAL) ; VAR returnType, - GccParam : Tree ; + GccParam : tree ; scope, Son, p, i : CARDINAL ; @@ -2526,7 +2526,7 @@ END DeclareProcedureToGccWholeProgram ; PROCEDURE DeclareProcedureToGccSeparateProgram (Sym: CARDINAL) ; VAR returnType, - GccParam : Tree ; + GccParam : tree ; scope, Son, p, i : CARDINAL ; @@ -3078,7 +3078,7 @@ END DumpFilteredDefinitive ; PreAddModGcc - adds a relationship between sym and tree. *) -PROCEDURE PreAddModGcc (sym: CARDINAL; tree: Tree) ; +PROCEDURE PreAddModGcc (sym: CARDINAL; tree: tree) ; BEGIN AddModGcc (sym, tree) END PreAddModGcc ; @@ -3088,9 +3088,9 @@ END PreAddModGcc ; DeclareDefaultType - declares a default type, sym, with, name. *) -PROCEDURE DeclareDefaultType (sym: CARDINAL; name: ARRAY OF CHAR; gcctype: Tree) ; +PROCEDURE DeclareDefaultType (sym: CARDINAL; name: ARRAY OF CHAR; gcctype: tree) ; VAR - t : Tree ; + t : tree ; high, low: CARDINAL ; location : location_t ; BEGIN @@ -3155,7 +3155,7 @@ END DeclareBoolean ; (if the back end support such a type). *) -PROCEDURE DeclareFixedSizedType (name: ARRAY OF CHAR; type: CARDINAL; t: Tree) ; +PROCEDURE DeclareFixedSizedType (name: ARRAY OF CHAR; type: CARDINAL; t: tree) ; VAR location : location_t ; typetype, @@ -3316,7 +3316,7 @@ END DeclareDefaultConstants ; a procedure will return the procedure Tree. *) -PROCEDURE FindContext (sym: CARDINAL) : Tree ; +PROCEDURE FindContext (sym: CARDINAL) : tree ; BEGIN sym := GetProcedureScope(sym) ; IF sym=NulSym @@ -3379,9 +3379,9 @@ END FindOuterModule ; PROCEDURE DoVariableDeclaration (var: CARDINAL; name: ADDRESS; isImported, isExported, isTemporary, isGlobal: BOOLEAN; - scope: Tree) ; + scope: tree) ; VAR - type : Tree ; + type : tree ; varType : CARDINAL ; location: location_t ; BEGIN @@ -3455,7 +3455,7 @@ END IsGlobal ; PROCEDURE DeclareVariable (ModSym, variable: CARDINAL) ; VAR - scope: Tree ; + scope: tree ; decl : CARDINAL ; BEGIN IF NOT GccKnowsAbout (variable) @@ -3483,7 +3483,7 @@ END DeclareVariable ; PROCEDURE DeclareVariableWholeProgram (mainModule, variable: CARDINAL) ; VAR - scope: Tree ; + scope: tree ; decl : CARDINAL ; BEGIN IF NOT GccKnowsAbout (variable) @@ -3624,7 +3624,7 @@ END DeclareLocalVariables ; PROCEDURE DeclareModuleVariables (sym: CARDINAL) ; VAR - scope : Tree ; + scope : tree ; i, Var: CARDINAL ; BEGIN i := 1 ; @@ -3649,7 +3649,7 @@ END DeclareModuleVariables ; DeclareFieldValue - *) -PROCEDURE DeclareFieldValue (sym: CARDINAL; value: Tree; VAR list: Tree) : Tree ; +PROCEDURE DeclareFieldValue (sym: CARDINAL; value: tree; VAR list: tree) : tree ; VAR location: location_t ; BEGIN @@ -3668,11 +3668,11 @@ END DeclareFieldValue ; DeclareFieldEnumeration - declares an enumerator within the current enumeration type. *) -PROCEDURE DeclareFieldEnumeration (sym: WORD) : Tree ; +PROCEDURE DeclareFieldEnumeration (sym: WORD) : tree ; VAR type : CARDINAL ; field, - enumlist: Tree ; + enumlist: tree ; BEGIN (* add relationship between gccSym and sym *) type := GetSType (sym) ; @@ -3688,10 +3688,10 @@ END DeclareFieldEnumeration ; DeclareEnumeration - declare an enumerated type. *) -PROCEDURE DeclareEnumeration (sym: WORD) : Tree ; +PROCEDURE DeclareEnumeration (sym: WORD) : tree ; VAR enumlist, - gccenum : Tree ; + gccenum : tree ; location: location_t ; BEGIN location := TokenToLocation (GetDeclaredMod (sym)) ; @@ -3707,11 +3707,11 @@ END DeclareEnumeration ; *) PROCEDURE DeclareSubrangeNarrow (location: location_t; - high, low: CARDINAL; type: Tree) : Tree ; + high, low: CARDINAL; type: tree) : tree ; VAR m2low, m2high, lowtree, - hightree : Tree ; + hightree : tree ; BEGIN (* No zero alignment, therefore the front end will prioritize subranges to match unsigned int, int, or ZTYPE assuming the low..high range fits. *) @@ -3743,10 +3743,10 @@ END DeclareSubrangeNarrow ; DeclareSubrange - declare a subrange type. *) -PROCEDURE DeclareSubrange (sym: CARDINAL) : Tree ; +PROCEDURE DeclareSubrange (sym: CARDINAL) : tree ; VAR type, - gccsym : Tree ; + gccsym : tree ; align, high, low: CARDINAL ; location: location_t ; @@ -4503,7 +4503,7 @@ END PrintTerse ; CheckAlignment - *) -PROCEDURE CheckAlignment (type: Tree; sym: CARDINAL) : Tree ; +PROCEDURE CheckAlignment (type: tree; sym: CARDINAL) : tree ; VAR align: CARDINAL ; BEGIN @@ -4525,7 +4525,7 @@ END CheckAlignment ; CheckPragma - *) -PROCEDURE CheckPragma (type: Tree; sym: CARDINAL) : Tree ; +PROCEDURE CheckPragma (type: tree; sym: CARDINAL) : tree ; BEGIN IF IsDeclaredPacked (sym) THEN @@ -4630,7 +4630,7 @@ END DetermineIfRecordPacked ; PROCEDURE DeclarePackedSubrange (equiv, sym: CARDINAL) ; VAR type, - gccsym : Tree ; + gccsym : tree ; high, low: CARDINAL ; location : location_t ; BEGIN @@ -4651,7 +4651,7 @@ PROCEDURE DeclarePackedSet (equiv, sym: CARDINAL) ; VAR highLimit, range, - gccsym : Tree ; + gccsym : tree ; type, high, low: CARDINAL ; location: location_t ; @@ -4680,7 +4680,7 @@ VAR equiv, type : CARDINAL ; field, - enumlist: Tree ; + enumlist: tree ; BEGIN (* add relationship between gccSym and sym *) type := GetSType (sym) ; @@ -4700,7 +4700,7 @@ END DeclarePackedFieldEnumeration ; PROCEDURE DeclarePackedEnumeration (equiv, sym: CARDINAL) ; VAR enumlist, - gccenum : Tree ; + gccenum : tree ; location: location_t ; BEGIN location := TokenToLocation(GetDeclaredMod(sym)) ; @@ -4740,7 +4740,7 @@ END DeclarePackedType ; doDeclareEquivalent - *) -PROCEDURE doDeclareEquivalent (sym: CARDINAL; p: doDeclareProcedure) : Tree ; +PROCEDURE doDeclareEquivalent (sym: CARDINAL; p: doDeclareProcedure) : tree ; VAR equiv: CARDINAL ; BEGIN @@ -4758,7 +4758,7 @@ END doDeclareEquivalent ; PossiblyPacked - *) -PROCEDURE PossiblyPacked (sym: CARDINAL; isPacked: BOOLEAN) : Tree ; +PROCEDURE PossiblyPacked (sym: CARDINAL; isPacked: BOOLEAN) : tree ; BEGIN IF isPacked THEN @@ -4784,7 +4784,7 @@ END PossiblyPacked ; GetPackedType - returns a possibly packed type for field. *) -PROCEDURE GetPackedType (sym: CARDINAL) : Tree ; +PROCEDURE GetPackedType (sym: CARDINAL) : tree ; BEGIN IF IsSubrange(sym) THEN @@ -4805,10 +4805,10 @@ END GetPackedType ; the offsets if appropriate. *) -PROCEDURE MaybeAlignField (field: CARDINAL; VAR byteOffset, bitOffset: Tree) : Tree ; +PROCEDURE MaybeAlignField (field: CARDINAL; VAR byteOffset, bitOffset: tree) : tree ; VAR f, ftype, - nbits : Tree ; + nbits : tree ; location: location_t ; BEGIN f := Mod2Gcc(field) ; @@ -4832,7 +4832,7 @@ END MaybeAlignField ; The final gcc record type is returned. *) -PROCEDURE DeclareRecord (Sym: CARDINAL) : Tree ; +PROCEDURE DeclareRecord (Sym: CARDINAL) : tree ; VAR Field : CARDINAL ; i : CARDINAL ; @@ -4842,11 +4842,11 @@ VAR byteOffset, bitOffset, FieldList, - RecordType: Tree ; + RecordType: tree ; location : location_t ; BEGIN i := 1 ; - FieldList := Tree(NIL) ; + FieldList := tree(NIL) ; RecordType := DoStartDeclaration(Sym, BuildStartRecord) ; location := TokenToLocation(GetDeclaredMod(Sym)) ; byteOffset := GetIntegerZero(location) ; @@ -4898,10 +4898,10 @@ END DeclareRecord ; DeclareRecordField - *) -PROCEDURE DeclareRecordField (sym: CARDINAL) : Tree ; +PROCEDURE DeclareRecordField (sym: CARDINAL) : tree ; VAR field, - GccFieldType: Tree ; + GccFieldType: tree ; location : location_t ; BEGIN location := TokenToLocation(GetDeclaredMod(sym)) ; @@ -4916,18 +4916,18 @@ END DeclareRecordField ; The final gcc record type is returned. *) -PROCEDURE DeclareVarient (sym: CARDINAL) : Tree ; +PROCEDURE DeclareVarient (sym: CARDINAL) : tree ; VAR Field : CARDINAL ; i : CARDINAL ; byteOffset, bitOffset, FieldList, - VarientType : Tree ; + VarientType : tree ; location : location_t ; BEGIN i := 1 ; - FieldList := Tree(NIL) ; + FieldList := tree(NIL) ; VarientType := DoStartDeclaration(sym, BuildStartVarient) ; location := TokenToLocation(GetDeclaredMod(sym)) ; byteOffset := GetIntegerZero(location) ; @@ -4958,19 +4958,19 @@ END DeclareVarient ; DeclareFieldVarient - *) -PROCEDURE DeclareFieldVarient (sym: CARDINAL) : Tree ; +PROCEDURE DeclareFieldVarient (sym: CARDINAL) : tree ; VAR i, f : CARDINAL ; VarientList, VarientType, byteOffset, bitOffset, - GccFieldType: Tree ; + GccFieldType: tree ; location : location_t ; BEGIN location := TokenToLocation(GetDeclaredMod(sym)) ; i := 1 ; - VarientList := Tree(NIL) ; + VarientList := tree(NIL) ; VarientType := DoStartDeclaration(sym, BuildStartFieldVarient) ; (* no need to store the [sym, RecordType] tuple as it is stored by DeclareRecord which calls us *) byteOffset := GetIntegerZero(location) ; @@ -4999,7 +4999,7 @@ END DeclareFieldVarient ; DeclarePointer - declares a pointer type to gcc and returns the Tree. *) -PROCEDURE DeclarePointer (sym: CARDINAL) : Tree ; +PROCEDURE DeclarePointer (sym: CARDINAL) : tree ; BEGIN RETURN( BuildPointerType(Mod2Gcc(GetSType(sym))) ) END DeclarePointer ; @@ -5009,7 +5009,7 @@ END DeclarePointer ; DeclareUnbounded - builds an unbounded type and returns the gcc tree. *) -PROCEDURE DeclareUnbounded (sym: CARDINAL) : Tree ; +PROCEDURE DeclareUnbounded (sym: CARDINAL) : tree ; VAR record: CARDINAL ; BEGIN @@ -5035,13 +5035,13 @@ END DeclareUnbounded ; BuildIndex - *) -PROCEDURE BuildIndex (tokenno: CARDINAL; array: CARDINAL) : Tree ; +PROCEDURE BuildIndex (tokenno: CARDINAL; array: CARDINAL) : tree ; VAR Subscript: CARDINAL ; Type, High, Low: CARDINAL ; n, - low, high: Tree ; + low, high: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -5079,12 +5079,12 @@ END BuildIndex ; DeclareArray - declares an array to gcc and returns the gcc tree. *) -PROCEDURE DeclareArray (Sym: CARDINAL) : Tree ; +PROCEDURE DeclareArray (Sym: CARDINAL) : tree ; VAR typeOfArray: CARDINAL ; ArrayType, GccArray, - GccIndex : Tree ; + GccIndex : tree ; Subscript : CARDINAL ; tokenno : CARDINAL ; location : location_t ; @@ -5122,12 +5122,12 @@ END DeclareArray ; DeclareProcType - declares a procedure type to gcc and returns the gcc type tree. *) -PROCEDURE DeclareProcType (Sym: CARDINAL) : Tree ; +PROCEDURE DeclareProcType (Sym: CARDINAL) : tree ; VAR i, p, Son, ReturnType: CARDINAL ; func, - GccParam : Tree ; + GccParam : tree ; location : location_t ; BEGIN ReturnType := GetSType(Sym) ; @@ -5287,14 +5287,14 @@ END PushNoOfBits ; low and high are the limits of the subrange. *) -PROCEDURE DeclareLargeSet (n: Name; type: CARDINAL; low, high: CARDINAL) : Tree ; +PROCEDURE DeclareLargeSet (n: Name; type: CARDINAL; low, high: CARDINAL) : tree ; VAR lowtree, hightree, BitsInSet, RecordType, GccField, - FieldList : Tree ; + FieldList : tree ; bpw : CARDINAL ; location : location_t ; BEGIN @@ -5304,7 +5304,7 @@ BEGIN lowtree := PopIntegerTree() ; PushValue(high) ; hightree := PopIntegerTree() ; - FieldList := Tree(NIL) ; + FieldList := tree(NIL) ; RecordType := BuildStartRecord(location, KeyToCharStar(n)) ; (* no problem with recursive types here *) PushNoOfBits(type, low, high) ; PushCard(1) ; @@ -5357,7 +5357,7 @@ END DeclareLargeSet ; *) PROCEDURE DeclareLargeOrSmallSet (sym: CARDINAL; - n: Name; type: CARDINAL; low, high: CARDINAL) : Tree ; + n: Name; type: CARDINAL; low, high: CARDINAL) : tree ; VAR location: location_t ; packed : BOOLEAN ; @@ -5383,9 +5383,9 @@ END DeclareLargeOrSmallSet ; DeclareSet - declares a set type to gcc and returns a Tree. *) -PROCEDURE DeclareSet (sym: CARDINAL) : Tree ; +PROCEDURE DeclareSet (sym: CARDINAL) : tree ; VAR - gccsym : Tree ; + gccsym : tree ; type, high, low: CARDINAL ; BEGIN @@ -5456,9 +5456,9 @@ END CheckResolveSubrange ; return the GCC Tree equivalent. *) -PROCEDURE TypeConstFullyDeclared (sym: CARDINAL) : Tree ; +PROCEDURE TypeConstFullyDeclared (sym: CARDINAL) : tree ; VAR - t: Tree ; + t: tree ; BEGIN IF IsEnumeration(sym) THEN @@ -6462,7 +6462,7 @@ END PoisonSymbols ; ConstantKnownAndUsed - *) -PROCEDURE ConstantKnownAndUsed (sym: CARDINAL; t: Tree) ; +PROCEDURE ConstantKnownAndUsed (sym: CARDINAL; t: tree) ; BEGIN DeclareConstantFromTree(sym, RememberConstant(t)) END ConstantKnownAndUsed ; diff --git a/gcc/m2/gm2-compiler/M2GenGCC.def b/gcc/m2/gm2-compiler/M2GenGCC.def index fc7cdf281dd5..762f5d797c8a 100644 --- a/gcc/m2/gm2-compiler/M2GenGCC.def +++ b/gcc/m2/gm2-compiler/M2GenGCC.def @@ -32,8 +32,7 @@ DEFINITION MODULE M2GenGCC ; *) FROM M2GCCDeclare IMPORT WalkAction ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; FROM M2BasicBlock IMPORT BasicBlock ; @@ -60,7 +59,7 @@ PROCEDURE ResolveConstantExpressions (p: WalkAction; bb: BasicBlock) : BOOLEAN ; param.HIGH. *) -PROCEDURE GetHighFromUnbounded (location: location_t; dim, param: CARDINAL) : Tree ; +PROCEDURE GetHighFromUnbounded (location: location_t; dim, param: CARDINAL) : tree ; (* @@ -68,7 +67,7 @@ PROCEDURE GetHighFromUnbounded (location: location_t; dim, param: CARDINAL) : Tr then convert the string into a character constant. *) -PROCEDURE StringToChar (t: Tree; type, str: CARDINAL) : Tree ; +PROCEDURE StringToChar (t: tree; type, str: CARDINAL) : tree ; (* @@ -76,7 +75,7 @@ PROCEDURE StringToChar (t: Tree; type, str: CARDINAL) : Tree ; It coerces a lvalue into an internal pointer type *) -PROCEDURE LValueToGenericPtr (location: location_t; sym: CARDINAL) : Tree ; +PROCEDURE LValueToGenericPtr (location: location_t; sym: CARDINAL) : tree ; (* @@ -84,7 +83,7 @@ PROCEDURE LValueToGenericPtr (location: location_t; sym: CARDINAL) : Tree ; coerces, t, appropriately. *) -PROCEDURE ZConstToTypedConst (t: Tree; op1, op2: CARDINAL) : Tree ; +PROCEDURE ZConstToTypedConst (t: tree; op1, op2: CARDINAL) : tree ; (* @@ -102,7 +101,7 @@ PROCEDURE ZConstToTypedConst (t: Tree; op1, op2: CARDINAL) : Tree ; which fits in dest. *) -PROCEDURE PrepareCopyString (tokenno: CARDINAL; VAR length, srcTree: Tree; +PROCEDURE PrepareCopyString (tokenno: CARDINAL; VAR length, srcTree: tree; src, destStrType: CARDINAL) : BOOLEAN ; diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod index fc3fa204ac0a..67d3e92ac4f3 100644 --- a/gcc/m2/gm2-compiler/M2GenGCC.mod +++ b/gcc/m2/gm2-compiler/M2GenGCC.mod @@ -210,8 +210,8 @@ FROM m2expr IMPORT GetIntegerZero, GetIntegerOne, BuildAddAddress, BuildIfInRangeGoto, BuildIfNotInRangeGoto ; -FROM m2tree IMPORT Tree, debug_tree, skip_const_decl ; -FROM m2linemap IMPORT location_t ; +FROM m2tree IMPORT debug_tree, skip_const_decl ; +FROM gcctypes IMPORT location_t, tree ; FROM m2decl IMPORT BuildStringConstant, BuildCStringConstant, DeclareKnownConstant, GetBitsPerBitset, @@ -673,7 +673,7 @@ END ResolveConstantExpressions ; constant representing the storage size in bytes. *) -PROCEDURE FindSize (tokenno: CARDINAL; sym: CARDINAL) : Tree ; +PROCEDURE FindSize (tokenno: CARDINAL; sym: CARDINAL) : tree ; VAR location: location_t ; BEGIN @@ -728,7 +728,7 @@ END FindType ; BuildTreeFromInterface - generates a GCC tree from an interface definition. *) -PROCEDURE BuildTreeFromInterface (sym: CARDINAL) : Tree ; +PROCEDURE BuildTreeFromInterface (sym: CARDINAL) : tree ; CONST DebugTokPos = FALSE ; VAR @@ -738,9 +738,9 @@ VAR str, obj : CARDINAL ; gccName, - tree : Tree ; + asmTree : tree ; BEGIN - tree := Tree (NIL) ; + asmTree := tree (NIL) ; IF sym#NulSym THEN i := 1 ; @@ -757,8 +757,8 @@ BEGIN ELSE gccName := BuildCStringConstant (KeyToCharStar (name), LengthKey (name)) END ; - tree := ChainOnParamValue (tree, gccName, PromoteToCString (tok, str), - skip_const_decl (Mod2Gcc (obj))) ; + asmTree := ChainOnParamValue (asmTree, gccName, PromoteToCString (tok, str), + skip_const_decl (Mod2Gcc (obj))) ; IF DebugTokPos THEN WarnStringAt (InitString ('input expression'), tok) @@ -772,7 +772,7 @@ BEGIN INC(i) UNTIL (str = NulSym) AND (obj = NulSym) ; END ; - RETURN tree + RETURN asmTree END BuildTreeFromInterface ; @@ -780,18 +780,18 @@ END BuildTreeFromInterface ; BuildTrashTreeFromInterface - generates a GCC string tree from an interface definition. *) -PROCEDURE BuildTrashTreeFromInterface (sym: CARDINAL) : Tree ; +PROCEDURE BuildTrashTreeFromInterface (sym: CARDINAL) : tree ; CONST DebugTokPos = FALSE ; VAR - tok : CARDINAL ; - i : CARDINAL ; + tok : CARDINAL ; + i : CARDINAL ; str, - obj : CARDINAL ; - name: Name ; - tree: Tree ; + obj : CARDINAL ; + name : Name ; + asmTree: tree ; BEGIN - tree := Tree (NIL) ; + asmTree := tree (NIL) ; IF sym # NulSym THEN i := 1 ; @@ -801,7 +801,7 @@ BEGIN THEN IF IsConstString (str) THEN - tree := AddStringToTreeList (tree, PromoteToCString (tok, str)) ; + asmTree := AddStringToTreeList (asmTree, PromoteToCString (tok, str)) ; IF DebugTokPos THEN WarnStringAt (InitString ('trash expression'), tok) @@ -821,7 +821,7 @@ BEGIN INC (i) UNTIL (str = NulSym) AND (obj = NulSym) END ; - RETURN tree + RETURN asmTree END BuildTrashTreeFromInterface ; @@ -843,7 +843,7 @@ VAR inputs, outputs, trash, - labels : Tree ; + labels : tree ; location : location_t ; BEGIN GetQuadOtok (quad, asmpos, op, op1, op2, GnuAsm, @@ -902,7 +902,7 @@ END FoldRange ; PROCEDURE CodeSaveException (des, exceptionProcedure: CARDINAL) ; VAR - functValue: Tree ; + functValue: tree ; location : location_t; BEGIN location := TokenToLocation (CurrentQuadToken) ; @@ -921,7 +921,7 @@ END CodeSaveException ; PROCEDURE CodeRestoreException (des, exceptionProcedure: CARDINAL) ; VAR - functValue: Tree ; + functValue: tree ; location : location_t; BEGIN location := TokenToLocation (CurrentQuadToken) ; @@ -1228,7 +1228,7 @@ END CodeFinallyEnd ; GetAddressOfUnbounded - returns the address of the unbounded array contents. *) -PROCEDURE GetAddressOfUnbounded (location: location_t; param: CARDINAL) : Tree ; +PROCEDURE GetAddressOfUnbounded (location: location_t; param: CARDINAL) : tree ; VAR UnboundedType: CARDINAL ; BEGIN @@ -1247,12 +1247,12 @@ END GetAddressOfUnbounded ; param.HIGH. *) -PROCEDURE GetHighFromUnbounded (location: location_t; dim, param: CARDINAL) : Tree ; +PROCEDURE GetHighFromUnbounded (location: location_t; dim, param: CARDINAL) : tree ; VAR UnboundedType, ArrayType, HighField : CARDINAL ; - HighTree : Tree ; + HighTree : tree ; accessibleDim: CARDINAL ; (* remainingDim : CARDINAL ; *) BEGIN @@ -1296,9 +1296,9 @@ END GetHighFromUnbounded ; occupies. *) -PROCEDURE GetSizeOfHighFromUnbounded (tokenno: CARDINAL; param: CARDINAL) : Tree ; +PROCEDURE GetSizeOfHighFromUnbounded (tokenno: CARDINAL; param: CARDINAL) : tree ; VAR - t : Tree ; + t : tree ; UnboundedType, ArrayType : CARDINAL ; i, n : CARDINAL ; @@ -1338,11 +1338,11 @@ END GetSizeOfHighFromUnbounded ; else call Builtins.alloca. *) -PROCEDURE MaybeDebugBuiltinAlloca (location: location_t; tok: CARDINAL; high: Tree) : Tree ; +PROCEDURE MaybeDebugBuiltinAlloca (location: location_t; tok: CARDINAL; high: tree) : tree ; VAR call, memptr, - func : Tree ; + func : tree ; BEGIN IF DebugBuiltins THEN @@ -1368,10 +1368,10 @@ END MaybeDebugBuiltinAlloca ; else call Builtins.memcpy. *) -PROCEDURE MaybeDebugBuiltinMemcpy (location: location_t; src, dest, nbytes: Tree) : Tree ; +PROCEDURE MaybeDebugBuiltinMemcpy (location: location_t; src, dest, nbytes: tree) : tree ; VAR call, - func: Tree ; + func: tree ; BEGIN IF DebugBuiltins THEN @@ -1405,7 +1405,7 @@ VAR UnboundedType: CARDINAL ; Addr, High, - NewArray : Tree ; + NewArray : tree ; BEGIN location := TokenToLocation (tokenno) ; UnboundedType := GetType (param) ; @@ -1431,7 +1431,7 @@ END MakeCopyUse ; GetParamAddress - returns the address of parameter, param. *) -PROCEDURE GetParamAddress (location: location_t; proc, param: CARDINAL) : Tree ; +PROCEDURE GetParamAddress (location: location_t; proc, param: CARDINAL) : tree ; VAR sym, type: CARDINAL ; @@ -1496,7 +1496,7 @@ END IsUnboundedWrittenTo ; GetParamSize - returns the size in bytes of, param. *) -PROCEDURE GetParamSize (tokenno: CARDINAL; param: CARDINAL) : Tree ; +PROCEDURE GetParamSize (tokenno: CARDINAL; param: CARDINAL) : tree ; BEGIN Assert(IsVar(param) OR IsParameter(param)) ; IF IsUnbounded(param) @@ -1513,7 +1513,7 @@ END GetParamSize ; else jump to, fLabel. *) -PROCEDURE DoIsIntersection (tokenno: CARDINAL; ta, tb, tc, td: Tree; tLabel, fLabel: String) ; +PROCEDURE DoIsIntersection (tokenno: CARDINAL; ta, tb, tc, td: tree; tLabel, fLabel: String) ; VAR location: location_t ; BEGIN @@ -1549,7 +1549,7 @@ PROCEDURE BuildCascadedIfThenElsif (tokenno: CARDINAL; proc, param: CARDINAL) ; VAR ta, tb, - tc, td : Tree ; + tc, td : tree ; n, j : CARDINAL ; tLabel, fLabel, @@ -1852,7 +1852,7 @@ END CodeNewLocalVar ; PROCEDURE CodeKillLocalVar (CurrentProcedure: CARDINAL) ; VAR begin, end: CARDINAL ; - proc : Tree ; + proc : tree ; BEGIN GetProcedureBeginEnd (CurrentProcedure, begin, end) ; CurrentQuadToken := end ; @@ -1907,7 +1907,7 @@ VAR expr, none, procedure : CARDINAL ; combinedpos, returnpos, exprpos, nonepos, procpos: CARDINAL ; - value, length : Tree ; + value, length : tree ; location : location_t ; BEGIN GetQuadOtok (quad, returnpos, op, expr, none, procedure, @@ -1942,17 +1942,17 @@ END CodeReturnValue ; PROCEDURE CodeCall (tokenno: CARDINAL; procedure: CARDINAL) ; VAR - tree : Tree ; + callTree: tree ; location: location_t ; BEGIN IF IsProcedure (procedure) THEN DeclareParameters (procedure) ; - tree := CodeDirectCall (tokenno, procedure) + callTree := CodeDirectCall (tokenno, procedure) ELSIF IsProcType (SkipType (GetType (procedure))) THEN DeclareParameters (SkipType (GetType (procedure))) ; - tree := CodeIndirectCall (tokenno, procedure) ; + callTree := CodeIndirectCall (tokenno, procedure) ; procedure := SkipType (GetType (procedure)) ELSE InternalError ('expecting Procedure or ProcType') @@ -1960,7 +1960,7 @@ BEGIN IF GetType (procedure) = NulSym THEN location := TokenToLocation (tokenno) ; - AddStatement (location, tree) + AddStatement (location, callTree) ELSE (* leave tree alone - as it will be picked up when processing FunctValue *) END @@ -1973,7 +1973,7 @@ END CodeCall ; CanUseBuiltin or IsProcedureBuiltinAvailable returns TRUE. *) -PROCEDURE UseBuiltin (tokenno: CARDINAL; Sym: CARDINAL) : Tree ; +PROCEDURE UseBuiltin (tokenno: CARDINAL; Sym: CARDINAL) : tree ; BEGIN IF BuiltinExists(KeyToCharStar(GetProcedureBuiltin(Sym))) THEN @@ -1988,10 +1988,10 @@ END UseBuiltin ; CodeDirectCall - calls a function/procedure. *) -PROCEDURE CodeDirectCall (tokenno: CARDINAL; procedure: CARDINAL) : Tree ; +PROCEDURE CodeDirectCall (tokenno: CARDINAL; procedure: CARDINAL) : tree ; VAR location: location_t ; - call : Tree ; + call : tree ; BEGIN location := TokenToLocation (tokenno) ; IF IsProcedureBuiltinAvailable (procedure) @@ -1999,7 +1999,7 @@ BEGIN call := UseBuiltin (tokenno, procedure) ; IF call # NIL THEN - call := BuildBuiltinCallTree (location, call) + call := BuildBuiltinCallTree (call) END ELSE call := NIL @@ -2027,9 +2027,9 @@ END CodeDirectCall ; CodeIndirectCall - calls a function/procedure indirectly. *) -PROCEDURE CodeIndirectCall (tokenno: CARDINAL; ProcVar: CARDINAL) : Tree ; +PROCEDURE CodeIndirectCall (tokenno: CARDINAL; ProcVar: CARDINAL) : tree ; VAR - ReturnType: Tree ; + ReturnType: tree ; proc : CARDINAL ; location : location_t ; BEGIN @@ -2037,9 +2037,9 @@ BEGIN proc := SkipType(GetType(ProcVar)) ; IF GetType(proc)=NulSym THEN - ReturnType := Tree(NIL) + ReturnType := tree(NIL) ELSE - ReturnType := Tree(Mod2Gcc(GetType(proc))) + ReturnType := tree(Mod2Gcc(GetType(proc))) END ; (* now we dereference the lvalue if necessary *) @@ -2060,7 +2060,7 @@ END CodeIndirectCall ; then convert the string into a character constant. *) -PROCEDURE StringToChar (t: Tree; type, str: CARDINAL) : Tree ; +PROCEDURE StringToChar (t: tree; type, str: CARDINAL) : tree ; VAR s: String ; n: Name ; @@ -2099,7 +2099,7 @@ END StringToChar ; a symbol of, type. *) -PROCEDURE ConvertTo (t: Tree; type, op3: CARDINAL) : Tree ; +PROCEDURE ConvertTo (t: tree; type, op3: CARDINAL) : tree ; BEGIN IF SkipType(type)#SkipType(GetType(op3)) THEN @@ -2121,7 +2121,7 @@ END ConvertTo ; first and then the remaining types. *) -PROCEDURE ConvertRHS (t: Tree; type, rhs: CARDINAL) : Tree ; +PROCEDURE ConvertRHS (t: tree; type, rhs: CARDINAL) : tree ; BEGIN t := StringToChar (Mod2Gcc (rhs), type, rhs) ; RETURN ConvertTo (t, type, rhs) @@ -2168,7 +2168,7 @@ END IsConstant ; CheckConvertCoerceParameter - *) -PROCEDURE CheckConvertCoerceParameter (tokenno: CARDINAL; op1, op2, op3: CARDINAL) : Tree ; +PROCEDURE CheckConvertCoerceParameter (tokenno: CARDINAL; op1, op2, op3: CARDINAL) : tree ; VAR OperandType, ParamType : CARDINAL ; @@ -2221,7 +2221,7 @@ END CheckConvertCoerceParameter ; CheckConstant - checks to see whether we should declare the constant. *) -PROCEDURE CheckConstant (tokenno: CARDINAL; des, expr: CARDINAL) : Tree ; +PROCEDURE CheckConstant (tokenno: CARDINAL; des, expr: CARDINAL) : tree ; VAR location: location_t ; BEGIN @@ -2249,7 +2249,7 @@ VAR max, tmp, res, - val : Tree ; + val : tree ; location: location_t ; BEGIN location := TokenToLocation (CurrentQuadToken) ; @@ -2334,7 +2334,7 @@ VAR bits, max, tmp, - val : Tree ; + val : tree ; location: location_t ; BEGIN location := TokenToLocation (tokenno) ; @@ -2427,7 +2427,7 @@ VAR op1, op2, op3 : CARDINAL ; op : QuadOperator ; - val, call : Tree ; + val, call : tree ; location : location_t ; BEGIN GetQuad (q, op, op1, op2, op3) ; @@ -2571,13 +2571,13 @@ END CodeParam ; Replace - replace the entry for sym in the double entry bookkeeping with sym/tree. *) -PROCEDURE Replace (sym: CARDINAL; tree: Tree) ; +PROCEDURE Replace (sym: CARDINAL; gcc: tree) ; BEGIN IF GccKnowsAbout (sym) THEN RemoveMod2Gcc (sym) END ; - AddModGcc (sym, tree) + AddModGcc (sym, gcc) END Replace ; @@ -2589,7 +2589,7 @@ END Replace ; PROCEDURE CodeFunctValue (location: location_t; op1: CARDINAL) ; VAR call, - value: Tree ; + value: tree ; BEGIN (* operator : FunctValueOp @@ -2710,7 +2710,7 @@ END FoldStringConvertCnul ; PROCEDURE CodeAddr (tokenno: CARDINAL; quad: CARDINAL; op1, op3: CARDINAL) ; VAR - value : Tree ; + value : tree ; type : CARDINAL ; location: location_t ; BEGIN @@ -2973,9 +2973,9 @@ END PerformFoldBecomes ; VAR - tryBlock: Tree ; (* this must be placed into gccgm2 and it must follow the + tryBlock: tree ; (* this must be placed into gccgm2 and it must follow the current function scope - ie it needs work with nested procedures *) - handlerBlock: Tree ; + handlerBlock: tree ; (* @@ -3003,7 +3003,7 @@ BEGIN location := TokenToLocation (CurrentQuadToken) ; IF value = NulSym THEN - AddStatement (location, BuildThrow (location, Tree (NIL))) + AddStatement (location, BuildThrow (location, tree (NIL))) ELSE DeclareConstant (CurrentQuadToken, value) ; (* checks to see whether it is a constant and declares it *) AddStatement (location, BuildThrow (location, BuildConvert (location, @@ -3061,7 +3061,7 @@ END DescribeTypeError ; typed constants. *) -PROCEDURE DefaultConvertGM2 (sym: CARDINAL) : Tree ; +PROCEDURE DefaultConvertGM2 (sym: CARDINAL) : tree ; BEGIN sym := SkipType (sym) ; IF sym=Bitset @@ -3080,9 +3080,9 @@ END DefaultConvertGM2 ; *) PROCEDURE FoldConstBecomes (tokenno: CARDINAL; - op1, op3: CARDINAL) : Tree ; + op1, op3: CARDINAL) : tree ; VAR - t, type : Tree ; + t, type : tree ; location: location_t ; BEGIN IF IsConstSet(op3) OR ((SkipType(GetType(op3))#NulSym) AND @@ -3144,7 +3144,7 @@ END FoldConstBecomes ; which fits in dest. *) -PROCEDURE PrepareCopyString (tokenno: CARDINAL; VAR length, srcTree: Tree; +PROCEDURE PrepareCopyString (tokenno: CARDINAL; VAR length, srcTree: tree; src, destStrType: CARDINAL) : BOOLEAN ; VAR location : location_t ; @@ -3216,7 +3216,7 @@ END PrepareCopyString ; PROCEDURE checkArrayElements (des, expr: CARDINAL; virtpos, despos, exprpos: CARDINAL) : BOOLEAN ; VAR - e1, e3: Tree ; + e1, e3: tree ; t1, t3: CARDINAL ; BEGIN t1 := GetType (des) ; @@ -3383,7 +3383,7 @@ VAR op2pos, exprpos : CARDINAL ; length, - exprt : Tree ; + exprt : tree ; location : location_t ; BEGIN GetQuadOtok (quad, becomespos, op, des, op2, expr, @@ -3463,9 +3463,9 @@ END CodeBecomes ; It coerces a lvalue into an internal pointer type *) -PROCEDURE LValueToGenericPtr (location: location_t; sym: CARDINAL) : Tree ; +PROCEDURE LValueToGenericPtr (location: location_t; sym: CARDINAL) : tree ; VAR - t: Tree ; + t: tree ; BEGIN t := Mod2Gcc (sym) ; IF t = NIL @@ -3485,9 +3485,9 @@ END LValueToGenericPtr ; else convert to type, type. Return the converted tree. *) -PROCEDURE LValueToGenericPtrOrConvert (sym: CARDINAL; type: Tree) : Tree ; +PROCEDURE LValueToGenericPtrOrConvert (sym: CARDINAL; type: tree) : tree ; VAR - n : Tree ; + n : tree ; location: location_t ; BEGIN n := Mod2Gcc (sym) ; @@ -3511,7 +3511,7 @@ END LValueToGenericPtrOrConvert ; coerces, t, appropriately. *) -PROCEDURE ZConstToTypedConst (t: Tree; op1, op2: CARDINAL) : Tree ; +PROCEDURE ZConstToTypedConst (t: tree; op1, op2: CARDINAL) : tree ; VAR location: location_t ; BEGIN @@ -3554,7 +3554,7 @@ END ZConstToTypedConst ; PROCEDURE FoldBinary (tokenno: CARDINAL; p: WalkAction; binop: BuildBinProcedure; quad: CARDINAL; op1, op2, op3: CARDINAL) ; VAR - tl, tr, tv, resType: Tree ; + tl, tr, tv, resType: tree ; location : location_t ; BEGIN (* firstly ensure that constant literals are declared *) @@ -3606,7 +3606,7 @@ END FoldBinary ; ConvertBinaryOperands - *) -PROCEDURE ConvertBinaryOperands (location: location_t; VAR tl, tr: Tree; type, op2, op3: CARDINAL) ; +PROCEDURE ConvertBinaryOperands (location: location_t; VAR tl, tr: tree; type, op2, op3: CARDINAL) ; BEGIN tl := NIL ; tr := NIL ; @@ -3651,7 +3651,7 @@ VAR min, max, lowest, tv, - tl, tr : Tree ; + tl, tr : tree ; location : location_t ; BEGIN (* firstly ensure that constant literals are declared. *) @@ -3721,7 +3721,7 @@ VAR op3pos, type : CARDINAL ; tv, - tl, tr : Tree ; + tl, tr : tree ; location: location_t ; BEGIN (* firstly ensure that constant literals are declared *) @@ -4638,7 +4638,7 @@ END CodeModFloor ; PROCEDURE FoldBuiltinConst (tokenno: CARDINAL; p: WalkAction; quad: CARDINAL; result, constDesc: CARDINAL) ; VAR - value: Tree ; + value: tree ; BEGIN value := GetBuiltinConst (KeyToCharStar (Name (constDesc))) ; IF value = NIL @@ -4660,7 +4660,7 @@ END FoldBuiltinConst ; PROCEDURE FoldBuiltinTypeInfo (tokenno: CARDINAL; p: WalkAction; quad: CARDINAL; op1, op2, op3: CARDINAL) ; VAR - t : Tree ; + t : tree ; location: location_t ; BEGIN IF GccKnowsAbout(op2) AND CompletelyResolved(op2) @@ -4919,7 +4919,7 @@ END CodeStandardFunction ; PROCEDURE CodeSavePriority (oldValue, scopeSym, procedureSym: CARDINAL) ; VAR - funcTree: Tree ; + funcTree: tree ; mod : CARDINAL ; n : Name ; location: location_t ; @@ -4963,7 +4963,7 @@ END CodeSavePriority ; PROCEDURE CodeRestorePriority (oldValue, scopeSym, procedureSym: CARDINAL) ; VAR - funcTree: Tree ; + funcTree: tree ; mod : CARDINAL ; n : Name ; location: location_t ; @@ -5104,7 +5104,7 @@ VAR unbounded, leftproc, rightproc, - varproc : Tree ; + varproc : tree ; location : location_t ; BEGIN (* firstly ensure that constant literals are declared *) @@ -5608,7 +5608,7 @@ END GetSetLimits ; GetFieldNo - returns the field number in the, set, which contains, element. *) -PROCEDURE GetFieldNo (tokenno: CARDINAL; element: CARDINAL; set: CARDINAL; VAR offset: Tree) : INTEGER ; +PROCEDURE GetFieldNo (tokenno: CARDINAL; element: CARDINAL; set: CARDINAL; VAR offset: tree) : INTEGER ; VAR low, high, bpw, c: CARDINAL ; location : location_t ; @@ -5673,7 +5673,7 @@ PROCEDURE CodeIncl (result, expr: CARDINAL) ; VAR low, high : CARDINAL ; - offset : Tree ; + offset : tree ; fieldno : INTEGER ; location: location_t ; BEGIN @@ -5750,7 +5750,7 @@ PROCEDURE CodeExcl (result, expr: CARDINAL) ; VAR low, high : CARDINAL ; - offset : Tree ; + offset : tree ; fieldno : INTEGER ; location: location_t ; BEGIN @@ -5792,10 +5792,10 @@ END CodeExcl ; *) PROCEDURE FoldUnary (tokenno: CARDINAL; p: WalkAction; - unop: BuildUnaryProcedure; ZConstToTypedConst: Tree; + unop: BuildUnaryProcedure; ZConstToTypedConst: tree; quad: CARDINAL; result, expr: CARDINAL) ; VAR - tv : Tree ; + tv : tree ; location: location_t ; BEGIN (* firstly ensure that any constant literal is declared *) @@ -5809,7 +5809,7 @@ BEGIN (* fine, we can take advantage of this and fold constants *) IF IsConst (result) THEN - IF ZConstToTypedConst = Tree(NIL) + IF ZConstToTypedConst = tree(NIL) THEN IF (GetType (expr) = NulSym) OR IsOrdinalType (SkipType (GetType (expr))) THEN @@ -5884,13 +5884,13 @@ END FoldUnarySet ; CodeUnaryCheck - encode a unary arithmetic operation. *) -PROCEDURE CodeUnaryCheck (unop: BuildUnaryCheckProcedure; ZConstToTypedConst: Tree; +PROCEDURE CodeUnaryCheck (unop: BuildUnaryCheckProcedure; ZConstToTypedConst: tree; quad: CARDINAL; result, expr: CARDINAL) ; VAR lowestType: CARDINAL ; min, max, lowest, - tv : Tree ; + tv : tree ; location : location_t ; BEGIN (* firstly ensure that any constant literal is declared *) @@ -5914,9 +5914,9 @@ BEGIN CheckOrResetOverflow (CurrentQuadToken, tv, MustCheckOverflow(quad)) ; IF IsConst (result) THEN - IF ZConstToTypedConst = Tree (NIL) + IF ZConstToTypedConst = tree (NIL) THEN - ZConstToTypedConst := Tree (Mod2Gcc( GetType (expr))) + ZConstToTypedConst := tree (Mod2Gcc( GetType (expr))) END ; (* still have a constant which was not resolved, pass it to gcc *) PutConst (result, FindType (expr)) ; @@ -5936,10 +5936,10 @@ END CodeUnaryCheck ; CodeUnary - encode a unary arithmetic operation. *) -PROCEDURE CodeUnary (unop: BuildUnaryProcedure; ZConstToTypedConst: Tree; +PROCEDURE CodeUnary (unop: BuildUnaryProcedure; ZConstToTypedConst: tree; quad: CARDINAL; result, expr: CARDINAL) ; VAR - tv : Tree ; + tv : tree ; location: location_t ; BEGIN (* firstly ensure that any constant literal is declared *) @@ -5951,9 +5951,9 @@ BEGIN CheckOrResetOverflow (CurrentQuadToken, tv, MustCheckOverflow (quad)) ; IF IsConst(result) THEN - IF ZConstToTypedConst=Tree(NIL) + IF ZConstToTypedConst=tree(NIL) THEN - ZConstToTypedConst := Tree(Mod2Gcc(GetType(expr))) + ZConstToTypedConst := tree(Mod2Gcc(GetType(expr))) END ; (* still have a constant which was not resolved, pass it to gcc *) PutConst (result, FindType (expr)) ; @@ -6014,7 +6014,7 @@ END CodeNegateChecked ; PROCEDURE FoldSize (tokenno: CARDINAL; p: WalkAction; quad: CARDINAL; op1, op2, op3: CARDINAL) ; VAR - t : Tree ; + t : tree ; location: location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -6083,7 +6083,7 @@ PROCEDURE FoldRecordField (tokenno: CARDINAL; p: WalkAction; VAR recordType, fieldType : CARDINAL ; - ptr : Tree ; + ptr : tree ; location : location_t ; BEGIN RETURN ; (* this procedure should no longer be called *) @@ -6131,7 +6131,7 @@ PROCEDURE CodeRecordField (result, record, field: CARDINAL) ; VAR recordType, fieldType : CARDINAL ; - ptr : Tree ; + ptr : tree ; location : location_t ; BEGIN location := TokenToLocation (CurrentQuadToken) ; @@ -6166,7 +6166,7 @@ END CodeRecordField ; BuildHighFromChar - *) -PROCEDURE BuildHighFromChar (operand: CARDINAL) : Tree ; +PROCEDURE BuildHighFromChar (operand: CARDINAL) : tree ; VAR location: location_t ; BEGIN @@ -6204,7 +6204,7 @@ END SkipToArray ; BuildHighFromArray - *) -PROCEDURE BuildHighFromArray (tokenno: CARDINAL; dim, operand: CARDINAL) : Tree ; +PROCEDURE BuildHighFromArray (tokenno: CARDINAL; dim, operand: CARDINAL) : tree ; VAR Type : CARDINAL ; location: location_t ; @@ -6219,7 +6219,7 @@ END BuildHighFromArray ; BuildHighFromStaticArray - *) -PROCEDURE BuildHighFromStaticArray (location: location_t; (* dim, *) Type: CARDINAL) : Tree ; +PROCEDURE BuildHighFromStaticArray (location: location_t; (* dim, *) Type: CARDINAL) : tree ; VAR High, Low: CARDINAL ; Subscript, @@ -6233,7 +6233,7 @@ BEGIN GetBaseTypeMinMax (Subrange, Low, High) ; IF GccKnowsAbout (High) THEN - RETURN Tree (Mod2Gcc (High)) + RETURN tree (Mod2Gcc (High)) END ELSIF IsSubrange(Subrange) THEN @@ -6244,13 +6244,13 @@ BEGIN END ELSE MetaError1 ('array subscript {%1EDad:for} must be a subrange or enumeration type', Type) ; - RETURN Tree(NIL) + RETURN tree(NIL) END ; IF GccKnowsAbout (High) THEN - RETURN Tree (Mod2Gcc (High)) + RETURN tree (Mod2Gcc (High)) ELSE - RETURN Tree (NIL) + RETURN tree (NIL) END END BuildHighFromStaticArray ; @@ -6259,7 +6259,7 @@ END BuildHighFromStaticArray ; BuildHighFromString - *) -PROCEDURE BuildHighFromString (operand: CARDINAL) : Tree ; +PROCEDURE BuildHighFromString (operand: CARDINAL) : tree ; VAR location: location_t ; BEGIN @@ -6279,7 +6279,7 @@ END BuildHighFromString ; HIGH(operand). *) -PROCEDURE ResolveHigh (tokenno: CARDINAL; dim, operand: CARDINAL) : Tree ; +PROCEDURE ResolveHigh (tokenno: CARDINAL; dim, operand: CARDINAL) : tree ; VAR Type : CARDINAL ; location: location_t ; @@ -6317,7 +6317,7 @@ END ResolveHigh ; PROCEDURE FoldHigh (tokenno: CARDINAL; p: WalkAction; quad: CARDINAL; op1, dim, op3: CARDINAL) ; VAR - t : Tree ; + t : tree ; location: location_t ; BEGIN (* firstly ensure that any constant literal is declared *) @@ -6327,7 +6327,7 @@ BEGIN THEN t := ResolveHigh(tokenno, dim, op3) ; (* fine, we can take advantage of this and fold constants *) - IF IsConst(op1) AND (t#Tree(NIL)) + IF IsConst(op1) AND (t#tree(NIL)) THEN PutConst(op1, Cardinal) ; AddModGcc(op1, @@ -6382,7 +6382,7 @@ END CodeHigh ; PROCEDURE CodeUnbounded (result, array: CARDINAL) ; VAR - Addr : Tree ; + Addr : tree ; location: location_t ; BEGIN location := TokenToLocation (CurrentQuadToken) ; @@ -6452,7 +6452,7 @@ VAR low, subscript : CARDINAL ; a, ta, - ti, tl : Tree ; + ti, tl : tree ; location : location_t ; BEGIN location := TokenToLocation (CurrentQuadToken) ; @@ -6604,7 +6604,7 @@ END FoldElementSize ; PopKindTree - returns a Tree from M2ALU of the type implied by, op. *) -PROCEDURE PopKindTree (op: CARDINAL; tokenno: CARDINAL) : Tree ; +PROCEDURE PopKindTree (op: CARDINAL; tokenno: CARDINAL) : tree ; VAR type: CARDINAL ; BEGIN @@ -6632,7 +6632,7 @@ PROCEDURE FoldConvert (tokenno: CARDINAL; p: WalkAction; quad: CARDINAL; op1, op2, op3: CARDINAL) ; VAR - tl : Tree ; + tl : tree ; location: location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -6712,7 +6712,7 @@ END FoldConvert ; PROCEDURE CodeConvert (quad: CARDINAL; lhs, type, rhs: CARDINAL) ; VAR - tl, tr : Tree ; + tl, tr : tree ; location: location_t ; BEGIN CheckStop(quad) ; @@ -7053,7 +7053,7 @@ END CodeIfSetLess ; PROCEDURE PerformCodeIfLess (quad: CARDINAL) ; VAR - tl, tr : Tree ; + tl, tr : tree ; location : location_t ; left, right, dest, combined, leftpos, rightpos, destpos : CARDINAL ; @@ -7166,7 +7166,7 @@ END CodeIfSetGre ; PROCEDURE PerformCodeIfGre (quad: CARDINAL) ; VAR - tl, tr : Tree ; + tl, tr : tree ; location : location_t ; left, right, dest, combined, leftpos, rightpos, destpos : CARDINAL ; @@ -7276,7 +7276,7 @@ END CodeIfSetLessEqu ; PROCEDURE PerformCodeIfLessEqu (quad: CARDINAL) ; VAR - tl, tr : Tree ; + tl, tr : tree ; location : location_t ; left, right, dest, combined, leftpos, rightpos, destpos : CARDINAL ; @@ -7388,7 +7388,7 @@ END CodeIfSetGreEqu ; PROCEDURE PerformCodeIfGreEqu (quad: CARDINAL) ; VAR - tl, tr: Tree ; + tl, tr: tree ; location : location_t ; left, right, dest, combined, leftpos, rightpos, destpos : CARDINAL ; @@ -7575,7 +7575,7 @@ END ComparisonMixTypes ; PROCEDURE PerformCodeIfEqu (quad: CARDINAL) ; VAR - tl, tr : Tree ; + tl, tr : tree ; location : location_t ; left, right, dest, combined, leftpos, rightpos, destpos : CARDINAL ; @@ -7627,7 +7627,7 @@ END PerformCodeIfEqu ; PROCEDURE PerformCodeIfNotEqu (quad: CARDINAL) ; VAR - tl, tr : Tree ; + tl, tr : tree ; location : location_t ; left, right, dest, combined, leftpos, rightpos, destpos : CARDINAL ; @@ -7760,7 +7760,7 @@ END MixTypes3 ; PROCEDURE BuildIfVarInConstValue (location: location_t; tokenno: CARDINAL; constsetvalue: PtrToValue; var, trueexit: CARDINAL) ; VAR - vt, lt, ht : Tree ; + vt, lt, ht : tree ; type, low, high, n: CARDINAL ; truelabel : String ; @@ -7783,7 +7783,7 @@ END BuildIfVarInConstValue ; PROCEDURE BuildIfNotVarInConstValue (quad: CARDINAL; constsetvalue: PtrToValue; var, trueexit: CARDINAL) ; VAR - vt, lt, ht : Tree ; + vt, lt, ht : tree ; type, low, high, n: CARDINAL ; falselabel, @@ -7830,7 +7830,7 @@ VAR high : CARDINAL ; lowtree, hightree, - offset : Tree ; + offset : tree ; fieldno : INTEGER ; location : location_t ; left, right, dest, combined, @@ -7900,7 +7900,7 @@ VAR high : CARDINAL ; lowtree, hightree, - offset : Tree ; + offset : tree ; fieldno : INTEGER ; location : location_t ; left, right, dest, combined, @@ -8039,7 +8039,7 @@ VAR typepos, xindrpos : CARDINAL ; length, - newstr : Tree ; + newstr : tree ; location : location_t ; BEGIN GetQuadOtok (quad, xindrpos, op, left, type, right, diff --git a/gcc/m2/gm2-compiler/M2LangDump.def b/gcc/m2/gm2-compiler/M2LangDump.def index 5d4c9b600a10..d8b049430e5d 100644 --- a/gcc/m2/gm2-compiler/M2LangDump.def +++ b/gcc/m2/gm2-compiler/M2LangDump.def @@ -21,7 +21,7 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE M2LangDump ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM DynamicStrings IMPORT String ; FROM FIO IMPORT File ; @@ -31,7 +31,7 @@ FROM FIO IMPORT File ; If no filter is specified it will always return default. *) -PROCEDURE IsDumpRequiredTree (tree: Tree; default: BOOLEAN) : BOOLEAN ; +PROCEDURE IsDumpRequiredTree (gcctree: tree; default: BOOLEAN) : BOOLEAN ; (* diff --git a/gcc/m2/gm2-compiler/M2LangDump.mod b/gcc/m2/gm2-compiler/M2LangDump.mod index 2ce77a03d143..72f5d66fcaad 100644 --- a/gcc/m2/gm2-compiler/M2LangDump.mod +++ b/gcc/m2/gm2-compiler/M2LangDump.mod @@ -511,11 +511,11 @@ END GetDumpFile ; IsDumpRequiredTree - return TRUE if the gcc tree should be dumped. *) -PROCEDURE IsDumpRequiredTree (tree: Tree; default: BOOLEAN) : BOOLEAN ; +PROCEDURE IsDumpRequiredTree (gcctree: tree; default: BOOLEAN) : BOOLEAN ; VAR sym: CARDINAL ; BEGIN - sym := Gcc2Mod (tree) ; + sym := Gcc2Mod (gcctree) ; IF sym = NulSym THEN RETURN default diff --git a/gcc/m2/gm2-compiler/M2LexBuf.def b/gcc/m2/gm2-compiler/M2LexBuf.def index 07f5934a6311..19e261e83cbc 100644 --- a/gcc/m2/gm2-compiler/M2LexBuf.def +++ b/gcc/m2/gm2-compiler/M2LexBuf.def @@ -32,7 +32,7 @@ DEFINITION MODULE M2LexBuf ; FROM SYSTEM IMPORT ADDRESS ; FROM M2Reserved IMPORT toktype ; FROM DynamicStrings IMPORT String ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; FROM NameKey IMPORT Name ; diff --git a/gcc/m2/gm2-compiler/M2LexBuf.mod b/gcc/m2/gm2-compiler/M2LexBuf.mod index fd2373fa5019..5a0b6086bcb0 100644 --- a/gcc/m2/gm2-compiler/M2LexBuf.mod +++ b/gcc/m2/gm2-compiler/M2LexBuf.mod @@ -35,7 +35,8 @@ FROM M2Printf IMPORT printf0, printf1, printf2, printf3 ; FROM M2Debug IMPORT Assert ; FROM NameKey IMPORT makekey ; FROM NumberIO IMPORT CardToStr ; -FROM m2linemap IMPORT location_t, GetLocationBinary ; +FROM gcctypes IMPORT location_t ; +FROM m2linemap IMPORT GetLocationBinary ; FROM M2Emit IMPORT UnknownLocation, BuiltinsLocation ; FROM M2Error IMPORT WarnStringAt ; FROM M2MetaError IMPORT MetaErrorT0 ; diff --git a/gcc/m2/gm2-compiler/M2Options.def b/gcc/m2/gm2-compiler/M2Options.def index d2d7e68fc353..3ddda3df0522 100644 --- a/gcc/m2/gm2-compiler/M2Options.def +++ b/gcc/m2/gm2-compiler/M2Options.def @@ -32,7 +32,7 @@ DEFINITION MODULE M2Options ; FROM SYSTEM IMPORT ADDRESS ; FROM DynamicStrings IMPORT String ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; VAR diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod index 3b230dc3fd5f..e4ffa362ff33 100644 --- a/gcc/m2/gm2-compiler/M2Options.mod +++ b/gcc/m2/gm2-compiler/M2Options.mod @@ -30,7 +30,7 @@ FROM M2Printf IMPORT printf0, printf1, fprintf1 ; FROM FIO IMPORT StdErr ; FROM libc IMPORT exit, printf ; FROM Debug IMPORT Halt ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; FROM m2configure IMPORT FullPathCPP, TargetIEEEQuadDefault ; FROM M2Error IMPORT InternalError ; FROM FormatStrings IMPORT Sprintf1 ; diff --git a/gcc/m2/gm2-compiler/M2Range.def b/gcc/m2/gm2-compiler/M2Range.def index f8c211566748..c328fd506f85 100644 --- a/gcc/m2/gm2-compiler/M2Range.def +++ b/gcc/m2/gm2-compiler/M2Range.def @@ -38,12 +38,12 @@ DEFINITION MODULE M2Range ; time, post optimization. *) -FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM CDataTypes IMPORT ConstCharStar ; +FROM gcctypes IMPORT location_t, tree ; FROM DynamicStrings IMPORT String ; + (* InitAssignmentRangeCheck - returns a range check node which remembers the information necessary @@ -315,7 +315,7 @@ PROCEDURE FoldRangeCheck (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; CodeErrorCheck - returns a Tree calling the approprate exception handler. *) -PROCEDURE CodeErrorCheck (r: CARDINAL; function, message: String) : Tree ; +PROCEDURE CodeErrorCheck (r: CARDINAL; function, message: String) : tree ; (* @@ -348,51 +348,51 @@ PROCEDURE WriteRangeCheck (r: CARDINAL) ; OverlapsRange - returns TRUE if a1..a2 overlaps with b1..b2. *) -PROCEDURE OverlapsRange (a1, a2, b1, b2: Tree) : BOOLEAN ; +PROCEDURE OverlapsRange (a1, a2, b1, b2: tree) : BOOLEAN ; (* IsEqual - returns TRUE if a=b. *) -PROCEDURE IsEqual (a, b: Tree) : BOOLEAN ; +PROCEDURE IsEqual (a, b: tree) : BOOLEAN ; (* IsGreaterOrEqual - returns TRUE if a>=b. *) -PROCEDURE IsGreaterOrEqual (a, b: Tree) : BOOLEAN ; +PROCEDURE IsGreaterOrEqual (a, b: tree) : BOOLEAN ; (* IsGreater - returns TRUE if a>b. *) -PROCEDURE IsGreater (a, b: Tree) : BOOLEAN ; +PROCEDURE IsGreater (a, b: tree) : BOOLEAN ; (* BuildIfCallWholeHandlerLoc - return a Tree containing a runtime test whether, condition, is true. *) -PROCEDURE BuildIfCallWholeHandlerLoc (location: location_t; condition: Tree; - scope, message: ADDRESS) : Tree ; +PROCEDURE BuildIfCallWholeHandlerLoc (location: location_t; condition: tree; + scope, message: ConstCharStar) : tree ; (* BuildIfCallRealHandlerLoc - return a Tree containing a runtime test whether, condition, is true. *) -PROCEDURE BuildIfCallRealHandlerLoc (location: location_t; condition: Tree; - scope, message: ADDRESS) : Tree ; +PROCEDURE BuildIfCallRealHandlerLoc (location: location_t; condition: tree; + scope, message: ConstCharStar) : tree ; (* GetMinMax - returns TRUE if we know the max and min of a type, t. *) -PROCEDURE GetMinMax (tokenno: CARDINAL; type: CARDINAL; VAR min, max: Tree) : BOOLEAN ; +PROCEDURE GetMinMax (tokenno: CARDINAL; type: CARDINAL; VAR min, max: tree) : BOOLEAN ; END M2Range. diff --git a/gcc/m2/gm2-compiler/M2Range.mod b/gcc/m2/gm2-compiler/M2Range.mod index a8e572eff507..c21bbfa885d1 100644 --- a/gcc/m2/gm2-compiler/M2Range.mod +++ b/gcc/m2/gm2-compiler/M2Range.mod @@ -31,7 +31,9 @@ FROM SymbolTable IMPORT NulSym, GetLowestType, PutReadQuad, RemoveReadQuad, IsParameter, GetDeclaredMod, IsVarParam, GetNthParam, ModeOfAddr ; -FROM m2tree IMPORT Tree, debug_tree ; +FROM SYSTEM IMPORT ADDRESS ; +FROM m2tree IMPORT debug_tree ; + FROM m2linemap IMPORT ErrorAt, GetFilenameFromLocation, GetColumnNoFromLocation, GetLineNoFromLocation ; FROM m2type IMPORT GetMinFrom, GetMaxFrom, @@ -155,7 +157,7 @@ VAR OverlapsRange - returns TRUE if a1..a2 overlaps with b1..b2. *) -PROCEDURE OverlapsRange (a1, a2, b1, b2: Tree) : BOOLEAN ; +PROCEDURE OverlapsRange (a1, a2, b1, b2: tree) : BOOLEAN ; BEGIN (* RETURN( ((a1<=b2) AND (a2>=b1)) ) *) RETURN( (CompareTrees(a1, b2)<=0) AND (CompareTrees(a2, b1)>=0) ) @@ -166,7 +168,7 @@ END OverlapsRange ; IsGreater - returns TRUE if a>b. *) -PROCEDURE IsGreater (a, b: Tree) : BOOLEAN ; +PROCEDURE IsGreater (a, b: tree) : BOOLEAN ; BEGIN RETURN( CompareTrees(a, b)>0 ) END IsGreater ; @@ -176,7 +178,7 @@ END IsGreater ; IsGreaterOrEqual - returns TRUE if a>=b. *) -PROCEDURE IsGreaterOrEqual (a, b: Tree) : BOOLEAN ; +PROCEDURE IsGreaterOrEqual (a, b: tree) : BOOLEAN ; BEGIN RETURN( CompareTrees(a, b)>=0 ) END IsGreaterOrEqual ; @@ -186,7 +188,7 @@ END IsGreaterOrEqual ; IsEqual - returns TRUE if a=b. *) -PROCEDURE IsEqual (a, b: Tree) : BOOLEAN ; +PROCEDURE IsEqual (a, b: tree) : BOOLEAN ; BEGIN RETURN( CompareTrees(a, b)=0 ) END IsEqual ; @@ -1073,7 +1075,7 @@ END FoldNil ; GetMinMax - returns TRUE if we know the max and min of m2type. *) -PROCEDURE GetMinMax (tokenno: CARDINAL; type: CARDINAL; VAR min, max: Tree) : BOOLEAN ; +PROCEDURE GetMinMax (tokenno: CARDINAL; type: CARDINAL; VAR min, max: tree) : BOOLEAN ; VAR minC, maxC: CARDINAL ; location : location_t ; @@ -1119,9 +1121,9 @@ END GetMinMax ; *) PROCEDURE OutOfRange (tokenno: CARDINAL; - min: Tree; + min: tree; expr: CARDINAL; - max: Tree; + max: tree; type: CARDINAL) : BOOLEAN ; BEGIN IF TreeOverflow (min) @@ -1209,7 +1211,7 @@ END HandlerExists ; PROCEDURE FoldAssignment (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice (RangeIndex, r) ; WITH p^ DO @@ -1246,7 +1248,7 @@ END FoldAssignment ; PROCEDURE FoldParameterAssign (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -1281,7 +1283,7 @@ END FoldParameterAssign ; PROCEDURE FoldReturn (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -1313,7 +1315,7 @@ END FoldReturn ; PROCEDURE FoldInc (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - t, min, max: Tree ; + t, min, max: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -1364,7 +1366,7 @@ END FoldInc ; PROCEDURE FoldDec (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - t, min, max: Tree ; + t, min, max: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -1481,7 +1483,7 @@ END CheckSet ; PROCEDURE FoldIncl (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -1519,7 +1521,7 @@ END FoldIncl ; PROCEDURE FoldExcl (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -1560,7 +1562,7 @@ VAR p : Range ; shiftMin, shiftMax, - min, max: Tree ; + min, max: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -1611,7 +1613,7 @@ VAR p : Range ; rotateMin, rotateMax, - min, max : Tree ; + min, max : tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -1937,7 +1939,7 @@ END ForLoopBeginTypeCompatible ; PROCEDURE FoldForLoopBegin (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -1972,7 +1974,7 @@ END FoldForLoopBegin ; PROCEDURE FoldForLoopTo (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -2004,7 +2006,7 @@ END FoldForLoopTo ; PROCEDURE FoldStaticArraySubscript (tokenno: CARDINAL; q: CARDINAL; r: CARDINAL) ; VAR p : Range ; - min, max: Tree ; + min, max: tree ; BEGIN p := GetIndice (RangeIndex, r) ; WITH p^ DO @@ -2327,9 +2329,9 @@ END FoldRangeCheck ; is an LValue. *) -PROCEDURE DeReferenceLValue (tokenno: CARDINAL; expr: CARDINAL) : Tree ; +PROCEDURE DeReferenceLValue (tokenno: CARDINAL; expr: CARDINAL) : tree ; VAR - e : Tree ; + e : tree ; location: location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -2371,13 +2373,13 @@ END BuildStringParamLoc ; CodeErrorCheck - returns a Tree calling the approprate exception handler. *) -PROCEDURE CodeErrorCheck (r: CARDINAL; function, message: String) : Tree ; +PROCEDURE CodeErrorCheck (r: CARDINAL; function, message: String) : tree ; VAR filename: String ; line, column : CARDINAL ; p : Range ; - f : Tree ; + f : tree ; location: location_t ; BEGIN IF HandlerExists (r) @@ -2468,11 +2470,11 @@ END IssueWarning ; *) PROCEDURE CodeErrorCheckLoc (location: location_t; - function, message: ADDRESS; func: CARDINAL) : Tree ; + function, message: ConstCharStar; func: CARDINAL) : tree ; VAR scope, errorMessage: String ; - t : Tree ; + t : tree ; filename : String ; line, column : CARDINAL ; @@ -2518,7 +2520,7 @@ END CodeErrorCheckLoc ; IssueWarningLoc - *) -PROCEDURE IssueWarningLoc (location: location_t; message: ADDRESS) ; +PROCEDURE IssueWarningLoc (location: location_t; message: ConstCharStar) ; VAR s: String ; BEGIN @@ -2533,8 +2535,8 @@ END IssueWarningLoc ; BuildIfCallWholeHandlerLoc - return a Tree containing a runtime test whether, condition, is true. *) -PROCEDURE BuildIfCallWholeHandlerLoc (location: location_t; condition: Tree; - scope, message: ADDRESS) : Tree ; +PROCEDURE BuildIfCallWholeHandlerLoc (location: location_t; condition: tree; + scope, message: ConstCharStar) : tree ; BEGIN RETURN BuildIfCallHandlerLoc (location, condition, scope, message, ExceptionWholeValue) END BuildIfCallWholeHandlerLoc ; @@ -2544,8 +2546,8 @@ END BuildIfCallWholeHandlerLoc ; BuildIfCallRealHandlerLoc - return a Tree containing a runtime test whether, condition, is true. *) -PROCEDURE BuildIfCallRealHandlerLoc (location: location_t; condition: Tree; - scope, message: ADDRESS) : Tree ; +PROCEDURE BuildIfCallRealHandlerLoc (location: location_t; condition: tree; + scope, message: ConstCharStar) : tree ; BEGIN RETURN BuildIfCallHandlerLoc (location, condition, scope, message, ExceptionRealValue) END BuildIfCallRealHandlerLoc ; @@ -2555,8 +2557,8 @@ END BuildIfCallRealHandlerLoc ; BuildIfCallHandlerLoc - return a Tree containing a runtime test whether, condition, is true. *) -PROCEDURE BuildIfCallHandlerLoc (location: location_t; condition: Tree; - scope, message: ADDRESS; func: CARDINAL) : Tree ; +PROCEDURE BuildIfCallHandlerLoc (location: location_t; condition: tree; + scope, message: ConstCharStar; func: CARDINAL) : tree ; BEGIN IF IsTrue (condition) THEN @@ -2570,8 +2572,8 @@ END BuildIfCallHandlerLoc ; BuildIfCallHandler - *) -PROCEDURE BuildIfCallHandler (condition: Tree; r: CARDINAL; - function, message: String; warning: BOOLEAN) : Tree ; +PROCEDURE BuildIfCallHandler (condition: tree; r: CARDINAL; + function, message: String; warning: BOOLEAN) : tree ; BEGIN IF warning AND IsTrue (condition) THEN @@ -2588,7 +2590,7 @@ END BuildIfCallHandler ; PROCEDURE RangeCheckReal (p: Range; r: CARDINAL; function, message: String) ; VAR e, - condition: Tree ; + condition: tree ; location : location_t ; BEGIN WITH p^ DO @@ -2610,7 +2612,7 @@ PROCEDURE RangeCheckOrdinal (p: Range; r: CARDINAL; function, message: String) ; VAR condition, desMin, desMax, - exprMin, exprMax: Tree ; + exprMin, exprMax: tree ; location : location_t ; BEGIN WITH p^ DO @@ -2670,7 +2672,7 @@ PROCEDURE DoCodeAssignmentWithoutExprType (p: Range; r: CARDINAL; function, message: String) ; VAR condition, - desMin, desMax: Tree ; + desMin, desMax: tree ; location : location_t ; BEGIN WITH p^ DO @@ -2762,10 +2764,10 @@ END CodeReturn ; IfOutsideLimitsDo - *) -PROCEDURE IfOutsideLimitsDo (tokenno: CARDINAL; min, expr, max: Tree; r: CARDINAL; +PROCEDURE IfOutsideLimitsDo (tokenno: CARDINAL; min, expr, max: tree; r: CARDINAL; function, message: String) ; VAR - condition: Tree ; + condition: tree ; location : location_t ; BEGIN location := TokenToLocation (tokenno) ; @@ -2786,7 +2788,7 @@ VAR p : Range ; t, condition, e, - desMin, desMax: Tree ; + desMin, desMax: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -2829,7 +2831,7 @@ VAR p : Range ; t, condition, e, - desMin, desMax: Tree ; + desMin, desMax: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -2870,7 +2872,7 @@ PROCEDURE CodeInclExcl (tokenno: CARDINAL; VAR p : Range ; e, - desMin, desMax: Tree ; + desMin, desMax: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -2916,7 +2918,7 @@ VAR p : Range ; e, shiftMin, shiftMax, - desMin, desMax : Tree ; + desMin, desMax : tree ; location : location_t ; BEGIN p := GetIndice(RangeIndex, r) ; @@ -2958,7 +2960,7 @@ PROCEDURE CodeStaticArraySubscript (tokenno: CARDINAL; r: CARDINAL; function, message: String) ; VAR p : Range ; - desMin, desMax: Tree ; + desMin, desMax: tree ; location : location_t ; BEGIN location := TokenToLocation (tokenno) ; @@ -2991,7 +2993,7 @@ PROCEDURE CodeDynamicArraySubscript (tokenno: CARDINAL; VAR UnboundedType: CARDINAL ; p : Range ; - high, e : Tree ; + high, e : tree ; location : location_t ; BEGIN location := TokenToLocation(tokenno) ; @@ -3109,12 +3111,12 @@ END CodeForLoopTo ; *) PROCEDURE SameTypesCodeForLoopEnd (tokenNo: CARDINAL; r: CARDINAL; function, message: String; - p: Range; dmax: Tree) ; + p: Range; dmax: tree) ; VAR inc, room, statement, - condition: Tree ; + condition: tree ; location : location_t ; BEGIN location := TokenToLocation(tokenNo) ; @@ -3134,7 +3136,7 @@ END SameTypesCodeForLoopEnd ; *) PROCEDURE DiffTypesCodeForLoopEnd (tokenNo: CARDINAL; r: CARDINAL; function, message: String; - p: Range; dmax, emin, emax: Tree) ; + p: Range; dmax, emin, emax: tree) ; VAR location : location_t ; desoftypee, @@ -3147,7 +3149,7 @@ VAR s4, s5, s6, s7, s8, lg1, lg2, - dz, ez : Tree ; + dz, ez : tree ; BEGIN location := TokenToLocation(tokenNo) ; WITH p^ DO @@ -3219,7 +3221,7 @@ VAR isCard : BOOLEAN ; p : Range ; dmin, dmax, - emin, emax: Tree ; + emin, emax: tree ; BEGIN p := GetIndice(RangeIndex, r) ; WITH p^ DO @@ -3255,7 +3257,7 @@ END CodeForLoopEnd ; PROCEDURE CodeNil (r: CARDINAL; function, message: String) ; VAR p : Range ; - condition, t: Tree ; + condition, t: tree ; location : location_t ; BEGIN p := GetIndice(RangeIndex, r) ; @@ -3287,7 +3289,7 @@ VAR zero : CARDINAL ; p : Range ; condition, - e : Tree ; + e : tree ; location : location_t ; BEGIN p := GetIndice(RangeIndex, r) ; @@ -3317,7 +3319,7 @@ VAR zero : CARDINAL ; p : Range ; condition, - e : Tree ; + e : tree ; location : location_t ; BEGIN p := GetIndice(RangeIndex, r) ; diff --git a/gcc/m2/gm2-compiler/M2System.def b/gcc/m2/gm2-compiler/M2System.def index 87612c161306..c8930fc85985 100644 --- a/gcc/m2/gm2-compiler/M2System.def +++ b/gcc/m2/gm2-compiler/M2System.def @@ -31,7 +31,7 @@ DEFINITION MODULE M2System ; are mapped onto their equivalents in the gcc backend. *) -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; EXPORT QUALIFIED System, (* The SYSTEM module symbol. *) diff --git a/gcc/m2/gm2-compiler/M2System.mod b/gcc/m2/gm2-compiler/M2System.mod index 69f21d5e1fae..38565b5e956e 100644 --- a/gcc/m2/gm2-compiler/M2System.mod +++ b/gcc/m2/gm2-compiler/M2System.mod @@ -73,7 +73,7 @@ FROM M2Base IMPORT Real, Cardinal, Integer, Complex, LongReal, LongCard, LongInt, LongComplex, ShortReal, ShortCard, ShortInt, ShortComplex ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM m2linemap IMPORT BuiltinsLocation ; FROM m2decl IMPORT GetBitsPerBitset, GetBitsPerUnit ; @@ -116,7 +116,7 @@ END Init ; CreateMinMaxFor - creates the min and max values for, type, given gccType. *) -PROCEDURE CreateMinMaxFor (type: CARDINAL; min, max: ARRAY OF CHAR; gccType: Tree) ; +PROCEDURE CreateMinMaxFor (type: CARDINAL; min, max: ARRAY OF CHAR; gccType: tree) ; VAR maxval, minval: CARDINAL ; BEGIN @@ -140,7 +140,7 @@ END CreateMinMaxFor ; PROCEDURE MapType (type: CARDINAL; name, min, max: ARRAY OF CHAR; - needsExporting: BOOLEAN; t: Tree) ; + needsExporting: BOOLEAN; t: tree) ; VAR n: Name ; BEGIN @@ -170,7 +170,7 @@ END MapType ; *) PROCEDURE CreateType (name, min, max: ARRAY OF CHAR; - needsExporting: BOOLEAN; gccType: Tree) : CARDINAL ; + needsExporting: BOOLEAN; gccType: tree) : CARDINAL ; VAR type: CARDINAL ; BEGIN @@ -194,7 +194,7 @@ END CreateType ; *) PROCEDURE AttemptToCreateType (name, min, max: ARRAY OF CHAR; - needsExporting: BOOLEAN; gccType: Tree) ; + needsExporting: BOOLEAN; gccType: tree) ; BEGIN Assert (IsLegal (CreateType (name, min, max, needsExporting, gccType))) END AttemptToCreateType ; @@ -206,7 +206,7 @@ END AttemptToCreateType ; *) PROCEDURE CreateSetType (name, highBit: ARRAY OF CHAR; - needsExporting: BOOLEAN; gccType: Tree) : CARDINAL ; + needsExporting: BOOLEAN; gccType: tree) : CARDINAL ; VAR low, high, @@ -237,7 +237,7 @@ END CreateSetType ; *) PROCEDURE AttemptToCreateSetType (name, highBit: ARRAY OF CHAR; - needsExporting: BOOLEAN; gccType: Tree) ; + needsExporting: BOOLEAN; gccType: tree) ; BEGIN Assert (IsLegal (CreateSetType (name, highBit, needsExporting, gccType))) END AttemptToCreateSetType ; diff --git a/gcc/m2/gm2-compiler/P2SymBuild.mod b/gcc/m2/gm2-compiler/P2SymBuild.mod index 0b90b762e2ea..a5060242a0e7 100644 --- a/gcc/m2/gm2-compiler/P2SymBuild.mod +++ b/gcc/m2/gm2-compiler/P2SymBuild.mod @@ -37,7 +37,7 @@ FROM M2Options IMPORT PedanticParamNames, ExtendedOpaque ; FROM StrIO IMPORT WriteString, WriteLn ; FROM M2Base IMPORT ZType ; FROM Storage IMPORT ALLOCATE ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; FROM M2LexBuf IMPORT TokenToLocation ; FROM M2Reserved IMPORT ImportTok, ExportTok, QualifiedTok, UnQualifiedTok, diff --git a/gcc/m2/gm2-compiler/SymbolConversion.def b/gcc/m2/gm2-compiler/SymbolConversion.def index 81a52e4aa1ec..f8deeecaaeeb 100644 --- a/gcc/m2/gm2-compiler/SymbolConversion.def +++ b/gcc/m2/gm2-compiler/SymbolConversion.def @@ -29,7 +29,7 @@ DEFINITION MODULE SymbolConversion ; Description: mapping between m2 symbols and gcc symbols. *) -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM SYSTEM IMPORT WORD ; @@ -37,21 +37,21 @@ FROM SYSTEM IMPORT WORD ; Mod2Gcc - given a modula-2 symbol, sym, return the gcc equivalent. *) -PROCEDURE Mod2Gcc (sym: CARDINAL) : Tree ; +PROCEDURE Mod2Gcc (sym: CARDINAL) : tree ; (* Gcc2Mod - given a gcc tree return the modula-2 symbol. *) -PROCEDURE Gcc2Mod (tree: Tree) : CARDINAL ; +PROCEDURE Gcc2Mod (tree: tree) : CARDINAL ; (* AddModGcc - adds the tuple [ sym, gcc ] into the database. *) -PROCEDURE AddModGcc (sym: CARDINAL; gcc: Tree) ; +PROCEDURE AddModGcc (sym: CARDINAL; gcc: tree) ; (* diff --git a/gcc/m2/gm2-compiler/SymbolConversion.mod b/gcc/m2/gm2-compiler/SymbolConversion.mod index 738b40d5be52..3b1b3b99c88c 100644 --- a/gcc/m2/gm2-compiler/SymbolConversion.mod +++ b/gcc/m2/gm2-compiler/SymbolConversion.mod @@ -32,7 +32,7 @@ FROM SymbolTable IMPORT IsConst, PopValue, IsValueSolved, GetSymName, FROM M2Error IMPORT InternalError ; FROM M2ALU IMPORT PushTypeOfTree ; FROM m2block IMPORT GetErrorNode, RememberConstant ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM M2Printf IMPORT printf1 ; FROM Storage IMPORT ALLOCATE ; FROM SYSTEM IMPORT ADDRESS ; @@ -53,11 +53,11 @@ VAR Mod2Gcc - given a modula-2 symbol, sym, return the gcc equivalent. *) -PROCEDURE Mod2Gcc (sym: CARDINAL) : Tree ; +PROCEDURE Mod2Gcc (sym: CARDINAL) : tree ; VAR n : Name ; t : PtrToCardinal ; - tr: Tree ; + tr: tree ; BEGIN IF USEPOISON THEN @@ -72,7 +72,7 @@ BEGIN END ; IF InBounds(mod2gcc, sym) THEN - tr := Tree(GetIndice(mod2gcc, sym)) ; + tr := tree(GetIndice(mod2gcc, sym)) ; IF tr=PoisonedSymbol THEN n := GetSymName(sym) ; @@ -91,7 +91,7 @@ END Mod2Gcc ; Gcc2Mod - given a gcc tree return the modula-2 symbol. *) -PROCEDURE Gcc2Mod (tree: Tree) : CARDINAL ; +PROCEDURE Gcc2Mod (tree: tree) : CARDINAL ; VAR high, i: CARDINAL ; BEGIN @@ -112,9 +112,9 @@ END Gcc2Mod ; AddModGcc - adds the tuple [ sym, gcc ] into the database. *) -PROCEDURE AddModGcc (sym: CARDINAL; gcc: Tree) ; +PROCEDURE AddModGcc (sym: CARDINAL; gcc: tree) ; VAR - old: Tree ; + old: tree ; t : PtrToCardinal ; BEGIN IF gcc=GetErrorNode() @@ -125,14 +125,14 @@ BEGIN IF USEPOISON THEN t := PtrToCardinal(gcc) ; - IF (gcc#Tree(NIL)) AND (t^=GGCPOISON) + IF (gcc#tree(NIL)) AND (t^=GGCPOISON) THEN InternalError ('gcc symbol has been poisoned') END END ; old := Mod2Gcc(sym) ; - IF old=Tree(NIL) + IF old=tree(NIL) THEN (* absent - add it *) PutIndice(mod2gcc, sym, gcc) ; @@ -211,14 +211,14 @@ END RemoveTemporaryKnown ; whether the gcc symbol has been poisoned. *) -PROCEDURE Mod2GccWithoutGCCPoison (sym: CARDINAL) : Tree ; +PROCEDURE Mod2GccWithoutGCCPoison (sym: CARDINAL) : tree ; VAR n : Name ; - tr: Tree ; + tr: tree ; BEGIN IF InBounds(mod2gcc, sym) THEN - tr := Tree(GetIndice(mod2gcc, sym)) ; + tr := tree(GetIndice(mod2gcc, sym)) ; IF tr=PoisonedSymbol THEN n := GetSymName(sym) ; diff --git a/gcc/m2/gm2-compiler/SymbolTable.def b/gcc/m2/gm2-compiler/SymbolTable.def index 05ef313f3227..2036e1efc4d5 100644 --- a/gcc/m2/gm2-compiler/SymbolTable.def +++ b/gcc/m2/gm2-compiler/SymbolTable.def @@ -32,7 +32,7 @@ DEFINITION MODULE SymbolTable ; FROM SYSTEM IMPORT WORD ; FROM SymbolKey IMPORT PerformOperation ; FROM NameKey IMPORT Name ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM DynamicStrings IMPORT String ; FROM M2Error IMPORT ErrorScope ; FROM Lists IMPORT List ; @@ -1467,14 +1467,14 @@ PROCEDURE GetModuleQuads (Sym: CARDINAL; PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym. *) -PROCEDURE PutModuleFinallyFunction (Sym: CARDINAL; finally: Tree) ; +PROCEDURE PutModuleFinallyFunction (Sym: CARDINAL; finally: tree) ; (* GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym. *) -PROCEDURE GetModuleFinallyFunction (Sym: CARDINAL) : Tree ; +PROCEDURE GetModuleFinallyFunction (Sym: CARDINAL) : tree ; (* diff --git a/gcc/m2/gm2-compiler/SymbolTable.mod b/gcc/m2/gm2-compiler/SymbolTable.mod index c76e942f7291..b5e2b9b72035 100644 --- a/gcc/m2/gm2-compiler/SymbolTable.mod +++ b/gcc/m2/gm2-compiler/SymbolTable.mod @@ -33,7 +33,7 @@ FROM Indexing IMPORT InitIndex, InBounds, LowIndice, HighIndice, PutIndice, GetIndice, InitIndexTuned ; FROM Sets IMPORT Set, InitSet, IncludeElementIntoSet, IsElementInSet ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; FROM M2Options IMPORT Pedantic, ExtendedOpaque, GetDebugFunctionLineNumbers, ScaffoldDynamic, @@ -82,7 +82,7 @@ FROM M2Base IMPORT MixTypes, InitBase, Char, Integer, LongReal, FROM M2System IMPORT Address ; FROM m2expr IMPORT OverflowZType ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM m2linemap IMPORT BuiltinsLocation ; FROM StrLib IMPORT StrEqual ; FROM m2builtins IMPORT BuiltinExists ; @@ -728,7 +728,7 @@ TYPE StartFinishQuad: CARDINAL ; (* Signify the finalization *) (* code. *) EndFinishQuad : CARDINAL ; (* should point to a finish *) - FinallyFunction: Tree ; (* The GCC function for finally *) + FinallyFunction: tree ; (* The GCC function for finally *) ExceptionFinally, ExceptionBlock: BOOLEAN ; (* does it have an exception? *) ContainsHiddenType: BOOLEAN ;(* True if this module *) @@ -803,7 +803,7 @@ TYPE StartFinishQuad: CARDINAL ; (* Signify the finalization *) (* code. *) EndFinishQuad : CARDINAL ; (* should point to a finish *) - FinallyFunction: Tree ; (* The GCC function for finally *) + FinallyFunction: tree ; (* The GCC function for finally *) ExceptionFinally, ExceptionBlock: BOOLEAN ; (* does it have an exception? *) ModLink : BOOLEAN ; (* Is the module parsed for *) @@ -12876,7 +12876,7 @@ END GetModuleQuads ; PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym. *) -PROCEDURE PutModuleFinallyFunction (Sym: CARDINAL; finally: Tree) ; +PROCEDURE PutModuleFinallyFunction (Sym: CARDINAL; finally: tree) ; VAR pSym: PtrToSymbol ; BEGIN @@ -12898,7 +12898,7 @@ END PutModuleFinallyFunction ; GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym. *) -PROCEDURE GetModuleFinallyFunction (Sym: CARDINAL) : Tree ; +PROCEDURE GetModuleFinallyFunction (Sym: CARDINAL) : tree ; VAR pSym: PtrToSymbol ; BEGIN diff --git a/gcc/m2/gm2-compiler/m2flex.def b/gcc/m2/gm2-compiler/m2flex.def index 3145964d5299..a793927534d7 100644 --- a/gcc/m2/gm2-compiler/m2flex.def +++ b/gcc/m2/gm2-compiler/m2flex.def @@ -33,7 +33,7 @@ DEFINITION MODULE m2flex ; *) FROM SYSTEM IMPORT ADDRESS ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t ; EXPORT QUALIFIED GetToken, M2Error, OpenSource, CloseSource, GetLineNo, GetColumnNo, GetLocation, GetTotalLines ; diff --git a/gcc/m2/gm2-gcc/CDataTypes.def b/gcc/m2/gm2-gcc/CDataTypes.def new file mode 100644 index 000000000000..38953d7ac842 --- /dev/null +++ b/gcc/m2/gm2-gcc/CDataTypes.def @@ -0,0 +1,33 @@ +(* CDataTypes provides a placeholder module for C address types. + +Copyright (C) 2024 Free Software Foundation, Inc. +Contributed by Gaius Mulley . + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Modula-2; see the file COPYING3. If not see +. *) + +DEFINITION MODULE CDataTypes ; (*!m2pim*) + +FROM SYSTEM IMPORT ADDRESS ; + +EXPORT UNQUALIFIED CharStar, ConstCharStar ; + +TYPE + CharStar = ADDRESS ; + ConstCharStar = ADDRESS ; + + +END CDataTypes. diff --git a/gcc/m2/gm2-gcc/gcctypes.def b/gcc/m2/gm2-gcc/gcctypes.def new file mode 100644 index 000000000000..e6065720431b --- /dev/null +++ b/gcc/m2/gm2-gcc/gcctypes.def @@ -0,0 +1,36 @@ +(* gcctypes provides a placeholder module for gcc declared data types. + +Copyright (C) 2024 Free Software Foundation, Inc. +Contributed by Gaius Mulley . + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Modula-2; see the file COPYING3. If not see +. *) + +DEFINITION MODULE gcctypes ; + +FROM SYSTEM IMPORT ADDRESS ; + +EXPORT UNQUALIFIED location_t, tree ; + + +TYPE + (* Not declared here by the bootstrap tool mc when + --gcc-config-system is used. *) + location_t = CARDINAL ; + tree = ADDRESS ; + + +END gcctypes. diff --git a/gcc/m2/gm2-gcc/init.def b/gcc/m2/gm2-gcc/init.def index 37972eed34f1..680aafba8a88 100644 --- a/gcc/m2/gm2-gcc/init.def +++ b/gcc/m2/gm2-gcc/init.def @@ -21,7 +21,7 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" init ; -FROM SYSTEM IMPORT ADDRESS ; +FROM CDataTypes IMPORT ConstCharStar ; (* @@ -37,7 +37,7 @@ PROCEDURE FrontEndInit ; This is to be called every time we compile a new file. *) -PROCEDURE PerCompilationInit (filename: ADDRESS) ; +PROCEDURE PerCompilationInit (filename: ConstCharStar) ; END init. diff --git a/gcc/m2/gm2-gcc/m2block.def b/gcc/m2/gm2-gcc/m2block.def index 1f195dbbc144..e16edadbb70d 100644 --- a/gcc/m2/gm2-gcc/m2block.def +++ b/gcc/m2/gm2-gcc/m2block.def @@ -21,10 +21,8 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2block ; - -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; -FROM SYSTEM IMPORT ADDRESS ; +FROM gcctypes IMPORT location_t, tree ; +FROM CDataTypes IMPORT CharStar ; (* @@ -46,7 +44,7 @@ PROCEDURE toplevel () : BOOLEAN ; in the global binding level. *) -PROCEDURE global_constant (t: Tree) : Tree ; +PROCEDURE global_constant (t: tree) : tree ; (* @@ -56,7 +54,7 @@ PROCEDURE global_constant (t: Tree) : Tree ; inside the current_binding_level I suspect. *) -PROCEDURE RememberInitModuleFunction (t: Tree) : Tree ; +PROCEDURE RememberInitModuleFunction (t: tree) : tree ; (* @@ -64,7 +62,7 @@ PROCEDURE RememberInitModuleFunction (t: Tree) : Tree ; poisoned. *) -PROCEDURE DumpGlobalConstants () : Tree ; +PROCEDURE DumpGlobalConstants () : tree ; (* @@ -74,21 +72,21 @@ PROCEDURE DumpGlobalConstants () : Tree ; can be used by many different functions if necessary. *) -PROCEDURE RememberConstant (t: Tree) : Tree ; +PROCEDURE RememberConstant (t: tree) : tree ; (* RememberType - remember the type, t, in the ggc marked list. *) -PROCEDURE RememberType (t: Tree) : Tree ; +PROCEDURE RememberType (t: tree) : tree ; (* pushDecl - pushes a declaration onto the current binding level. *) -PROCEDURE pushDecl (decl: Tree) : Tree ; +PROCEDURE pushDecl (decl: tree) : tree ; (* @@ -113,14 +111,14 @@ PROCEDURE pushGlobalScope ; binding level. *) -PROCEDURE popFunctionScope () : Tree ; +PROCEDURE popFunctionScope () : tree ; (* pushFunctionScope - push a binding level. *) -PROCEDURE pushFunctionScope (fndecl: Tree) ; +PROCEDURE pushFunctionScope (fndecl: tree) ; (* @@ -129,7 +127,7 @@ PROCEDURE pushFunctionScope (fndecl: Tree) ; The cur_stmt_list is appended to the STATEMENT_LIST. *) -PROCEDURE finishFunctionCode (fndecl: Tree) ; +PROCEDURE finishFunctionCode (fndecl: tree) ; (* @@ -142,7 +140,7 @@ PROCEDURE finishFunctionCode (fndecl: Tree) ; containing the DECL_EXPR is also created. *) -PROCEDURE finishFunctionDecl (location: location_t; fndecl: Tree) ; +PROCEDURE finishFunctionDecl (location: location_t; fndecl: tree) ; (* @@ -150,14 +148,14 @@ PROCEDURE finishFunctionDecl (location: location_t; fndecl: Tree) ; in the current scope. *) -PROCEDURE getLabel (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE getLabel (location: location_t; name: CharStar) : tree ; (* GetErrorNode - returns the gcc error_mark_node. *) -PROCEDURE GetErrorNode () : Tree ; +PROCEDURE GetErrorNode () : tree ; (* @@ -165,21 +163,21 @@ PROCEDURE GetErrorNode () : Tree ; it is not already present. *) -PROCEDURE includeDecl (decl: Tree) ; +PROCEDURE includeDecl (decl: tree) ; (* GetGlobals - returns a list of global variables, functions, constants. *) -PROCEDURE GetGlobals () : Tree ; +PROCEDURE GetGlobals () : tree ; (* GetGlobalContext - returns the global context tree. *) -PROCEDURE GetGlobalContext () : Tree ; +PROCEDURE GetGlobalContext () : tree ; (* @@ -187,7 +185,7 @@ PROCEDURE GetGlobalContext () : Tree ; statement list and returns the list node. *) -PROCEDURE begin_statement_list () : Tree ; +PROCEDURE begin_statement_list () : tree ; (* @@ -195,7 +193,7 @@ PROCEDURE begin_statement_list () : Tree ; current binding level. *) -PROCEDURE push_statement_list (t: Tree) : Tree ; +PROCEDURE push_statement_list (t: tree) : tree ; (* @@ -203,7 +201,7 @@ PROCEDURE push_statement_list (t: Tree) : Tree ; current binding level. *) -PROCEDURE pop_statement_list () : Tree ; +PROCEDURE pop_statement_list () : tree ; (* diff --git a/gcc/m2/gm2-gcc/m2builtins.def b/gcc/m2/gm2-gcc/m2builtins.def index defe003ed660..c3e002aa98ae 100644 --- a/gcc/m2/gm2-gcc/m2builtins.def +++ b/gcc/m2/gm2-gcc/m2builtins.def @@ -21,9 +21,8 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2builtins ; -FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM CDataTypes IMPORT CharStar, ConstCharStar ; +FROM gcctypes IMPORT location_t, tree ; EXPORT QUALIFIED GetBuiltinConst, GetBuiltinConstType, GetBuiltinTypeInfoType, GetBuiltinTypeInfo, @@ -37,7 +36,7 @@ EXPORT QUALIFIED GetBuiltinConst, GetBuiltinConstType, NIL is returned if the constant is unknown. *) -PROCEDURE GetBuiltinConst (name: ADDRESS) : Tree ; +PROCEDURE GetBuiltinConst (name: CharStar) : tree ; (* @@ -48,7 +47,7 @@ PROCEDURE GetBuiltinConst (name: ADDRESS) : Tree ; 2 = real *) -PROCEDURE GetBuiltinConstType (name: ADDRESS) : CARDINAL ; +PROCEDURE GetBuiltinConstType (name: CharStar) : CARDINAL ; @@ -62,21 +61,21 @@ PROCEDURE GetBuiltinConstType (name: ADDRESS) : CARDINAL ; 3 if ident is large, small. *) -PROCEDURE GetBuiltinTypeInfoType (ident: ADDRESS) : CARDINAL ; +PROCEDURE GetBuiltinTypeInfoType (ident: ConstCharStar) : CARDINAL ; (* - GetBuiltinTypeInfo - returns a Tree value: + GetBuiltinTypeInfo - returns a tree value: NULL_TREE if ident is unknown. - boolean Tree if ident is IEC559, LIA1, ISO, IEEE, rounds, underflow, + boolean tree if ident is IEC559, LIA1, ISO, IEEE, rounds, underflow, exception, extend. - ZType Tree if ident is radix, places, exponentmin, exponentmax, + ZType tree if ident is radix, places, exponentmin, exponentmax, noofmodes. - RType Tree if ident is large, small. + RType tree if ident is large, small. *) -PROCEDURE GetBuiltinTypeInfo (location: location_t; type: Tree; ident: ADDRESS) : Tree ; +PROCEDURE GetBuiltinTypeInfo (location: location_t; type: tree; ident: ConstCharStar) : tree ; (* @@ -84,28 +83,28 @@ PROCEDURE GetBuiltinTypeInfo (location: location_t; type: Tree; ident: ADDRESS) for this target architecture. *) -PROCEDURE BuiltinExists (name: ADDRESS) : BOOLEAN ; +PROCEDURE BuiltinExists (name: CharStar) : BOOLEAN ; (* - BuildBuiltinTree - returns a Tree containing the builtin function, name. + BuildBuiltinTree - returns a tree containing the builtin function, name. *) -PROCEDURE BuildBuiltinTree (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE BuildBuiltinTree (location: location_t; name: CharStar) : tree ; (* BuiltinMemCopy and BuiltinAlloca - are called by M2GenGCC to implement open arrays. *) -PROCEDURE BuiltinMemCopy (location: location_t; dest, src, n: Tree) : Tree ; +PROCEDURE BuiltinMemCopy (location: location_t; dest, src, n: tree) : tree ; (* BuiltinMemSet is called by M2GenGCC to implement the set type. *) -PROCEDURE BuiltinMemSet (location: location_t; dest, bytevalue, nbytes: Tree) : Tree ; +PROCEDURE BuiltinMemSet (location: location_t; dest, bytevalue, nbytes: tree) : tree ; (* @@ -113,16 +112,16 @@ PROCEDURE BuiltinMemSet (location: location_t; dest, bytevalue, nbytes: Tree) : of the current function. *) -PROCEDURE BuiltInAlloca (location: location_t; n: Tree) : Tree ; +PROCEDURE BuiltInAlloca (location: location_t; n: tree) : tree ; (* - BuiltInIsfinite - given an expression, e, return an integer Tree of 1 if the - value is finite. Return an integer Tree 0 if the value is + BuiltInIsfinite - given an expression, e, return an integer tree of 1 if the + value is finite. Return an integer tree 0 if the value is not finite. *) -PROCEDURE BuiltInIsfinite (location: location_t; e: Tree) : Tree ; +PROCEDURE BuiltInIsfinite (location: location_t; e: tree) : tree ; END m2builtins. diff --git a/gcc/m2/gm2-gcc/m2convert.def b/gcc/m2/gm2-gcc/m2convert.def index 5e34e9317e18..411fa40ca9c2 100644 --- a/gcc/m2/gm2-gcc/m2convert.def +++ b/gcc/m2/gm2-gcc/m2convert.def @@ -21,8 +21,7 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2convert ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; (* @@ -30,35 +29,35 @@ FROM m2linemap IMPORT location_t ; a WORD. *) -PROCEDURE ToWord (location: location_t; expr: Tree) : Tree ; +PROCEDURE ToWord (location: location_t; expr: tree) : tree ; (* ToCardinal - convert an expression, expr, to a CARDINAL. *) -PROCEDURE ToCardinal (location: location_t; expr: Tree) : Tree ; +PROCEDURE ToCardinal (location: location_t; expr: tree) : tree ; (* ToInteger - convert an expression, expr, to an INTEGER. *) -PROCEDURE ToInteger (location: location_t; expr: Tree) : Tree ; +PROCEDURE ToInteger (location: location_t; expr: tree) : tree ; (* ToBitset - convert an expression, expr, to a BITSET. *) -PROCEDURE ToBitset (location: location_t; expr: Tree) : Tree ; +PROCEDURE ToBitset (location: location_t; expr: tree) : tree ; (* ConvertToPtr - convert an expression to a void *. *) -PROCEDURE ConvertToPtr (p: Tree) : Tree ; +PROCEDURE ConvertToPtr (p: tree) : tree ; (* @@ -67,7 +66,7 @@ PROCEDURE ConvertToPtr (p: Tree) : Tree ; should suppress overflow checking. *) -PROCEDURE BuildConvert (location: location_t; type: Tree; value: Tree; checkOverflow: BOOLEAN) : Tree ; +PROCEDURE BuildConvert (location: location_t; type: tree; value: tree; checkOverflow: BOOLEAN) : tree ; (* @@ -76,14 +75,14 @@ PROCEDURE BuildConvert (location: location_t; type: Tree; value: Tree; checkOver overflow checking is performed. *) -PROCEDURE ConvertConstantAndCheck (location: location_t; type: Tree; expr: Tree) : Tree ; +PROCEDURE ConvertConstantAndCheck (location: location_t; type: tree; expr: tree) : tree ; (* ConvertString - converts string, expr, into a string of type, type. *) -PROCEDURE ConvertString (type, expr: Tree) : Tree ; +PROCEDURE ConvertString (type, expr: tree) : tree ; (* @@ -92,7 +91,7 @@ PROCEDURE ConvertString (type, expr: Tree) : Tree ; expr is returned unaltered. *) -PROCEDURE GenericToType (location: location_t; type, expr: Tree) : Tree ; +PROCEDURE GenericToType (location: location_t; type, expr: tree) : tree ; END m2convert. diff --git a/gcc/m2/gm2-gcc/m2decl.cc b/gcc/m2/gm2-gcc/m2decl.cc index d8a2bc898d07..7888b13fac8d 100644 --- a/gcc/m2/gm2-gcc/m2decl.cc +++ b/gcc/m2/gm2-gcc/m2decl.cc @@ -165,7 +165,7 @@ m2decl_DeclareKnownConstant (location_t location, tree type, tree value) param_type_list. */ tree -m2decl_BuildParameterDeclaration (location_t location, char *name, tree type, +m2decl_BuildParameterDeclaration (location_t location, const char *name, tree type, bool isreference) { tree parm_decl; diff --git a/gcc/m2/gm2-gcc/m2decl.def b/gcc/m2/gm2-gcc/m2decl.def index 993a41975d13..0c7e2a62aca2 100644 --- a/gcc/m2/gm2-gcc/m2decl.def +++ b/gcc/m2/gm2-gcc/m2decl.def @@ -22,8 +22,8 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE m2decl ; FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; +FROM CDataTypes IMPORT ConstCharStar ; (* @@ -31,14 +31,14 @@ FROM m2linemap IMPORT location_t ; the dynamic linking scaffold. *) -PROCEDURE BuildModuleCtor (moduleCtor: Tree) ; +PROCEDURE BuildModuleCtor (moduleCtor: tree) ; (* DeclareModuleCtor configures the function to be used as a ctor. *) -PROCEDURE DeclareModuleCtor (decl: Tree) : Tree ; +PROCEDURE DeclareModuleCtor (decl: tree) : tree ; @@ -47,13 +47,13 @@ PROCEDURE DeclareModuleCtor (decl: Tree) : Tree ; *) PROCEDURE DeclareM2linkForcedModuleInitOrder (location: location_t; - RuntimeOverride: ADDRESS) : Tree ; + RuntimeOverride: ADDRESS) : tree ; PROCEDURE DeclareM2linkStaticInitialization (location: location_t; - ScaffoldStatic: INTEGER) : Tree ; + ScaffoldStatic: INTEGER) : tree ; -PROCEDURE BuildPtrToTypeString (location: location_t; string: ADDRESS; type: Tree) : Tree ; +PROCEDURE BuildPtrToTypeString (location: location_t; string: ADDRESS; type: tree) : tree ; (* @@ -88,14 +88,14 @@ PROCEDURE GetBitsPerWord () : INTEGER ; BuildIntegerConstant - return a tree containing the integer value. *) -PROCEDURE BuildIntegerConstant (value: INTEGER) : Tree ; +PROCEDURE BuildIntegerConstant (value: INTEGER) : tree ; (* BuildStringConstantType - builds a string constant with a type. *) -PROCEDURE BuildStringConstantType (length: INTEGER; string: ADDRESS; type: Tree) : Tree ; +PROCEDURE BuildStringConstantType (length: INTEGER; string: ConstCharStar; type: tree) : tree ; (* @@ -105,9 +105,9 @@ PROCEDURE BuildStringConstantType (length: INTEGER; string: ADDRESS; type: Tree) isglobal is TRUE. *) -PROCEDURE DeclareKnownVariable (location: location_t; name: ADDRESS; type: Tree; +PROCEDURE DeclareKnownVariable (location: location_t; name: ConstCharStar; type: tree; exported, imported, istemporary, isglobal: BOOLEAN; - scope, initial: Tree) : Tree ; + scope, initial: tree) : tree ; (* @@ -120,7 +120,7 @@ PROCEDURE DeclareKnownVariable (location: location_t; name: ADDRESS; type: Tree; always be referenced. *) -PROCEDURE DeclareKnownConstant (location: location_t; type: Tree; value: Tree) : Tree ; +PROCEDURE DeclareKnownConstant (location: location_t; type: tree; value: tree) : tree ; (* @@ -130,8 +130,8 @@ PROCEDURE DeclareKnownConstant (location: location_t; type: Tree; value: Tree) : type declaration and we ignore names. *) -PROCEDURE BuildParameterDeclaration (location: location_t; name: ADDRESS; type: Tree; - isreference: BOOLEAN) : Tree ; +PROCEDURE BuildParameterDeclaration (location: location_t; name: ConstCharStar; type: tree; + isreference: BOOLEAN) : tree ; (* @@ -148,16 +148,16 @@ PROCEDURE BuildStartFunctionDeclaration (uses_varargs: BOOLEAN) ; *) PROCEDURE BuildEndFunctionDeclaration (location_begin, location_end: location_t; - name: ADDRESS; returntype: Tree; + name: ConstCharStar; returntype: tree; isexternal, isnested, ispublic, - isnoreturn: BOOLEAN) : Tree ; + isnoreturn: BOOLEAN) : tree ; (* RememberVariables - *) -PROCEDURE RememberVariables (l: Tree) ; +PROCEDURE RememberVariables (l: tree) ; (* @@ -168,8 +168,8 @@ PROCEDURE RememberVariables (l: Tree) ; *) PROCEDURE BuildConstLiteralNumber (location: location_t; - str: ADDRESS; base: CARDINAL; - issueError: BOOLEAN) : Tree ; + str: ConstCharStar; base: CARDINAL; + issueError: BOOLEAN) : tree ; (* @@ -177,7 +177,7 @@ PROCEDURE BuildConstLiteralNumber (location: location_t; and, length. *) -PROCEDURE BuildStringConstant (string: ADDRESS; length: INTEGER) : Tree ; +PROCEDURE BuildStringConstant (string: ConstCharStar; length: INTEGER) : tree ; (* @@ -185,11 +185,11 @@ PROCEDURE BuildStringConstant (string: ADDRESS; length: INTEGER) : Tree ; and, length. *) -PROCEDURE BuildCStringConstant (string: ADDRESS; length: INTEGER) : Tree ; +PROCEDURE BuildCStringConstant (string: ConstCharStar; length: INTEGER) : tree ; -PROCEDURE GetDeclContext (t: Tree) : Tree ; +PROCEDURE GetDeclContext (t: tree) : tree ; END m2decl. diff --git a/gcc/m2/gm2-gcc/m2decl.h b/gcc/m2/gm2-gcc/m2decl.h index 5798db908c85..7957b816c051 100644 --- a/gcc/m2/gm2-gcc/m2decl.h +++ b/gcc/m2/gm2-gcc/m2decl.h @@ -58,7 +58,7 @@ EXTERN tree m2decl_BuildEndFunctionDeclaration ( tree returntype, bool isexternal, bool isnested, bool ispublic, bool isnoreturn); EXTERN void m2decl_BuildStartFunctionDeclaration (bool uses_varargs); -EXTERN tree m2decl_BuildParameterDeclaration (location_t location, char *name, +EXTERN tree m2decl_BuildParameterDeclaration (location_t location, const char *name, tree type, bool isreference); EXTERN tree m2decl_DeclareKnownConstant (location_t location, tree type, tree value); diff --git a/gcc/m2/gm2-gcc/m2except.def b/gcc/m2/gm2-gcc/m2except.def index 4816197bdc13..a1b586df00f4 100644 --- a/gcc/m2/gm2-gcc/m2except.def +++ b/gcc/m2/gm2-gcc/m2except.def @@ -21,8 +21,7 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2except ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; (* @@ -38,14 +37,14 @@ PROCEDURE InitExceptions (location: location_t) ; BuildThrow - builds a throw statement and return the tree. *) -PROCEDURE BuildThrow (location: location_t; t: Tree) : Tree ; +PROCEDURE BuildThrow (location: location_t; t: tree) : tree ; (* BuildTryBegin - returns a tree representing the 'try' block. *) -PROCEDURE BuildTryBegin (location: location_t) : Tree ; +PROCEDURE BuildTryBegin (location: location_t) : tree ; (* @@ -53,7 +52,7 @@ PROCEDURE BuildTryBegin (location: location_t) : Tree ; for the catch handlers. *) -PROCEDURE BuildTryEnd (tryBlock: Tree) ; +PROCEDURE BuildTryEnd (tryBlock: tree) ; (* @@ -62,7 +61,7 @@ PROCEDURE BuildTryEnd (tryBlock: Tree) ; It returns the handler tree. *) -PROCEDURE BuildCatchBegin (location: location_t) : Tree ; +PROCEDURE BuildCatchBegin (location: location_t) : tree ; (* @@ -73,7 +72,7 @@ PROCEDURE BuildCatchBegin (location: location_t) : Tree ; '}' which matches the catch above. *) -PROCEDURE BuildCatchEnd (location: location_t; handler, tryBlock: Tree) : Tree ; +PROCEDURE BuildCatchEnd (location: location_t; handler, tryBlock: tree) : tree ; END m2except. diff --git a/gcc/m2/gm2-gcc/m2expr.def b/gcc/m2/gm2-gcc/m2expr.def index c195f1987a89..6fcb047c435e 100644 --- a/gcc/m2/gm2-gcc/m2expr.def +++ b/gcc/m2/gm2-gcc/m2expr.def @@ -21,20 +21,19 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2expr ; -FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; +FROM CDataTypes IMPORT CharStar, ConstCharStar ; TYPE - BuildBinCheckProcedure = PROCEDURE (location_t, Tree, Tree, Tree, Tree, Tree) : Tree ; - BuildBinProcedure = PROCEDURE (location_t, Tree, Tree, BOOLEAN) : Tree ; - BuildUnaryProcedure = PROCEDURE (location_t, Tree, BOOLEAN) : Tree ; - BuildUnaryCheckProcedure = PROCEDURE (location_t, Tree, Tree, Tree, Tree) : Tree ; - BuildExprProcedure = PROCEDURE (location_t, Tree, Tree) : Tree ; - BuildSetProcedure = PROCEDURE (location_t, Tree, Tree, Tree, Tree, BOOLEAN) ; - BuildUnarySetProcedure = PROCEDURE (location_t, Tree, BOOLEAN) ; - BuildUnarySetFunction = PROCEDURE (location_t, Tree, BOOLEAN) : Tree ; + BuildBinCheckProcedure = PROCEDURE (location_t, tree, tree, tree, tree, tree) : tree ; + BuildBinProcedure = PROCEDURE (location_t, tree, tree, BOOLEAN) : tree ; + BuildUnaryProcedure = PROCEDURE (location_t, tree, BOOLEAN) : tree ; + BuildUnaryCheckProcedure = PROCEDURE (location_t, tree, tree, tree, tree) : tree ; + BuildExprProcedure = PROCEDURE (location_t, tree, tree) : tree ; + BuildSetProcedure = PROCEDURE (location_t, tree, tree, tree, tree, BOOLEAN) ; + BuildUnarySetProcedure = PROCEDURE (location_t, tree, BOOLEAN) ; + BuildUnarySetFunction = PROCEDURE (location_t, tree, BOOLEAN) : tree ; (* @@ -49,53 +48,54 @@ PROCEDURE init (location: location_t) ; The string returned will have been malloc'd. *) -PROCEDURE CSTIntToString (t: Tree) : ADDRESS ; +PROCEDURE CSTIntToString (t: tree) : CharStar ; + (* CSTIntToChar - return the CHAR representation of tree t. *) -PROCEDURE CSTIntToChar (t: Tree) : CHAR ; +PROCEDURE CSTIntToChar (t: tree) : CHAR ; PROCEDURE CheckConstStrZtypeRange (location: location_t; - str: ADDRESS; base: CARDINAL) : BOOLEAN ; + str: CharStar; base: CARDINAL) : BOOLEAN ; (* CompareTrees - returns -1 if e1 < e2, 0 if e1 == e2, and 1 if e1 > e2. *) -PROCEDURE CompareTrees (e1: Tree; e2: Tree) : INTEGER ; +PROCEDURE CompareTrees (e1: tree; e2: tree) : INTEGER ; -PROCEDURE GetPointerOne (location: location_t) : Tree ; +PROCEDURE GetPointerOne (location: location_t) : tree ; -PROCEDURE GetPointerZero (location: location_t) : Tree ; +PROCEDURE GetPointerZero (location: location_t) : tree ; -PROCEDURE GetWordOne (location: location_t) : Tree ; +PROCEDURE GetWordOne (location: location_t) : tree ; -PROCEDURE GetWordZero (location: location_t) : Tree ; +PROCEDURE GetWordZero (location: location_t) : tree ; -PROCEDURE GetIntegerOne (location: location_t) : Tree ; +PROCEDURE GetIntegerOne (location: location_t) : tree ; -PROCEDURE GetIntegerZero (location: location_t) : Tree ; +PROCEDURE GetIntegerZero (location: location_t) : tree ; -PROCEDURE GetCardinalOne (location: location_t) : Tree ; +PROCEDURE GetCardinalOne (location: location_t) : tree ; -PROCEDURE GetCardinalZero (location: location_t) : Tree ; +PROCEDURE GetCardinalZero (location: location_t) : tree ; -PROCEDURE GetSizeOfInBits (type: Tree) : Tree ; +PROCEDURE GetSizeOfInBits (type: tree) : tree ; -PROCEDURE GetSizeOf (location: location_t; type: Tree) : Tree ; +PROCEDURE GetSizeOf (location: location_t; type: tree) : tree ; (* @@ -103,7 +103,7 @@ PROCEDURE GetSizeOf (location: location_t; type: Tree) : Tree ; for a fundamental data type. *) -PROCEDURE BuildLogicalRotate (location: location_t; op1: Tree; op2: Tree; op3: Tree; nBits: Tree; needconvert: BOOLEAN) ; +PROCEDURE BuildLogicalRotate (location: location_t; op1: tree; op2: tree; op3: tree; nBits: tree; needconvert: BOOLEAN) ; (* @@ -111,7 +111,7 @@ PROCEDURE BuildLogicalRotate (location: location_t; op1: Tree; op2: Tree; op3: T it rotates a set of size, nBits. *) -PROCEDURE BuildLRRn (location: location_t; op1: Tree; op2: Tree; nBits: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLRRn (location: location_t; op1: tree; op2: tree; nBits: tree; needconvert: BOOLEAN) : tree ; (* @@ -119,39 +119,39 @@ PROCEDURE BuildLRRn (location: location_t; op1: Tree; op2: Tree; nBits: Tree; ne it rotates a set of size, nBits. *) -PROCEDURE BuildLRLn (location: location_t; op1: Tree; op2: Tree; nBits: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLRLn (location: location_t; op1: tree; op2: tree; nBits: tree; needconvert: BOOLEAN) : tree ; -PROCEDURE BuildMask (location: location_t; nBits: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildMask (location: location_t; nBits: tree; needconvert: BOOLEAN) : tree ; (* BuildMult - builds a multiplication tree. *) -PROCEDURE BuildMult (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildMult (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildMultCheck - builds a multiplication tree after checking for overflow. *) -PROCEDURE BuildMultCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildMultCheck (location: location_t; op1, op2, lowest, min, max: tree) : tree ; (* BuildLRR - builds and returns tree (op1 rotate right by op2 bits) *) -PROCEDURE BuildLRR (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLRR (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildLRL - builds and returns tree (op1 rotate left by op2 bits) *) -PROCEDURE BuildLRL (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLRL (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* @@ -159,21 +159,21 @@ PROCEDURE BuildLRL (location: location_t; op1: Tree; op2: Tree; needconvert: BOO for a fundamental data type. *) -PROCEDURE BuildLogicalShift (location: location_t; op1: Tree; op2: Tree; op3: Tree; nBits: Tree; needconvert: BOOLEAN) ; +PROCEDURE BuildLogicalShift (location: location_t; op1: tree; op2: tree; op3: tree; nBits: tree; needconvert: BOOLEAN) ; (* BuildLSR - builds and returns tree (op1 >> op2) *) -PROCEDURE BuildLSR (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLSR (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildLSL - builds and returns tree (op1 << op2) *) -PROCEDURE BuildLSL (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLSL (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* @@ -182,7 +182,7 @@ PROCEDURE BuildLSL (location: location_t; op1: Tree; op2: Tree; needconvert: BOO return op1 div trunc op2 *) -PROCEDURE BuildDivM2 (location: location_t; op1, op2: Tree; needsconvert: BOOLEAN) : Tree ; +PROCEDURE BuildDivM2 (location: location_t; op1, op2: tree; needsconvert: BOOLEAN) : tree ; (* @@ -191,7 +191,7 @@ PROCEDURE BuildDivM2 (location: location_t; op1, op2: Tree; needsconvert: BOOLEA return op1 div trunc op2. Use the checking div equivalents. *) -PROCEDURE BuildDivM2Check (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildDivM2Check (location: location_t; op1, op2, lowest, min, max: tree) : tree ; (* @@ -200,7 +200,7 @@ PROCEDURE BuildDivM2Check (location: location_t; op1, op2, lowest, min, max: Tre return op1 div trunc op2 *) -PROCEDURE BuildModM2 (location: location_t; op1, op2: Tree; needsconvert: BOOLEAN) : Tree ; +PROCEDURE BuildModM2 (location: location_t; op1, op2: tree; needsconvert: BOOLEAN) : tree ; (* @@ -212,56 +212,56 @@ PROCEDURE BuildModM2 (location: location_t; op1, op2: Tree; needsconvert: BOOLEA return op1 div trunc op2. Use the checking div equivalents. *) -PROCEDURE BuildModM2Check (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildModM2Check (location: location_t; op1, op2, lowest, min, max: tree) : tree ; (* BuildModFloor - builds a modulus tree. *) -PROCEDURE BuildModFloor (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildModFloor (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildDivCeil - builds a division tree. *) -PROCEDURE BuildDivCeil (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildDivCeil (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildModCeil - builds a modulus tree. *) -PROCEDURE BuildModCeil (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildModCeil (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildDivFloor - builds a division tree. *) -PROCEDURE BuildDivFloor (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildDivFloor (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildModTrunc - builds a modulus tree. *) -PROCEDURE BuildModTrunc (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildModTrunc (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildDivTrunc - builds a division tree. *) -PROCEDURE BuildDivTrunc (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildDivTrunc (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildDivTruncCheck - builds a division tree after checking for overflow. *) -PROCEDURE BuildDivTruncCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildDivTruncCheck (location: location_t; op1, op2, lowest, min, max: tree) : tree ; (* @@ -269,42 +269,42 @@ PROCEDURE BuildDivTruncCheck (location: location_t; op1, op2, lowest, min, max: types and NEVER for integer based types). *) -PROCEDURE BuildRDiv (location: location_t; op1, op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildRDiv (location: location_t; op1, op2: tree; needconvert: BOOLEAN) : tree ; (* BuildSubCheck - builds a subtraction tree after checking for overflow. *) -PROCEDURE BuildSubCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildSubCheck (location: location_t; op1, op2, lowest, min, max: tree) : tree ; (* BuildAddCheck - builds an addition tree after checking for overflow. *) -PROCEDURE BuildAddCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildAddCheck (location: location_t; op1, op2, lowest, min, max: tree) : tree ; (* BuildSub - builds a subtraction tree. *) -PROCEDURE BuildSub (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildSub (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildAdd - builds an addition tree. *) -PROCEDURE BuildAdd (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildAdd (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* FoldAndStrip - return expression, t, after it has been folded (if possible). *) -PROCEDURE FoldAndStrip (t: Tree) : Tree ; +PROCEDURE FoldAndStrip (t: tree) : tree ; (* @@ -312,7 +312,7 @@ PROCEDURE FoldAndStrip (t: Tree) : Tree ; of, string. *) -PROCEDURE StringLength (string: Tree) : CARDINAL ; +PROCEDURE StringLength (string: tree) : CARDINAL ; (* @@ -321,7 +321,7 @@ PROCEDURE StringLength (string: Tree) : CARDINAL ; is emitted and no modification is made to, t. *) -PROCEDURE TreeOverflow (t: Tree) : BOOLEAN ; +PROCEDURE TreeOverflow (t: tree) : BOOLEAN ; (* @@ -329,7 +329,7 @@ PROCEDURE TreeOverflow (t: Tree) : BOOLEAN ; any overflow flag and returns, t. *) -PROCEDURE RemoveOverflow (t: Tree) : Tree ; +PROCEDURE RemoveOverflow (t: tree) : tree ; (* @@ -337,49 +337,49 @@ PROCEDURE RemoveOverflow (t: Tree) : Tree ; it has been coersed to, type. *) -PROCEDURE BuildCoerce (location: location_t; des: Tree; type: Tree; expr: Tree) : Tree ; +PROCEDURE BuildCoerce (location: location_t; des: tree; type: tree; expr: tree) : tree ; (* BuildTrunc - returns an integer expression from a REAL or LONGREAL op1. *) -PROCEDURE BuildTrunc (op1: Tree) : Tree ; +PROCEDURE BuildTrunc (op1: tree) : tree ; (* BuildNegate - builds a negate expression and returns the tree. *) -PROCEDURE BuildNegate (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildNegate (location: location_t; op1: tree; needconvert: BOOLEAN) : tree ; (* BuildNegateCheck - builds a negate expression and returns the tree. *) -PROCEDURE BuildNegateCheck (location: location_t; arg, lowest, min, max: Tree) : Tree ; +PROCEDURE BuildNegateCheck (location: location_t; arg, lowest, min, max: tree) : tree ; (* BuildSetNegate - builds a set negate expression and returns the tree. *) -PROCEDURE BuildSetNegate (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildSetNegate (location: location_t; op1: tree; needconvert: BOOLEAN) : tree ; (* BuildTBitSize - returns the minimum number of bits to represent, type. *) -PROCEDURE BuildTBitSize (location: location_t; type: Tree) : Tree ; +PROCEDURE BuildTBitSize (location: location_t; type: tree) : tree ; (* BuildSize - builds a SIZE function expression and returns the tree. *) -PROCEDURE BuildSize (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildSize (location: location_t; op1: tree; needconvert: BOOLEAN) : tree ; (* @@ -387,7 +387,7 @@ PROCEDURE BuildSize (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tr op1 and returns the tree. *) -PROCEDURE BuildAddr (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildAddr (location: location_t; op1: tree; needconvert: BOOLEAN) : tree ; (* @@ -398,7 +398,7 @@ PROCEDURE BuildAddr (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tr The expression is returned. *) -PROCEDURE BuildOffset1 (location: location_t; field: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildOffset1 (location: location_t; field: tree; needconvert: BOOLEAN) : tree ; (* @@ -407,32 +407,32 @@ PROCEDURE BuildOffset1 (location: location_t; field: Tree; needconvert: BOOLEAN) The expression is returned. *) -PROCEDURE BuildOffset (location: location_t; record: Tree; field: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildOffset (location: location_t; record: tree; field: tree; needconvert: BOOLEAN) : tree ; (* BuildLogicalOrAddress - build a logical or expressions and return the tree. *) -PROCEDURE BuildLogicalOrAddress (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLogicalOrAddress (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildLogicalOr - build a logical or expressions and return the tree. *) -PROCEDURE BuildLogicalOr (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLogicalOr (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildLogicalAnd - build a logical and expression and return the tree. *) -PROCEDURE BuildLogicalAnd (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLogicalAnd (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; -PROCEDURE BuildSymmetricDifference (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildSymmetricDifference (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* @@ -441,99 +441,99 @@ PROCEDURE BuildSymmetricDifference (location: location_t; op1: Tree; op2: Tree; (op1 and (not op2)) *) -PROCEDURE BuildLogicalDifference (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; +PROCEDURE BuildLogicalDifference (location: location_t; op1: tree; op2: tree; needconvert: BOOLEAN) : tree ; (* BuildLessThan - return a tree which computes < *) -PROCEDURE BuildLessThan (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildLessThan (location: location_t; op1: tree; op2: tree) : tree ; (* BuildGreaterThan - return a tree which computes > *) -PROCEDURE BuildGreaterThan (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildGreaterThan (location: location_t; op1: tree; op2: tree) : tree ; (* BuildLessThanOrEqual - return a tree which computes < *) -PROCEDURE BuildLessThanOrEqual (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildLessThanOrEqual (location: location_t; op1: tree; op2: tree) : tree ; (* BuildGreaterThanOrEqual - return a tree which computes >= *) -PROCEDURE BuildGreaterThanOrEqual (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildGreaterThanOrEqual (location: location_t; op1: tree; op2: tree) : tree ; (* BuildEqualTo - return a tree which computes = *) -PROCEDURE BuildEqualTo (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildEqualTo (location: location_t; op1: tree; op2: tree) : tree ; -PROCEDURE BuildNotEqualTo (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildNotEqualTo (location: location_t; op1: tree; op2: tree) : tree ; (* BuildIsSuperset - return a tree which computes: op1 & op2 == op2 *) -PROCEDURE BuildIsSuperset (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildIsSuperset (location: location_t; op1: tree; op2: tree) : tree ; (* BuildIsNotSuperset - return a tree which computes: op1 & op2 != op2 *) -PROCEDURE BuildIsNotSuperset (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildIsNotSuperset (location: location_t; op1: tree; op2: tree) : tree ; (* BuildIsSubset - return a tree which computes: op1 & op2 == op1 *) -PROCEDURE BuildIsSubset (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildIsSubset (location: location_t; op1: tree; op2: tree) : tree ; (* BuildIsNotSubset - return a tree which computes: op1 & op2 != op1 *) -PROCEDURE BuildIsNotSubset (location: location_t; op1: Tree; op2: Tree) : Tree ; +PROCEDURE BuildIsNotSubset (location: location_t; op1: tree; op2: tree) : tree ; (* BuildIfConstInVar - generates: if constel in varset then goto label. *) -PROCEDURE BuildIfConstInVar (location: location_t; type: Tree; varset: Tree; constel: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: ADDRESS) ; +PROCEDURE BuildIfConstInVar (location: location_t; type: tree; varset: tree; constel: tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: CharStar) ; -PROCEDURE BuildIfNotConstInVar (location: location_t; type: Tree; varset: Tree; constel: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: ADDRESS) ; +PROCEDURE BuildIfNotConstInVar (location: location_t; type: tree; varset: tree; constel: tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: CharStar) ; (* BuildIfVarInVar - generates: if varel in varset then goto label *) -PROCEDURE BuildIfVarInVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree; high: Tree; label: ADDRESS) ; +PROCEDURE BuildIfVarInVar (location: location_t; type: tree; varset: tree; varel: tree; is_lvalue: BOOLEAN; low: tree; high: tree; label: CharStar) ; (* BuildIfNotVarInVar - generates: if not (varel in varset) then goto label *) -PROCEDURE BuildIfNotVarInVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree; high: Tree; label: ADDRESS) ; +PROCEDURE BuildIfNotVarInVar (location: location_t; type: tree; varset: tree; varel: tree; is_lvalue: BOOLEAN; low: tree; high: tree; label: CharStar) ; (* @@ -542,24 +542,24 @@ PROCEDURE BuildIfNotVarInVar (location: location_t; type: Tree; varset: Tree; va *) PROCEDURE BuildForeachWordInSetDoIfExpr (location: location_t; - type, op1, op2: Tree; + type, op1, op2: tree; is_op1lvalue, is_op2lvalue, is_op1const, isop2const: BOOLEAN; - expr: BuildExprProcedure; label: ADDRESS) ; + expr: BuildExprProcedure; label: CharStar) ; (* BuildIfInRangeGoto - if var is in the range low..high then goto label *) -PROCEDURE BuildIfInRangeGoto (location: location_t; var: Tree; low: Tree; high: Tree; label: ADDRESS) ; +PROCEDURE BuildIfInRangeGoto (location: location_t; var: tree; low: tree; high: tree; label: CharStar) ; (* BuildIfNotInRangeGoto - if var is not in the range low..high then goto label *) -PROCEDURE BuildIfNotInRangeGoto (location: location_t; var: Tree; low: Tree; high: Tree; label: ADDRESS) ; +PROCEDURE BuildIfNotInRangeGoto (location: location_t; var: tree; low: tree; high: tree; label: CharStar) ; (* @@ -567,7 +567,7 @@ PROCEDURE BuildIfNotInRangeGoto (location: location_t; var: Tree; low: Tree; hig given, lowIndice. *) -PROCEDURE BuildArray (location: location_t; type: Tree; array: Tree; index: Tree; lowIndice: Tree) : Tree ; +PROCEDURE BuildArray (location: location_t; type: tree; array: tree; index: tree; lowIndice: tree) : tree ; (* @@ -576,35 +576,35 @@ PROCEDURE BuildArray (location: location_t; type: Tree; array: Tree; index: Tree BuildComponentRef on the penultimate field. *) -PROCEDURE BuildComponentRef (location: location_t; record: Tree; field: Tree) : Tree ; +PROCEDURE BuildComponentRef (location: location_t; record: tree; field: tree) : tree ; (* BuildIndirect - build: ( *target) given that the object to be copied is of, type. *) -PROCEDURE BuildIndirect (location: location_t; target: Tree; type: Tree) : Tree ; +PROCEDURE BuildIndirect (location: location_t; target: tree; type: tree) : tree ; (* IsTrue - returns TRUE if, t, is known to be TRUE. *) -PROCEDURE IsTrue (t: Tree) : BOOLEAN ; +PROCEDURE IsTrue (t: tree) : BOOLEAN ; (* IsFalse - returns FALSE if, t, is known to be FALSE. *) -PROCEDURE IsFalse (t: Tree) : BOOLEAN ; +PROCEDURE IsFalse (t: tree) : BOOLEAN ; (* GetCstInteger - return the integer value of the cst tree. *) -PROCEDURE GetCstInteger (cst: Tree) : INTEGER ; +PROCEDURE GetCstInteger (cst: tree) : INTEGER ; (* @@ -612,7 +612,7 @@ PROCEDURE GetCstInteger (cst: Tree) : INTEGER ; TRUE if the value of e1 is the same as e2. *) -PROCEDURE AreConstantsEqual (e1: Tree; e2: Tree) : BOOLEAN ; +PROCEDURE AreConstantsEqual (e1: tree; e2: tree) : BOOLEAN ; (* @@ -624,7 +624,7 @@ PROCEDURE AreConstantsEqual (e1: Tree; e2: Tree) : BOOLEAN ; -0 == 0 and NaN != NaN. *) -PROCEDURE AreRealOrComplexConstantsEqual (e1: Tree; e2: Tree) : BOOLEAN ; +PROCEDURE AreRealOrComplexConstantsEqual (e1: tree; e2: tree) : BOOLEAN ; (* @@ -635,44 +635,44 @@ PROCEDURE AreRealOrComplexConstantsEqual (e1: Tree; e2: Tree) : BOOLEAN ; an unsigned constant will never return -1 *) -PROCEDURE DetermineSign (e: Tree) : INTEGER ; +PROCEDURE DetermineSign (e: tree) : INTEGER ; (* BuildCap - builds the Modula-2 function CAP(t) and returns - the result in a gcc Tree. + the result in a gcc tree. *) -PROCEDURE BuildCap (location: location_t; t: Tree) : Tree ; +PROCEDURE BuildCap (location: location_t; t: tree) : tree ; (* BuildAbs - builds the Modula-2 function ABS(t) and returns - the result in a gcc Tree. + the result in a gcc tree. *) -PROCEDURE BuildAbs (location: location_t; t: Tree) : Tree ; +PROCEDURE BuildAbs (location: location_t; t: tree) : tree ; (* BuildRe - builds an expression for the function RE. *) -PROCEDURE BuildRe (op1: Tree) : Tree ; +PROCEDURE BuildRe (op1: tree) : tree ; (* BuildIm - builds an expression for the function IM. *) -PROCEDURE BuildIm (op1: Tree) : Tree ; +PROCEDURE BuildIm (op1: tree) : tree ; (* BuildCmplx - builds an expression for the function CMPLX. *) -PROCEDURE BuildCmplx (location: location_t; type: Tree; real: Tree; imag: Tree) : Tree ; +PROCEDURE BuildCmplx (location: location_t; type: tree; real: tree; imag: tree) : tree ; (* @@ -683,7 +683,7 @@ PROCEDURE BuildCmplx (location: location_t; type: Tree; real: Tree; imag: Tree) *) PROCEDURE BuildBinaryForeachWordDo (location: location_t; - type, op1, op2, op3: Tree; + type, op1, op2, op3: tree; binop: BuildBinProcedure; is_op1lvalue, is_op2lvalue, @@ -700,17 +700,17 @@ PROCEDURE BuildBinaryForeachWordDo (location: location_t; *) PROCEDURE BuildBinarySetDo (location: location_t; - settype, op1, op2, op3: Tree; + settype, op1, op2, op3: tree; binop: BuildSetProcedure; is_op1lvalue, is_op2lvalue, is_op3lvalue: BOOLEAN; - nBits, unbounded: Tree; - varproc, leftproc, rightproc: Tree) ; + nBits, unbounded: tree; + varproc, leftproc, rightproc: tree) ; (* ConstantExpressionWarning - issue a warning if the constant has overflowed. *) -PROCEDURE ConstantExpressionWarning (value: Tree) ; +PROCEDURE ConstantExpressionWarning (value: tree) ; (* @@ -718,7 +718,7 @@ PROCEDURE ConstantExpressionWarning (value: Tree) ; and op2 is not a pointer type. *) -PROCEDURE BuildAddAddress (location: location_t; op1, op2: Tree) : Tree ; +PROCEDURE BuildAddAddress (location: location_t; op1, op2: tree) : tree ; (* @@ -726,7 +726,7 @@ PROCEDURE BuildAddAddress (location: location_t; op1, op2: Tree) : Tree ; represent: min..max. *) -PROCEDURE calcNbits (location: location_t; min, max: Tree) : Tree ; +PROCEDURE calcNbits (location: location_t; min, max: tree) : tree ; (* @@ -734,7 +734,7 @@ PROCEDURE calcNbits (location: location_t; min, max: Tree) : Tree ; *) PROCEDURE OverflowZType (location: location_t; - str: ADDRESS; base: CARDINAL; + str: ConstCharStar; base: CARDINAL; issueError: BOOLEAN) : BOOLEAN ; (* @@ -742,7 +742,7 @@ PROCEDURE OverflowZType (location: location_t; (condition) ? (left) : right. *) -PROCEDURE BuildCondIfExpression (condition, type, left, right: Tree) : Tree ; +PROCEDURE BuildCondIfExpression (condition, type, left, right: tree) : tree ; END m2expr. diff --git a/gcc/m2/gm2-gcc/m2linemap.def b/gcc/m2/gm2-gcc/m2linemap.def index a56e0bf79e93..aabdb9b06227 100644 --- a/gcc/m2/gm2-gcc/m2linemap.def +++ b/gcc/m2/gm2-gcc/m2linemap.def @@ -1,4 +1,4 @@ -(* m2linemap.def provides access to GCC location_t. +(* m2linemap.def provides access to GCC location_t functions. Copyright (C) 2011-2024 Free Software Foundation, Inc. Contributed by Gaius Mulley . @@ -22,15 +22,13 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2linemap ; FROM SYSTEM IMPORT ADDRESS ; +FROM gcctypes IMPORT location_t ; EXPORT QUALIFIED StartFile, EndFile, StartLine, GetLocationColumn, GetLocationRange, GetLocationBinary, UnknownLocation, BuiltinsLocation, GetLineNoFromLocation, GetColumnNoFromLocation, GetFilenameFromLocation, ErrorAt, ErrorAtf, - WarningAtf, NoteAtf, internal_error, location_t ; - -TYPE - location_t = CARDINAL ; + WarningAtf, NoteAtf, internal_error ; PROCEDURE StartFile (filename: ADDRESS; linebegin: CARDINAL) ; diff --git a/gcc/m2/gm2-gcc/m2misc.def b/gcc/m2/gm2-gcc/m2misc.def index 77fd2833f641..1ca675cb1465 100644 --- a/gcc/m2/gm2-gcc/m2misc.def +++ b/gcc/m2/gm2-gcc/m2misc.def @@ -21,10 +21,10 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2misc ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; FROM SYSTEM IMPORT ADDRESS ; -PROCEDURE DebugTree (t: Tree) ; +PROCEDURE DebugTree (t: tree) ; PROCEDURE error (message: ARRAY OF CHAR) ; PROCEDURE cerror (message: ADDRESS) ; PROCEDURE warning_m2_dump_filter (message, rule: ADDRESS) ; diff --git a/gcc/m2/gm2-gcc/m2pp.def b/gcc/m2/gm2-gcc/m2pp.def index 20077176da2e..63e78c5a1519 100644 --- a/gcc/m2/gm2-gcc/m2pp.def +++ b/gcc/m2/gm2-gcc/m2pp.def @@ -22,7 +22,7 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2pp ; FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; +FROM gcctypes IMPORT tree ; (* @@ -39,7 +39,7 @@ PROCEDURE CreateDumpGimple (templatename: ADDRESS; templatelen: CARDINAL) ; PROCEDURE CloseDumpGimple ; -PROCEDURE DumpGimpleFd (fd: INTEGER; fndecl: Tree) ; +PROCEDURE DumpGimpleFd (fd: INTEGER; fndecl: tree) ; END m2pp. diff --git a/gcc/m2/gm2-gcc/m2statement.cc b/gcc/m2/gm2-gcc/m2statement.cc index 8b51febd12f0..5e51179b7206 100644 --- a/gcc/m2/gm2-gcc/m2statement.cc +++ b/gcc/m2/gm2-gcc/m2statement.cc @@ -361,7 +361,7 @@ m2statement_BuildIndirectProcedureCallTree (location_t location, /* BuildBuiltinCallTree calls the builtin procedure. */ tree -m2statement_BuildBuiltinCallTree (location_t location, tree func) +m2statement_BuildBuiltinCallTree (tree func) { TREE_USED (func) = true; TREE_SIDE_EFFECTS (func) = true; diff --git a/gcc/m2/gm2-gcc/m2statement.def b/gcc/m2/gm2-gcc/m2statement.def index 7fb4f6b7de6e..d9b24900f96f 100644 --- a/gcc/m2/gm2-gcc/m2statement.def +++ b/gcc/m2/gm2-gcc/m2statement.def @@ -21,10 +21,8 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2statement ; - -FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; +FROM CDataTypes IMPORT CharStar ; FROM m2expr IMPORT BuildUnarySetFunction ; @@ -33,28 +31,28 @@ FROM m2expr IMPORT BuildUnarySetFunction ; result of the expression is TRUE or FALSE. *) -PROCEDURE DoJump (location: location_t; exp: Tree; falselabel: ADDRESS; truelabel: ADDRESS) ; +PROCEDURE DoJump (location: location_t; exp: tree; falselabel, truelabel: CharStar) ; (* BuildStartFunctionCode - generate function entry code. *) -PROCEDURE BuildStartFunctionCode (location: location_t; fndecl: Tree; isexported: BOOLEAN; isinline: BOOLEAN) ; +PROCEDURE BuildStartFunctionCode (location: location_t; fndecl: tree; isexported: BOOLEAN; isinline: BOOLEAN) ; (* BuildEndFunctionCode - generates the function epilogue. *) -PROCEDURE BuildEndFunctionCode (location: location_t; fndecl: Tree; nested: BOOLEAN) ; +PROCEDURE BuildEndFunctionCode (location: location_t; fndecl: tree; nested: BOOLEAN) ; (* BuildReturnValueCode - generates the code associated with: RETURN( value ) *) -PROCEDURE BuildReturnValueCode (location: location_t; fndecl: Tree; value: Tree) ; +PROCEDURE BuildReturnValueCode (location: location_t; fndecl: tree; value: tree) ; (* @@ -78,28 +76,28 @@ PROCEDURE BuildPopFunctionContext ; It returns, des. *) -PROCEDURE BuildAssignmentTree (location: location_t; des, expr: Tree) : Tree ; +PROCEDURE BuildAssignmentTree (location: location_t; des, expr: tree) : tree ; (* BuildAssignmentStatement builds the assignment of, des, and, expr. *) -PROCEDURE BuildAssignmentStatement (location: location_t; des, expr: Tree) ; +PROCEDURE BuildAssignmentStatement (location: location_t; des, expr: tree) ; (* BuildGoto - builds a goto operation. *) -PROCEDURE BuildGoto (location: location_t; name: ADDRESS) ; +PROCEDURE BuildGoto (location: location_t; name: CharStar) ; (* DeclareLabel - create a label, name. *) -PROCEDURE DeclareLabel (location: location_t; name: ADDRESS) ; +PROCEDURE DeclareLabel (location: location_t; name: CharStar) ; (* @@ -107,7 +105,7 @@ PROCEDURE DeclareLabel (location: location_t; name: ADDRESS) ; statement, s, if, condition, is true. *) -PROCEDURE BuildIfThenDoEnd (condition: Tree; then_block: Tree) : Tree ; +PROCEDURE BuildIfThenDoEnd (condition: tree; then_block: tree) : tree ; (* @@ -116,14 +114,14 @@ PROCEDURE BuildIfThenDoEnd (condition: Tree; then_block: Tree) : Tree ; condition. *) -PROCEDURE BuildIfThenElseEnd (condition: Tree; then_block: Tree; else_block: Tree) : Tree ; +PROCEDURE BuildIfThenElseEnd (condition: tree; then_block: tree; else_block: tree) : tree ; (* BuildParam - build a list of parameters, ready for a subsequent procedure call. *) -PROCEDURE BuildParam (location: location_t; param: Tree) ; +PROCEDURE BuildParam (location: location_t; param: tree) ; (* @@ -136,7 +134,7 @@ PROCEDURE BuildParam (location: location_t; param: Tree) ; a call to BuildFunctionCallTree. *) -PROCEDURE BuildFunctionCallTree (location: location_t; procedure: Tree; rettype: Tree) ; +PROCEDURE BuildFunctionCallTree (location: location_t; procedure: tree; rettype: tree) ; (* @@ -144,7 +142,7 @@ PROCEDURE BuildFunctionCallTree (location: location_t; procedure: Tree; rettype: parameter list and the return type, rettype. *) -PROCEDURE BuildProcedureCallTree (location: location_t; procedure: Tree; rettype: Tree) : Tree ; +PROCEDURE BuildProcedureCallTree (location: location_t; procedure: tree; rettype: tree) : tree ; (* @@ -152,14 +150,14 @@ PROCEDURE BuildProcedureCallTree (location: location_t; procedure: Tree; rettype parameter list and the return type, rettype. *) -PROCEDURE BuildIndirectProcedureCallTree (location: location_t; procedure: Tree; rettype: Tree) : Tree ; +PROCEDURE BuildIndirectProcedureCallTree (location: location_t; procedure: tree; rettype: tree) : tree ; (* BuildFunctValue - generates code for value := last_function(foobar); *) -PROCEDURE BuildFunctValue (location: location_t; value: Tree) : Tree ; +PROCEDURE BuildFunctValue (location: location_t; value: tree) : tree ; (* @@ -167,7 +165,7 @@ PROCEDURE BuildFunctValue (location: location_t; value: Tree) : Tree ; *) PROCEDURE BuildCall2 (location: location_t; - function, rettype, arg1, arg2: Tree) : Tree ; + function, rettype, arg1, arg2: tree) : tree ; (* @@ -175,28 +173,28 @@ PROCEDURE BuildCall2 (location: location_t; *) PROCEDURE BuildCall3 (location: location_t; - function, rettype, arg1, arg2, arg3: Tree) : Tree ; + function, rettype, arg1, arg2, arg3: tree) : tree ; (* SetLastFunction - set the last_function to, t. *) -PROCEDURE SetLastFunction (t: Tree) ; +PROCEDURE SetLastFunction (t: tree) ; (* GetLastFunction - returns, last_function. *) -PROCEDURE GetLastFunction () : Tree ; +PROCEDURE GetLastFunction () : tree ; (* GetParamTree - return parameter, i. *) -PROCEDURE GetParamTree (call: Tree; i: CARDINAL) : Tree ; +PROCEDURE GetParamTree (call: tree; i: CARDINAL) : tree ; (* @@ -204,23 +202,23 @@ PROCEDURE GetParamTree (call: Tree; i: CARDINAL) : Tree ; attached. *) -PROCEDURE BuildTryFinally (location: location_t; call: Tree; cleanups: Tree) : Tree ; +PROCEDURE BuildTryFinally (location: location_t; call: tree; cleanups: tree) : tree ; (* BuildCleanUp - return a CLEANUP_POINT_EXPR which will clobber, param. *) -PROCEDURE BuildCleanUp (param: Tree) : Tree ; +PROCEDURE BuildCleanUp (param: tree) : tree ; (* BuildAsm - generates an inline assembler instruction. *) -PROCEDURE BuildAsm (location: location_t; instr: Tree; +PROCEDURE BuildAsm (location: location_t; instr: tree; isVolatile: BOOLEAN; isSimple: BOOLEAN; - inputs: Tree; outputs: Tree; trash: Tree; labels: Tree) ; + inputs: tree; outputs: tree; trash: tree; labels: tree) ; (* @@ -231,7 +229,7 @@ PROCEDURE BuildAsm (location: location_t; instr: Tree; of the large set invoking the unop. *) -PROCEDURE BuildUnaryForeachWordDo (location: location_t; type: Tree; op1: Tree; op2: Tree; +PROCEDURE BuildUnaryForeachWordDo (location: location_t; type: tree; op1: tree; op2: tree; unop: BuildUnarySetFunction; is_op1lvalue, is_op2lvalue, is_op1const, is_op2const: BOOLEAN) ; @@ -242,7 +240,7 @@ PROCEDURE BuildUnaryForeachWordDo (location: location_t; type: Tree; op1: Tree; op2 is a constant. *) -PROCEDURE BuildExcludeVarConst (location: location_t; type: Tree; op1: Tree; op2: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ; +PROCEDURE BuildExcludeVarConst (location: location_t; type: tree; op1: tree; op2: tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ; (* @@ -250,7 +248,7 @@ PROCEDURE BuildExcludeVarConst (location: location_t; type: Tree; op1: Tree; op2 varel is a variable. *) -PROCEDURE BuildExcludeVarVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree) ; +PROCEDURE BuildExcludeVarVar (location: location_t; type: tree; varset: tree; varel: tree; is_lvalue: BOOLEAN; low: tree) ; (* @@ -259,7 +257,7 @@ PROCEDURE BuildExcludeVarVar (location: location_t; type: Tree; varset: Tree; va op2 is a constant. *) -PROCEDURE BuildIncludeVarConst (location: location_t; type: Tree; op1: Tree; op2: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ; +PROCEDURE BuildIncludeVarConst (location: location_t; type: tree; op1: tree; op2: tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ; (* @@ -267,7 +265,7 @@ PROCEDURE BuildIncludeVarConst (location: location_t; type: Tree; op1: Tree; op2 op2 is a variable. *) -PROCEDURE BuildIncludeVarVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree) ; +PROCEDURE BuildIncludeVarVar (location: location_t; type: tree; varset: tree; varel: tree; is_lvalue: BOOLEAN; low: tree) ; (* @@ -278,21 +276,21 @@ PROCEDURE BuildIncludeVarVar (location: location_t; type: Tree; varset: Tree; va sequence for all modules. *) -PROCEDURE BuildStart (location: location_t; name: ADDRESS; inner_module: BOOLEAN) : Tree ; +PROCEDURE BuildStart (location: location_t; name: CharStar; inner_module: BOOLEAN) : tree ; (* BuildEnd - complete the initialisation function for this module. *) -PROCEDURE BuildEnd (location: location_t; fndecl: Tree; nested: BOOLEAN) ; +PROCEDURE BuildEnd (location: location_t; fndecl: tree; nested: BOOLEAN) ; (* BuildCallInner - call the inner module function. It has no parameters and no return value. *) -PROCEDURE BuildCallInner (location: location_t; fndecl: Tree) ; +PROCEDURE BuildCallInner (location: location_t; fndecl: tree) ; (* @@ -313,7 +311,7 @@ PROCEDURE SetEndLocation (location: location_t) ; BuildBuiltinCallTree - calls the builtin procedure. *) -PROCEDURE BuildBuiltinCallTree (location: location_t; func: Tree) : Tree ; +PROCEDURE BuildBuiltinCallTree (func: tree) : tree ; END m2statement. diff --git a/gcc/m2/gm2-gcc/m2statement.h b/gcc/m2/gm2-gcc/m2statement.h index 9bdd5487142f..a1eed4881f97 100644 --- a/gcc/m2/gm2-gcc/m2statement.h +++ b/gcc/m2/gm2-gcc/m2statement.h @@ -103,7 +103,7 @@ EXTERN tree m2statement_GetCurrentFunction (void); EXTERN void m2statement_SetBeginLocation (location_t location); EXTERN void m2statement_SetEndLocation (location_t location); EXTERN tree m2statement_GetParamTree (tree call, unsigned int i); -EXTERN tree m2statement_BuildBuiltinCallTree (location_t location, tree func); +EXTERN tree m2statement_BuildBuiltinCallTree (tree func); EXTERN tree m2statement_BuildTryFinally (location_t location, tree call, tree cleanups); diff --git a/gcc/m2/gm2-gcc/m2tree.def b/gcc/m2/gm2-gcc/m2tree.def index 158c57c68c78..27e70d0f0ead 100644 --- a/gcc/m2/gm2-gcc/m2tree.def +++ b/gcc/m2/gm2-gcc/m2tree.def @@ -22,20 +22,18 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2tree ; FROM SYSTEM IMPORT ADDRESS ; - -TYPE - Tree = ADDRESS ; - - -PROCEDURE IsAConstant (t: Tree) : BOOLEAN ; -PROCEDURE IsOrdinal (type: Tree) : BOOLEAN ; -PROCEDURE IsTreeOverflow (value: Tree) : BOOLEAN ; -PROCEDURE skip_const_decl (exp: Tree) : Tree ; -PROCEDURE skip_type_decl (type: Tree) : Tree ; -PROCEDURE is_type (type: Tree) : BOOLEAN ; -PROCEDURE is_array (array: Tree) : BOOLEAN ; -PROCEDURE is_var (var: Tree) : BOOLEAN ; -PROCEDURE debug_tree (t: Tree) ; +FROM gcctypes IMPORT tree ; + + +PROCEDURE IsAConstant (t: tree) : BOOLEAN ; +PROCEDURE IsOrdinal (type: tree) : BOOLEAN ; +PROCEDURE IstreeOverflow (value: tree) : BOOLEAN ; +PROCEDURE skip_const_decl (exp: tree) : tree ; +PROCEDURE skip_type_decl (type: tree) : tree ; +PROCEDURE is_type (type: tree) : BOOLEAN ; +PROCEDURE is_array (array: tree) : BOOLEAN ; +PROCEDURE is_var (var: tree) : BOOLEAN ; +PROCEDURE debug_tree (t: tree) ; END m2tree. diff --git a/gcc/m2/gm2-gcc/m2treelib.def b/gcc/m2/gm2-gcc/m2treelib.def index 1803db7299ce..61f57378d2bc 100644 --- a/gcc/m2/gm2-gcc/m2treelib.def +++ b/gcc/m2/gm2-gcc/m2treelib.def @@ -21,8 +21,7 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2treelib ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; +FROM gcctypes IMPORT location_t, tree ; FROM SYSTEM IMPORT ADDRESS ; TYPE @@ -35,28 +34,28 @@ TYPE NULL is returned if, op, is a constant. *) -PROCEDURE get_set_address_if_var (location: location_t; op: Tree; is_lvalue, is_const: BOOLEAN) : Tree ; +PROCEDURE get_set_address_if_var (location: location_t; op: tree; is_lvalue, is_const: BOOLEAN) : tree ; (* get_set_field_rhs - returns the value of p->field. *) -PROCEDURE get_set_field_rhs (location: location_t; p: Tree; field: Tree) : Tree ; +PROCEDURE get_set_field_rhs (location: location_t; p: tree; field: tree) : tree ; (* get_set_field_lhs - returns the address of p->field. *) -PROCEDURE get_set_field_lhs (location: location_t; p: Tree; field: Tree) : Tree ; +PROCEDURE get_set_field_lhs (location: location_t; p: tree; field: tree) : tree ; (* get_set_address - returns the address of op1. *) -PROCEDURE get_set_address (location: location_t; op1: Tree; is_lvalue: BOOLEAN) : Tree ; +PROCEDURE get_set_address (location: location_t; op1: tree; is_lvalue: BOOLEAN) : tree ; (* @@ -64,7 +63,7 @@ PROCEDURE get_set_address (location: location_t; op1: Tree; is_lvalue: BOOLEAN) Either p->field or the constant(op.fieldNo) is returned. *) -PROCEDURE get_set_value (location: location_t; p: Tree; field: Tree; is_const: BOOLEAN; op: Tree; fieldNo: CARDINAL) : Tree ; +PROCEDURE get_set_value (location: location_t; p: tree; field: tree; is_const: BOOLEAN; op: tree; fieldNo: CARDINAL) : tree ; (* @@ -76,7 +75,7 @@ PROCEDURE get_set_value (location: location_t; p: Tree; field: Tree; is_const: B appropriate field number. *) -PROCEDURE get_field_no (type: Tree; op: Tree; is_const: BOOLEAN; fieldNo: CARDINAL) : Tree ; +PROCEDURE get_field_no (type: tree; op: tree; is_const: BOOLEAN; fieldNo: CARDINAL) : tree ; (* @@ -84,18 +83,18 @@ PROCEDURE get_field_no (type: Tree; op: Tree; is_const: BOOLEAN; fieldNo: CARDIN copied upon indirection. *) -PROCEDURE get_rvalue (location: location_t; t: Tree; type: Tree; is_lvalue: BOOLEAN) : Tree ; +PROCEDURE get_rvalue (location: location_t; t: tree; type: tree; is_lvalue: BOOLEAN) : tree ; (* DoCall - build a call tree arranging the parameter list as a vector. *) -PROCEDURE DoCall (location: location_t; rettype: Tree; funcptr: Tree; param_list: Tree) : Tree ; +PROCEDURE DoCall (location: location_t; rettype: tree; funcptr: tree; param_list: tree) : tree ; -PROCEDURE build_modify_expr (location: location_t; des: Tree; modifycode: tree_code; copy: Tree) : Tree ; +PROCEDURE build_modify_expr (location: location_t; des: tree; modifycode: tree_code; copy: tree) : tree ; (* @@ -103,7 +102,7 @@ PROCEDURE build_modify_expr (location: location_t; des: Tree; modifycode: tree_c If the result is true then jump to label. *) -PROCEDURE do_jump_if_bit (location: location_t; code: tree_code; word: Tree; bit: Tree; label: ADDRESS) ; +PROCEDURE do_jump_if_bit (location: location_t; code: tree_code; word: tree; bit: tree; label: ADDRESS) ; END m2treelib. diff --git a/gcc/m2/gm2-gcc/m2type.def b/gcc/m2/gm2-gcc/m2type.def index fc248e27b7d6..c39c9d06b25c 100644 --- a/gcc/m2/gm2-gcc/m2type.def +++ b/gcc/m2/gm2-gcc/m2type.def @@ -22,9 +22,8 @@ along with GNU Modula-2; see the file COPYING3. If not see DEFINITION MODULE FOR "C" m2type ; FROM SYSTEM IMPORT ADDRESS ; -FROM m2tree IMPORT Tree ; -FROM m2linemap IMPORT location_t ; - +FROM gcctypes IMPORT location_t, tree ; +FROM CDataTypes IMPORT CharStar, ConstCharStar ; TYPE Constructor = ADDRESS ; @@ -35,7 +34,7 @@ TYPE of, type. *) -PROCEDURE ValueInTypeRange (type: Tree; value: Tree) : BOOLEAN ; +PROCEDURE ValueInTypeRange (type: tree; value: tree) : BOOLEAN ; (* @@ -43,49 +42,49 @@ PROCEDURE ValueInTypeRange (type: Tree; value: Tree) : BOOLEAN ; of, type. *) -PROCEDURE ValueOutOfTypeRange (type: Tree; value: Tree) : BOOLEAN ; +PROCEDURE ValueOutOfTypeRange (type: tree; value: tree) : BOOLEAN ; (* ExceedsTypeRange - return TRUE if low or high exceed the range of, type. *) -PROCEDURE ExceedsTypeRange (type: Tree; low, high: Tree) : BOOLEAN ; +PROCEDURE ExceedsTypeRange (type: tree; low, high: tree) : BOOLEAN ; (* WithinTypeRange - return TRUE if low and high are within the range of, type. *) -PROCEDURE WithinTypeRange (type: Tree; low, high: Tree) : BOOLEAN ; +PROCEDURE WithinTypeRange (type: tree; low, high: tree) : BOOLEAN ; (* BuildSubrangeType - creates a subrange of, type, with, lowval, highval. *) -PROCEDURE BuildSubrangeType (location: location_t; name: ADDRESS; type: Tree; lowval: Tree; highval: Tree) : Tree ; +PROCEDURE BuildSubrangeType (location: location_t; name: CharStar; type: tree; lowval: tree; highval: tree) : tree ; (* BuildCharConstant - creates a character constant given a, string. *) -PROCEDURE BuildCharConstant (location: location_t; string: ADDRESS) : Tree ; +PROCEDURE BuildCharConstant (location: location_t; string: ConstCharStar) : tree ; (* BuildCharConstantChar - creates a character constant given a character, ch. *) -PROCEDURE BuildCharConstantChar (location: location_t; ch: CHAR) : Tree ; +PROCEDURE BuildCharConstantChar (location: location_t; ch: CHAR) : tree ; (* BuildArrayConstructorElement - adds, value, to the constructor_element_list. *) -PROCEDURE BuildArrayConstructorElement (p: ADDRESS; value: Tree; indice: Tree) ; +PROCEDURE BuildArrayConstructorElement (p: ADDRESS; value: tree; indice: tree) ; (* @@ -93,7 +92,7 @@ PROCEDURE BuildArrayConstructorElement (p: ADDRESS; value: Tree; indice: Tree) ; compound literal. *) -PROCEDURE BuildEndArrayConstructor (p: Constructor) : Tree ; +PROCEDURE BuildEndArrayConstructor (p: Constructor) : tree ; (* @@ -101,21 +100,21 @@ PROCEDURE BuildEndArrayConstructor (p: Constructor) : Tree ; compound literal. *) -PROCEDURE BuildStartArrayConstructor (type: Tree) : Constructor ; +PROCEDURE BuildStartArrayConstructor (type: tree) : Constructor ; (* BuildRecordConstructorElement - adds, value, to the constructor_element_list. *) -PROCEDURE BuildRecordConstructorElement (p: Constructor; value: Tree) ; +PROCEDURE BuildRecordConstructorElement (p: Constructor; value: tree) ; (* BuildEndRecordConstructor - returns a tree containing the record compound literal. *) -PROCEDURE BuildEndRecordConstructor (p: Constructor) : Tree ; +PROCEDURE BuildEndRecordConstructor (p: Constructor) : tree ; (* @@ -123,21 +122,21 @@ PROCEDURE BuildEndRecordConstructor (p: Constructor) : Tree ; constructor frame. *) -PROCEDURE BuildStartRecordConstructor (type: Tree) : Constructor ; +PROCEDURE BuildStartRecordConstructor (type: tree) : Constructor ; (* BuildEndSetConstructor - finishes building a set constant. *) -PROCEDURE BuildEndSetConstructor (p: Constructor) : Tree ; +PROCEDURE BuildEndSetConstructor (p: Constructor) : tree ; (* BuildSetConstructorElement - adds, value, to the constructor_element_list. *) -PROCEDURE BuildSetConstructorElement (p: Constructor; value: Tree) ; +PROCEDURE BuildSetConstructorElement (p: Constructor; value: tree) ; (* @@ -145,28 +144,28 @@ PROCEDURE BuildSetConstructorElement (p: Constructor; value: Tree) ; Remember that type is really a record type. *) -PROCEDURE BuildStartSetConstructor (type: Tree) : Constructor ; +PROCEDURE BuildStartSetConstructor (type: tree) : Constructor ; (* BuildSetType - creates a SET OF [lowval..highval] *) -PROCEDURE BuildSetType (location: location_t; name: ADDRESS; type: Tree; lowval: Tree; highval: Tree; ispacked: BOOLEAN) : Tree ; +PROCEDURE BuildSetType (location: location_t; name: CharStar; type: tree; lowval: tree; highval: tree; ispacked: BOOLEAN) : tree ; (* BuildConstPointerType - returns a type which is a const pointer to, totype. *) -PROCEDURE BuildConstPointerType (totype: Tree) : Tree ; +PROCEDURE BuildConstPointerType (totype: tree) : tree ; (* BuildPointerType - returns a type which is a pointer to, totype. *) -PROCEDURE BuildPointerType (totype: Tree) : Tree ; +PROCEDURE BuildPointerType (totype: tree) : tree ; (* @@ -174,8 +173,8 @@ PROCEDURE BuildPointerType (totype: Tree) : Tree ; It returns a copy of the value. --fixme-- why do this? *) -PROCEDURE BuildEnumerator (location: location_t; name: ADDRESS; value: Tree; - VAR enumvalues: Tree) : Tree ; +PROCEDURE BuildEnumerator (location: location_t; name: CharStar; value: tree; + VAR enumvalues: tree) : tree ; (* @@ -183,21 +182,21 @@ PROCEDURE BuildEnumerator (location: location_t; name: ADDRESS; value: Tree; list, enumvalues, and returns a enumeration type tree. *) -PROCEDURE BuildEndEnumeration (location: location_t; type: Tree; enumvalues: Tree) : Tree ; +PROCEDURE BuildEndEnumeration (location: location_t; type: tree; enumvalues: tree) : tree ; (* BuildStartEnumeration - create an enumerated type in gcc. *) -PROCEDURE BuildStartEnumeration (location: location_t; name: ADDRESS; ispacked: BOOLEAN) : Tree ; +PROCEDURE BuildStartEnumeration (location: location_t; name: CharStar; ispacked: BOOLEAN) : tree ; (* BuildTypeDeclaration - adds the, type, to the current statement list. *) -PROCEDURE BuildTypeDeclaration (location: location_t; type: Tree) ; +PROCEDURE BuildTypeDeclaration (location: location_t; type: tree) ; (* @@ -205,7 +204,7 @@ PROCEDURE BuildTypeDeclaration (location: location_t; type: Tree) ; legal value. *) -PROCEDURE GetMaxFrom (location: location_t; type: Tree) : Tree ; +PROCEDURE GetMaxFrom (location: location_t; type: tree) : tree ; (* @@ -213,7 +212,7 @@ PROCEDURE GetMaxFrom (location: location_t; type: Tree) : Tree ; legal value. *) -PROCEDURE GetMinFrom (location: location_t; type: Tree) : Tree ; +PROCEDURE GetMinFrom (location: location_t; type: tree) : tree ; (* @@ -229,14 +228,14 @@ PROCEDURE GetMinFrom (location: location_t; type: Tree) : Tree ; declare C default types and _some_ M2 default types. *) -PROCEDURE GetDefaultType (location: location_t; name: ADDRESS; type: Tree) : Tree ; +PROCEDURE GetDefaultType (location: location_t; name: CharStar; type: tree) : tree ; (* BuildEndType - finish declaring, type, and return, type. *) -PROCEDURE BuildEndType (location: location_t; type: Tree) : Tree ; +PROCEDURE BuildEndType (location: location_t; type: tree) : tree ; (* @@ -248,7 +247,7 @@ PROCEDURE BuildEndType (location: location_t; type: Tree) : Tree ; yet to be 'gm2_finish_decl'ed. *) -PROCEDURE BuildStartType (location: location_t; name: ADDRESS; type: Tree) : Tree ; +PROCEDURE BuildStartType (location: location_t; name: CharStar; type: tree) : tree ; (* @@ -271,7 +270,7 @@ PROCEDURE InitBaseTypes (location: location_t) ; This creates and array index, array type and local variable. *) -PROCEDURE BuildVariableArrayAndDeclare (location: location_t; elementtype: Tree; high: Tree; name: ADDRESS; scope: Tree) : Tree ; +PROCEDURE BuildVariableArrayAndDeclare (location: location_t; elementtype: tree; high: tree; name: CharStar; scope: tree) : tree ; (* @@ -286,7 +285,7 @@ PROCEDURE InitFunctionTypeParameters ; It appends this parameter to the internal param_type_list. *) -PROCEDURE BuildProcTypeParameterDeclaration (location: location_t; type: Tree; isreference: BOOLEAN) : Tree ; +PROCEDURE BuildProcTypeParameterDeclaration (location: location_t; type: tree; isreference: BOOLEAN) : tree ; (* @@ -294,7 +293,7 @@ PROCEDURE BuildProcTypeParameterDeclaration (location: location_t; type: Tree; i create a function type. *) -PROCEDURE BuildStartFunctionType (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE BuildStartFunctionType (location: location_t; name: CharStar) : tree ; (* @@ -302,14 +301,14 @@ PROCEDURE BuildStartFunctionType (location: location_t; name: ADDRESS) : Tree ; The arguments have been created by BuildParameterDeclaration. *) -PROCEDURE BuildEndFunctionType (func: Tree; type: Tree; usesvarags: BOOLEAN) : Tree ; +PROCEDURE BuildEndFunctionType (func: tree; type: tree; usesvarags: BOOLEAN) : tree ; (* GetTreeType - returns TREE_TYPE (t). *) -PROCEDURE GetTreeType (type: Tree) : Tree ; +PROCEDURE GetTreeType (type: tree) : tree ; (* @@ -318,31 +317,31 @@ PROCEDURE GetTreeType (type: Tree) : Tree ; name = foo ; *) -PROCEDURE DeclareKnownType (location: location_t; name: ADDRESS; type: Tree) : Tree ; +PROCEDURE DeclareKnownType (location: location_t; name: CharStar; type: tree) : tree ; (* GetM2ZType - return the ISO Z data type, the longest int datatype. *) -PROCEDURE GetM2ZType () : Tree ; +PROCEDURE GetM2ZType () : tree ; (* GetM2RType - return the ISO R data type, the longest real datatype. *) -PROCEDURE GetM2RType () : Tree ; +PROCEDURE GetM2RType () : tree ; (* BuildSetTypeFromSubrange - constructs a set type from a subrangeType. *) -PROCEDURE BuildSetTypeFromSubrange (location: location_t; name: ADDRESS; - subrangeType: Tree; - lowval: Tree; highval: Tree; - ispacked: BOOLEAN) : Tree ; +PROCEDURE BuildSetTypeFromSubrange (location: location_t; name: CharStar; + subrangeType: tree; + lowval: tree; highval: tree; + ispacked: BOOLEAN) : tree ; (* @@ -350,434 +349,434 @@ PROCEDURE BuildSetTypeFromSubrange (location: location_t; name: ADDRESS; sufficient to contain values: low..high. *) -PROCEDURE BuildSmallestTypeRange (location: location_t; low: Tree; high: Tree) : Tree ; +PROCEDURE BuildSmallestTypeRange (location: location_t; low: tree; high: tree) : tree ; (* GetBooleanType - *) -PROCEDURE GetBooleanType () : Tree ; +PROCEDURE GetBooleanType () : tree ; (* GetBooleanFalse - *) -PROCEDURE GetBooleanFalse () : Tree ; +PROCEDURE GetBooleanFalse () : tree ; (* GetBooleanTrue - *) -PROCEDURE GetBooleanTrue () : Tree ; +PROCEDURE GetBooleanTrue () : tree ; (* GetPackedBooleanType - return the packed boolean data type node. *) -PROCEDURE GetPackedBooleanType () : Tree ; +PROCEDURE GetPackedBooleanType () : tree ; (* GetCharType - return the char type node. *) -PROCEDURE GetCharType () : Tree ; +PROCEDURE GetCharType () : tree ; (* GetByteType - return the byte type node. *) -PROCEDURE GetByteType () : Tree ; +PROCEDURE GetByteType () : tree ; (* GetVoidType - return the C void type. *) -PROCEDURE GetVoidType () : Tree ; +PROCEDURE GetVoidType () : tree ; (* GetBitnumType - return the ISO bitnum type. *) -PROCEDURE GetBitnumType () : Tree ; +PROCEDURE GetBitnumType () : tree ; (* GetRealType - *) -PROCEDURE GetRealType () : Tree ; +PROCEDURE GetRealType () : tree ; (* GetLongRealType - return the C long double data type. *) -PROCEDURE GetLongRealType () : Tree ; +PROCEDURE GetLongRealType () : tree ; (* GetShortRealType - return the C float data type. *) -PROCEDURE GetShortRealType () : Tree ; +PROCEDURE GetShortRealType () : tree ; (* GetLongIntType - return the C long int data type. *) -PROCEDURE GetLongIntType () : Tree ; +PROCEDURE GetLongIntType () : tree ; (* GetPointerType - return the GCC ptr type node. Equivalent to (void * ). *) -PROCEDURE GetPointerType () : Tree ; +PROCEDURE GetPointerType () : tree ; (* GetCardinalType - return the cardinal type. *) -PROCEDURE GetCardinalType () : Tree ; +PROCEDURE GetCardinalType () : tree ; (* GetIntegerType - return the integer type node. *) -PROCEDURE GetIntegerType () : Tree ; +PROCEDURE GetIntegerType () : tree ; (* GetWordType - return the C unsigned data type. *) -PROCEDURE GetWordType () : Tree ; +PROCEDURE GetWordType () : tree ; (* GetM2CardinalType - return the m2 cardinal data type. *) -PROCEDURE GetM2CardinalType () : Tree ; +PROCEDURE GetM2CardinalType () : tree ; (* GetBitsetType - return the bitset type. *) -PROCEDURE GetBitsetType () : Tree ; +PROCEDURE GetBitsetType () : tree ; (* GetM2CType - a test function. *) -PROCEDURE GetM2CType () : Tree ; +PROCEDURE GetM2CType () : tree ; (* GetProcType - return the m2 proc data type. *) -PROCEDURE GetProcType () : Tree ; +PROCEDURE GetProcType () : tree ; (* GetM2ComplexType - return the complex type. *) -PROCEDURE GetM2ComplexType () : Tree ; +PROCEDURE GetM2ComplexType () : tree ; (* GetM2LongComplexType - return the long complex type. *) -PROCEDURE GetM2LongComplexType () : Tree ; +PROCEDURE GetM2LongComplexType () : tree ; (* GetM2ShortComplexType - return the short complex type. *) -PROCEDURE GetM2ShortComplexType () : Tree ; +PROCEDURE GetM2ShortComplexType () : tree ; (* GetM2Complex128Type - return the fixed size complex type. *) -PROCEDURE GetM2Complex128 () : Tree ; +PROCEDURE GetM2Complex128 () : tree ; (* GetM2Complex96 - return the fixed size complex type. *) -PROCEDURE GetM2Complex96 () : Tree ; +PROCEDURE GetM2Complex96 () : tree ; (* GetM2Complex64 - return the fixed size complex type. *) -PROCEDURE GetM2Complex64 () : Tree ; +PROCEDURE GetM2Complex64 () : tree ; (* GetM2Complex32 - return the fixed size complex type. *) -PROCEDURE GetM2Complex32 () : Tree ; +PROCEDURE GetM2Complex32 () : tree ; (* GetM2Real128 - return the real 128 bit type. *) -PROCEDURE GetM2Real128 () : Tree ; +PROCEDURE GetM2Real128 () : tree ; (* GetM2Real96 - return the real 96 bit type. *) -PROCEDURE GetM2Real96 () : Tree ; +PROCEDURE GetM2Real96 () : tree ; (* GetM2Real64 - return the real 64 bit type. *) -PROCEDURE GetM2Real64 () : Tree ; +PROCEDURE GetM2Real64 () : tree ; (* GetM2Real32 - return the real 32 bit type. *) -PROCEDURE GetM2Real32 () : Tree ; +PROCEDURE GetM2Real32 () : tree ; (* GetM2Bitset32 - return the bitset 32 bit type. *) -PROCEDURE GetM2Bitset32 () : Tree ; +PROCEDURE GetM2Bitset32 () : tree ; (* GetM2Bitset16 - return the bitset 16 bit type. *) -PROCEDURE GetM2Bitset16 () : Tree ; +PROCEDURE GetM2Bitset16 () : tree ; (* GetM2Bitset8 - return the bitset 8 bit type. *) -PROCEDURE GetM2Bitset8 () : Tree ; +PROCEDURE GetM2Bitset8 () : tree ; (* GetM2Word64 - return the word 64 bit type. *) -PROCEDURE GetM2Word64 () : Tree ; +PROCEDURE GetM2Word64 () : tree ; (* GetM2Word32 - return the word 32 bit type. *) -PROCEDURE GetM2Word32 () : Tree ; +PROCEDURE GetM2Word32 () : tree ; (* GetM2Word16 - return the word 16 bit type. *) -PROCEDURE GetM2Word16 () : Tree ; +PROCEDURE GetM2Word16 () : tree ; (* GetM2Cardinal64 - return the cardinal 64 bit type. *) -PROCEDURE GetM2Cardinal64 () : Tree ; +PROCEDURE GetM2Cardinal64 () : tree ; (* GetM2Cardinal32 - return the cardinal 32 bit type. *) -PROCEDURE GetM2Cardinal32 () : Tree ; +PROCEDURE GetM2Cardinal32 () : tree ; (* GetM2Cardinal16 - return the cardinal 16 bit type. *) -PROCEDURE GetM2Cardinal16 () : Tree ; +PROCEDURE GetM2Cardinal16 () : tree ; (* GetM2Cardinal8 - return the cardinal 8 bit type. *) -PROCEDURE GetM2Cardinal8 () : Tree ; +PROCEDURE GetM2Cardinal8 () : tree ; (* GetM2Integer64 - return the integer 64 bit type. *) -PROCEDURE GetM2Integer64 () : Tree ; +PROCEDURE GetM2Integer64 () : tree ; (* GetM2Integer32 - return the integer 32 bit type. *) -PROCEDURE GetM2Integer32 () : Tree ; +PROCEDURE GetM2Integer32 () : tree ; (* GetM2Integer16 - return the integer 16 bit type. *) -PROCEDURE GetM2Integer16 () : Tree ; +PROCEDURE GetM2Integer16 () : tree ; (* GetM2Integer8 - return the integer 8 bit type. *) -PROCEDURE GetM2Integer8 () : Tree ; +PROCEDURE GetM2Integer8 () : tree ; (* GetISOLocType - return the m2 loc word data type. *) -PROCEDURE GetISOLocType () : Tree ; +PROCEDURE GetISOLocType () : tree ; (* GetISOByteType - return the m2 iso byte data type. *) -PROCEDURE GetISOByteType () : Tree ; +PROCEDURE GetISOByteType () : tree ; (* GetISOWordType - return the m2 iso word data type. *) -PROCEDURE GetISOWordType () : Tree ; +PROCEDURE GetISOWordType () : tree ; (* GetShortCardType - return the C short unsigned data type. *) -PROCEDURE GetShortCardType () : Tree ; +PROCEDURE GetShortCardType () : tree ; (* GetM2ShortCardType - return the m2 short cardinal data type. *) -PROCEDURE GetM2ShortCardType () : Tree ; +PROCEDURE GetM2ShortCardType () : tree ; (* GetShortIntType - return the C short int data type. *) -PROCEDURE GetShortIntType () : Tree ; +PROCEDURE GetShortIntType () : tree ; (* GetM2ShortIntType - return the m2 short integer data type. *) -PROCEDURE GetM2ShortIntType () : Tree ; +PROCEDURE GetM2ShortIntType () : tree ; (* GetM2LongCardType - return the m2 long cardinal data type. *) -PROCEDURE GetM2LongCardType () : Tree ; +PROCEDURE GetM2LongCardType () : tree ; (* GetM2LongIntType - return the m2 long integer data type. *) -PROCEDURE GetM2LongIntType () : Tree ; +PROCEDURE GetM2LongIntType () : tree ; (* GetM2LongRealType - return the m2 long real data type. *) -PROCEDURE GetM2LongRealType () : Tree ; +PROCEDURE GetM2LongRealType () : tree ; (* GetM2RealType - return the m2 real data type. *) -PROCEDURE GetM2RealType () : Tree ; +PROCEDURE GetM2RealType () : tree ; (* GetM2ShortRealType - return the m2 short real data type. *) -PROCEDURE GetM2ShortRealType () : Tree ; +PROCEDURE GetM2ShortRealType () : tree ; (* GetM2IntegerType - return the m2 integer data type. *) -PROCEDURE GetM2IntegerType () : Tree ; +PROCEDURE GetM2IntegerType () : tree ; (* GetM2CharType - return the m2 char data type. *) -PROCEDURE GetM2CharType () : Tree ; +PROCEDURE GetM2CharType () : tree ; (* GetCSizeTType - return a type representing, size_t on this system. *) -PROCEDURE GetCSizeTType () : Tree ; +PROCEDURE GetCSizeTType () : tree ; (* GetCSSizeTType - return a type representing, ssize_t on this system. *) -PROCEDURE GetCSSizeTType () : Tree ; +PROCEDURE GetCSSizeTType () : tree ; (* @@ -786,52 +785,52 @@ PROCEDURE GetCSSizeTType () : Tree ; defined by, str, of, length, characters. *) -PROCEDURE BuildArrayStringConstructor (location: location_t; arrayType: Tree; str: Tree; length: Tree) : Tree ; +PROCEDURE BuildArrayStringConstructor (location: location_t; arrayType: tree; str: tree; length: tree) : tree ; (* RealToTree - convert a real number into a Tree. *) -PROCEDURE RealToTree (name: ADDRESS) : Tree ; +PROCEDURE RealToTree (name: CharStar) : tree ; (* BuildStartRecord - return a RECORD tree. *) -PROCEDURE BuildStartRecord (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE BuildStartRecord (location: location_t; name: CharStar) : tree ; (* BuildStartUnion - return a union tree. *) -PROCEDURE BuildStartUnion (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE BuildStartUnion (location: location_t; name: CharStar) : tree ; -PROCEDURE BuildStartVarient (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE BuildStartVarient (location: location_t; name: CharStar) : tree ; -PROCEDURE BuildEndVarient (location: location_t; varientField: Tree; varientList: Tree; isPacked: BOOLEAN) : Tree ; +PROCEDURE BuildEndVarient (location: location_t; varientField: tree; varientList: tree; isPacked: BOOLEAN) : tree ; -PROCEDURE BuildStartFieldVarient (location: location_t; name: ADDRESS) : Tree ; +PROCEDURE BuildStartFieldVarient (location: location_t; name: CharStar) : tree ; -PROCEDURE BuildEndFieldVarient (location: location_t; varientField: Tree; varientList: Tree; isPacked: BOOLEAN) : Tree ; +PROCEDURE BuildEndFieldVarient (location: location_t; varientField: tree; varientList: tree; isPacked: BOOLEAN) : tree ; -PROCEDURE BuildStartFieldRecord (location: location_t; name: ADDRESS; type: Tree) : Tree ; +PROCEDURE BuildStartFieldRecord (location: location_t; name: CharStar; type: tree) : tree ; -PROCEDURE BuildFieldRecord (location: location_t; name: ADDRESS; type: Tree) : Tree ; +PROCEDURE BuildFieldRecord (location: location_t; name: CharStar; type: tree) : tree ; (* @@ -839,21 +838,21 @@ PROCEDURE BuildFieldRecord (location: location_t; name: ADDRESS; type: Tree) : T declarations. *) -PROCEDURE ChainOn (t1: Tree; t2: Tree) : Tree ; +PROCEDURE ChainOn (t1: tree; t2: tree) : tree ; (* ChainOnParamValue - adds a list node {{name, str}, value} into the tree list. *) -PROCEDURE ChainOnParamValue (list: Tree; name: Tree; str: Tree; value: Tree) : Tree ; +PROCEDURE ChainOnParamValue (list: tree; name: tree; str: tree; value: tree) : tree ; (* AddStringToTreeList - adds, string, to list. *) -PROCEDURE AddStringToTreeList (list: Tree; string: Tree) : Tree ; +PROCEDURE AddStringToTreeList (list: tree; string: tree) : tree ; (* @@ -863,7 +862,7 @@ PROCEDURE AddStringToTreeList (list: Tree; string: Tree) : Tree ; the structure. *) -PROCEDURE BuildEndRecord (location: location_t; record: Tree; fieldlist: Tree; isPacked: BOOLEAN) : Tree ; +PROCEDURE BuildEndRecord (location: location_t; record: tree; fieldlist: tree; isPacked: BOOLEAN) : tree ; (* @@ -872,7 +871,7 @@ PROCEDURE BuildEndRecord (location: location_t; record: Tree; fieldlist: Tree; i to prevent alignment effecting behaviour elsewhere. *) -PROCEDURE SetAlignment (node: Tree; align: Tree) : Tree ; +PROCEDURE SetAlignment (node: tree; align: tree) : tree ; (* @@ -880,7 +879,7 @@ PROCEDURE SetAlignment (node: Tree; align: Tree) : Tree ; It returns the node. *) -PROCEDURE SetDeclPacked (node: Tree) : Tree ; +PROCEDURE SetDeclPacked (node: tree) : tree ; (* @@ -888,7 +887,7 @@ PROCEDURE SetDeclPacked (node: Tree) : Tree ; It returns the node. *) -PROCEDURE SetTypePacked (node: Tree) : Tree ; +PROCEDURE SetTypePacked (node: tree) : tree ; (* @@ -896,7 +895,7 @@ PROCEDURE SetTypePacked (node: Tree) : Tree ; has been applied to it. *) -PROCEDURE SetRecordFieldOffset (field: Tree; byteOffset: Tree; bitOffset: Tree; fieldtype: Tree; nbits: Tree) : Tree ; +PROCEDURE SetRecordFieldOffset (field: tree; byteOffset: tree; bitOffset: tree; fieldtype: tree; nbits: tree) : tree ; (* @@ -904,7 +903,7 @@ PROCEDURE SetRecordFieldOffset (field: Tree; byteOffset: Tree; bitOffset: Tree; name, and, fieldtype. *) -PROCEDURE BuildPackedFieldRecord (location: location_t; name: ADDRESS; fieldtype: Tree) : Tree ; +PROCEDURE BuildPackedFieldRecord (location: location_t; name: CharStar; fieldtype: tree) : tree ; (* @@ -912,21 +911,21 @@ PROCEDURE BuildPackedFieldRecord (location: location_t; name: ADDRESS; fieldtype arrayType. *) -PROCEDURE BuildNumberOfArrayElements (location: location_t; arrayType: Tree) : Tree ; +PROCEDURE BuildNumberOfArrayElements (location: location_t; arrayType: tree) : tree ; (* AddStatement - maps onto add_stmt. *) -PROCEDURE AddStatement (location: location_t; t: Tree) ; +PROCEDURE AddStatement (location: location_t; t: tree) ; (* MarkFunctionReferenced - marks a function as referenced. *) -PROCEDURE MarkFunctionReferenced (f: Tree) ; +PROCEDURE MarkFunctionReferenced (f: tree) ; (* @@ -941,14 +940,14 @@ PROCEDURE GarbageCollect ; low and high are the min, max elements of the array. *) -PROCEDURE BuildArrayIndexType (low: Tree; high: Tree) : Tree ; +PROCEDURE BuildArrayIndexType (low: tree; high: tree) : tree ; (* GetArrayNoOfElements - returns the number of elements in, arraytype. *) -PROCEDURE GetArrayNoOfElements (location: location_t; arraytype: Tree) : Tree ; +PROCEDURE GetArrayNoOfElements (location: location_t; arraytype: tree) : tree ; (* @@ -956,14 +955,14 @@ PROCEDURE GetArrayNoOfElements (location: location_t; arraytype: Tree) : Tree ; and which has ElementType elements. *) -PROCEDURE BuildEndArrayType (arraytype: Tree; elementtype: Tree; indextype: Tree; type: INTEGER) : Tree ; +PROCEDURE BuildEndArrayType (arraytype: tree; elementtype: tree; indextype: tree; type: INTEGER) : tree ; (* PutArrayType - *) -PROCEDURE PutArrayType (array: Tree; type: Tree) ; +PROCEDURE PutArrayType (array: tree; type: tree) ; (* @@ -973,21 +972,21 @@ PROCEDURE PutArrayType (array: Tree; type: Tree) ; NULL_TREE. *) -PROCEDURE BuildStartArrayType (index_type: Tree; elt_type: Tree; type: INTEGER) : Tree ; +PROCEDURE BuildStartArrayType (index_type: tree; elt_type: tree; type: INTEGER) : tree ; (* IsAddress - return TRUE if the type is an ADDRESS. *) -PROCEDURE IsAddress (type: Tree) : BOOLEAN ; +PROCEDURE IsAddress (type: tree) : BOOLEAN ; (* SameRealType - return true if real types a and b are the same. *) -PROCEDURE SameRealType (a, b: Tree) : BOOLEAN ; +PROCEDURE SameRealType (a, b: tree) : BOOLEAN ; END m2type. diff --git a/gcc/m2/m2.flex b/gcc/m2/m2.flex index 2483b282d486..7f9b2d3d9319 100644 --- a/gcc/m2/m2.flex +++ b/gcc/m2/m2.flex @@ -26,6 +26,7 @@ along with GNU Modula-2; see the file COPYING3. If not see #include "GM2LexBuf.h" #include "input.h" #include "m2options.h" +#include "Gm2linemap.h" static int cpreprocessor = 0; /* Replace this with correct getter. */ diff --git a/gcc/m2/mc-boot/GDynamicStrings.cc b/gcc/m2/mc-boot/GDynamicStrings.cc index 329696929851..2b182b9b2c0d 100644 --- a/gcc/m2/mc-boot/GDynamicStrings.cc +++ b/gcc/m2/mc-boot/GDynamicStrings.cc @@ -653,7 +653,7 @@ static void writeStringDesc (DynamicStrings_String__opaque s) writeString ((const char *) ":", 1); writeCstring (s->debug.proc); writeString ((const char *) " ", 1); - writeAddress (reinterpret_cast (s)); + writeAddress (reinterpret_cast (s)); writeString ((const char *) " ", 1); switch (s->head->state) { @@ -1332,7 +1332,7 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne (*c).next->head = NULL; (*c).next->contents.len = 0; (*c).next->contents.next = static_cast (NULL); - ConcatContentsAddress (&(*c).next->contents, reinterpret_cast (p), h-j); + ConcatContentsAddress (&(*c).next->contents, reinterpret_cast (p), h-j); AddDebugInfo ((*c).next); if (TraceOn) { @@ -1472,7 +1472,7 @@ static void DumpStringSynopsis (DynamicStrings_String__opaque s) writeString ((const char *) ":", 1); writeCstring (s->debug.proc); writeString ((const char *) " string ", 8); - writeAddress (reinterpret_cast (s)); + writeAddress (reinterpret_cast (s)); writeString ((const char *) " ", 1); DumpState (s); if (IsOnAllocated (s)) @@ -2064,7 +2064,7 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, DynamicStrings_String__opaque d; DynamicStrings_String__opaque t; int start; - int end; + int stop; int o; if (PoisonOn) @@ -2107,7 +2107,7 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, { start = low-o; } - end = Max (Min (MaxBuf, static_cast (high-o)), 0); + stop = Max (Min (MaxBuf, static_cast (high-o)), 0); while (t->contents.len == MaxBuf) { if (t->contents.next == NULL) @@ -2123,7 +2123,7 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, } t = t->contents.next; } - ConcatContentsAddress (&t->contents, &static_cast (s)->contents.buf.array[start], static_cast (end-start)); + ConcatContentsAddress (&t->contents, &static_cast (s)->contents.buf.array[start], static_cast (stop-start)); o += static_cast (s)->contents.len; s = static_cast (static_cast (s)->contents.next); } diff --git a/gcc/m2/mc-boot/GFIO.cc b/gcc/m2/mc-boot/GFIO.cc index 229dc175e75b..b05c33000bd8 100644 --- a/gcc/m2/mc-boot/GFIO.cc +++ b/gcc/m2/mc-boot/GFIO.cc @@ -585,7 +585,7 @@ static FIO_File InitializeFile (FIO_File f, void * fname, unsigned int flength, } else { - Indexing_PutIndice (FileInfo, f, reinterpret_cast (fd)); + Indexing_PutIndice (FileInfo, f, reinterpret_cast (fd)); fd->name.size = flength+1; /* need to guarantee the nul for C */ fd->usage = use; /* need to guarantee the nul for C */ fd->output = towrite; diff --git a/gcc/m2/mc-boot/GIndexing.cc b/gcc/m2/mc-boot/GIndexing.cc index 7812ebb07a66..dd314001108c 100644 --- a/gcc/m2/mc-boot/GIndexing.cc +++ b/gcc/m2/mc-boot/GIndexing.cc @@ -426,7 +426,7 @@ extern "C" void Indexing_DeleteIndice (Indexing_Index i, unsigned int j) b += sizeof (void *)*(j-static_cast (i)->Low); p = (Indexing_PtrToAddress) (b); b += sizeof (void *); - p = static_cast (libc_memmove (reinterpret_cast (p), reinterpret_cast (b), static_cast ((static_cast (i)->High-j)*sizeof (void *)))); + p = static_cast (libc_memmove (reinterpret_cast (p), reinterpret_cast (b), static_cast ((static_cast (i)->High-j)*sizeof (void *)))); static_cast (i)->High -= 1; static_cast (i)->Used -= 1; } diff --git a/gcc/m2/mc-boot/GM2Dependent.cc b/gcc/m2/mc-boot/GM2Dependent.cc index 25b47b35e217..c965f4bf7f3c 100644 --- a/gcc/m2/mc-boot/GM2Dependent.cc +++ b/gcc/m2/mc-boot/GM2Dependent.cc @@ -590,7 +590,7 @@ static M2Dependent_ModuleChain LookupModuleN (M2Dependent_DependencyState state, { ptr = Modules.array[state-M2Dependent_unregistered]; do { - if (((strncmp (reinterpret_cast (ptr->name), reinterpret_cast (name), max (namelen, static_cast (strlen_ (reinterpret_cast (ptr->name)))))) == 0) && ((strncmp (reinterpret_cast (ptr->libname), reinterpret_cast (libname), max (libnamelen, static_cast (strlen_ (reinterpret_cast (ptr->libname)))))) == 0)) + if (((strncmp (reinterpret_cast (ptr->name), reinterpret_cast (name), max (namelen, static_cast (strlen_ (reinterpret_cast (ptr->name)))))) == 0) && ((strncmp (reinterpret_cast (ptr->libname), reinterpret_cast (libname), max (libnamelen, static_cast (strlen_ (reinterpret_cast (ptr->libname)))))) == 0)) { return ptr; } @@ -610,7 +610,7 @@ static M2Dependent_ModuleChain LookupModuleN (M2Dependent_DependencyState state, static M2Dependent_ModuleChain LookupModule (M2Dependent_DependencyState state, void * name, void * libname) { - return LookupModuleN (state, name, static_cast (strlen_ (reinterpret_cast (name))), libname, static_cast (strlen_ (reinterpret_cast (libname)))); + return LookupModuleN (state, name, static_cast (strlen_ (reinterpret_cast (name))), libname, static_cast (strlen_ (reinterpret_cast (libname)))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1113,7 +1113,7 @@ static void ForceDependencies (void * overrideliborder) case ',': modname = start; modlen = len; - ForceModule (reinterpret_cast (modname), modlen, reinterpret_cast (libname), liblen); + ForceModule (reinterpret_cast (modname), modlen, reinterpret_cast (libname), liblen); libname = NULL; liblen = 0; modlen = 0; @@ -1131,7 +1131,7 @@ static void ForceDependencies (void * overrideliborder) } if (start != pc) { - ForceModule (reinterpret_cast (start), len, reinterpret_cast (libname), liblen); + ForceModule (reinterpret_cast (start), len, reinterpret_cast (libname), liblen); } combine (M2Dependent_user, M2Dependent_ordered); } @@ -1208,7 +1208,7 @@ static bool equal (void * cstr, const char *str_, unsigned int _str_high) /* make a local copy of each unbounded array. */ memcpy (str, str_, _str_high+1); - return (strncmp (reinterpret_cast (cstr), reinterpret_cast (const_cast (static_cast(str))), StrLib_StrLen ((const char *) str, _str_high))) == 0; + return (strncmp (reinterpret_cast (cstr), reinterpret_cast (const_cast (static_cast(str))), StrLib_StrLen ((const char *) str, _str_high))) == 0; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1249,7 +1249,7 @@ static void SetupDebugFlags (void) pc = static_cast (libc_getenv (const_cast (static_cast("GCC_M2LINK_RTFLAG")))); while ((pc != NULL) && ((*pc) != ASCII_nul)) { - if (equal (reinterpret_cast (pc), (const char *) "all", 3)) + if (equal (reinterpret_cast (pc), (const char *) "all", 3)) { ModuleTrace = true; DependencyTrace = true; @@ -1260,43 +1260,43 @@ static void SetupDebugFlags (void) WarningTrace = true; pc += 3; } - else if (equal (reinterpret_cast (pc), (const char *) "module", 6)) + else if (equal (reinterpret_cast (pc), (const char *) "module", 6)) { /* avoid dangling else. */ ModuleTrace = true; pc += 6; } - else if (equal (reinterpret_cast (pc), (const char *) "warning", 7)) + else if (equal (reinterpret_cast (pc), (const char *) "warning", 7)) { /* avoid dangling else. */ WarningTrace = true; pc += 7; } - else if (equal (reinterpret_cast (pc), (const char *) "hex", 3)) + else if (equal (reinterpret_cast (pc), (const char *) "hex", 3)) { /* avoid dangling else. */ HexTrace = true; pc += 3; } - else if (equal (reinterpret_cast (pc), (const char *) "dep", 3)) + else if (equal (reinterpret_cast (pc), (const char *) "dep", 3)) { /* avoid dangling else. */ DependencyTrace = true; pc += 3; } - else if (equal (reinterpret_cast (pc), (const char *) "pre", 3)) + else if (equal (reinterpret_cast (pc), (const char *) "pre", 3)) { /* avoid dangling else. */ PreTrace = true; pc += 3; } - else if (equal (reinterpret_cast (pc), (const char *) "post", 4)) + else if (equal (reinterpret_cast (pc), (const char *) "post", 4)) { /* avoid dangling else. */ PostTrace = true; pc += 4; } - else if (equal (reinterpret_cast (pc), (const char *) "force", 5)) + else if (equal (reinterpret_cast (pc), (const char *) "force", 5)) { /* avoid dangling else. */ ForceTrace = true; diff --git a/gcc/m2/mc-boot/GSArgs.cc b/gcc/m2/mc-boot/GSArgs.cc index 042dbe3fb3f1..93083a056dc3 100644 --- a/gcc/m2/mc-boot/GSArgs.cc +++ b/gcc/m2/mc-boot/GSArgs.cc @@ -94,7 +94,7 @@ extern "C" bool SArgs_GetArg (DynamicStrings_String *s, unsigned int n) a = (void *) (UnixArgs_GetArgV ()); a = reinterpret_cast (reinterpret_cast (a)+n*sizeof (SArgs_PtrToChar)); ppc = static_cast (a); - (*s) = DynamicStrings_InitStringCharStar (reinterpret_cast ((*ppc))); + (*s) = DynamicStrings_InitStringCharStar (reinterpret_cast ((*ppc))); return true; } else diff --git a/gcc/m2/mc-boot/GStringConvert.cc b/gcc/m2/mc-boot/GStringConvert.cc index 5ab4b00a2b78..80efd0c9fc48 100644 --- a/gcc/m2/mc-boot/GStringConvert.cc +++ b/gcc/m2/mc-boot/GStringConvert.cc @@ -1772,11 +1772,11 @@ extern "C" DynamicStrings_String StringConvert_LongrealToString (long double x, if (TotalWidth == 0) { maxprecision = true; - r = ldtoa_ldtoa (x, ldtoa_decimaldigits, 100, &point, &sign); + r = ldtoa_ldtoa (x, static_cast (ldtoa_decimaldigits), 100, &point, &sign); } else { - r = ldtoa_ldtoa (x, ldtoa_decimaldigits, 100, &point, &sign); + r = ldtoa_ldtoa (x, static_cast (ldtoa_decimaldigits), 100, &point, &sign); } s = DynamicStrings_InitStringCharStar (r); libc_free (r); diff --git a/gcc/m2/mc-boot/Gdecl.cc b/gcc/m2/mc-boot/Gdecl.cc index defe0b29537f..9af2842ca18d 100644 --- a/gcc/m2/mc-boot/Gdecl.cc +++ b/gcc/m2/mc-boot/Gdecl.cc @@ -635,6 +635,7 @@ struct decl_moduleT_r { struct decl_defT_r { nameKey_Name name; nameKey_Name source; + bool unqualified; bool hasHidden; bool forC; Indexing_Index exported; @@ -727,6 +728,8 @@ static decl_group freeGroup; static decl_group globalGroup; static FIO_File outputFile; static decl_language lang; +static decl_node__opaque charStarN; +static decl_node__opaque constCharStarN; static decl_node__opaque bitsperunitN; static decl_node__opaque bitsperwordN; static decl_node__opaque bitspercharN; @@ -934,6 +937,18 @@ extern "C" decl_node decl_lookupModule (nameKey_Name n); extern "C" void decl_putDefForC (decl_node n); +/* + putDefUnqualified - the definition module uses unqualified. +*/ + +extern "C" void decl_putDefUnqualified (decl_node n); + +/* + isDefUnqualified - returns TRUE if the definition module uses unqualified. +*/ + +extern "C" bool decl_isDefUnqualified (decl_node n); + /* lookupInScope - looks up a symbol named, n, from, scope. */ @@ -2088,6 +2103,20 @@ static bool isLocal (decl_node__opaque n); static void importEnumFields (decl_node__opaque m, decl_node__opaque n); +/* + checkGccType - check to see if node n is gcc tree or location_t + and record its use in keyc. +*/ + +static void checkGccType (decl_node__opaque n); + +/* + checkCDataTypes - check to see if node n is CharStar or ConstCharStar + and if necessary assign n to the global variable. +*/ + +static void checkCDataTypes (decl_node__opaque n); + /* isComplex - returns TRUE if, n, is the complex type. */ @@ -3306,6 +3335,58 @@ static bool isDeclInImp (decl_node__opaque type); static void doTypeNameModifier (mcPretty_pretty p, decl_node__opaque n); +/* + isGccType - return TRUE if n is tree or location_t. +*/ + +static bool isGccType (decl_node__opaque n); + +/* + doGccType - record whether we are going to declare tree or location_t + so that the appropriate gcc header can be included instead. +*/ + +static void doGccType (mcPretty_pretty p, decl_node__opaque n); + +/* + isCDataType - return true if n is charStar or constCharStar. +*/ + +static bool isCDataType (decl_node__opaque n); + +/* + isCDataTypes - return TRUE if n is CharStar or ConstCharStar. +*/ + +static bool isCDataTypes (decl_node__opaque n); + +/* + doCDataTypes - if we are going to declare CharStar or ConstCharStar + then generate a comment instead. +*/ + +static void doCDataTypes (mcPretty_pretty p, decl_node__opaque n); + +/* + doCDataTypesC - generate the C representation of the CDataTypes data types. +*/ + +static void doCDataTypesC (mcPretty_pretty p, decl_node__opaque n); + +/* + doTypeOrPointer - only declare type or pointer n providing that + the name is not location_t or tree and + the --gccConfigSystem option is enabled. +*/ + +static void doTypeOrPointer (mcPretty_pretty p, decl_node__opaque n); + +/* + doTypedef - generate a typedef for n provuiding it is not +*/ + +static void doTypedef (mcPretty_pretty p, decl_node__opaque n); + /* doTypesC - */ @@ -3983,6 +4064,25 @@ static bool typePair (decl_node__opaque a, decl_node__opaque b, decl_node__opaqu static bool needsCast (decl_node__opaque at, decl_node__opaque ft); +/* + castDestType - emit the destination type ft +*/ + +static void castDestType (mcPretty_pretty p, decl_node__opaque formal, decl_node__opaque ft); + +/* + identifyPointer - +*/ + +static decl_node__opaque identifyPointer (decl_node__opaque type); + +/* + castPointer - provides a six way cast between ADDRESS (ie void * ), + char * and const char *. +*/ + +static unsigned int castPointer (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal, decl_node__opaque at, decl_node__opaque ft); + /* checkSystemCast - checks to see if we are passing to/from a system generic type (WORD, BYTE, ADDRESS) @@ -5538,6 +5638,12 @@ static void makeBaseSymbols (void); static void makeBuiltins (void); +/* + makeCDataTypes - assign the charStarN and constCharStarN to NIL. +*/ + +static void makeCDataTypes (void); + /* init - */ @@ -5556,7 +5662,7 @@ static decl_node__opaque newNode (decl_nodeT k) Storage_ALLOCATE ((void **) &d, sizeof (decl_nodeRec)); if (enableMemsetOnAllocation) { - d = static_cast (libc_memset (reinterpret_cast (d), 0, static_cast (sizeof ((*d))))); + d = static_cast (libc_memset (reinterpret_cast (d), 0, static_cast (sizeof ((*d))))); } if (d == NULL) { @@ -5724,6 +5830,52 @@ static void importEnumFields (decl_node__opaque m, decl_node__opaque n) } +/* + checkGccType - check to see if node n is gcc tree or location_t + and record its use in keyc. +*/ + +static void checkGccType (decl_node__opaque n) +{ + if (((mcOptions_getGccConfigSystem ()) && ((decl_getScope (static_cast (n))) != NULL)) && ((decl_getSymName (decl_getScope (static_cast (n)))) == (nameKey_makeKey ((const char *) "gcctypes", 8)))) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "location_t", 10))) + { + keyc_useGccLocation (); + } + else if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "tree", 4))) + { + /* avoid dangling else. */ + keyc_useGccTree (); + } + } +} + + +/* + checkCDataTypes - check to see if node n is CharStar or ConstCharStar + and if necessary assign n to the global variable. +*/ + +static void checkCDataTypes (decl_node__opaque n) +{ + if (((decl_getScope (static_cast (n))) != NULL) && ((decl_getSymName (decl_getScope (static_cast (n)))) == (nameKey_makeKey ((const char *) "CDataTypes", 10)))) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "CharStar", 8))) + { + charStarN = n; + } + else if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "ConstCharStar", 13))) + { + /* avoid dangling else. */ + constCharStarN = n; + } + } +} + + /* isComplex - returns TRUE if, n, is the complex type. */ @@ -5802,6 +5954,7 @@ static decl_node__opaque makeDef (nameKey_Name n) d->defF.source = nameKey_NulName; d->defF.hasHidden = false; d->defF.forC = false; + d->defF.unqualified = false; d->defF.exported = Indexing_InitIndex (1); d->defF.importedModules = Indexing_InitIndex (1); d->defF.constFixup = initFixupInfo (); @@ -5913,7 +6066,7 @@ static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d) /* avoid gcc warning by using compound statement even if not strictly necessary. */ if ((symbolKey_getSymKey ((*decls).symbols, n)) == NULL) { - symbolKey_putSymKey ((*decls).symbols, n, reinterpret_cast (d)); + symbolKey_putSymKey ((*decls).symbols, n, reinterpret_cast (d)); } else { @@ -5923,22 +6076,22 @@ static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d) } if (decl_isConst (static_cast (d))) { - Indexing_IncludeIndiceIntoIndex ((*decls).constants, reinterpret_cast (d)); + Indexing_IncludeIndiceIntoIndex ((*decls).constants, reinterpret_cast (d)); } else if (decl_isVar (static_cast (d))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex ((*decls).variables, reinterpret_cast (d)); + Indexing_IncludeIndiceIntoIndex ((*decls).variables, reinterpret_cast (d)); } else if (decl_isType (static_cast (d))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex ((*decls).types, reinterpret_cast (d)); + Indexing_IncludeIndiceIntoIndex ((*decls).types, reinterpret_cast (d)); } else if (decl_isProcedure (static_cast (d))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex ((*decls).procedures, reinterpret_cast (d)); + Indexing_IncludeIndiceIntoIndex ((*decls).procedures, reinterpret_cast (d)); if (debugDecl) { libc_printf ((const char *) "%d procedures on the dynamic array\\n", 36, Indexing_HighIndice ((*decls).procedures)); @@ -5957,7 +6110,7 @@ static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d) static void export_ (decl_node__opaque d, decl_node__opaque n) { mcDebug_assert (decl_isDef (static_cast (d))); - Indexing_IncludeIndiceIntoIndex (d->defF.exported, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (d->defF.exported, reinterpret_cast (n)); } @@ -6207,7 +6360,7 @@ static decl_node__opaque addProcedureToScope (decl_node__opaque d, nameKey_Name if (((decl_isDef (static_cast (m))) && ((decl_getSymName (static_cast (m))) == (nameKey_makeKey ((const char *) "M2RTS", 5)))) && ((decl_getSymName (static_cast (d))) == (nameKey_makeKey ((const char *) "HALT", 4)))) { haltN = d; - symbolKey_putSymKey (baseSymbols, n, reinterpret_cast (haltN)); + symbolKey_putSymKey (baseSymbols, n, reinterpret_cast (haltN)); } return addToScope (d); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -6375,7 +6528,7 @@ static void putFieldVarient (decl_node__opaque f, decl_node__opaque v) switch (v->kind) { case decl_varient: - Indexing_IncludeIndiceIntoIndex (v->varientF.listOfSons, reinterpret_cast (f)); + Indexing_IncludeIndiceIntoIndex (v->varientF.listOfSons, reinterpret_cast (f)); break; @@ -6413,14 +6566,14 @@ static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, switch (r->kind) { case decl_record: - Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast (n)); /* ensure that field, n, is in the parents Local Symbols. */ if (tag != nameKey_NulName) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ if ((symbolKey_getSymKey (r->recordF.localSymbols, tag)) == symbolKey_NulKey) { - symbolKey_putSymKey (r->recordF.localSymbols, tag, reinterpret_cast (n)); + symbolKey_putSymKey (r->recordF.localSymbols, tag, reinterpret_cast (n)); } else { @@ -6431,12 +6584,12 @@ static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, break; case decl_varientfield: - Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast (n)); p = getParent (r); mcDebug_assert (p->kind == decl_record); if (tag != nameKey_NulName) { - symbolKey_putSymKey (p->recordF.localSymbols, tag, reinterpret_cast (n)); + symbolKey_putSymKey (p->recordF.localSymbols, tag, reinterpret_cast (n)); } break; @@ -6472,14 +6625,14 @@ static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, static void ensureOrder (Indexing_Index i, decl_node__opaque a, decl_node__opaque b) { - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); - Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (a)); - Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (b)); - Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (a)); - Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (b)); - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); + Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (a)); + Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (b)); + Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (a)); + Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (b)); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); } @@ -6584,17 +6737,17 @@ static void addEnumToModule (decl_node__opaque m, decl_node__opaque e) mcDebug_assert (((decl_isModule (static_cast (m))) || (decl_isDef (static_cast (m)))) || (decl_isImp (static_cast (m)))); if (decl_isModule (static_cast (m))) { - Indexing_IncludeIndiceIntoIndex (m->moduleF.enumFixup.info, reinterpret_cast (e)); + Indexing_IncludeIndiceIntoIndex (m->moduleF.enumFixup.info, reinterpret_cast (e)); } else if (decl_isDef (static_cast (m))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->defF.enumFixup.info, reinterpret_cast (e)); + Indexing_IncludeIndiceIntoIndex (m->defF.enumFixup.info, reinterpret_cast (e)); } else if (decl_isImp (static_cast (m))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->impF.enumFixup.info, reinterpret_cast (e)); + Indexing_IncludeIndiceIntoIndex (m->impF.enumFixup.info, reinterpret_cast (e)); } } @@ -6648,8 +6801,8 @@ static decl_node__opaque doMakeEnumField (decl_node__opaque e, nameKey_Name n) if (f == NULL) { f = newNode (decl_enumerationfield); - symbolKey_putSymKey (e->enumerationF.localSymbols, n, reinterpret_cast (f)); - Indexing_IncludeIndiceIntoIndex (e->enumerationF.listOfSons, reinterpret_cast (f)); + symbolKey_putSymKey (e->enumerationF.localSymbols, n, reinterpret_cast (f)); + Indexing_IncludeIndiceIntoIndex (e->enumerationF.listOfSons, reinterpret_cast (f)); f->enumerationfieldF.name = n; f->enumerationfieldF.type = e; f->enumerationfieldF.scope = static_cast (decl_getDeclScope ()); @@ -6750,17 +6903,17 @@ static void addConstToModule (decl_node__opaque m, decl_node__opaque e) mcDebug_assert (((decl_isModule (static_cast (m))) || (decl_isDef (static_cast (m)))) || (decl_isImp (static_cast (m)))); if (decl_isModule (static_cast (m))) { - Indexing_IncludeIndiceIntoIndex (m->moduleF.constFixup.info, reinterpret_cast (e)); + Indexing_IncludeIndiceIntoIndex (m->moduleF.constFixup.info, reinterpret_cast (e)); } else if (decl_isDef (static_cast (m))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->defF.constFixup.info, reinterpret_cast (e)); + Indexing_IncludeIndiceIntoIndex (m->defF.constFixup.info, reinterpret_cast (e)); } else if (decl_isImp (static_cast (m))) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->impF.constFixup.info, reinterpret_cast (e)); + Indexing_IncludeIndiceIntoIndex (m->impF.constFixup.info, reinterpret_cast (e)); } } @@ -8378,7 +8531,7 @@ static DynamicStrings_String getFQstring (decl_node__opaque n) DynamicStrings_String i; DynamicStrings_String s; - if ((decl_getScope (static_cast (n))) == NULL) + if (((decl_getScope (static_cast (n))) == NULL) || (decl_isDefUnqualified (decl_getScope (static_cast (n))))) { return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); } @@ -8389,7 +8542,7 @@ static DynamicStrings_String getFQstring (decl_node__opaque n) s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast (n))))); return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); } - else if ((! (decl_isExported (static_cast (n)))) || (mcOptions_getIgnoreFQ ())) + else if (((! (decl_isExported (static_cast (n)))) || (mcOptions_getIgnoreFQ ())) || (decl_isDefUnqualified (decl_getScope (static_cast (n))))) { /* avoid dangling else. */ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); @@ -8415,7 +8568,7 @@ static DynamicStrings_String getFQDstring (decl_node__opaque n, bool scopes) DynamicStrings_String i; DynamicStrings_String s; - if ((decl_getScope (static_cast (n))) == NULL) + if (((decl_getScope (static_cast (n))) == NULL) || (decl_isDefUnqualified (decl_getScope (static_cast (n))))) { return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes))); } @@ -8427,7 +8580,7 @@ static DynamicStrings_String getFQDstring (decl_node__opaque n, bool scopes) s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast (n))))); return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); } - else if ((! (decl_isExported (static_cast (n)))) || (mcOptions_getIgnoreFQ ())) + else if (((! (decl_isExported (static_cast (n)))) || (mcOptions_getIgnoreFQ ())) || (decl_isDefUnqualified (decl_getScope (static_cast (n))))) { /* avoid dangling else. */ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes))); @@ -8490,14 +8643,14 @@ static void doNothing (decl_node__opaque n) static void doConstC (decl_node__opaque n) { - if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) + if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) { mcPretty_print (doP, (const char *) "# define ", 11); doFQNameC (doP, n); mcPretty_setNeedSpace (doP); doExprC (doP, n->constF.value); mcPretty_print (doP, (const char *) "\\n", 2); - alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); + alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); } } @@ -11978,6 +12131,195 @@ static void doTypeNameModifier (mcPretty_pretty p, decl_node__opaque n) } +/* + isGccType - return TRUE if n is tree or location_t. +*/ + +static bool isGccType (decl_node__opaque n) +{ + return (mcOptions_getGccConfigSystem ()) && (((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "location_t", 10))) || ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "tree", 4)))); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + doGccType - record whether we are going to declare tree or location_t + so that the appropriate gcc header can be included instead. +*/ + +static void doGccType (mcPretty_pretty p, decl_node__opaque n) +{ + if (mcOptions_getGccConfigSystem ()) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "location_t", 10))) + { + outText (p, (const char *) "/* Not going to declare ", 24); + doTypeNameC (p, n); + outText (p, (const char *) " as it is declared in the gcc header input.h. */\\n\\n", 53); + keyc_useGccLocation (); + } + else if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "tree", 4))) + { + /* avoid dangling else. */ + outText (p, (const char *) "/* Not going to declare ", 24); + doTypeNameC (p, n); + outText (p, (const char *) " as it is declared in the gcc header tree.h. */\\n\\n", 52); + keyc_useGccTree (); + } + } +} + + +/* + isCDataType - return true if n is charStar or constCharStar. +*/ + +static bool isCDataType (decl_node__opaque n) +{ + return (n != NULL) && ((n == charStarN) || (n == constCharStarN)); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + isCDataTypes - return TRUE if n is CharStar or ConstCharStar. +*/ + +static bool isCDataTypes (decl_node__opaque n) +{ + decl_node__opaque scope; + + scope = static_cast (decl_getScope (static_cast (n))); + return ((scope != NULL) && ((decl_getSymName (static_cast (scope))) == (nameKey_makeKey ((const char *) "CDataTypes", 10)))) && (((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "CharStar", 8))) || ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "ConstCharStar", 13)))); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + doCDataTypes - if we are going to declare CharStar or ConstCharStar + then generate a comment instead. +*/ + +static void doCDataTypes (mcPretty_pretty p, decl_node__opaque n) +{ + if (isCDataTypes (n)) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "CharStar", 8))) + { + outText (p, (const char *) "/* Not going to declare ", 24); + doTypeNameC (p, n); + outText (p, (const char *) " as it is a C type. */\\n\\n", 27); + charStarN = n; + } + else if ((decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "ConstCharStar", 13))) + { + /* avoid dangling else. */ + outText (p, (const char *) "/* Not going to declare ", 24); + doTypeNameC (p, n); + outText (p, (const char *) " as it is a C type. */\\n\\n", 27); + constCharStarN = n; + } + } +} + + +/* + doCDataTypesC - generate the C representation of the CDataTypes data types. +*/ + +static void doCDataTypesC (mcPretty_pretty p, decl_node__opaque n) +{ + if (n == charStarN) + { + outText (p, (const char *) "char *", 6); + mcPretty_setNeedSpace (p); + } + else if (n == constCharStarN) + { + /* avoid dangling else. */ + outText (p, (const char *) "const char *", 12); + mcPretty_setNeedSpace (p); + } +} + + +/* + doTypeOrPointer - only declare type or pointer n providing that + the name is not location_t or tree and + the --gccConfigSystem option is enabled. +*/ + +static void doTypeOrPointer (mcPretty_pretty p, decl_node__opaque n) +{ + decl_node__opaque m; + + if (isGccType (n)) + { + doGccType (p, n); + } + else if (isCDataTypes (n)) + { + /* avoid dangling else. */ + doCDataTypes (p, n); + } + else + { + /* avoid dangling else. */ + m = static_cast (decl_getType (static_cast (n))); + outText (p, (const char *) "typedef", 7); + mcPretty_setNeedSpace (p); + doTypeC (p, m, &m); + if (decl_isType (static_cast (m))) + { + mcPretty_setNeedSpace (p); + } + doTypeNameC (p, n); + doTypeNameModifier (p, n); + outText (p, (const char *) ";\\n\\n", 5); + } +} + + +/* + doTypedef - generate a typedef for n provuiding it is not +*/ + +static void doTypedef (mcPretty_pretty p, decl_node__opaque n) +{ + decl_node__opaque m; + + if (isGccType (n)) + { + doGccType (p, n); + } + else if (isCDataTypes (n)) + { + /* avoid dangling else. */ + doCDataTypes (p, n); + } + else + { + /* avoid dangling else. */ + m = static_cast (decl_getType (static_cast (n))); + outText (p, (const char *) "typedef", 7); + mcPretty_setNeedSpace (p); + doTypeC (p, m, &m); + if (decl_isType (static_cast (m))) + { + mcPretty_setNeedSpace (p); + } + doTypeNameC (p, n); + doTypeNameModifier (p, n); + outText (p, (const char *) ";\\n\\n", 5); + } +} + + /* doTypesC - */ @@ -11996,16 +12338,7 @@ static void doTypesC (decl_node__opaque n) else if ((decl_isType (static_cast (m))) || (decl_isPointer (static_cast (m)))) { /* avoid dangling else. */ - outText (doP, (const char *) "typedef", 7); - mcPretty_setNeedSpace (doP); - doTypeC (doP, m, &m); - if (decl_isType (static_cast (m))) - { - mcPretty_setNeedSpace (doP); - } - doTypeNameC (doP, n); - doTypeNameModifier (doP, n); - outText (doP, (const char *) ";\\n\\n", 5); + doTypeOrPointer (doP, n); } else if (decl_isEnumeration (static_cast (m))) { @@ -12023,16 +12356,7 @@ static void doTypesC (decl_node__opaque n) else { /* avoid dangling else. */ - outText (doP, (const char *) "typedef", 7); - mcPretty_setNeedSpace (doP); - doTypeC (doP, m, &m); - if (decl_isType (static_cast (m))) - { - mcPretty_setNeedSpace (doP); - } - doTypeNameC (doP, n); - doTypeNameModifier (doP, n); - outText (doP, (const char *) ";\\n\\n", 5); + doTypedef (doP, n); } } } @@ -13045,6 +13369,11 @@ static void doTypeC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque * { outText (p, (const char *) "void", 4); } + else if (isCDataTypes (n)) + { + /* avoid dangling else. */ + doCDataTypesC (p, n); + } else if (isBase (n)) { /* avoid dangling else. */ @@ -13095,15 +13424,17 @@ static void doTypeC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque * /* avoid dangling else. */ doSetC (p, n); } + else if (isCDataTypes (n)) + { + /* avoid dangling else. */ + doCDataTypesC (p, n); + } else { /* avoid dangling else. */ - /* --fixme-- */ - mcPretty_print (p, (const char *) "to do ... typedef etc etc ", 27); - doFQNameC (p, n); - mcPretty_print (p, (const char *) ";\\n", 3); - M2RTS_HALT (-1); - __builtin_unreachable (); + mcMetaError_metaError1 ((const char *) "expecting a type symbol rather than a {%1DMd} {%1DMa}", 53, (const unsigned char *) &n, (sizeof (n)-1)); + mcError_flushErrors (); + mcError_errorAbort0 ((const char *) "terminating compilation", 23); } } @@ -13160,6 +13491,18 @@ static void doTypeNameC (mcPretty_pretty p, decl_node__opaque n) outText (p, (const char *) "void", 4); mcPretty_setNeedSpace (p); } + else if (n == charStarN) + { + /* avoid dangling else. */ + outText (p, (const char *) "char *", 6); + mcPretty_setNeedSpace (p); + } + else if (n == constCharStarN) + { + /* avoid dangling else. */ + outText (p, (const char *) "const char *", 12); + mcPretty_setNeedSpace (p); + } else if (isBase (n)) { /* avoid dangling else. */ @@ -13582,12 +13925,12 @@ static void doPrototypeC (decl_node__opaque n) static void addTodo (decl_node__opaque n) { - if (((n != NULL) && (! (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))))) && (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))))) + if (((n != NULL) && (! (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))))) && (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))))) { mcDebug_assert (! (decl_isVarient (static_cast (n)))); mcDebug_assert (! (decl_isVarientField (static_cast (n)))); mcDebug_assert (! (decl_isDef (static_cast (n)))); - alists_includeItemIntoList (globalGroup->todoQ, reinterpret_cast (n)); + alists_includeItemIntoList (globalGroup->todoQ, reinterpret_cast (n)); } } @@ -13841,9 +14184,9 @@ static void doSimplifyNode (alists_alist l, decl_node__opaque n) static void simplifyNode (alists_alist l, decl_node__opaque n) { - if (! (alists_isItemInList (l, reinterpret_cast (n)))) + if (! (alists_isItemInList (l, reinterpret_cast (n)))) { - alists_includeItemIntoList (l, reinterpret_cast (n)); + alists_includeItemIntoList (l, reinterpret_cast (n)); doSimplifyNode (l, n); } } @@ -15235,6 +15578,155 @@ static bool needsCast (decl_node__opaque at, decl_node__opaque ft) } +/* + castDestType - emit the destination type ft +*/ + +static void castDestType (mcPretty_pretty p, decl_node__opaque formal, decl_node__opaque ft) +{ + doTypeNameC (p, ft); + if (decl_isVarParam (static_cast (formal))) + { + outText (p, (const char *) "*", 1); + } +} + + +/* + identifyPointer - +*/ + +static decl_node__opaque identifyPointer (decl_node__opaque type) +{ + if (decl_isPointer (static_cast (type))) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((decl_skipType (decl_getType (static_cast (type)))) == charN) + { + return charStarN; + } + else if (((decl_skipType (decl_getType (static_cast (type)))) == byteN) || ((decl_skipType (decl_getType (static_cast (type)))) == locN)) + { + /* avoid dangling else. */ + return addressN; + } + } + return type; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + castPointer - provides a six way cast between ADDRESS (ie void * ), + char * and const char *. +*/ + +static unsigned int castPointer (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal, decl_node__opaque at, decl_node__opaque ft) +{ + decl_node__opaque sat; + decl_node__opaque sft; + unsigned int parenth; + + parenth = 0; + if (at != ft) + { + sat = identifyPointer (static_cast (decl_skipType (static_cast (at)))); + sft = identifyPointer (static_cast (decl_skipType (static_cast (ft)))); + if (sat == addressN) + { + if (sft == charStarN) + { + outText (p, (const char *) "reinterpret_cast <", 18); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + else if (sft == constCharStarN) + { + /* avoid dangling else. */ + outText (p, (const char *) "const_cast <", 12); + castDestType (p, formal, ft); + outText (p, (const char *) "> (static_cast <", 16); + doTypeNameC (p, charStarN); + outText (p, (const char *) ">", 1); + parenth += 1; + } + else + { + /* avoid dangling else. */ + outText (p, (const char *) "reinterpret_cast <", 18); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + } + else if (sat == charStarN) + { + /* avoid dangling else. */ + if (sft == addressN) + { + outText (p, (const char *) "reinterpret_cast <", 18); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + else if (sft == constCharStarN) + { + /* avoid dangling else. */ + outText (p, (const char *) "const_cast <", 12); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + else + { + /* avoid dangling else. */ + outText (p, (const char *) "reinterpret_cast <", 18); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + } + else if (sat == constCharStarN) + { + /* avoid dangling else. */ + if (sft == addressN) + { + outText (p, (const char *) "static_cast <", 13); + castDestType (p, formal, ft); + outText (p, (const char *) "> (const_cast <", 15); + doTypeNameC (p, charStarN); + outText (p, (const char *) ">", 1); + parenth += 1; + } + else if (sft == charStarN) + { + /* avoid dangling else. */ + outText (p, (const char *) "const_cast <", 12); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + else + { + /* avoid dangling else. */ + outText (p, (const char *) "reinterpret_cast <", 18); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + } + else + { + /* avoid dangling else. */ + outText (p, (const char *) "reinterpret_cast <", 18); + castDestType (p, formal, ft); + outText (p, (const char *) ">", 1); + } + mcPretty_setNeedSpace (p); + outText (p, (const char *) "(", 1); + parenth += 1; + } + return parenth; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + /* checkSystemCast - checks to see if we are passing to/from a system generic type (WORD, BYTE, ADDRESS) @@ -15254,12 +15746,18 @@ static unsigned int checkSystemCast (mcPretty_pretty p, decl_node__opaque actual /* avoid gcc warning by using compound statement even if not strictly necessary. */ if (lang == decl_ansiCP) { - if ((isString (actual)) && ((decl_skipType (static_cast (ft))) == addressN)) + if ((isString (actual)) && (isCDataType (static_cast (decl_skipType (static_cast (ft)))))) + { + /* Nothing to do. */ + return 0; + } + else if ((isString (actual)) && ((decl_skipType (static_cast (ft))) == addressN)) { + /* avoid dangling else. */ outText (p, (const char *) "const_cast (static_cast (", 45); return 2; } - else if ((decl_isPointer (decl_skipType (static_cast (ft)))) || ((decl_skipType (static_cast (ft))) == addressN)) + else if (((decl_isPointer (decl_skipType (static_cast (ft)))) || ((decl_skipType (static_cast (ft))) == addressN)) || (isCDataType (static_cast (decl_skipType (static_cast (ft)))))) { /* avoid dangling else. */ if (actual == nilN) @@ -15273,14 +15771,7 @@ static unsigned int checkSystemCast (mcPretty_pretty p, decl_node__opaque actual } else { - outText (p, (const char *) "reinterpret_cast<", 17); - doTypeNameC (p, ft); - if (decl_isVarParam (static_cast (formal))) - { - outText (p, (const char *) "*", 1); - } - mcPretty_noSpace (p); - outText (p, (const char *) "> (", 3); + return castPointer (p, actual, formal, at, ft); } } else @@ -17529,11 +18020,11 @@ static decl_dependentState allDependants (decl_node__opaque n) static decl_dependentState walkDependants (alists_alist l, decl_node__opaque n) { - if ((n == NULL) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) + if ((n == NULL) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) { return decl_completed; } - else if (alists_isItemInList (l, reinterpret_cast (n))) + else if (alists_isItemInList (l, reinterpret_cast (n))) { /* avoid dangling else. */ return decl_recursive; @@ -17541,7 +18032,7 @@ static decl_dependentState walkDependants (alists_alist l, decl_node__opaque n) else { /* avoid dangling else. */ - alists_includeItemIntoList (l, reinterpret_cast (n)); + alists_includeItemIntoList (l, reinterpret_cast (n)); return doDependants (l, n); } /* static analysis guarentees a RETURN statement will be used before here. */ @@ -17558,11 +18049,11 @@ static decl_dependentState walkType (alists_alist l, decl_node__opaque n) decl_node__opaque t; t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) { return decl_completed; } - else if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) + else if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* avoid dangling else. */ return decl_blocked; @@ -17667,18 +18158,18 @@ static void dbq (decl_node__opaque n) if (mcOptions_getDebugTopological ()) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (alists_isItemInList (globalGroup->todoQ, reinterpret_cast (n))) + if (alists_isItemInList (globalGroup->todoQ, reinterpret_cast (n))) { db ((const char *) "{T", 2, n); outText (doP, (const char *) "}", 1); } - else if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))) + else if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))) { /* avoid dangling else. */ db ((const char *) "{P", 2, n); outText (doP, (const char *) "}", 1); } - else if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))) + else if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))) { /* avoid dangling else. */ db ((const char *) "{D", 2, n); @@ -17786,7 +18277,7 @@ static decl_dependentState walkVarient (alists_alist l, decl_node__opaque n) static void queueBlocked (decl_node__opaque n) { - if (! ((alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))) || (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))))) + if (! ((alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))) || (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))))) { addTodo (n); } @@ -17802,7 +18293,7 @@ static decl_dependentState walkVar (alists_alist l, decl_node__opaque n) decl_node__opaque t; t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) { return decl_completed; } @@ -17909,7 +18400,7 @@ static decl_dependentState walkPointer (alists_alist l, decl_node__opaque n) /* if the type of, n, is done or partial then we can output pointer. */ t = static_cast (decl_getType (static_cast (n))); - if ((alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t)))) + if ((alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t)))) { /* pointer to partial can always generate a complete type. */ return decl_completed; @@ -17929,7 +18420,7 @@ static decl_dependentState walkArray (alists_alist l, decl_node__opaque n) decl_dependentState s; /* an array can only be declared if its data type has already been emitted. */ - if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n->arrayF.type)))) + if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n->arrayF.type)))) { s = walkDependants (l, n->arrayF.type); queueBlocked (n->arrayF.type); @@ -17982,7 +18473,7 @@ static decl_dependentState walkVarParam (alists_alist l, decl_node__opaque n) decl_node__opaque t; t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* parameter can be issued from a partial. */ return decl_completed; @@ -18002,7 +18493,7 @@ static decl_dependentState walkParam (alists_alist l, decl_node__opaque n) decl_node__opaque t; t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* parameter can be issued from a partial. */ return decl_completed; @@ -18022,7 +18513,7 @@ static decl_dependentState walkOptarg (alists_alist l, decl_node__opaque n) decl_node__opaque t; t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* parameter can be issued from a partial. */ return decl_completed; @@ -18044,12 +18535,12 @@ static decl_dependentState walkRecordField (alists_alist l, decl_node__opaque n) mcDebug_assert (decl_isRecordField (static_cast (n))); t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { dbs (decl_partial, n); return decl_partial; } - else if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) + else if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) { /* avoid dangling else. */ dbs (decl_completed, n); @@ -18137,7 +18628,7 @@ static decl_dependentState walkProcType (alists_alist l, decl_node__opaque n) decl_node__opaque t; t = static_cast (decl_getType (static_cast (n))); - if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) + if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) {} /* empty. */ else { @@ -19298,7 +19789,7 @@ static void visitIntrinsic (alists_alist v, decl_node__opaque n, decl_nodeProced static void visitDependants (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (n != NULL); - mcDebug_assert (alists_isItemInList (v, reinterpret_cast (n))); + mcDebug_assert (alists_isItemInList (v, reinterpret_cast (n))); switch (n->kind) { case decl_explist: @@ -19651,9 +20142,9 @@ static void visitDependants (alists_alist v, decl_node__opaque n, decl_nodeProce static void visitNode (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - if ((n != NULL) && (! (alists_isItemInList (v, reinterpret_cast (n))))) + if ((n != NULL) && (! (alists_isItemInList (v, reinterpret_cast (n))))) { - alists_includeItemIntoList (v, reinterpret_cast (n)); + alists_includeItemIntoList (v, reinterpret_cast (n)); (*p.proc) (n); visitDependants (v, n, p); } @@ -20222,15 +20713,15 @@ static void tryOutputTodo (decl_nodeProcedure c, decl_nodeProcedure t, decl_node d = static_cast (alists_getItemFromList (globalGroup->todoQ, i)); if (tryComplete (d, c, t, v)) { - alists_removeItemFromList (globalGroup->todoQ, reinterpret_cast (d)); + alists_removeItemFromList (globalGroup->todoQ, reinterpret_cast (d)); addDone (d); i = 1; } else if (tryPartial (d, pt)) { /* avoid dangling else. */ - alists_removeItemFromList (globalGroup->todoQ, reinterpret_cast (d)); - alists_includeItemIntoList (globalGroup->partialQ, reinterpret_cast (d)); + alists_removeItemFromList (globalGroup->todoQ, reinterpret_cast (d)); + alists_includeItemIntoList (globalGroup->partialQ, reinterpret_cast (d)); i = 1; } else @@ -20260,7 +20751,7 @@ static void tryOutputPartial (decl_nodeProcedure t) d = static_cast (alists_getItemFromList (globalGroup->partialQ, i)); if (tryCompleteFromPartial (d, t)) { - alists_removeItemFromList (globalGroup->partialQ, reinterpret_cast (d)); + alists_removeItemFromList (globalGroup->partialQ, reinterpret_cast (d)); addDone (d); i = 1; n -= 1; @@ -21624,7 +22115,7 @@ static void addDone (decl_node__opaque n) { DynamicStrings_String s; - alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); + alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); if ((decl_isVar (static_cast (n))) || (decl_isParameter (static_cast (n)))) { initNodeOpaqueState (n); @@ -21674,7 +22165,7 @@ static decl_node__opaque dbgAdd (alists_alist l, decl_node__opaque n) { if (n != NULL) { - alists_includeItemIntoList (l, reinterpret_cast (n)); + alists_includeItemIntoList (l, reinterpret_cast (n)); } return n; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -21963,7 +22454,7 @@ static void dbg (const char *listName_, unsigned int _listName_high, const char outputFile = FIO_StdOut; doP = mcPretty_initPretty ((mcPretty_writeProc) {(mcPretty_writeProc_t) write_}, (mcPretty_writeLnProc) {(mcPretty_writeLnProc_t) writeln}); l = alists_initList (); - alists_includeItemIntoList (l, reinterpret_cast (n)); + alists_includeItemIntoList (l, reinterpret_cast (n)); i = 1; do { n = static_cast (alists_getItemFromList (l, i)); @@ -22558,46 +23049,46 @@ static void makeBaseSymbols (void) imN = makeBase (decl_im); reN = makeBase (decl_re); cmplxN = makeBase (decl_cmplx); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "BOOLEAN", 7), reinterpret_cast (booleanN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "PROC", 4), reinterpret_cast (procN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CHAR", 4), reinterpret_cast (charN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CARDINAL", 8), reinterpret_cast (cardinalN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTCARD", 9), reinterpret_cast (shortcardN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGCARD", 8), reinterpret_cast (longcardN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "INTEGER", 7), reinterpret_cast (integerN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGINT", 7), reinterpret_cast (longintN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTINT", 8), reinterpret_cast (shortintN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "BITSET", 6), reinterpret_cast (bitsetN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "REAL", 4), reinterpret_cast (realN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTREAL", 9), reinterpret_cast (shortrealN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGREAL", 8), reinterpret_cast (longrealN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "COMPLEX", 7), reinterpret_cast (complexN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGCOMPLEX", 11), reinterpret_cast (longcomplexN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTCOMPLEX", 12), reinterpret_cast (shortcomplexN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "NIL", 3), reinterpret_cast (nilN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "TRUE", 4), reinterpret_cast (trueN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "FALSE", 5), reinterpret_cast (falseN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SIZE", 4), reinterpret_cast (sizeN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "MIN", 3), reinterpret_cast (minN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "MAX", 3), reinterpret_cast (maxN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "FLOAT", 5), reinterpret_cast (floatN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "TRUNC", 5), reinterpret_cast (truncN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "ORD", 3), reinterpret_cast (ordN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "VAL", 3), reinterpret_cast (valN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CHR", 3), reinterpret_cast (chrN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CAP", 3), reinterpret_cast (capN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "ABS", 3), reinterpret_cast (absN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "NEW", 3), reinterpret_cast (newN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "DISPOSE", 7), reinterpret_cast (disposeN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LENGTH", 6), reinterpret_cast (lengthN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "INC", 3), reinterpret_cast (incN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "DEC", 3), reinterpret_cast (decN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "INCL", 4), reinterpret_cast (inclN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "EXCL", 4), reinterpret_cast (exclN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "HIGH", 4), reinterpret_cast (highN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CMPLX", 5), reinterpret_cast (cmplxN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "RE", 2), reinterpret_cast (reN)); - symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "IM", 2), reinterpret_cast (imN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "BOOLEAN", 7), reinterpret_cast (booleanN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "PROC", 4), reinterpret_cast (procN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CHAR", 4), reinterpret_cast (charN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CARDINAL", 8), reinterpret_cast (cardinalN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTCARD", 9), reinterpret_cast (shortcardN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGCARD", 8), reinterpret_cast (longcardN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "INTEGER", 7), reinterpret_cast (integerN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGINT", 7), reinterpret_cast (longintN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTINT", 8), reinterpret_cast (shortintN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "BITSET", 6), reinterpret_cast (bitsetN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "REAL", 4), reinterpret_cast (realN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTREAL", 9), reinterpret_cast (shortrealN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGREAL", 8), reinterpret_cast (longrealN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "COMPLEX", 7), reinterpret_cast (complexN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LONGCOMPLEX", 11), reinterpret_cast (longcomplexN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SHORTCOMPLEX", 12), reinterpret_cast (shortcomplexN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "NIL", 3), reinterpret_cast (nilN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "TRUE", 4), reinterpret_cast (trueN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "FALSE", 5), reinterpret_cast (falseN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "SIZE", 4), reinterpret_cast (sizeN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "MIN", 3), reinterpret_cast (minN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "MAX", 3), reinterpret_cast (maxN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "FLOAT", 5), reinterpret_cast (floatN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "TRUNC", 5), reinterpret_cast (truncN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "ORD", 3), reinterpret_cast (ordN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "VAL", 3), reinterpret_cast (valN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CHR", 3), reinterpret_cast (chrN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CAP", 3), reinterpret_cast (capN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "ABS", 3), reinterpret_cast (absN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "NEW", 3), reinterpret_cast (newN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "DISPOSE", 7), reinterpret_cast (disposeN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "LENGTH", 6), reinterpret_cast (lengthN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "INC", 3), reinterpret_cast (incN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "DEC", 3), reinterpret_cast (decN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "INCL", 4), reinterpret_cast (inclN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "EXCL", 4), reinterpret_cast (exclN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "HIGH", 4), reinterpret_cast (highN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "CMPLX", 5), reinterpret_cast (cmplxN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "RE", 2), reinterpret_cast (reN)); + symbolKey_putSymKey (baseSymbols, nameKey_makeKey ((const char *) "IM", 2), reinterpret_cast (imN)); addDone (booleanN); addDone (charN); addDone (cardinalN); @@ -22640,6 +23131,22 @@ static void makeBuiltins (void) } +/* + makeCDataTypes - assign the charStarN and constCharStarN to NIL. +*/ + +static void makeCDataTypes (void) +{ + decl_node__opaque CdatatypesN; + + CdatatypesN = static_cast (decl_lookupDef (nameKey_makeKey ((const char *) "CDataTypes", 10))); + decl_enterScope (static_cast (CdatatypesN)); + charStarN = static_cast (decl_makePointer (static_cast (charN))); + constCharStarN = static_cast (decl_makePointer (static_cast (charN))); + decl_leaveScope (); +} + + /* init - */ @@ -22663,6 +23170,7 @@ static void init (void) outputState = decl_punct; tempCount = 0; mustVisitScope = false; + makeCDataTypes (); } @@ -23006,8 +23514,8 @@ extern "C" decl_node decl_lookupDef (nameKey_Name n) if (d == NULL) { d = makeDef (n); - symbolKey_putSymKey (defUniverse, n, reinterpret_cast (d)); - Indexing_IncludeIndiceIntoIndex (defUniverseI, reinterpret_cast (d)); + symbolKey_putSymKey (defUniverse, n, reinterpret_cast (d)); + Indexing_IncludeIndiceIntoIndex (defUniverseI, reinterpret_cast (d)); } return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -23027,8 +23535,8 @@ extern "C" decl_node decl_lookupImp (nameKey_Name n) if (m == NULL) { m = makeImp (n); - symbolKey_putSymKey (modUniverse, n, reinterpret_cast (m)); - Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast (m)); + symbolKey_putSymKey (modUniverse, n, reinterpret_cast (m)); + Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast (m)); } mcDebug_assert (! (decl_isModule (static_cast (m)))); return static_cast (m); @@ -23049,8 +23557,8 @@ extern "C" decl_node decl_lookupModule (nameKey_Name n) if (m == NULL) { m = makeModule (n); - symbolKey_putSymKey (modUniverse, n, reinterpret_cast (m)); - Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast (m)); + symbolKey_putSymKey (modUniverse, n, reinterpret_cast (m)); + Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast (m)); } mcDebug_assert (! (decl_isImp (static_cast (m)))); return static_cast (m); @@ -23070,6 +23578,35 @@ extern "C" void decl_putDefForC (decl_node n) } +/* + putDefUnqualified - the definition module uses unqualified. +*/ + +extern "C" void decl_putDefUnqualified (decl_node n) +{ + mcDebug_assert (decl_isDef (n)); + /* Currently (and this is a temporary development restriction to + reduce any search space for bugs) the only module which can be + export unqualified is gcctypes. */ + if (static_cast (n)->defF.name == (nameKey_makeKey ((const char *) "gcctypes", 8))) + { + static_cast (n)->defF.unqualified = true; + } +} + + +/* + isDefUnqualified - returns TRUE if the definition module uses unqualified. +*/ + +extern "C" bool decl_isDefUnqualified (decl_node n) +{ + return (decl_isDef (n)) && static_cast (n)->defF.unqualified; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + /* lookupInScope - looks up a symbol named, n, from, scope. */ @@ -23491,7 +24028,7 @@ extern "C" decl_node decl_getType (decl_node n) extern "C" decl_node decl_skipType (decl_node n) { - while ((n != NULL) && (decl_isType (n))) + while (((n != NULL) && (decl_isType (n))) && (! (isCDataType (static_cast (n))))) { if ((decl_getType (n)) == NULL) { @@ -23620,7 +24157,7 @@ extern "C" bool decl_isExported (decl_node n) switch (s->kind) { case decl_def: - return Indexing_IsIndiceInIndex (s->defF.exported, reinterpret_cast (n)); + return Indexing_IsIndiceInIndex (s->defF.exported, reinterpret_cast (n)); break; @@ -24552,11 +25089,11 @@ extern "C" decl_node decl_makeVarient (decl_node r) { case decl_record: /* now add, n, to the record/varient, r, field list */ - Indexing_IncludeIndiceIntoIndex (static_cast (r)->recordF.listOfSons, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (static_cast (r)->recordF.listOfSons, reinterpret_cast (n)); break; case decl_varientfield: - Indexing_IncludeIndiceIntoIndex (static_cast (r)->varientfieldF.listOfSons, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (static_cast (r)->varientfieldF.listOfSons, reinterpret_cast (n)); break; @@ -25051,21 +25588,23 @@ extern "C" decl_node decl_import (decl_node m, decl_node n) mcDebug_assert (((decl_isDef (m)) || (decl_isModule (m))) || (decl_isImp (m))); name = decl_getSymName (n); + checkGccType (static_cast (n)); + checkCDataTypes (static_cast (n)); r = static_cast (decl_lookupInScope (m, name)); if (r == NULL) { switch (static_cast (m)->kind) { case decl_def: - symbolKey_putSymKey (static_cast (m)->defF.decls.symbols, name, reinterpret_cast (n)); + symbolKey_putSymKey (static_cast (m)->defF.decls.symbols, name, reinterpret_cast (n)); break; case decl_imp: - symbolKey_putSymKey (static_cast (m)->impF.decls.symbols, name, reinterpret_cast (n)); + symbolKey_putSymKey (static_cast (m)->impF.decls.symbols, name, reinterpret_cast (n)); break; case decl_module: - symbolKey_putSymKey (static_cast (m)->moduleF.decls.symbols, name, reinterpret_cast (n)); + symbolKey_putSymKey (static_cast (m)->moduleF.decls.symbols, name, reinterpret_cast (n)); break; @@ -25152,17 +25691,17 @@ extern "C" void decl_addImportedModule (decl_node m, decl_node i, bool scoped) mcDebug_assert ((decl_isDef (i)) || (decl_isModule (i))); if (decl_isDef (m)) { - Indexing_IncludeIndiceIntoIndex (static_cast (m)->defF.importedModules, reinterpret_cast (i)); + Indexing_IncludeIndiceIntoIndex (static_cast (m)->defF.importedModules, reinterpret_cast (i)); } else if (decl_isImp (m)) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (static_cast (m)->impF.importedModules, reinterpret_cast (i)); + Indexing_IncludeIndiceIntoIndex (static_cast (m)->impF.importedModules, reinterpret_cast (i)); } else if (decl_isModule (m)) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (static_cast (m)->moduleF.importedModules, reinterpret_cast (i)); + Indexing_IncludeIndiceIntoIndex (static_cast (m)->moduleF.importedModules, reinterpret_cast (i)); } else { @@ -25287,14 +25826,14 @@ extern "C" void decl_foreachModModuleDo (symbolKey_performOperation p) extern "C" void decl_enterScope (decl_node n) { - if (Indexing_IsIndiceInIndex (scopeStack, reinterpret_cast (n))) + if (Indexing_IsIndiceInIndex (scopeStack, reinterpret_cast (n))) { M2RTS_HALT (-1); __builtin_unreachable (); } else { - Indexing_IncludeIndiceIntoIndex (scopeStack, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (scopeStack, reinterpret_cast (n)); } if (debugScopes) { @@ -25315,7 +25854,7 @@ extern "C" void decl_leaveScope (void) i = Indexing_HighIndice (scopeStack); n = static_cast (Indexing_GetIndice (scopeStack, i)); - Indexing_RemoveIndiceFromIndex (scopeStack, reinterpret_cast (n)); + Indexing_RemoveIndiceFromIndex (scopeStack, reinterpret_cast (n)); if (debugScopes) { libc_printf ((const char *) "leave scope\\n", 13); @@ -25582,7 +26121,7 @@ extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type, else { p = static_cast (decl_makeVarParameter (i, type, n, isused)); - Indexing_IncludeIndiceIntoIndex (static_cast (n)->procedureF.parameters, reinterpret_cast (p)); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->procedureF.parameters, reinterpret_cast (p)); } } @@ -25606,7 +26145,7 @@ extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node ty else { p = static_cast (decl_makeNonVarParameter (i, type, n, isused)); - Indexing_IncludeIndiceIntoIndex (static_cast (n)->procedureF.parameters, reinterpret_cast (p)); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->procedureF.parameters, reinterpret_cast (p)); } } @@ -25649,7 +26188,7 @@ extern "C" void decl_addParameter (decl_node proc, decl_node param) switch (static_cast (proc)->kind) { case decl_procedure: - Indexing_IncludeIndiceIntoIndex (static_cast (proc)->procedureF.parameters, reinterpret_cast (param)); + Indexing_IncludeIndiceIntoIndex (static_cast (proc)->procedureF.parameters, reinterpret_cast (param)); if (decl_isVarargs (param)) { static_cast (proc)->procedureF.vararg = true; @@ -25661,7 +26200,7 @@ extern "C" void decl_addParameter (decl_node proc, decl_node param) break; case decl_proctype: - Indexing_IncludeIndiceIntoIndex (static_cast (proc)->proctypeF.parameters, reinterpret_cast (param)); + Indexing_IncludeIndiceIntoIndex (static_cast (proc)->proctypeF.parameters, reinterpret_cast (param)); if (decl_isVarargs (param)) { static_cast (proc)->proctypeF.vararg = true; @@ -26086,7 +26625,7 @@ extern "C" decl_node decl_putSetValue (decl_node n, decl_node t) extern "C" decl_node decl_includeSetValue (decl_node n, decl_node l, decl_node h) { mcDebug_assert (decl_isSetValue (n)); - Indexing_IncludeIndiceIntoIndex (static_cast (n)->setvalueF.values, reinterpret_cast (l)); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->setvalueF.values, reinterpret_cast (l)); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26165,7 +26704,7 @@ extern "C" void decl_putExpList (decl_node n, decl_node e) { mcDebug_assert (n != NULL); mcDebug_assert (decl_isExpList (n)); - Indexing_PutIndice (static_cast (n)->explistF.exp, (Indexing_HighIndice (static_cast (n)->explistF.exp))+1, reinterpret_cast (e)); + Indexing_PutIndice (static_cast (n)->explistF.exp, (Indexing_HighIndice (static_cast (n)->explistF.exp))+1, reinterpret_cast (e)); } @@ -26349,7 +26888,7 @@ extern "C" void decl_addStatement (decl_node s, decl_node n) if (n != NULL) { mcDebug_assert (decl_isStatementSequence (s)); - Indexing_PutIndice (static_cast (s)->stmtF.statements, (Indexing_HighIndice (static_cast (s)->stmtF.statements))+1, reinterpret_cast (n)); + Indexing_PutIndice (static_cast (s)->stmtF.statements, (Indexing_HighIndice (static_cast (s)->stmtF.statements))+1, reinterpret_cast (n)); if ((isIntrinsic (static_cast (n))) && static_cast (n)->intrinsicF.postUnreachable) { static_cast (n)->intrinsicF.postUnreachable = false; @@ -27050,7 +27589,7 @@ extern "C" decl_node decl_putCaseStatement (decl_node n, decl_node l, decl_node { mcDebug_assert (decl_isCase (n)); mcDebug_assert (decl_isCaseList (l)); - Indexing_IncludeIndiceIntoIndex (static_cast (n)->caseF.caseLabelList, reinterpret_cast (decl_makeCaseLabelList (l, s))); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->caseF.caseLabelList, reinterpret_cast (decl_makeCaseLabelList (l, s))); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -27123,7 +27662,7 @@ extern "C" bool decl_isCaseList (decl_node n) extern "C" decl_node decl_putCaseRange (decl_node n, decl_node lo, decl_node hi) { mcDebug_assert (decl_isCaseList (n)); - Indexing_IncludeIndiceIntoIndex (static_cast (n)->caselistF.rangePairs, reinterpret_cast (decl_makeRange (lo, hi))); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->caselistF.rangePairs, reinterpret_cast (decl_makeRange (lo, hi))); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); diff --git a/gcc/m2/mc-boot/Gdecl.h b/gcc/m2/mc-boot/Gdecl.h index a237a25a3f6c..99d78087ae2a 100644 --- a/gcc/m2/mc-boot/Gdecl.h +++ b/gcc/m2/mc-boot/Gdecl.h @@ -190,6 +190,18 @@ EXTERN decl_node decl_lookupModule (nameKey_Name n); EXTERN void decl_putDefForC (decl_node n); +/* + putDefUnqualified - the definition module uses export unqualified. +*/ + +EXTERN void decl_putDefUnqualified (decl_node n); + +/* + isDefUnqualified - returns TRUE if the definition module uses unqualified. +*/ + +EXTERN bool decl_isDefUnqualified (decl_node n); + /* lookupInScope - looks up a symbol named, n, from, scope. */ diff --git a/gcc/m2/mc-boot/Gdtoa.h b/gcc/m2/mc-boot/Gdtoa.h index 946e339d69ad..c1b3619ce475 100644 --- a/gcc/m2/mc-boot/Gdtoa.h +++ b/gcc/m2/mc-boot/Gdtoa.h @@ -68,7 +68,7 @@ EXTERN double dtoa_strtod (void * s, bool *error); sign does the string have a sign? */ -EXTERN void * dtoa_dtoa (double d, dtoa_Mode mode, int ndigits, int *decpt, bool *sign); +EXTERN void * dtoa_dtoa (double d, int mode, int ndigits, int *decpt, bool *sign); # ifdef __cplusplus } # endif diff --git a/gcc/m2/mc-boot/Gkeyc.cc b/gcc/m2/mc-boot/Gkeyc.cc index 15f03509989a..3a5dd5ccc1de 100644 --- a/gcc/m2/mc-boot/Gkeyc.cc +++ b/gcc/m2/mc-boot/Gkeyc.cc @@ -73,6 +73,8 @@ static symbolKey_symbolTree keywords; static symbolKey_symbolTree macros; static bool initializedCP; static bool initializedGCC; +static bool seenGccTree; +static bool seenGccLocation; static bool seenIntMin; static bool seenUIntMin; static bool seenLongMin; @@ -108,6 +110,18 @@ static bool seenM2RTS; static bool seenStrlen; static bool seenCtype; +/* + useGccTree - indicate we have imported tree from gcctypes. +*/ + +extern "C" void keyc_useGccTree (void); + +/* + useGccLocation - indicate we have imported tree from gcctypes. +*/ + +extern "C" void keyc_useGccLocation (void); + /* useUnistd - need to use unistd.h call using open/close/read/write require this header. */ @@ -369,6 +383,13 @@ extern "C" void keyc_cp (void); static void checkGccConfigSystem (mcPretty_pretty p); +/* + checkGccTypes - if we have imported tree or location_t from gcctypes + then we include the gcc headers. +*/ + +static void checkGccTypes (mcPretty_pretty p); + /* checkCtype - */ @@ -556,11 +577,26 @@ static void checkGccConfigSystem (mcPretty_pretty p) initializedGCC = true; mcPretty_print (p, (const char *) "#include \"config.h\"\\n", 21); mcPretty_print (p, (const char *) "#include \"system.h\"\\n", 21); + checkGccTypes (p); } } } +/* + checkGccTypes - if we have imported tree or location_t from gcctypes + then we include the gcc headers. +*/ + +static void checkGccTypes (mcPretty_pretty p) +{ + if (seenGccTree || seenGccLocation) + { + mcPretty_print (p, (const char *) "#include \"gcc-consolidation.h\"\\n\\n", 34); + } +} + + /* checkCtype - */ @@ -976,7 +1012,7 @@ static void add (symbolKey_symbolTree s, const char *a_, unsigned int _a_high) /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - symbolKey_putSymKey (s, nameKey_makeKey ((const char *) a, _a_high), reinterpret_cast (DynamicStrings_InitString ((const char *) a, _a_high))); + symbolKey_putSymKey (s, nameKey_makeKey ((const char *) a, _a_high), reinterpret_cast (DynamicStrings_InitString ((const char *) a, _a_high))); } @@ -1104,6 +1140,8 @@ static void init (void) seenSize_t = false; seenSSize_t = false; seenSysTypes = false; + seenGccTree = false; + seenGccLocation = false; initializedCP = false; initializedGCC = false; stack = NULL; @@ -1113,6 +1151,26 @@ static void init (void) } +/* + useGccTree - indicate we have imported tree from gcctypes. +*/ + +extern "C" void keyc_useGccTree (void) +{ + seenGccTree = true; +} + + +/* + useGccLocation - indicate we have imported tree from gcctypes. +*/ + +extern "C" void keyc_useGccLocation (void) +{ + seenGccLocation = true; +} + + /* useUnistd - need to use unistd.h call using open/close/read/write require this header. */ @@ -1547,7 +1605,7 @@ extern "C" DynamicStrings_String keyc_cname (nameKey_Name n, bool scopes) { /* no longer a clash with, m, so add it to the current scope. */ n = nameKey_makekey (DynamicStrings_string (m)); - symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (m)); + symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (m)); } } else @@ -1561,7 +1619,7 @@ extern "C" DynamicStrings_String keyc_cname (nameKey_Name n, bool scopes) { /* avoid dangling else. */ /* no clash, add it to the current scope. */ - symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)))); + symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)))); } return m; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1593,7 +1651,7 @@ extern "C" nameKey_Name keyc_cnamen (nameKey_Name n, bool scopes) if (scopes) { /* no longer a clash with, m, so add it to the current scope. */ - symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (m)); + symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (m)); } } else @@ -1607,7 +1665,7 @@ extern "C" nameKey_Name keyc_cnamen (nameKey_Name n, bool scopes) { /* avoid dangling else. */ /* no clash, add it to the current scope. */ - symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)))); + symbolKey_putSymKey (stack->symbols, n, reinterpret_cast (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)))); } m = DynamicStrings_KillString (m); return n; diff --git a/gcc/m2/mc-boot/Gkeyc.h b/gcc/m2/mc-boot/Gkeyc.h index 2157bab57ac8..afa945d03c02 100644 --- a/gcc/m2/mc-boot/Gkeyc.h +++ b/gcc/m2/mc-boot/Gkeyc.h @@ -48,6 +48,18 @@ extern "C" { # endif +/* + useGccTree - indicate we have imported tree from gcctypes. +*/ + +EXTERN void keyc_useGccTree (void); + +/* + useGccLocation - indicate we have imported tree from gcctypes. +*/ + +EXTERN void keyc_useGccLocation (void); + /* useUnistd - need to use unistd.h call using open/close/read/write require this header. */ diff --git a/gcc/m2/mc-boot/Glibc.h b/gcc/m2/mc-boot/Glibc.h index 957232345f56..def419fb3c9a 100644 --- a/gcc/m2/mc-boot/Glibc.h +++ b/gcc/m2/mc-boot/Glibc.h @@ -85,6 +85,17 @@ typedef libc_exitP_t libc_exitP_C; struct libc_exitP_p { libc_exitP_t proc; }; +EXTERN double libc_atof (void * nptr); +EXTERN int libc_atoi (void * nptr); +EXTERN ssize_t libc_atol (void * nptr); +EXTERN long int libc_atoll (void * nptr); +EXTERN double libc_strtod (void * nptr, void * endptr); +EXTERN float libc_strtof (void * nptr, void * endptr); +EXTERN long double libc_strtold (void * nptr, void * endptr); +EXTERN ssize_t libc_strtol (void * nptr, void * endptr, int base); +EXTERN long int libc_strtoll (void * nptr, void * endptr, int base); +EXTERN size_t libc_strtoul (void * nptr, void * endptr, int base); +EXTERN long unsigned int libc_strtoull (void * nptr, void * endptr, int base); EXTERN ssize_t libc_write (int d, void * buf, size_t nbytes); EXTERN ssize_t libc_read (int d, void * buf, size_t nbytes); EXTERN int libc_system (void * a); diff --git a/gcc/m2/mc-boot/GmcComp.cc b/gcc/m2/mc-boot/GmcComp.cc index f7baf21af894..c941c618030d 100644 --- a/gcc/m2/mc-boot/GmcComp.cc +++ b/gcc/m2/mc-boot/GmcComp.cc @@ -593,9 +593,9 @@ static void doPass (bool parseDefs, bool parseMain, unsigned int no, symbolKey_p if (parseDefs && (decl_isImp (decl_getMainModule ()))) { /* we need to parse the definition module of a corresponding implementation module. */ - (*p.proc) (reinterpret_cast (decl_lookupDef (decl_getSymName (decl_getMainModule ())))); + (*p.proc) (reinterpret_cast (decl_lookupDef (decl_getSymName (decl_getMainModule ())))); } - (*p.proc) (reinterpret_cast (decl_getMainModule ())); + (*p.proc) (reinterpret_cast (decl_getMainModule ())); } if (parseDefs) { diff --git a/gcc/m2/mc-boot/GmcLexBuf.cc b/gcc/m2/mc-boot/GmcLexBuf.cc index bd6d45738dfa..4cbd54429d11 100644 --- a/gcc/m2/mc-boot/GmcLexBuf.cc +++ b/gcc/m2/mc-boot/GmcLexBuf.cc @@ -707,7 +707,7 @@ static void checkIfNeedToDuplicate (void) currentSource = newList (); while (l != h) { - addTo (newElement (reinterpret_cast (l->name))); + addTo (newElement (reinterpret_cast (l->name))); l = l->right; } } diff --git a/gcc/m2/mc-boot/GmcPreprocess.cc b/gcc/m2/mc-boot/GmcPreprocess.cc index 942c8b1754b8..741109ad7fbf 100644 --- a/gcc/m2/mc-boot/GmcPreprocess.cc +++ b/gcc/m2/mc-boot/GmcPreprocess.cc @@ -93,7 +93,7 @@ static DynamicStrings_String makeTempFile (DynamicStrings_String ext) static DynamicStrings_String onExitDelete (DynamicStrings_String filename) { - alists_includeItemIntoList (listOfFiles, reinterpret_cast (DynamicStrings_Dup (filename))); + alists_includeItemIntoList (listOfFiles, reinterpret_cast (DynamicStrings_Dup (filename))); return filename; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -148,7 +148,7 @@ extern "C" DynamicStrings_String mcPreprocess_preprocessModule (DynamicStrings_S } else { - tempfile = DynamicStrings_InitStringCharStar (reinterpret_cast (makeTempFile (DynamicStrings_InitString ((const char *) "cpp", 3)))); + tempfile = DynamicStrings_InitStringCharStar (reinterpret_cast (makeTempFile (DynamicStrings_InitString ((const char *) "cpp", 3)))); commandLine = DynamicStrings_Dup (command); commandLine = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Dup (commandLine), ' '), filename), DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " -o ", 4))), tempfile); if (mcOptions_getVerbose ()) diff --git a/gcc/m2/mc-boot/GmcStream.cc b/gcc/m2/mc-boot/GmcStream.cc index 3d8d01da4650..da44d8f66a8e 100644 --- a/gcc/m2/mc-boot/GmcStream.cc +++ b/gcc/m2/mc-boot/GmcStream.cc @@ -123,7 +123,7 @@ static void copy (mcStream_ptrToFile p); static DynamicStrings_String removeLater (DynamicStrings_String filename) { - alists_includeItemIntoList (listOfFiles, reinterpret_cast (filename)); + alists_includeItemIntoList (listOfFiles, reinterpret_cast (filename)); return filename; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -213,7 +213,7 @@ extern "C" FIO_File mcStream_openFrag (unsigned int id) f = createTemporaryFile (id); Storage_ALLOCATE ((void **) &p, sizeof (FIO_File)); (*p) = f; - Indexing_PutIndice (frag, id, reinterpret_cast (p)); + Indexing_PutIndice (frag, id, reinterpret_cast (p)); return f; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); diff --git a/gcc/m2/mc-boot/Gmcp1.cc b/gcc/m2/mc-boot/Gmcp1.cc index b6b0f87a43af..b4ccf806cb08 100644 --- a/gcc/m2/mc-boot/Gmcp1.cc +++ b/gcc/m2/mc-boot/Gmcp1.cc @@ -1739,7 +1739,9 @@ static void Priority (mcp1_SetOfStop0 stopset0, mcp1_SetOfStop1 stopset1, mcp1_S /* Export := 'EXPORT' ( 'QUALIFIED' IdentList | - 'UNQUALIFIED' IdentList | + 'UNQUALIFIED' + % putDefUnqualified (curmodule) % + IdentList | IdentList ) ';' first symbols:exporttok @@ -6753,7 +6755,9 @@ static void Priority (mcp1_SetOfStop0 stopset0, mcp1_SetOfStop1 stopset1, mcp1_S /* Export := 'EXPORT' ( 'QUALIFIED' IdentList | - 'UNQUALIFIED' IdentList | + 'UNQUALIFIED' + % putDefUnqualified (curmodule) % + IdentList | IdentList ) ';' first symbols:exporttok @@ -6773,6 +6777,7 @@ static void Export (mcp1_SetOfStop0 stopset0, mcp1_SetOfStop1 stopset1, mcp1_Set { /* avoid dangling else. */ Expect (mcReserved_unqualifiedtok, stopset0, stopset1, stopset2|(mcp1_SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok)))); + decl_putDefUnqualified (curmodule); IdentList (stopset0|(mcp1_SetOfStop0) ((1 << (mcReserved_semicolontok-mcReserved_eoftok))), stopset1, stopset2); } else if (mcLexBuf_currenttoken == mcReserved_identtok) diff --git a/gcc/m2/mc-boot/Gmcp3.cc b/gcc/m2/mc-boot/Gmcp3.cc index e327d366b560..5cb83f464e7c 100644 --- a/gcc/m2/mc-boot/Gmcp3.cc +++ b/gcc/m2/mc-boot/Gmcp3.cc @@ -2231,7 +2231,7 @@ static void TrashList (mcp3_SetOfStop0 stopset0, mcp3_SetOfStop1 stopset1, mcp3_ static decl_node push (decl_node n) { - return static_cast (mcStack_push (stk, reinterpret_cast (n))); + return static_cast (mcStack_push (stk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2255,7 +2255,7 @@ static decl_node pop (void) static decl_node replace (decl_node n) { - return static_cast (mcStack_replace (stk, reinterpret_cast (n))); + return static_cast (mcStack_replace (stk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } diff --git a/gcc/m2/mc-boot/Gmcp4.cc b/gcc/m2/mc-boot/Gmcp4.cc index 2fdd0ae25232..ce8cb78f443a 100644 --- a/gcc/m2/mc-boot/Gmcp4.cc +++ b/gcc/m2/mc-boot/Gmcp4.cc @@ -2165,7 +2165,7 @@ static void TrashList (mcp4_SetOfStop0 stopset0, mcp4_SetOfStop1 stopset1, mcp4_ static decl_node push (decl_node n) { - return static_cast (mcStack_push (stk, reinterpret_cast (n))); + return static_cast (mcStack_push (stk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2189,7 +2189,7 @@ static decl_node pop (void) static decl_node replace (decl_node n) { - return static_cast (mcStack_replace (stk, reinterpret_cast (n))); + return static_cast (mcStack_replace (stk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } diff --git a/gcc/m2/mc-boot/Gmcp5.cc b/gcc/m2/mc-boot/Gmcp5.cc index d1e1fe984fa4..909c62215c82 100644 --- a/gcc/m2/mc-boot/Gmcp5.cc +++ b/gcc/m2/mc-boot/Gmcp5.cc @@ -2500,7 +2500,7 @@ static void followNode (decl_node n) static decl_node push (decl_node n) { - return static_cast (mcStack_push (stk, reinterpret_cast (n))); + return static_cast (mcStack_push (stk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2524,7 +2524,7 @@ static decl_node pop (void) static decl_node replace (decl_node n) { - return static_cast (mcStack_replace (stk, reinterpret_cast (n))); + return static_cast (mcStack_replace (stk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2592,7 +2592,7 @@ static bool isQualident (decl_node n) static void startWith (decl_node n) { - n = static_cast (mcStack_push (withStk, reinterpret_cast (n))); + n = static_cast (mcStack_push (withStk, reinterpret_cast (n))); } @@ -2644,7 +2644,7 @@ static decl_node lookupWithSym (nameKey_Name i) static decl_node pushStmt (decl_node n) { - return static_cast (mcStack_push (stmtStk, reinterpret_cast (n))); + return static_cast (mcStack_push (stmtStk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2681,7 +2681,7 @@ static decl_node peepStmt (void) static decl_node pushLoop (decl_node n) { - return static_cast (mcStack_push (loopStk, reinterpret_cast (n))); + return static_cast (mcStack_push (loopStk, reinterpret_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } diff --git a/gcc/m2/mc-boot/GnameKey.cc b/gcc/m2/mc-boot/GnameKey.cc index ba9eaa026c03..3e868886e293 100644 --- a/gcc/m2/mc-boot/GnameKey.cc +++ b/gcc/m2/mc-boot/GnameKey.cc @@ -192,12 +192,12 @@ static nameKey_Name doMakeKey (nameKey_ptrToChar n, unsigned int higha) lastIndice += 1; child->key = lastIndice; child->data = n; - Indexing_PutIndice (keyIndex, child->key, reinterpret_cast (n)); + Indexing_PutIndice (keyIndex, child->key, reinterpret_cast (n)); k = lastIndice; } else { - Storage_DEALLOCATE (reinterpret_cast (&n), higha+1); + Storage_DEALLOCATE (reinterpret_cast (&n), higha+1); k = child->key; } return k; @@ -305,7 +305,7 @@ extern "C" nameKey_Name nameKey_makeKey (const char *a_, unsigned int _a_high) memcpy (a, a_, _a_high+1); higha = StrLib_StrLen ((const char *) a, _a_high); - Storage_ALLOCATE (reinterpret_cast (&p), higha+1); + Storage_ALLOCATE (reinterpret_cast (&p), higha+1); if (p == NULL) { M2RTS_HALT (-1); /* out of memory error */ @@ -352,7 +352,7 @@ extern "C" nameKey_Name nameKey_makekey (void * a) else { higha = static_cast (libc_strlen (a)); - Storage_ALLOCATE (reinterpret_cast (&p), higha+1); + Storage_ALLOCATE (reinterpret_cast (&p), higha+1); if (p == NULL) { M2RTS_HALT (-1); /* out of memory error */ diff --git a/gcc/m2/mc-boot/Gvarargs.cc b/gcc/m2/mc-boot/Gvarargs.cc index 5c8abd9940b8..69f5f2c57564 100644 --- a/gcc/m2/mc-boot/Gvarargs.cc +++ b/gcc/m2/mc-boot/Gvarargs.cc @@ -329,7 +329,7 @@ extern "C" varargs_vararg varargs_start2 (const unsigned char *a_, unsigned int v->arg.array[0].ptr = static_cast (p); v->arg.array[0].len = _a_high+1; p += v->arg.array[0].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); v->arg.array[1].ptr = static_cast (p); v->arg.array[1].len = _b_high+1; return static_cast (v); @@ -366,11 +366,11 @@ extern "C" varargs_vararg varargs_start3 (const unsigned char *a_, unsigned int v->arg.array[0].ptr = static_cast (p); v->arg.array[0].len = _a_high+1; p += v->arg.array[0].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); v->arg.array[1].ptr = static_cast (p); v->arg.array[1].len = _b_high+1; p += v->arg.array[1].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); v->arg.array[2].ptr = static_cast (p); v->arg.array[2].len = _c_high+1; return static_cast (v); @@ -408,15 +408,15 @@ extern "C" varargs_vararg varargs_start4 (const unsigned char *a_, unsigned int p = static_cast (libc_memcpy (v->contents, const_cast (static_cast(a)), static_cast (_a_high+1))); v->arg.array[0].len = _a_high+1; p += v->arg.array[0].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); v->arg.array[1].ptr = static_cast (p); v->arg.array[1].len = _b_high+1; p += v->arg.array[1].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); v->arg.array[2].ptr = static_cast (p); v->arg.array[2].len = _c_high+1; p += v->arg.array[2].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); v->arg.array[3].ptr = static_cast (p); v->arg.array[3].len = _c_high+1; return static_cast (v); diff --git a/gcc/m2/mc/decl.def b/gcc/m2/mc/decl.def index 8f12f010850c..fa3514b2d4d7 100644 --- a/gcc/m2/mc/decl.def +++ b/gcc/m2/mc/decl.def @@ -184,6 +184,20 @@ PROCEDURE lookupModule (n: Name) : node ; PROCEDURE putDefForC (n: node) ; +(* + putDefUnqualified - the definition module uses export unqualified. +*) + +PROCEDURE putDefUnqualified (n: node) ; + + +(* + isDefUnqualified - returns TRUE if the definition module uses unqualified. +*) + +PROCEDURE isDefUnqualified (n: node) : BOOLEAN ; + + (* lookupInScope - looks up a symbol named, n, from, scope. *) diff --git a/gcc/m2/mc/decl.mod b/gcc/m2/mc/decl.mod index 8293c7f5d1f5..356290b349ca 100644 --- a/gcc/m2/mc/decl.mod +++ b/gcc/m2/mc/decl.mod @@ -662,6 +662,7 @@ TYPE defT = RECORD name : Name ; source : Name ; + unqualified, hasHidden, forC : BOOLEAN ; exported, @@ -721,6 +722,8 @@ VAR globalGroup : group ; (* The global group of all alists. *) outputFile : File ; lang : language ; + charStarN, + constCharStarN, bitsperunitN, bitsperwordN, bitspercharN, @@ -1187,6 +1190,47 @@ BEGIN END importEnumFields ; +(* + checkGccType - check to see if node n is gcc tree or location_t + and record its use in keyc. +*) + +PROCEDURE checkGccType (n: node) ; +BEGIN + IF getGccConfigSystem () AND (getScope (n) # NIL) AND + (getSymName (getScope (n)) = makeKey ('gcctypes')) + THEN + IF getSymName (n) = makeKey ('location_t') + THEN + keyc.useGccLocation + ELSIF getSymName (n) = makeKey ('tree') + THEN + keyc.useGccTree + END + END +END checkGccType ; + + +(* + checkCDataTypes - check to see if node n is CharStar or ConstCharStar + and if necessary assign n to the global variable. +*) + +PROCEDURE checkCDataTypes (n: node) ; +BEGIN + IF (getScope (n) # NIL) AND (getSymName (getScope (n)) = makeKey ('CDataTypes')) + THEN + IF getSymName (n) = makeKey ('CharStar') + THEN + charStarN := n + ELSIF getSymName (n) = makeKey ('ConstCharStar') + THEN + constCharStarN := n + END + END +END checkCDataTypes ; + + (* import - attempts to add node, n, into the scope of module, m. It might fail due to a name clash in which case the @@ -1201,6 +1245,8 @@ VAR BEGIN assert (isDef (m) OR isModule (m) OR isImp (m)) ; name := getSymName (n) ; + checkGccType (n) ; + checkCDataTypes (n) ; r := lookupInScope (m, name) ; IF r=NIL THEN @@ -1563,6 +1609,7 @@ BEGIN defF.source := NulName ; defF.hasHidden := FALSE ; defF.forC := FALSE ; + defF.unqualified := FALSE ; defF.exported := InitIndex (1) ; defF.importedModules := InitIndex (1) ; defF.constFixup := initFixupInfo () ; @@ -1653,6 +1700,33 @@ BEGIN END isDefForC ; +(* + putDefUnqualified - the definition module uses unqualified. +*) + +PROCEDURE putDefUnqualified (n: node) ; +BEGIN + assert (isDef (n)) ; + (* Currently (and this is a temporary development restriction to + reduce any search space for bugs) the only module which can be + export unqualified is gcctypes. *) + IF n^.defF.name = makeKey ('gcctypes') + THEN + n^.defF.unqualified := TRUE + END +END putDefUnqualified ; + + +(* + isDefUnqualified - returns TRUE if the definition module uses unqualified. +*) + +PROCEDURE isDefUnqualified (n: node) : BOOLEAN ; +BEGIN + RETURN isDef (n) AND n^.defF.unqualified +END isDefUnqualified ; + + (* lookupDef - returns a definition module node named, n. *) @@ -3555,7 +3629,7 @@ BEGIN THEN RETURN getNextFixup (impF.constFixup) ELSE - assert (isModule (currentModule)) + assert (isModule (currentModule)) ; RETURN getNextFixup (moduleF.constFixup) END END @@ -5421,7 +5495,7 @@ END getExprType ; PROCEDURE skipType (n: node) : node ; BEGIN - WHILE (n#NIL) AND isType (n) DO + WHILE (n#NIL) AND isType (n) AND (NOT isCDataType (n)) DO IF getType (n) = NIL THEN (* this will occur if, n, is an opaque type. *) @@ -5720,7 +5794,7 @@ PROCEDURE getFQstring (n: node) : String ; VAR i, s: String ; BEGIN - IF getScope (n) = NIL + IF (getScope (n) = NIL) OR (isDefUnqualified (getScope (n))) THEN RETURN InitStringCharStar (keyToCharStar (getSymName (n))) ELSIF isQualifiedForced (n) @@ -5728,7 +5802,7 @@ BEGIN i := InitStringCharStar (keyToCharStar (getSymName (n))) ; s := InitStringCharStar (keyToCharStar (getSymName (getScope (n)))) ; RETURN Sprintf2 (InitString ("%s_%s"), s, i) - ELSIF (NOT isExported (n)) OR getIgnoreFQ () + ELSIF (NOT isExported (n)) OR getIgnoreFQ () OR (isDefUnqualified (getScope (n))) THEN RETURN InitStringCharStar (keyToCharStar (getSymName (n))) ELSE @@ -5747,7 +5821,7 @@ PROCEDURE getFQDstring (n: node; scopes: BOOLEAN) : String ; VAR i, s: String ; BEGIN - IF getScope (n) = NIL + IF (getScope (n) = NIL) OR (isDefUnqualified (getScope (n))) THEN RETURN InitStringCharStar (keyToCharStar (getDName (n, scopes))) ELSIF isQualifiedForced (n) @@ -5756,7 +5830,7 @@ BEGIN i := InitStringCharStar (keyToCharStar (getSymName (n))) ; s := InitStringCharStar (keyToCharStar (getSymName (getScope (n)))) ; RETURN Sprintf2 (InitString ("%s_%s"), s, i) - ELSIF (NOT isExported (n)) OR getIgnoreFQ () + ELSIF (NOT isExported (n)) OR getIgnoreFQ () OR (isDefUnqualified (getScope (n))) THEN RETURN InitStringCharStar (keyToCharStar (getDName (n, scopes))) ELSE @@ -8250,6 +8324,173 @@ BEGIN END doTypeNameModifier ; +(* + isGccType - return TRUE if n is tree or location_t. +*) + +PROCEDURE isGccType (n: node) : BOOLEAN ; +BEGIN + RETURN (getGccConfigSystem () AND + ((getSymName (n) = makeKey ('location_t')) OR + (getSymName (n) = makeKey ('tree')))) +END isGccType ; + + +(* + doGccType - record whether we are going to declare tree or location_t + so that the appropriate gcc header can be included instead. +*) + +PROCEDURE doGccType (p: pretty; n: node) ; +BEGIN + IF getGccConfigSystem () + THEN + IF getSymName (n) = makeKey ('location_t') + THEN + outText (p, "/* Not going to declare ") ; + doTypeNameC (p, n) ; + outText (p, " as it is declared in the gcc header input.h. */\n\n") ; + keyc.useGccLocation + ELSIF getSymName (n) = makeKey ('tree') + THEN + outText (p, "/* Not going to declare ") ; + doTypeNameC (p, n) ; + outText (p, " as it is declared in the gcc header tree.h. */\n\n") ; + keyc.useGccTree + END + END +END doGccType ; + + +(* + isCDataType - return true if n is charStar or constCharStar. +*) + +PROCEDURE isCDataType (n: node) : BOOLEAN ; +BEGIN + RETURN (n # NIL) AND ((n = charStarN) OR (n = constCharStarN)) +END isCDataType ; + + +(* + isCDataTypes - return TRUE if n is CharStar or ConstCharStar. +*) + +PROCEDURE isCDataTypes (n: node) : BOOLEAN ; +VAR + scope: node ; +BEGIN + scope := getScope (n) ; + RETURN (scope # NIL) AND (getSymName (scope) = makeKey ('CDataTypes')) AND + ((getSymName (n) = makeKey ('CharStar')) OR + (getSymName (n) = makeKey ('ConstCharStar'))) +END isCDataTypes ; + + +(* + doCDataTypes - if we are going to declare CharStar or ConstCharStar + then generate a comment instead. +*) + +PROCEDURE doCDataTypes (p: pretty; n: node) ; +BEGIN + IF isCDataTypes (n) + THEN + IF getSymName (n) = makeKey ('CharStar') + THEN + outText (p, "/* Not going to declare ") ; + doTypeNameC (p, n) ; + outText (p, " as it is a C type. */\n\n") ; + charStarN := n + ELSIF getSymName (n) = makeKey ('ConstCharStar') + THEN + outText (p, "/* Not going to declare ") ; + doTypeNameC (p, n) ; + outText (p, " as it is a C type. */\n\n") ; + constCharStarN := n + END + END +END doCDataTypes ; + + +(* + doCDataTypesC - generate the C representation of the CDataTypes data types. +*) + +PROCEDURE doCDataTypesC (p: pretty; n: node) ; +BEGIN + IF n = charStarN + THEN + outText (p, "char *") ; + setNeedSpace (p) + ELSIF n = constCharStarN + THEN + outText (p, "const char *") ; + setNeedSpace (p) + END +END doCDataTypesC ; + + +(* + doTypeOrPointer - only declare type or pointer n providing that + the name is not location_t or tree and + the --gccConfigSystem option is enabled. +*) + +PROCEDURE doTypeOrPointer (p: pretty; n: node) ; +VAR + m: node ; +BEGIN + IF isGccType (n) + THEN + doGccType (p, n) + ELSIF isCDataTypes (n) + THEN + doCDataTypes (p, n) + ELSE + m := getType (n) ; + outText (p, "typedef") ; setNeedSpace (p) ; + doTypeC (p, m, m) ; + IF isType (m) + THEN + setNeedSpace (p) + END ; + doTypeNameC (p, n) ; + doTypeNameModifier (p, n) ; + outText (p, ";\n\n") + END +END doTypeOrPointer ; + + +(* + doTypedef - generate a typedef for n provuiding it is not +*) + +PROCEDURE doTypedef (p: pretty; n: node) ; +VAR + m: node ; +BEGIN + IF isGccType (n) + THEN + doGccType (p, n) + ELSIF isCDataTypes (n) + THEN + doCDataTypes (p, n) + ELSE + m := getType (n) ; + outText (p, "typedef") ; setNeedSpace (p) ; + doTypeC (p, m, m) ; + IF isType (m) + THEN + setNeedSpace (p) + END ; + doTypeNameC (p, n) ; + doTypeNameModifier (p, n) ; + outText (p, ";\n\n") + END +END doTypedef ; + + (* doTypesC - *) @@ -8266,15 +8507,7 @@ BEGIN doProcTypeC (doP, n, m) ELSIF isType (m) OR isPointer (m) THEN - outText (doP, "typedef") ; setNeedSpace (doP) ; - doTypeC (doP, m, m) ; - IF isType (m) - THEN - setNeedSpace (doP) - END ; - doTypeNameC (doP, n) ; - doTypeNameModifier (doP, n) ; - outText (doP, ";\n\n") + doTypeOrPointer (doP, n) ELSIF isEnumeration (m) THEN IF isDeclType (n) @@ -8286,15 +8519,7 @@ BEGIN outText (doP, ";\n\n") END ELSE - outText (doP, "typedef") ; setNeedSpace (doP) ; - doTypeC (doP, m, m) ; - IF isType (m) - THEN - setNeedSpace (doP) - END ; - doTypeNameC (doP, n) ; - doTypeNameModifier (doP, n) ; - outText (doP, ";\n\n") + doTypedef (doP, n) END END END doTypesC ; @@ -9048,6 +9273,9 @@ BEGIN IF n=NIL THEN outText (p, "void") + ELSIF isCDataTypes (n) + THEN + doCDataTypesC (p, n) ELSIF isBase (n) THEN doBaseC (p, n) @@ -9078,10 +9306,13 @@ BEGIN ELSIF isSet (n) THEN doSetC (p, n) + ELSIF isCDataTypes (n) + THEN + doCDataTypesC (p, n) ELSE - (* --fixme-- *) - print (p, "to do ... typedef etc etc ") ; doFQNameC (p, n) ; print (p, ";\n") ; - HALT + metaError1 ('expecting a type symbol rather than a {%1DMd} {%1DMa}', n) ; + flushErrors ; + errorAbort0 ('terminating compilation') END END doTypeC ; @@ -9133,6 +9364,14 @@ BEGIN THEN outText (p, "void") ; setNeedSpace (p) + ELSIF n = charStarN + THEN + outText (p, "char *") ; + setNeedSpace (p) + ELSIF n = constCharStarN + THEN + outText (p, "const char *") ; + setNeedSpace (p) ELSIF isBase (n) THEN doBaseC (p, n) @@ -11022,6 +11261,126 @@ BEGIN END needsCast ; +(* + castDestType - emit the destination type ft +*) + +PROCEDURE castDestType (p: pretty; formal, ft: node) ; +BEGIN + doTypeNameC (p, ft) ; + IF isVarParam (formal) + THEN + outText (p, '*') + END +END castDestType ; + + +(* + identifyPointer - +*) + +PROCEDURE identifyPointer (type: node) : node ; +BEGIN + IF isPointer (type) + THEN + IF skipType (getType (type)) = charN + THEN + RETURN charStarN + ELSIF (skipType (getType (type)) = byteN) OR + (skipType (getType (type)) = locN) + THEN + RETURN addressN + END + END ; + RETURN type +END identifyPointer ; + + +(* + castPointer - provides a six way cast between ADDRESS (ie void * ), + char * and const char *. +*) + +PROCEDURE castPointer (p: pretty; actual, formal, at, ft: node) : CARDINAL ; +VAR + sat, sft: node ; + parenth : CARDINAL ; +BEGIN + parenth := 0 ; + IF at # ft + THEN + sat := identifyPointer (skipType (at)) ; + sft := identifyPointer (skipType (ft)) ; + IF sat = addressN + THEN + IF sft = charStarN + THEN + outText (p, 'reinterpret_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + ELSIF sft = constCharStarN + THEN + outText (p, 'const_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '> (static_cast <') ; + doTypeNameC (p, charStarN) ; + outText (p, '>') ; + INC (parenth) + ELSE + outText (p, 'reinterpret_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + END + ELSIF sat = charStarN + THEN + IF sft = addressN + THEN + outText (p, 'reinterpret_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + ELSIF sft = constCharStarN + THEN + outText (p, 'const_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + ELSE + outText (p, 'reinterpret_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + END + ELSIF sat = constCharStarN + THEN + IF sft = addressN + THEN + outText (p, 'static_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '> (const_cast <') ; + doTypeNameC (p, charStarN) ; + outText (p, '>') ; + INC (parenth) + ELSIF sft = charStarN + THEN + outText (p, 'const_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + ELSE + outText (p, 'reinterpret_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + END + ELSE + outText (p, 'reinterpret_cast <') ; + castDestType (p, formal, ft) ; + outText (p, '>') + END ; + setNeedSpace (p) ; + outText (p, '(') ; + INC (parenth) + END ; + RETURN parenth +END castPointer ; + + (* checkSystemCast - checks to see if we are passing to/from a system generic type (WORD, BYTE, ADDRESS) @@ -11039,11 +11398,16 @@ BEGIN THEN IF lang = ansiCP THEN - IF isString (actual) AND (skipType (ft) = addressN) + IF isString (actual) AND isCDataType (skipType (ft)) + THEN + (* Nothing to do. *) + RETURN 0 + ELSIF isString (actual) AND (skipType (ft) = addressN) THEN outText (p, "const_cast (static_cast (") ; RETURN 2 - ELSIF isPointer (skipType (ft)) OR (skipType (ft) = addressN) + ELSIF isPointer (skipType (ft)) OR (skipType (ft) = addressN) OR + isCDataType (skipType (ft)) THEN IF actual = nilN THEN @@ -11054,14 +11418,7 @@ BEGIN (* NULL is compatible with pointers/address. *) RETURN 0 ELSE - outText (p, 'reinterpret_cast<') ; - doTypeNameC (p, ft) ; - IF isVarParam (formal) - THEN - outText (p, '*') - END ; - noSpace (p) ; - outText (p, '> (') + RETURN castPointer (p, actual, formal, at, ft) END ELSE outText (p, 'static_cast<') ; @@ -18061,6 +18418,22 @@ BEGIN END makeBuiltins ; +(* + makeCDataTypes - assign the charStarN and constCharStarN to NIL. +*) + +PROCEDURE makeCDataTypes ; +VAR + CdatatypesN: node ; +BEGIN + CdatatypesN := lookupDef (makeKey ('CDataTypes')) ; + enterScope (CdatatypesN) ; + charStarN := makePointer (charN) ; + constCharStarN := makePointer (charN) ; + leaveScope +END makeCDataTypes ; + + (* init - *) @@ -18083,7 +18456,8 @@ BEGIN makeM2rts ; outputState := punct ; tempCount := 0 ; - mustVisitScope := FALSE + mustVisitScope := FALSE ; + makeCDataTypes END init ; diff --git a/gcc/m2/mc/keyc.def b/gcc/m2/mc/keyc.def index cdf3f67e1311..687a310bf82e 100644 --- a/gcc/m2/mc/keyc.def +++ b/gcc/m2/mc/keyc.def @@ -27,6 +27,20 @@ FROM decl IMPORT node ; FROM nameKey IMPORT Name ; +(* + useGccTree - indicate we have imported tree from gcctypes. +*) + +PROCEDURE useGccTree ; + + +(* + useGccLocation - indicate we have imported tree from gcctypes. +*) + +PROCEDURE useGccLocation ; + + (* useUnistd - need to use unistd.h call using open/close/read/write require this header. *) diff --git a/gcc/m2/mc/keyc.mod b/gcc/m2/mc/keyc.mod index 4436a3212252..f3f09309ad5c 100644 --- a/gcc/m2/mc/keyc.mod +++ b/gcc/m2/mc/keyc.mod @@ -44,6 +44,8 @@ VAR initializedCP, initializedGCC, + seenGccTree, + seenGccLocation, seenIntMin, seenUIntMin, seenLongMin, @@ -95,11 +97,32 @@ BEGIN initializedGCC := TRUE ; print (p, '#include "config.h"\n'); print (p, '#include "system.h"\n'); + checkGccTypes (p) END END END checkGccConfigSystem ; +(* + useGccTree - indicate we have imported tree from gcctypes. +*) + +PROCEDURE useGccTree ; +BEGIN + seenGccTree := TRUE +END useGccTree ; + + +(* + useGccLocation - indicate we have imported tree from gcctypes. +*) + +PROCEDURE useGccLocation ; +BEGIN + seenGccLocation := TRUE +END useGccLocation ; + + (* useStorage - indicate we have used storage. *) @@ -411,6 +434,20 @@ BEGIN END useCtype ; +(* + checkGccTypes - if we have imported tree or location_t from gcctypes + then we include the gcc headers. +*) + +PROCEDURE checkGccTypes (p: pretty) ; +BEGIN + IF seenGccTree OR seenGccLocation + THEN + print (p, '#include "gcc-consolidation.h"\n\n') + END +END checkGccTypes ; + + (* checkCtype - *) @@ -419,7 +456,7 @@ PROCEDURE checkCtype (p: pretty) ; BEGIN IF seenCtype THEN - checkGccConfigSystem (p); + checkGccConfigSystem (p) ; IF getGccConfigSystem () THEN (* GCC header files use a safe variant. *) @@ -1149,6 +1186,8 @@ BEGIN seenSize_t := FALSE ; seenSSize_t := FALSE ; seenSysTypes := FALSE ; + seenGccTree := FALSE ; + seenGccLocation := FALSE ; initializedCP := FALSE ; initializedGCC := FALSE ; diff --git a/gcc/m2/mc/mcp1.bnf b/gcc/m2/mc/mcp1.bnf index 5b9661b4c232..42e41ef52a6d 100644 --- a/gcc/m2/mc/mcp1.bnf +++ b/gcc/m2/mc/mcp1.bnf @@ -57,7 +57,7 @@ FROM mcLexBuf IMPORT currentstring, currenttoken, getToken, insertToken, insertTokenAndRewind, getTokenNo, lastcomment ; FROM decl IMPORT node, lookupDef, lookupImp, lookupModule, getSymName, - lookupSym, putDefForC, + lookupSym, putDefForC, putDefUnqualified, makeProcedure, makeType, makeTypeImp, makeVar, makeConst, enterScope, leaveScope, putTypeHidden, putTypeOpaque, addImportedModule, getCurrentModule, @@ -1031,7 +1031,7 @@ Priority := "[" ConstExpression "]" =: Export := "EXPORT" ( "QUALIFIED" IdentList | - "UNQUALIFIED" + "UNQUALIFIED" % putDefUnqualified (curmodule) % IdentList | IdentList ) ";" =: