string constants inside struct constants +test
This commit is contained in:
Родитель
0d1ff8042b
Коммит
268226c46c
|
@ -136,7 +136,7 @@ function JSify(data) {
|
|||
|
||||
// Gets an entire constant expression
|
||||
function parseConst(value, type) {
|
||||
dprint('gconst', '//yyyyy ' + JSON.stringify(value) + ',' + type + '\n');
|
||||
//dprint('gconst', '//yyyyy ' + JSON.stringify(value) + ',' + type + '\n');
|
||||
if (Runtime.isNumberType(type) || pointingLevels(type) == 1) {
|
||||
return makePointer(indexizeFunctions(parseNumerical(toNiceIdent(value.text))), null, 'ALLOC_STATIC', type);
|
||||
} else if (value.text == 'zeroinitializer') {
|
||||
|
@ -147,9 +147,10 @@ function JSify(data) {
|
|||
} else {
|
||||
// Gets an array of constant items, separated by ',' tokens
|
||||
function handleSegments(tokens) {
|
||||
//dprint('gconst', '// segggS: ' + JSON.stringify(tokens) + '\n' + '\n')
|
||||
// Handle a single segment (after comma separation)
|
||||
function handleSegment(segment) {
|
||||
dprint('gconst', '// seggg: ' + JSON.stringify(segment) + '\n' + '\n')
|
||||
//dprint('gconst', '// seggg: ' + JSON.stringify(segment) + '\n' + '\n')
|
||||
if (segment[1].text == 'null') {
|
||||
return '0';
|
||||
} else if (segment[1].text == 'zeroinitializer') {
|
||||
|
@ -171,6 +172,11 @@ function JSify(data) {
|
|||
return '[' + alignStruct(handleSegments(segment[1].item.tokens), type).join(', ') + ']';
|
||||
} else if (segment.length == 2) {
|
||||
return parseNumerical(toNiceIdent(segment[1].text));
|
||||
} else if (segment[1].text === 'c') {
|
||||
// string
|
||||
var text = segment[2].text;
|
||||
text = text.substr(1, text.length-2);
|
||||
return JSON.stringify(parseLLVMString(text)) + ' /* ' + text + '*/';
|
||||
} else {
|
||||
throw 'Invalid segment: ' + dump(segment);
|
||||
}
|
||||
|
|
|
@ -596,12 +596,22 @@ if 'benchmark' not in sys.argv:
|
|||
{ 't', 0.27, 2 },
|
||||
};
|
||||
|
||||
const unsigned char faceedgesidx[6][4] =
|
||||
{
|
||||
{ 4, 5, 8, 10 },
|
||||
{ 6, 7, 9, 11 },
|
||||
{ 0, 2, 8, 9 },
|
||||
{ 1, 3, 10,11 },
|
||||
{ 0, 1, 4, 6 },
|
||||
{ 2, 3, 5, 7 },
|
||||
};
|
||||
|
||||
int main( int argc, const char *argv[] ) {
|
||||
printf("*%d,%d,%d*\\n", iub[0].c, int(iub[1].p*100), iub[2].pi);
|
||||
printf("*%d,%d,%d,%d*\\n", iub[0].c, int(iub[1].p*100), iub[2].pi, faceedgesidx[3][2]);
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
self.do_test(src, '*97,15,3*')
|
||||
self.do_test(src, '*97,15,3,10*')
|
||||
|
||||
def test_conststructs(self):
|
||||
src = '''
|
||||
|
|
Загрузка…
Ссылка в новой задаче