Skip to content

Commit

Permalink
Resolve #47, #48, #51
Browse files Browse the repository at this point in the history
  • Loading branch information
TarasBereznyak committed Aug 21, 2020
1 parent cd4e4aa commit 6b0f34b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
3 changes: 2 additions & 1 deletion builtinImpl.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ staticityOfBinResult: [

result: @processor.@varForCallTrace FALSE dynamic @processor @block createRefNoOp @processor @block createAllocIR Dynamic @processor @block makeStaticity;
result @processor @block createGetCallTrace
result @block push
result @processor @block derefAndPush

TRUE @block.!hasCallTrace
] "mplBuiltinGetCallTrace" @declareBuiltin ucall
Expand Down Expand Up @@ -1542,6 +1542,7 @@ staticityOfBinResult: [
block.astArrayIndex @processor @block printAstArrayTree
] "mplBuiltinPrintMatchingTree" @declareBuiltin ucall


[
debugMemory [
("compilerMaxAllocationSize=" getMemoryMetrics.memoryMaxAllocationSize LF) printList
Expand Down
31 changes: 19 additions & 12 deletions codeNode.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -2777,24 +2777,31 @@ addNamesFromModule: [

finalizeListNode: [
struct: Struct;
validOutputCount: block.stack.size;

processor compilable [
i: 0 dynamic;

[
i block.stack.size < [
curRef: i @block.@stack.at;
curRef getVar.data.getTag VarInvalid = [
i @validOutputCount set
FALSE
] [
newField: Field;
processor.specialNames.emptyNameInfo @newField.@nameInfo set

newField: Field;
processor.specialNames.emptyNameInfo @newField.@nameInfo set
curRef getVar.temporary [
curRef @newField.@refToVar set
] [
@curRef TRUE dynamic @processor @block createRef @newField.@refToVar set
@curRef makeVarPtrCaptured
] if

curRef getVar.temporary [
curRef @newField.@refToVar set
] [
@curRef TRUE dynamic @processor @block createRef @newField.@refToVar set
@curRef makeVarPtrCaptured
newField @struct.@fields.pushBack
i 1 + @i set processor compilable
] if

newField @struct.@fields.pushBack
i 1 + @i set processor compilable
] &&
] loop
] when
Expand All @@ -2809,7 +2816,7 @@ finalizeListNode: [

i: 0 dynamic;
[
i block.stack.size < [
i validOutputCount < [
curFieldRef: i @struct.@fields.at.@refToVar;

curFieldRef isVirtual [
Expand All @@ -2826,7 +2833,7 @@ finalizeListNode: [
] &&
] loop

@block.@stack.clear
block.stack.size validOutputCount - @block.@stack.shrink
refToStruct @block.@stack.pushBack
] when
];
Expand Down
20 changes: 12 additions & 8 deletions debugWriter.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ getPointerTypeDebugDeclaration: [
var: refToVar getVar;
debugDeclarationIndex: refToVar @processor getMplSchema.dbgTypeDeclarationId copy;
[debugDeclarationIndex -1 = ~] "Pointee has no type debug info!" assert
"DW_TAG_pointer_type" makeStringView debugDeclarationIndex processor.options.pointerSize 0ix cast 0 cast @processor addDerivedTypeInfo
index: "DW_TAG_pointer_type" makeStringView debugDeclarationIndex processor.options.pointerSize 0ix cast 0 cast @processor addDerivedTypeInfo;

index
];

addMemberInfo: [
Expand All @@ -147,17 +149,16 @@ addMemberInfo: [
name: field.nameInfo processor.nameManager.getText;

name "" = [
("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"f" fieldNumber "\", scope: !" block.funcDbgIndex
("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"f" fieldNumber "\""
", file: !" processor.positions.last.file.debugId
", line: " processor.positions.last.line ", baseType: !" debugDeclarationIndex ", size: " fsize 8 * ", offset: " offset 8 * ")") assembleString
] [
("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"" name "\", scope: !" block.funcDbgIndex
("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"" name "\""
", file: !" processor.positions.last.file.debugId
", line: " processor.positions.last.line ", baseType: !" debugDeclarationIndex ", size: " fsize 8 * ", offset: " offset 8 * ")") assembleString
] if

addDebugString
index block.funcDbgIndex @processor.@debugInfo.@locationIds.insert

offset fsize + @offset set
index
Expand Down Expand Up @@ -213,15 +214,13 @@ getTypeDebugDeclaration: [
"}" @newDebugInfo.cat
@newDebugInfo move addDebugString

index block.funcDbgIndex @processor.@debugInfo.@locationIds.insert

index: processor.debugInfo.lastId copy;
processor.debugInfo.lastId 1 + @processor.@debugInfo.@lastId set

("!" index " = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !" processor.positions.last.file.debugId
", name: \"" refToVar @processor block getDebugType "\", line: " processor.positions.last.line ", size: " refToVar @processor getStorageSize 0ix cast 0 cast 8 * ", elements: !" index 1 -
", name: \"" refToVar @processor block getDebugType "\", size: " refToVar @processor getStorageSize 0ix cast 0 cast 8 * ", elements: !" index 1 -
")") assembleString addDebugString
index block.funcDbgIndex @processor.@debugInfo.@locationIds.insert
index
] [
[FALSE] "Unknown type in getTypeDebugDeclaration!" assert
Expand Down Expand Up @@ -508,13 +507,18 @@ correctUnitInfo: [
clearUnusedDebugInfo: [
processor:;

clearString: [
s:;
String @s set
];

processor.debugInfo.locationIds [
pair:;
locId: pair.key;
funcDbgId: pair.value;
debugString: funcDbgId 4 + processor.debugInfo.strings.at;
debugString.size 0 = [
String locId 4 + @processor.@debugInfo.@strings.at set
locId 4 + @processor.@debugInfo.@strings.at clearString
] when
] each

Expand Down
11 changes: 10 additions & 1 deletion processSubNodes.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,15 @@ applyNodeChanges: [
addAppliedVar: [
stackEntry: cacheEntry: appliedVars: ;;;

[stackEntry cacheEntry variablesAreSame] "Applied vars has different type!" assert
[stackEntry cacheEntry variablesAreSame
[
(
"Stack entry type is " stackEntry @processor @block getMplType LF
"cache entry type is " cacheEntry @processor @block getMplType LF
) printList
FALSE
] ||
] "Applied vars has different type!" assert

stackEntry noMatterToCopy ~ [
[stackEntry getVar.host.id block.id =] "Stack entry is not from here!" assert
Expand Down Expand Up @@ -2215,6 +2223,7 @@ processDynamicLoop: [
successBeforeCaptures: processor.result.success copy;
TRUE @processor.@result.@success set


newNode: newNodeIndex processor.blocks.at.get;

processor.result.passErrorThroughPRE ~ [
Expand Down

0 comments on commit 6b0f34b

Please sign in to comment.