Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The bug in the way the TypeOf operator is implemented #22

Open
FlatAssembler opened this issue Dec 15, 2024 · 2 comments
Open

The bug in the way the TypeOf operator is implemented #22

FlatAssembler opened this issue Dec 15, 2024 · 2 comments

Comments

@FlatAssembler
Copy link
Owner

FlatAssembler commented Dec 15, 2024

So, for example, this program:

Function strlen(PointerToCharacter str) Which Returns Integer32 Does
  Return ValueAt(str)=0?0:1+strlen(str+1);
EndFunction

Structure Point Consists Of
  Decimal32 x, y, z;
EndStructure

Function main() Which Returns Integer32 Does
  InstantiateStructure Point myPoint;
  Return strlen(TypeOf(AddressOf(myPoint)));
EndFunction

That program crashes the compiler, with this error message:

Running the tests...
All the tests passed in 8 milliseconds.
Reading the file "debug.aec"...
All characters read in 0 milliseconds.
Tokenizing the program...
Finished tokenizing the program in 0 milliseconds.
I have made a forum thread about how to speed up the tokenizer,
in case you are interested:
https://www.forum.hr/showthread.php?t=1243509
Parsing the program...
Finished parsing the program in 0 milliseconds.
Compiling the program...
Line 11, Column 18, Internal compiler error: A pointer to the string "PointPointer" is being attempted to compile before the string itself has been compiled, aborting the compilation!
Internal compiler error: Uncaught exception in the compiler: class CorruptCompilationContextException: Corrupt compilation context!
The JSON of the compilation context, at the time of throwing that exception, was:
{
"stackSize":4096,
"globalVariablePointer":4272,
"variableTypes":[
{
"first":"\"Character\"",
"second":"CharacterPointer"
},
{
"first":"\"CharacterPointer\"",
"second":"CharacterPointer"
},
{
"first":"\"Decimal32\"",
"second":"CharacterPointer"
},
{
"first":"\"Decimal32Pointer\"",
"second":"CharacterPointer"
},
{
"first":"\"Decimal64\"",
"second":"CharacterPointer"
},
{
"first":"\"Decimal64Pointer\"",
"second":"CharacterPointer"
},
{
"first":"\"Integer16\"",
"second":"CharacterPointer"
},
{
"first":"\"Integer16Pointer\"",
"second":"CharacterPointer"
},
{
"first":"\"Integer32\"",
"second":"CharacterPointer"
},
{
"first":"\"Integer32Pointer\"",
"second":"CharacterPointer"
},
{
"first":"\"Integer64\"",
"second":"CharacterPointer"
},
{
"first":"\"Integer64Pointer\"",
"second":"CharacterPointer"
},
{
"first":"\"Nothing\"",
"second":"CharacterPointer"
},
{
"first":"\"Point\"",
"second":"CharacterPointer"
},
{
"first":"myPoint",
"second":"Point"
}
],
"placesOfVariableDeclarations":[
{
"first":"myPoint",
"second":10
}
],
"globalVariables":[
{
"first":"\"Character\"",
"second":4096
},
{
"first":"\"CharacterPointer\"",
"second":4106
},
{
"first":"\"Decimal32\"",
"second":4123
},
{
"first":"\"Decimal32Pointer\"",
"second":4133
},
{
"first":"\"Decimal64\"",
"second":4150
},
{
"first":"\"Decimal64Pointer\"",
"second":4160
},
{
"first":"\"Integer16\"",
"second":4177
},
{
"first":"\"Integer16Pointer\"",
"second":4187
},
{
"first":"\"Integer32\"",
"second":4204
},
{
"first":"\"Integer32Pointer\"",
"second":4214
},
{
"first":"\"Integer64\"",
"second":4231
},
{
"first":"\"Integer64Pointer\"",
"second":4241
},
{
"first":"\"Nothing\"",
"second":4258
},
{
"first":"\"Point\"",
"second":4266
}
],
"localVariables":[
{
"first":"myPoint",
"second":12
}
],
"functions":[
{
"name":"strlen(",
"returnType":"Integer32",
"argumentTypes":["CharacterPointer"],
"defaultArgumentValues":[0.000000],
"argumentNames":["str"]
},
{
"name":"main(",
"returnType":"Integer32",
"argumentTypes":[],
"defaultArgumentValues":[],
"argumentNames":[]
}
],
"stackSizeOfThisFunction":12,
"stackSizeOfThisScope":12,
"currentFunctionName":"main(",
"structures":[
{
"name":"Point",
"sizeInBytes":12,
"memberNames":["x","y","z"],
"memberTypes":[
{
"first":"x",
"second":"Decimal32"
},
{
"first":"y",
"second":"Decimal32"
},
{
"first":"z",
"second":"Decimal32"
}
],
"memberOffsetInBytes":[
{
"first":"x",
"second":0
},
{
"first":"y",
"second":4
},
{
"first":"z",
"second":8
}
],
"defaultValuesOfMembers":[
{
"first":"x",
"second":0.000000
},
{
"first":"y",
"second":0.000000
},
{
"first":"z",
"second":0.000000
}
],
"arraySize":[
{
"first":"x",
"second":1
},
{
"first":"y",
"second":1
},
{
"first":"z",
"second":1
}
]
}
],
"structureSizes":[
{
"first":"Point",
"second":12
}
]
}

If you have time, please report this to me on GitHub as an issue:
https://github.com/FlatAssembler/AECforWebAssembly/issues

Given the way the compiler is structured, there doesn't seem to be a simple solution.

FlatAssembler added a commit that referenced this issue Dec 15, 2024
@FlatAssembler
Copy link
Owner Author

I've started a forum question about that: https://www.theflatearthsociety.org/forum/index.php?topic=92938.0

@FlatAssembler
Copy link
Owner Author

I've also started a question about that on forum.hr: https://www.forum.hr/showthread.php?p=106424493#post106424493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant