Skip to content

Commit

Permalink
Addition of meta to prevent DCE removing scriptable accessible code
Browse files Browse the repository at this point in the history
Also prevent watchable macro generated fields to be removed
added hl build script
  • Loading branch information
tpr-evilempire committed Oct 31, 2019
1 parent c1dc201 commit c10ea6c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions interpret/DynamicModule.hx
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ class DynamicModule {
for (item in module) {
switch (item) {
case TInst(t, params):
// add a meta to prevent that class to be altered by dce
t.get().meta.add(":keepSub", [], currentPos);

// Type
var rawTypePath = t.toString();

Expand Down
10 changes: 9 additions & 1 deletion interpret/macros/InterpretableMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class InterpretableMacro {
var hasFieldsWithInterpretMeta = false;

var localClass = Context.getLocalClass().get();
// add a meta to prevent that class to be altered by dce, and depending classes
localClass.meta.add(":keepSub", [], currentPos);

var classHasInterpretMeta = hasInterpretMeta(localClass.meta.get());

var filePath = Context.getPosInfos(localClass.pos).file;
Expand Down Expand Up @@ -318,7 +321,7 @@ class InterpretableMacro {
kind: FVar(
macro :interpret.LiveReload,
macro new interpret.LiveReload($v{filePath}, function(content:String) {
trace('File changed at path ' + $v{filePath});
//trace('File changed at path ' + $v{filePath});
try {
if (interpretWillReloadClass != null) {
interpretWillReloadClass(__interpretClass);
Expand All @@ -344,8 +347,13 @@ class InterpretableMacro {
name: ':noCompletion',
params: [],
pos: currentPos
}, {
name: ':keepSub',
params: [],
pos: currentPos
}]
});

#end

}
Expand Down
9 changes: 9 additions & 0 deletions sample-livereload-hl.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-lib hscript:2.3.0
-main sample.LiveReloadSample
-cp .
-debug
-D interpretable
-D interpret_watch
-D interpret_mute_import_warnings

-hl bin/run.hl

0 comments on commit c10ea6c

Please sign in to comment.