Skip to content

Commit

Permalink
Support updated move semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
MatwayBurkow committed Feb 14, 2021
1 parent 924d63f commit 57c2514
Show file tree
Hide file tree
Showing 21 changed files with 528 additions and 529 deletions.
4 changes: 2 additions & 2 deletions Block.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ makeInstruction: [{
irName1: -1 dynamic;
irName2: -1 dynamic;
irName3: -1 dynamic;
codeOffset: copy;
codeSize: copy;
codeOffset: new;
codeSize: new;
}];

Instruction: [0 0 makeInstruction];
Expand Down
14 changes: 7 additions & 7 deletions NameManager.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ NameManager: [{
createName: [
text:;
result: text textNameIds.find;
result.success [result.value copy] [
result.success [result.value new] [
string: text String same [@text] [text toString] uif;
nameId: names.size;
nameId 1 + @names.enlarge
string.getStringView nameId @textNameIds.insertUnsafe # Make StringView using the source String object, reference should remain valid when we move String
@string move @names.last.@text set
@string @names.last.@text set
0 @names.last.!overloadCount
0 @names.last.!localCount
nameId
Expand All @@ -27,11 +27,11 @@ NameManager: [{
current: nameId @names.at;
item.file isNil [current.overloadCount 1 + @current.!overloadCount] when
item.isLocal [current.localCount 1 + @current.!localCount] when
@item move @current.@items.pushBack
@item @current.@items.pushBack
];

findItem: [
index: file: nameId:;; copy;
index: file: nameId:;; new;
items: nameId names.at.items;

index -1 = [items.size !index] when
Expand All @@ -47,7 +47,7 @@ NameManager: [{
];

findItemStrong: [
index: file: nameId:;; copy;
index: file: nameId:;; new;
items: nameId names.at.items;

index -1 = [items.size !index] when
Expand All @@ -63,12 +63,12 @@ NameManager: [{
];

hasOverload: [
nameId: copy;
nameId: new;
nameId @names.at.overloadCount 0 >
];

hasLocalDefinition: [
nameId: copy;
nameId: new;
nameId @names.at.localCount 0 >
];

Expand Down
33 changes: 17 additions & 16 deletions Var.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"Owner" use
"String" use
"Variant" use
"algorithm" use
"control" use

"Mref" use
Expand Down Expand Up @@ -73,7 +74,7 @@ Struct: [{
}]; #IDs of pointee vars

makeRefBranch: [{
refToVar: copy;
refToVar: new;
usedHere: FALSE dynamic;
}];

Expand Down Expand Up @@ -104,12 +105,12 @@ RefToVar: [{
];

setMutable: [
copy newMutable:;
newMutable: new;
newMutable [1nx] [0nx] if data 1nx ~ and or !data
];

setMoved: [
copy newMoved:;
newMoved: new;
newMoved [2nx] [0nx] if data 2nx ~ and or !data
];

Expand All @@ -121,8 +122,8 @@ RefToVar: [{
makeValuePair: [
type:;
{
begin: type copy;
end: type copy;
begin: type new;
end: type new;
}
];

Expand Down Expand Up @@ -215,7 +216,7 @@ isVirtualType: [
var.data.getTag VarBuiltin =
[var.data.getTag VarCode =] ||
[var.data.getTag VarInvalid =] ||
[var.data.getTag VarStruct = [VarStruct var.data.get.get.fullVirtual copy] &&] ||
[var.data.getTag VarStruct = [VarStruct var.data.get.get.fullVirtual new] &&] ||
];

isInt: [
Expand Down Expand Up @@ -292,7 +293,7 @@ isAutoStruct: [
refToVar:;
var: refToVar getVar;
var.data.getTag VarStruct =
[VarStruct var.data.get.get.hasDestructor copy] &&
[VarStruct var.data.get.get.hasDestructor new] &&
];

getVirtualValue: [
Expand Down Expand Up @@ -358,7 +359,7 @@ getStringImplementation: [
[
i stringView.size < [
codeRef: stringView.data storageAddress i Natx cast + Nat8 addressToReference;
code: codeRef copy;
code: codeRef new;
code 32n8 < ~ [code 127n8 <] && [code 34n8 = ~] && [code 92n8 = ~] && [ # exclude " and \
code 0n32 cast @result.catSymbolCode
] [
Expand Down Expand Up @@ -440,7 +441,7 @@ getPlainValueInformation: [
" dynamic" toString !result
] [
var.data.getTag VarCond VarReal64 1 + [
copy tag:;
tag: new;
branch: tag var.data.get;
(" static: " branch.end) assembleString !result
] staticCall
Expand All @@ -449,7 +450,7 @@ getPlainValueInformation: [
];

bitView: [
copy f:;
f: new;
buffer: f storageAddress (0n8 0n8 0n8 0n8 0n8 0n8 0n8 0n8) addressToReference;
result: String;
"0x" @result.cat
Expand Down Expand Up @@ -503,7 +504,7 @@ getStructStorageSize: [
refToVar: processor: ;;
var: refToVar getVar;
struct: VarStruct var.data.get.get;
struct.structStorageSize copy
struct.structStorageSize new
];

getStorageSize: [
Expand All @@ -519,7 +520,7 @@ getStructAlignment: [
refToVar: processor: ;;
var: refToVar getVar;
struct: VarStruct var.data.get.get;
struct.structAlignment copy
struct.structAlignment new
];

getAlignment: [
Expand All @@ -535,11 +536,11 @@ makeStringId: [
string: processor: ;;
fr: string @processor.@nameTable.find;
fr.success [
fr.value copy
fr.value new
] [
result: processor.nameBuffer.size;
string makeStringView result @processor.@nameTable.insert
@string move @processor.@nameBuffer.pushBack
@string @processor.@nameBuffer.pushBack
result
] if
];
Expand All @@ -553,7 +554,7 @@ makeDefaultVarId: [

result: varId @processor.@defaultVarNames.at;
result 0 < [("%var." varId) assembleString @processor makeStringId @result set] when
result copy
result new
];

markAsUnableToDie: [
Expand All @@ -576,7 +577,7 @@ variablesAreSame: [
staticityOfVar: [
refToVar:;
var: refToVar getVar;
var.staticity.end copy
var.staticity.end new
];

fullUntemporize: [
Expand Down
8 changes: 4 additions & 4 deletions astNodeType.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ NamedBranch: [{

makePositionInfo: [{
token: String;
column: copy;
line: copy;
offset: copy;
fileId: copy;
column: new;
line: new;
offset: new;
fileId: new;
}];

PositionInfo: [-1 dynamic -1 dynamic 1 dynamic 0 dynamic makePositionInfo];
Expand Down
10 changes: 5 additions & 5 deletions astOptimizers.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ optimizeLabels: [
currentIndexArray:;

newIndexArray: AstNodeArray;
@currentIndexArray.@positionInfo move @newIndexArray.@positionInfo set
@currentIndexArray.@positionInfo @newIndexArray.@positionInfo set

@currentIndexArray.@nodes [
current:;
current.data.getTag AstNodeType.Label = [
AstNodeType.Label current.data.get.children @parserResult.@memory.at.@nodes [
move @newIndexArray.@nodes.pushBack
@newIndexArray.@nodes.pushBack
] each
] when

@current move @newIndexArray.@nodes.pushBack
@current @newIndexArray.@nodes.pushBack
] each

@newIndexArray move @currentIndexArray set
@newIndexArray @currentIndexArray set
] each
];

Expand Down Expand Up @@ -90,7 +90,7 @@ concatParserResult: [
] if
] each

@currentArray move @mresult.@memory.pushBack
@currentArray @mresult.@memory.pushBack
] each

current.root @mresult.@roots.pushBack
Expand Down
2 changes: 1 addition & 1 deletion build/link.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@ECHO OFF
clang.exe -O3 -Wno-override-module -o mplc.exe mplc.ll
clang.exe -O3 -Wl,/STACK:reserve=1048576 -Wno-override-module -o mplc.exe mplc.ll
Loading

0 comments on commit 57c2514

Please sign in to comment.