Rearranged types to ensure better compliance with C type rules
This commit is contained in:
parent
c2cbc518f9
commit
18a66f6296
|
@ -1,6 +0,0 @@
|
|||
M2.M1
|
||||
M2.hex2
|
||||
cc_x86
|
||||
hold
|
||||
seed.hex2
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
## Copyright (C) 2017 Jeremiah Orians
|
||||
## This file is part of M2-Planet.
|
||||
##
|
||||
## M2-Planet 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 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## M2-Planet 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 M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set -eux
|
||||
[ -e ../bin/M2-Planet ] && rm ../bin/M2-Planet
|
||||
|
||||
# Make the required bin directry
|
||||
[ -d ../bin ] || mkdir ../bin
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f x86/cc_x86.M1 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
-o seed.hex2 || exit 1
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f ../test/common_x86/ELF-i386.hex2 \
|
||||
-f seed.hex2 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o cc_x86 \
|
||||
--exec_enable || exit 2
|
||||
|
||||
# Build M2-Planet from cc_x86
|
||||
catm hold ../test/common_x86/functions/file.c \
|
||||
../test/common_x86/functions/malloc.c \
|
||||
../functions/calloc.c \
|
||||
../test/common_x86/functions/exit.c \
|
||||
../functions/match.c \
|
||||
../functions/in_set.c \
|
||||
../functions/numerate_number.c \
|
||||
../functions/file_print.c \
|
||||
../functions/number_pack.c \
|
||||
../functions/fixup.c \
|
||||
../functions/string.c \
|
||||
../cc.h \
|
||||
../cc_reader.c \
|
||||
../cc_strings.c \
|
||||
../cc_types.c \
|
||||
../cc_core.c \
|
||||
../cc.c
|
||||
./cc_x86 hold M2.M1
|
||||
M1 --architecture x86 \
|
||||
--LittleEndian \
|
||||
-f ../test/common_x86/x86_defs.M1 \
|
||||
-f ../test/common_x86/libc-core.M1 \
|
||||
-f M2.M1 \
|
||||
-o M2.hex2
|
||||
|
||||
hex2 -f ../test/common_x86/ELF-i386.hex2 \
|
||||
-f M2.hex2 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o ../bin/M2-Planet-seed \
|
||||
--exec_enable
|
File diff suppressed because it is too large
Load Diff
1
cc.h
1
cc.h
|
@ -49,6 +49,7 @@ struct type
|
|||
struct type* next;
|
||||
int size;
|
||||
int offset;
|
||||
int SIGNED;
|
||||
struct type* indirect;
|
||||
struct type* members;
|
||||
struct type* type;
|
||||
|
|
86
cc_types.c
86
cc_types.c
|
@ -29,84 +29,100 @@ void initialize_types()
|
|||
/* Define void */
|
||||
global_types = calloc(1, sizeof(struct type));
|
||||
global_types->name = "void";
|
||||
global_types->SIGNED = FALSE;
|
||||
global_types->size = register_size;
|
||||
global_types->type = global_types;
|
||||
/* void* has the same properties as void */
|
||||
global_types->indirect = global_types;
|
||||
|
||||
/* Define int */
|
||||
/* Define UNSIGNED LONG */
|
||||
struct type* a = calloc(1, sizeof(struct type));
|
||||
a->name = "int";
|
||||
a->name = "SCM";
|
||||
a->SIGNED = FALSE;
|
||||
a->size = register_size;
|
||||
/* int* has the same properties as int */
|
||||
a->indirect = a;
|
||||
a->type = a;
|
||||
|
||||
/* Define char* */
|
||||
/* Define LONG */
|
||||
struct type* b = calloc(1, sizeof(struct type));
|
||||
b->name = "char*";
|
||||
b->name = "long";
|
||||
b->SIGNED = TRUE;
|
||||
b->size = register_size;
|
||||
b->indirect = b;
|
||||
b->type = b;
|
||||
|
||||
/* Define char */
|
||||
/* Define UNSIGNED */
|
||||
struct type* c = calloc(1, sizeof(struct type));
|
||||
c->name = "char";
|
||||
c->size = 1;
|
||||
c->name = "unsigned";
|
||||
c->SIGNED = FALSE;
|
||||
c->size = register_size;
|
||||
c->type = c;
|
||||
/* unsigned* has the same properties as unsigned */
|
||||
c->indirect = c;
|
||||
|
||||
/* Define char** */
|
||||
/* Define int */
|
||||
struct type* d = calloc(1, sizeof(struct type));
|
||||
d->name = "char**";
|
||||
d->name = "int";
|
||||
d->SIGNED = TRUE;
|
||||
d->size = register_size;
|
||||
d->type = b;
|
||||
/* int* has the same properties as int */
|
||||
d->indirect = d;
|
||||
d->type = d;
|
||||
|
||||
/*fix up indrects for chars */
|
||||
c->indirect = b;
|
||||
b->indirect = d;
|
||||
|
||||
/* Define FILE */
|
||||
/* Define char* */
|
||||
struct type* e = calloc(1, sizeof(struct type));
|
||||
e->name = "FILE";
|
||||
e->name = "char*";
|
||||
e->SIGNED = FALSE;
|
||||
e->size = register_size;
|
||||
e->type = e;
|
||||
/* FILE* has the same properties as FILE */
|
||||
e->indirect = e;
|
||||
|
||||
/* Define FUNCTION */
|
||||
/* Define char */
|
||||
struct type* f = calloc(1, sizeof(struct type));
|
||||
f->name = "FUNCTION";
|
||||
f->size = register_size;
|
||||
f->name = "char";
|
||||
f->SIGNED = FALSE;
|
||||
f->size = 1;
|
||||
f->type = f;
|
||||
/* FUNCTION* has the same properties as FUNCTION */
|
||||
f->indirect = f;
|
||||
|
||||
/* Define UNSIGNED */
|
||||
/* Define char** */
|
||||
struct type* g = calloc(1, sizeof(struct type));
|
||||
g->name = "unsigned";
|
||||
g->name = "char**";
|
||||
g->SIGNED = FALSE;
|
||||
g->size = register_size;
|
||||
g->type = g;
|
||||
/* unsigned* has the same properties as unsigned */
|
||||
g->type = e;
|
||||
g->indirect = g;
|
||||
|
||||
/* Custom type for mescc*/
|
||||
/*fix up indrects for chars */
|
||||
f->indirect = e;
|
||||
e->indirect = g;
|
||||
|
||||
/* Define FILE */
|
||||
struct type* h = calloc(1, sizeof(struct type));
|
||||
h->name = "SCM";
|
||||
h->name = "FILE";
|
||||
h->SIGNED = FALSE;
|
||||
h->size = register_size;
|
||||
h->type = h;
|
||||
/* FILE* has the same properties as FILE */
|
||||
h->indirect = h;
|
||||
|
||||
/* Define FUNCTION */
|
||||
struct type* i = calloc(1, sizeof(struct type));
|
||||
i->name = "long";
|
||||
i->name = "FUNCTION";
|
||||
i->SIGNED = FALSE;
|
||||
i->size = register_size;
|
||||
i->type = i;
|
||||
/* FUNCTION* has the same properties as FUNCTION */
|
||||
i->indirect = i;
|
||||
|
||||
/* Primitives mes.c wanted */
|
||||
struct type* j = calloc(1, sizeof(struct type));
|
||||
j->name = "size_t";
|
||||
j->SIGNED = FALSE;
|
||||
j->size = register_size;
|
||||
j->indirect = j;
|
||||
|
||||
struct type* k = calloc(1, sizeof(struct type));
|
||||
k->name = "ssize_t";
|
||||
k->SIGNED = FALSE;
|
||||
k->size = register_size;
|
||||
k->indirect = k;
|
||||
|
||||
|
@ -116,10 +132,10 @@ void initialize_types()
|
|||
h->next = i;
|
||||
g->next = h;
|
||||
f->next = g;
|
||||
e->next = f;
|
||||
d->next = e;
|
||||
c->next = e;
|
||||
a->next = c;
|
||||
d->next = f;
|
||||
c->next = d;
|
||||
b->next = c;
|
||||
a->next = b;
|
||||
global_types->next = a;
|
||||
prim_types = global_types;
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@ a9cf4422e05075395ad75bbfe4b2659aec4541edd46d8c6b5064d3496b06a0b6 test/results/t
|
|||
1154f39f25dcd6d914e9a542306f95280926baf985d011b2152c7ea0b87ab42d test/results/test10-knight-native-binary
|
||||
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary
|
||||
b3e13d54aab689137628fb9c4487bfd8288f9bd18bef8fe756577c8d2dce1f1f test/results/test10-x86-binary
|
||||
67fe5708ecb58ff63262d002c81e007177395613166649c23119c154cd347254 test/results/test100-amd64-binary
|
||||
057cbf1a026f80c6f377af1eeeba6e38007697e8c12546ec853a4ca68f7869ce test/results/test100-armv7l-binary
|
||||
0c563f8028cc93be2091992ef1210cd1a25e006680ec3b1bac5ecc61370c9258 test/results/test100-knight-posix-binary
|
||||
84db585b6a8f51151c658ecbbcbd97a411d88d7379d5e416841ca616cf723374 test/results/test100-x86-binary
|
||||
4d41cd9cc1ac08bda0372a1e7be17965b7a6f3bc77f87ca024bc4cc7948aedf5 test/results/test100-amd64-binary
|
||||
a157f35aa2acf791464b242fe36f69816e1b91dd5559bca6a5bab1ad8ddcfbac test/results/test100-armv7l-binary
|
||||
1ce45071c156ce9f012b9cc8b179205c3948405b252c29db1f036c097f22947f test/results/test100-knight-posix-binary
|
||||
5e9e50ee0ca2c0cd290c4c764dfd1329baa563e078247b93754500543cb24c2e test/results/test100-x86-binary
|
||||
34e6d535e30ef8826a4ad1a4d08b76cfa370c54595599ad3be784b64c9cd8ec5 test/results/test11-amd64-binary
|
||||
d9d465340abbce2d5964a6bc58e6cdd0ef93fb3d0199eaa823c86ec6abd0452a test/results/test11-armv7l-binary
|
||||
955b564d2c89abf2cfc6c80d766cd11479d146b828dec69e654b0958a62d5e6e test/results/test11-knight-native-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
d37c7ede25b79a5ba457fd80aec9f4a21df5a8c3d467e52c4f1d7146d83d2d64 test/test100/proof
|
||||
857519b111433c1cc3fd2f9fa60e86222e4227e9fce1601d08ceec6dfd7160e9 test/test100/proof
|
||||
|
|
Loading…
Reference in New Issue