[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/ilasm ilasm.c,NONE,1.1 Makefile.am,1.6,1
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/ilasm ilasm.c,NONE,1.1 Makefile.am,1.6,1.7 ilasm_build.c,1.16,1.17 ilasm_build.h,1.6,1.7 ilasm_data.c,1.1,1.2 ilasm_data.h,1.1,1.2 ilasm_grammar.y,1.23,1.24 ilasm_main.c,1.8,1.9 ilasm_output.c,1.14,1.15 ilasm_output.h,1.5,1.6 |
Date: |
Thu, 12 Dec 2002 19:33:32 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/ilasm
In directory subversions:/tmp/cvs-serv24016/ilasm
Modified Files:
Makefile.am ilasm_build.c ilasm_build.h ilasm_data.c
ilasm_data.h ilasm_grammar.y ilasm_main.c ilasm_output.c
ilasm_output.h
Added Files:
ilasm.c
Log Message:
Turn "ilasm" into a library that can be directly linked into
"cscc", and then link it into "cscc".
--- NEW FILE ---
/*
* ilasm.c - Main entry point for the "ilasm" program.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef __cplusplus
extern "C" {
#endif
int ILAsmMain(int argc, char *argv[]);
int main(int argc, char *argv[])
{
return ILAsmMain(argc, argv);
}
#ifdef __cplusplus
};
#endif
Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Makefile.am 12 Dec 2002 03:35:44 -0000 1.6
--- Makefile.am 13 Dec 2002 00:33:30 -0000 1.7
***************
*** 1,12 ****
bin_PROGRAMS = ilasm
man_MANS = ilasm.1
EXTRA_DIST = $(man_MANS)
! ilasm_SOURCES = ilasm_build.c \
! ilasm_data.c \
! ilasm_grammar.y \
! ilasm_main.c \
! ilasm_output.c \
! ilasm_scanner.l
! ilasm_LDADD = ../image/libILImage.a ../support/libILSupport.a
AM_YFLAGS = -d
--- 1,16 ----
bin_PROGRAMS = ilasm
+ lib_LIBRARIES = libILAsm.a
man_MANS = ilasm.1
EXTRA_DIST = $(man_MANS)
!
! libILAsm_a_SOURCES = ilasm_build.c \
! ilasm_data.c \
! ilasm_grammar.y \
! ilasm_main.c \
! ilasm_output.c \
! ilasm_scanner.l
!
! ilasm_SOURCES = ilasm.c
! ilasm_LDADD = libILAsm.a ../image/libILImage.a ../support/libILSupport.a
AM_YFLAGS = -d
***************
*** 14,28 ****
AM_CFLAGS = -I$(top_srcdir)/include
-
- ## Install a second copy of "ilasm" into the "${prefix}/lib/cscc/plugins"
- ## directory, just in case some other package overwrites our primary
- ## copy with its own "ilasm".
-
- install-exec-local:
- @$(NORMALL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(libdir)/cscc/plugins
- $(INSTALL_PROGRAM) ilasm $(DESTDIR)$(libdir)/cscc/plugins/ilasm
-
- uninstall-local:
- @$(NORMALL_UNINSTALL)
- rm -f $(DESTDIR)$(libdir)/cscc/plugins/ilasm
--- 18,19 ----
Index: ilasm_build.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_build.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** ilasm_build.c 14 Sep 2002 10:59:56 -0000 1.16
--- ilasm_build.c 13 Dec 2002 00:33:30 -0000 1.17
***************
*** 65,68 ****
--- 65,109 ----
static int scopeStackSize;
static int scopeStackMax;
+ static long nextUnique = 1;
+
+ void ILAsmBuildReset(void)
+ {
+ /* Destroy the global state */
+ if(ILAsmContext)
+ {
+ ILContextDestroy(ILAsmContext);
+ }
+ if(classStack)
+ {
+ ILFree(classStack);
+ }
+ if(scopeStack)
+ {
+ ILFree(scopeStack);
+ }
+
+ /* Set the globals back to their defaults */
+ ILAsmContext = 0;
+ ILAsmImage = 0;
+ ILAsmModule = 0;
+ ILAsmAssembly = 0;
+ ILAsmLastToken = 0;
+ ILAsmCurrScope = 0;
+ ILAsmClass = 0;
+ ILAsmCurrAssemblyRef = 0;
+ ILAsmModuleClass = 0;
+ ILAsmDebugMode = 0;
+ ILAsmDebugLastFile = "";
+ ILAsmLibraryName = "mscorlib";
+ namespace.string = 0;
+ namespace.len = 0;
+ classStack = 0;
+ classStackSize = 0;
+ classStackMax = 0;
+ scopeStack = 0;
+ scopeStackSize = 0;
+ scopeStackMax = 0;
+ nextUnique = 1;
+ }
void ILAsmBuildInit(const char *outputFilename)
***************
*** 216,220 ****
{
ILClass *info;
- static long nextUnique = 1;
char uniqueName[64];
--- 257,260 ----
Index: ilasm_build.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_build.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ilasm_build.h 29 Jul 2002 04:09:59 -0000 1.6
--- ilasm_build.h 13 Dec 2002 00:33:30 -0000 1.7
***************
*** 102,105 ****
--- 102,110 ----
/*
+ * Reset global variables to their default state.
+ */
+ void ILAsmBuildReset(void);
+
+ /*
* Initialize the building routines.
*/
Index: ilasm_data.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_data.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ilasm_data.c 16 Mar 2002 11:42:39 -0000 1.1
--- ilasm_data.c 13 Dec 2002 00:33:30 -0000 1.2
***************
*** 44,47 ****
--- 44,59 ----
static ILHashTable *nameTable = 0;
+ void ILAsmDataReset(void)
+ {
+ sectionIsData = 1;
+ dataOffset = 0;
+ tlsOffset = 0;
+ if(nameTable != 0)
+ {
+ ILHashDestroy(nameTable);
+ nameTable = 0;
+ }
+ }
+
void ILAsmDataSetNormal(void)
{
***************
*** 86,89 ****
--- 98,106 ----
}
+ static void DataLabelFreeFunc(void *elem)
+ {
+ ILFree(elem);
+ }
+
void ILAsmDataSetLabel(char *name)
{
***************
*** 93,97 ****
nameTable = ILHashCreate(0, DataLabelComputeFunc,
DataLabelKeyComputeFunc,
!
DataLabelMatchFunc, 0);
if(!nameTable)
{
--- 110,115 ----
nameTable = ILHashCreate(0, DataLabelComputeFunc,
DataLabelKeyComputeFunc,
!
DataLabelMatchFunc,
!
DataLabelFreeFunc);
if(!nameTable)
{
Index: ilasm_data.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_data.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ilasm_data.h 16 Mar 2002 11:42:39 -0000 1.1
--- ilasm_data.h 13 Dec 2002 00:33:30 -0000 1.2
***************
*** 27,30 ****
--- 27,35 ----
/*
+ * Reset the data output routines to the startup default.
+ */
+ void ILAsmDataReset(void);
+
+ /*
* Set the output data section to normal initialized data.
*/
Index: ilasm_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_grammar.y,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** ilasm_grammar.y 31 Oct 2002 14:21:02 -0000 1.23
--- ilasm_grammar.y 13 Dec 2002 00:33:30 -0000 1.24
***************
*** 125,129 ****
void ILAsmOutOfMemory(void)
{
! fprintf(stderr, "virtual memory exhausted\n");
exit(1);
}
--- 125,129 ----
void ILAsmOutOfMemory(void)
{
! fprintf(stderr, "ilasm: virtual memory exhausted\n");
exit(1);
}
Index: ilasm_main.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** ilasm_main.c 12 Dec 2002 07:32:10 -0000 1.8
--- ilasm_main.c 13 Dec 2002 00:33:30 -0000 1.9
***************
*** 2,6 ****
* ilasm_main.c - Main entry point for "ilasm".
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* ilasm_main.c - Main entry point for "ilasm".
*
! * Copyright (C) 2001, 2002 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 23,26 ****
--- 23,27 ----
#include "il_utils.h"
#include "ilasm_build.h"
+ #include "ilasm_data.h"
#include "ilasm_output.h"
***************
*** 123,126 ****
--- 124,128 ----
extern int ILAsmErrors;
extern int ILAsmParseHexBytes;
+ extern int ILAsmParseJava;
/*
***************
*** 131,136 ****
static void usage(const char *progname);
static void version(void);
! int main(int argc, char *argv[])
{
char *progname = argv[0];
--- 133,139 ----
static void usage(const char *progname);
static void version(void);
+ static void reset(void);
! int ILAsmMain(int argc, char *argv[])
{
char *progname = argv[0];
***************
*** 148,151 ****
--- 151,158 ----
char *resourceFile = 0;
+ /* Reset the global option variables, in case we were called
+ multiple times within the same process */
+ reset();
+
/* Parse the command-line arguments */
state = 0;
***************
*** 178,181 ****
--- 185,189 ----
{
usage(progname);
+ reset();
return 1;
}
***************
*** 316,319 ****
--- 324,328 ----
{
version();
+ reset();
return 0;
}
***************
*** 344,347 ****
--- 353,357 ----
{
usage(progname);
+ reset();
return 1;
}
***************
*** 354,357 ****
--- 364,368 ----
{
usage(progname);
+ reset();
return 1;
}
***************
*** 438,441 ****
--- 449,453 ----
{
perror(outputFile);
+ reset();
return 1;
}
***************
*** 511,514 ****
--- 523,527 ----
ILDeleteFile(outputFile);
}
+ reset();
return 1;
}
***************
*** 521,524 ****
--- 534,538 ----
fclose(outfile);
}
+ reset();
return 1;
}
***************
*** 529,532 ****
--- 543,547 ----
/* Done */
+ reset();
return 0;
}
***************
*** 535,539 ****
{
fprintf(stdout, "ILASM " VERSION " - Intermediate Language
Assembler\n");
! fprintf(stdout, "Copyright (c) 2001 Southern Storm Software, Pty
Ltd.\n");
fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s [options] input.il ...\n", progname);
--- 550,554 ----
{
fprintf(stdout, "ILASM " VERSION " - Intermediate Language
Assembler\n");
! fprintf(stdout, "Copyright (c) 2001, 2002 Southern Storm Software, Pty
Ltd.\n");
fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s [options] input.il ...\n", progname);
***************
*** 546,550 ****
printf("ILASM " VERSION " - Intermediate Language Assembler\n");
! printf("Copyright (c) 2001 Southern Storm Software, Pty Ltd.\n");
printf("\n");
printf("ILASM comes with ABSOLUTELY NO WARRANTY. This is free
software,\n");
--- 561,565 ----
printf("ILASM " VERSION " - Intermediate Language Assembler\n");
! printf("Copyright (c) 2001, 2002 Southern Storm Software, Pty Ltd.\n");
printf("\n");
printf("ILASM comes with ABSOLUTELY NO WARRANTY. This is free
software,\n");
***************
*** 553,556 ****
--- 568,589 ----
printf("\n");
printf("Use the `--help' option to get help on the command-line
options.\n");
+ }
+
+ /*
+ * Reset all global variables to their defaults so that we
+ * can re-enter the assembler multiple times.
+ */
+ static void reset(void)
+ {
+ ilasm_debug = 0;
+ ILAsmFilename = 0;
+ ILAsmLineNum = 1;
+ ILAsmErrors = 0;
+ ILAsmParseHexBytes = 0;
+ ILAsmParseJava = 0;
+ ILAsmShortInsns = 1;
+ ILAsmOutReset();
+ ILAsmBuildReset();
+ ILAsmDataReset();
}
Index: ilasm_output.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_output.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** ilasm_output.c 12 Dec 2002 07:32:10 -0000 1.14
--- ilasm_output.c 13 Dec 2002 00:33:30 -0000 1.15
***************
*** 70,73 ****
--- 70,80 ----
static unsigned long numExceptions = 0;
static int haveDebug = 0;
+ static ILUInt32 switchCountOffset = 0;
+ static ILUInt32 ssaStartOffset = 0;
+ static ILUInt32 switchStartOffset = 0;
+ static ILUInt32 switchHighOffset = 0;
+ static ILUInt32 switchNPairsOffset = 0;
+ static char* defaultTableSwitchLabel = 0;
+ static char* defaultLookupSwitchLabel = 0;
/*
***************
*** 242,245 ****
--- 249,310 ----
}
+ void ILAsmOutReset(void)
+ {
+ LocalInfo *local, *nextLocal;
+ ILAsmOutException *exception, *nextException;
+
+ /* Destroy allocated data structures */
+ if(ILAsmWriter)
+ {
+ ILWriterDestroy(ILAsmWriter);
+ }
+ if(buffer)
+ {
+ ILFree(buffer);
+ }
+ local = localNames;
+ while(local != 0)
+ {
+ nextLocal = local->next;
+ ILFree(local);
+ local = nextLocal;
+ }
+ exception = exceptionList;
+ while(exception != 0)
+ {
+ nextException = exception->next;
+ ILFree(exception);
+ exception = nextException;
+ }
+ if(initLabelPool)
+ {
+ ILMemPoolClear(&labelPool);
+ ILMemPoolClear(&labelRefPool);
+ }
+
+ /* Set the global variables back to their defaults */
+ ILAsmWriter = 0;
+ buffer = 0;
+ length = 0;
+ localVars = 0;
+ maxStack = 0;
+ initLocals = 0;
+ localIndex = 0;
+ localNames = 0;
+ exceptionList = 0;
+ lastException = 0;
+ numExceptions = 0;
+ haveDebug = 0;
+ switchCountOffset = 0;
+ ssaStartOffset = 0;
+ switchStartOffset = 0;
+ switchHighOffset = 0;
+ switchNPairsOffset = 0;
+ defaultTableSwitchLabel = 0;
+ defaultLookupSwitchLabel = 0;
+ initLabelPool = 0;
+ labels = 0;
+ }
+
void ILAsmOutCreate(FILE *stream, int seekable, int type, int flags)
{
***************
*** 257,260 ****
--- 322,326 ----
ILWriterOutputMetadata(ILAsmWriter, ILAsmImage);
error = ILWriterDestroy(ILAsmWriter);
+ ILAsmWriter = 0;
if(error < 0)
{
***************
*** 894,899 ****
}
- static ILUInt32 switchCountOffset = 0;
-
/*
* Output a switch label reference.
--- 960,963 ----
***************
*** 1232,1237 ****
}
- static ILUInt32 ssaStartOffset = 0;
-
void ILAsmOutSSAStart(ILInt32 opcode)
{
--- 1296,1299 ----
***************
*** 2251,2258 ****
}
- static ILUInt32 switchStartOffset = 0;
- static ILUInt32 switchHighOffset = 0;
- static ILUInt32 switchNPairsOffset = 0;
-
/*
* Output a switch label reference in java.
--- 2313,2316 ----
***************
*** 2292,2297 ****
}
- static char* defaultTableSwitchLabel = 0;
-
void ILJavaAsmOutTableSwitchDefaultRefInt(ILInt64 addr)
{
--- 2350,2353 ----
***************
*** 2353,2358 ****
buffer[switchHighOffset + 3] = (unsigned char)high;
}
-
- static char* defaultLookupSwitchLabel = 0;
void ILJavaAsmOutLookupSwitchDefaultRefInt(ILInt64 addr)
--- 2409,2412 ----
Index: ilasm_output.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_output.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ilasm_output.h 12 Dec 2002 07:32:10 -0000 1.5
--- ilasm_output.h 13 Dec 2002 00:33:30 -0000 1.6
***************
*** 36,39 ****
--- 36,44 ----
/*
+ * Reset global variables back to their defaults.
+ */
+ void ILAsmOutReset(void);
+
+ /*
* Create the global image writer.
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/ilasm ilasm.c,NONE,1.1 Makefile.am,1.6,1.7 ilasm_build.c,1.16,1.17 ilasm_build.h,1.6,1.7 ilasm_data.c,1.1,1.2 ilasm_data.h,1.1,1.2 ilasm_grammar.y,1.23,1.24 ilasm_main.c,1.8,1.9 ilasm_output.c,1.14,1.15 ilasm_output.h,1.5,1.6,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet ChangeLog,1.1974,1.1975
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/cscc Makefile.am,1.16,1.17 cscc.c,1.25,1.26
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet ChangeLog,1.1974,1.1975
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet/cscc Makefile.am,1.16,1.17 cscc.c,1.25,1.26
- Index(es):