Further cleanup and proper sorting of generated bytecode map files
This commit is contained in:
39
Makefile
39
Makefile
@@ -18,23 +18,14 @@ COMMON = \
|
||||
out/ASTNode.o \
|
||||
|
||||
BYTES = \
|
||||
out/python_10.o \
|
||||
out/python_11.o \
|
||||
out/python_13.o \
|
||||
out/python_14.o \
|
||||
out/python_15.o \
|
||||
out/python_16.o \
|
||||
out/python_20.o \
|
||||
out/python_21.o \
|
||||
out/python_22.o \
|
||||
out/python_23.o \
|
||||
out/python_24.o \
|
||||
out/python_25.o \
|
||||
out/python_26.o \
|
||||
out/python_27.o \
|
||||
out/python_30.o \
|
||||
out/python_31.o \
|
||||
out/python_32.o
|
||||
python_10 python_11 python_13 python_14 python_15 python_16 \
|
||||
python_20 python_21 python_22 python_23 python_24 \
|
||||
python_25 python_26 python_27 \
|
||||
python_30 python_31 python_32
|
||||
|
||||
BYTE_OBJS = $(BYTES:%=out/%.o)
|
||||
BYTE_SRCS = $(BYTES:%=bytes/%.cpp)
|
||||
BYTE_MAPS = $(BYTES:%=bytes/%.map)
|
||||
|
||||
ALL = \
|
||||
bin/pycdas \
|
||||
@@ -45,7 +36,7 @@ PREFIX = /usr/local
|
||||
all: $(ALL)
|
||||
|
||||
clean:
|
||||
rm -f $(COMMON) $(BYTES)
|
||||
rm -f $(COMMON) $(BYTE_OBJS) $(BYTE_SRCS)
|
||||
|
||||
install:
|
||||
mkdir -p $(PREFIX)/bin
|
||||
@@ -74,17 +65,17 @@ test: all
|
||||
echo -e "$${errors[i]}\n"; \
|
||||
done;
|
||||
|
||||
bin/pycdas: pycdas.cpp $(COMMON) $(BYTES)
|
||||
$(CXX) $(CXXFLAGS) $(LFLAGS) $(COMMON) $(BYTES) pycdas.cpp -o $@
|
||||
bin/pycdas: pycdas.cpp $(COMMON) $(BYTE_OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(LFLAGS) $^ -o $@
|
||||
|
||||
bin/pycdc: pycdc.cpp $(COMMON) $(BYTES)
|
||||
$(CXX) $(CXXFLAGS) $(LFLAGS) $(COMMON) $(BYTES) pycdc.cpp -o $@
|
||||
bin/pycdc: pycdc.cpp $(COMMON) $(BYTE_OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(LFLAGS) $^ -o $@
|
||||
|
||||
out/%.o: %.cpp %.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
out/python_%.o: bytes/python_%.cpp
|
||||
out/python_%.o: bytes/python_%.cpp $(BYTE_SRCS)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
bytes/python_%.cpp: bytes/python_%.map
|
||||
$(BYTE_SRCS): $(BYTE_MAPS)
|
||||
( cd bytes ; ./comp_map.py )
|
||||
|
@@ -15,37 +15,36 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pycdc. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
maplist = [ 'python_10', 'python_11', 'python_13', 'python_14', 'python_15',
|
||||
'python_16', 'python_20', 'python_21', 'python_22', 'python_23',
|
||||
'python_24', 'python_25', 'python_26', 'python_27', 'python_30',
|
||||
'python_31', 'python_32' ]
|
||||
maplist = [ 10, 11, 13, 14, 15, 16,
|
||||
20, 21, 22, 23, 24, 25, 26, 27,
|
||||
30, 31, 32 ]
|
||||
|
||||
for mapfile in maplist:
|
||||
infile = open(mapfile + '.map', 'rt')
|
||||
outfile = open(mapfile + '.cpp', 'wb')
|
||||
for mapver in maplist:
|
||||
infile = open('python_%d.map' % mapver, 'rt')
|
||||
outfile = open('python_%d.cpp' % mapver, 'wb')
|
||||
|
||||
idToOpcode = {}
|
||||
opcodeToId = {}
|
||||
for ln in infile.readlines():
|
||||
fileid, code = ln.split()
|
||||
idToOpcode[fileid] = code
|
||||
opcodeToId[code] = fileid
|
||||
idToOpcode[int(fileid)] = code
|
||||
opcodeToId[code] = int(fileid)
|
||||
|
||||
outfile.write('/* This file was auto-generated with comp_map.py. DO NOT EDIT! */\n\n')
|
||||
outfile.write('#include "../bytecode.h"\n\n')
|
||||
outfile.write('int ' + mapfile + '_map(int id)\n')
|
||||
outfile.write('int python_%d_map(int id)\n' % mapver)
|
||||
outfile.write('{\n')
|
||||
outfile.write(' switch (id) {\n')
|
||||
for i in idToOpcode:
|
||||
outfile.write(' case ' + i + ': return Pyc::' + idToOpcode[i] + ';\n')
|
||||
for i in sorted(idToOpcode):
|
||||
outfile.write(' case %d: return Pyc::%s;\n' % (i, idToOpcode[i]))
|
||||
outfile.write(' default: return Pyc::PYC_INVALID_OPCODE;\n')
|
||||
outfile.write(' }\n')
|
||||
outfile.write('}\n\n')
|
||||
outfile.write('int ' + mapfile + '_unmap(int id)\n')
|
||||
outfile.write('int python_%d_unmap(int id)\n' % mapver)
|
||||
outfile.write('{\n')
|
||||
outfile.write(' switch (id) {\n')
|
||||
for i in opcodeToId:
|
||||
outfile.write(' case Pyc::' + i + ': return ' + opcodeToId[i] + ';\n')
|
||||
for i in sorted(opcodeToId):
|
||||
outfile.write(' case Pyc::%s: return %d;\n' % (i, opcodeToId[i]))
|
||||
outfile.write(' default: return -1;\n')
|
||||
outfile.write(' }\n')
|
||||
outfile.write('}\n')
|
||||
|
Reference in New Issue
Block a user