Skip to content

Commit

Permalink
Use hscript to manage ?.
Browse files Browse the repository at this point in the history
include revert of eb4605a
  • Loading branch information
yuxiaomao committed May 31, 2024
1 parent eb4605a commit 911b0e0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install haxelib dependencies
run: |
haxelib git format https://github.com/HaxeFoundation/format.git
haxelib install hscript
haxelib git hscript https://github.com/HaxeFoundation/hscript.git
haxelib install vshaxe
haxelib install vscode
haxelib install vscode-debugadapter
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Additionally, you need to install these dependencies:
haxelib install vshaxe
haxelib install vscode
haxelib install vscode-debugadapter
haxelib install hscript
haxelib install format
haxelib git hscript https://github.com/HaxeFoundation/hscript.git
haxelib git format https://github.com/HaxeFoundation/format.git
```

You will need [NodeJS](https://nodejs.org/en/download), if you would like to compile vscode extension or use commandline nodejs version.
Expand Down
14 changes: 12 additions & 2 deletions hld/Eval.hx
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,18 @@ class Eval {
}
case EBlock(el):
var v : Value = { v : VNull, t : HDyn };
for( e in el )
v = evalExpr(e);
switch(el) {
case [EVar(id,_,e), ETernary(EBinop("==",EIdent(id2),EIdent("null")), EIdent("null"), EField(EIdent(id3),f))] if ( id == id2 && id == id3 ):
// Special case for e?.field
var ve : Value = evalExpr(e);
if( compare(ve, v) != 0 ) {
v = readField(ve, f);
if( v == null ) throw valueStr(ve)+" has no field "+f;
}
default:
for( e in el )
v = evalExpr(e);
}
return v;
case EField(e, f):
var e = e;
Expand Down
2 changes: 0 additions & 2 deletions src/HLAdapter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,6 @@ class HLAdapter extends DebugSession {
// ?ident => hover on optional param (most likely)
if( ~/^\?[A-Za-z0-9_]+$/.match(args.expression) )
args.expression = args.expression.substr(1);
// ?. => likely null safe field access, replace to .
args.expression = StringTools.replace(args.expression, "?.", ".");
if( KEYWORDS.exists(args.expression) ) {
// Do nothing
} else {
Expand Down

0 comments on commit 911b0e0

Please sign in to comment.