Skip to content

Commit

Permalink
Implement partial compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
MatwayBurkow committed Jun 28, 2020
1 parent a150a50 commit 770f172
Show file tree
Hide file tree
Showing 25 changed files with 1,516 additions and 1,764 deletions.
35 changes: 21 additions & 14 deletions Block.mpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"Array" use
"HashTable" use
"String" use
"Variant" use
"control" use

"Array.Array" use
"HashTable.HashTable" use
"String.String" use
"Variant.Variant" use

"Mref.Mref" use
"Var.RefToVar" use
"Var.Struct" use
"Mref" use
"Var" use

ArgVirtual: [0n8 dynamic];
ArgGlobal: [1n8 dynamic];
Expand Down Expand Up @@ -67,7 +65,7 @@ Capture: [{
captureCase: NameCaseInvalid;
nameInfo: -1 dynamic;
nameOverloadDepth: -1 dynamic;
file: ["File.FileSchema" use FileSchema] Mref;
file: ["MplFile.FileSchema" use FileSchema] Mref;
}];

CFunctionSignature: [{
Expand All @@ -78,7 +76,7 @@ CFunctionSignature: [{
}];

CompilerPositionInfo: [{
file: ["File.FileSchema" use FileSchema] Mref;
file: ["MplFile.FileSchema" use FileSchema] Mref;
line: -1 dynamic;
column: -1 dynamic;
token: String;
Expand All @@ -90,7 +88,7 @@ FieldCapture: [{
nameInfo: -1 dynamic;
nameOverloadDepth: -1 dynamic;
fieldIndex: -1 dynamic;
file: ["File.FileSchema" use FileSchema] Mref;
file: ["MplFile.FileSchema" use FileSchema] Mref;
}];

makeInstruction: [{
Expand All @@ -110,6 +108,7 @@ Instruction: [0 0 makeInstruction];
ShadowEvent: [(
Cond #ShadowReasonNo
ShadowEventCapture #ShadowReasonCapture
ShadowEventStableName #ShadowReasonStableName
ShadowEventFieldCapture #ShadowReasonFieldCapture
ShadowEventInput #ShadowReasonInput
ShadowEventField #ShadowReasonField
Expand All @@ -125,7 +124,7 @@ MatchingInfo: [{

NameWithOverload: [{
nameInfo: -1 dynamic;
nameOverloadDepth: -1 dynamic;
nameOverloadDepth: -1 dynamic;
}];

NameWithOverloadAndRefToVar: [{
Expand All @@ -138,7 +137,7 @@ NameWithOverloadAndRefToVar: [{
}];

TokenRef: [{
file: ["File.FileSchema" use FileSchema] Mref;
file: ["MplFile.FileSchema" use FileSchema] Mref;
token: Int32;
}];

Expand Down Expand Up @@ -171,7 +170,9 @@ ShadowEventStableName: [{
Block: [{
id: Int32;
root: FALSE dynamic;
file: ["File.FileSchema" use FileSchema] Mref;
file: ["MplFile.FileSchema" use FileSchema] Mref;
topNode: [@BlockSchema] Mref;
capturedFiles: Cond Array;
beginPosition: CompilerPositionInfo;
parent: 0 dynamic;
nodeCase: NodeCaseCode;
Expand All @@ -182,7 +183,9 @@ Block: [{
aliases: String Array;
lastLambdaName: Int32;
nextRecLambdaId: -1 dynamic;
globalPriority: Int32;

hasEmptyLambdas: FALSE dynamic;
nodeIsRecursive: FALSE dynamic;
nextLabelIsVirtual: FALSE dynamic;
nextLabelIsConst: FALSE dynamic;
Expand All @@ -204,6 +207,8 @@ Block: [{
uncompilable: FALSE dynamic;
variadic: FALSE dynamic;
hasNestedCall: FALSE dynamic;
hasCallTrace: FALSE dynamic;
changedStableName: FALSE dynamic;

countOfUCall: 0 dynamic;
declarationRefs: Cond Array;
Expand All @@ -217,9 +222,11 @@ Block: [{
labelNames: NameWithOverloadAndRefToVar Array;
captureNames: NameWithOverloadAndRefToVar Array;
fieldCaptureNames: NameWithOverloadAndRefToVar Array;
stableNames: Int32 Array;

candidatesToDie: RefToVar Array;
unprocessedAstNodes: TokenRef Array;
globalVariableNames: Int32 RefToVar Array HashTable;

refToVar: RefToVar; #refToVar of function with compiled node
varNameInfo: -1 dynamic; #variable name of imported function
Expand Down
6 changes: 4 additions & 2 deletions File.mpl → MplFile.mpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"Mref.Mref" use
"String.String" use
"Mref" use
"String" use
"control" use

File: [{
name: String;
usedInParams: Cond;
fileId: Int32;
text: String;
debugId: Int32;
rootBlock: ["Block.BlockSchema" use BlockSchema] Mref;
Expand Down
2 changes: 2 additions & 0 deletions Mref.mpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"control" use

Mref: [{
ObjectSchema:;
data: 0nx dynamic;
Expand Down
36 changes: 27 additions & 9 deletions NameManager.mpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"Array.Array" use
"HashTable.HashTable" use
"HashTable.hash" use
"String.String" use
"String.StringView" use
"String.hash" use
"String.toString" use
"Array" use
"HashTable" use
"String" use
"control" use

NameManager: [{
Expand All @@ -19,14 +15,19 @@ NameManager: [{
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
0 @names.last.!overloadCount
0 @names.last.!localCount
nameId
] if
];

addItem: [
item: nameId:;;

@item move nameId @[email protected]
current: nameId @names.at;
item.file isNil [current.overloadCount 1 + @current.!overloadCount] when
item.isLocal [current.localCount 1 + @current.!localCount] when
@item move @[email protected]
];

findItem: [
Expand All @@ -45,6 +46,16 @@ NameManager: [{
index
];

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

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

getItem: [
index: nameId:;;
index nameId @[email protected]
Expand All @@ -58,14 +69,21 @@ NameManager: [{
removeItem: [
nameId:;

nameId @[email protected]
current: nameId @names.at;
current.items.last.file isNil [current.overloadCount 1 - @current.!overloadCount] when
current.items.last.isLocal [current.localCount 1 - @current.!localCount] when

@[email protected]

];

# Private

Name: [{
text: String;
items: @itemSchema Array;
overloadCount: Int32;
localCount: Int32;
}];

names: Name Array;
Expand Down
42 changes: 24 additions & 18 deletions Var.mpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@

"Array.Array" use
"Owner.Owner" use
"String.String" use
"String.StringView" use
"String.addLog" use
"String.assembleString" use
"String.makeStringView" use
"String.toString" use
"Variant.Variant" use
"Array" use
"Owner" use
"String" use
"Variant" use
"control" use

"Mref.Mref" use
"staticCall.staticCall" use
"Mref" use
"staticCall" use

Dirty: [0n8 dynamic];
Dynamic: [1n8 dynamic];
Expand All @@ -21,10 +15,11 @@ Virtual: [4n8 dynamic];

ShadowReasonNo: [0];
ShadowReasonCapture: [1];
ShadowReasonFieldCapture: [2];
ShadowReasonInput: [3];
ShadowReasonField: [4];
ShadowReasonPointee: [5];
ShadowReasonStableName: [2];
ShadowReasonFieldCapture: [3];
ShadowReasonInput: [4];
ShadowReasonField: [5];
ShadowReasonPointee: [6];

VarInvalid: [ 0 static];
VarCond: [ 1 static];
Expand All @@ -49,7 +44,7 @@ VarStruct: [19 static];
VarEnd: [20 static];

CodeNodeInfo: [{
file: ["File.FileSchema" use FileSchema] Mref;
file: ["MplFile.FileSchema" use FileSchema] Mref;
line: Int32;
column: Int32;
index: Int32;
Expand Down Expand Up @@ -341,7 +336,6 @@ getVirtualValue: [
refToVar isPlain [
refToVar getPlainConstantIR @result.cat
] [
("Tag = " var.data.getTag) addLog
[FALSE] "Wrong type for virtual value!" assert
] if
]
Expand Down Expand Up @@ -544,6 +538,18 @@ makeStringId: [
] if
];

makeDefaultVarId: [
varId: processor: ;;

[varId processor.defaultVarNames.getSize < ~] [
-1 @[email protected]
] while

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

markAsUnableToDie: [
refToVar:;
var: @refToVar getVar;
Expand Down
14 changes: 7 additions & 7 deletions astNodeType.mpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"Array" use
"HashTable" use
"Owner" use
"String" use
"Variant" use
"control" use

"Array.Array" use
"HashTable.HashTable" use
"String.String" use
"Variant.Variant" use

AstNodeType: {
Code: [ 0];
Label: [ 1];
Expand Down Expand Up @@ -103,8 +103,8 @@ ParserResult: [{
ParserResults: [ParserResult Array];

MultiParserResult: [{
memory: AstNode Array;
nodes: IndexArray Array; # order of going is not defined before compiling
memory: AstNode Owner Array;
nodes: IndexArray Owner Array; # order of going is not defined before compiling

INIT: []; DIE: []; # default life control, and ban uneffective copy, because object is too big
}];
Loading

0 comments on commit 770f172

Please sign in to comment.