Skip to content

Commit 546fea5

Browse files
authored
Merge pull request #4 from vandermond/patch-3
Fix void operator and property statement
2 parents 0168365 + 2394023 commit 546fea5

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

Project/Assets/Plugins/Jint/ExecutionVisitor.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Text;
44
using Jint.Expressions;
@@ -343,15 +343,15 @@ public void Visit(ExpressionStatement statement) {
343343

344344
public void Visit(ForEachInStatement statement) {
345345
// todo: may be declare own property in the current scope if not a globalDeclaration?
346-
bool globalDeclaration = true;
347-
string identifier = String.Empty;
346+
//bool globalDeclaration = true;
347+
var identifier = string.Empty;
348348

349349
if (statement.InitialisationStatement is VariableDeclarationStatement) {
350-
globalDeclaration = ((VariableDeclarationStatement)statement.InitialisationStatement).Global;
350+
//globalDeclaration = ((VariableDeclarationStatement)statement.InitialisationStatement).Global;
351351
identifier = ((VariableDeclarationStatement)statement.InitialisationStatement).Identifier;
352352
}
353353
else if (statement.InitialisationStatement is Identifier) {
354-
globalDeclaration = true;
354+
//globalDeclaration = true;
355355
identifier = ((Identifier)statement.InitialisationStatement).Text;
356356
}
357357
else {
@@ -542,6 +542,7 @@ public void Visit(ThrowStatement statement) {
542542
statement.Expression.Accept(this);
543543
}
544544

545+
UnityEngine.Debug.LogError(Result.Value.ToString());
545546
throw new JsException(Result);
546547
}
547548

@@ -1131,7 +1132,7 @@ public void Visit(UnaryExpression expression) {
11311132

11321133
case UnaryExpressionType.Void:
11331134

1134-
expression.Accept(this);
1135+
expression.Expression.Accept(this);
11351136
Result = JsUndefined.Instance;
11361137
break;
11371138

@@ -1449,25 +1450,23 @@ public void Visit(Identifier expression) {
14491450

14501451
string propertyName = lastIdentifier = expression.Text;
14511452

1452-
JsInstance result = null;
1453-
if (CurrentScope.TryGetProperty(propertyName, out result)) {
1454-
Result = result;
1455-
if (Result != null)
1456-
return;
1457-
}
1458-
1459-
if (propertyName == "null") {
1453+
if (propertyName == "null")
1454+
{
14601455
Result = JsNull.Instance;
1456+
return;
14611457
}
14621458

1463-
if (propertyName == "undefined") {
1459+
if (propertyName == "undefined")
1460+
{
14641461
Result = JsUndefined.Instance;
1462+
return;
14651463
}
14661464

1467-
// Try to record full path in case it's a type
1468-
if (Result == null) {
1469-
typeFullname.Append(propertyName);
1470-
}
1465+
JsInstance result = null;
1466+
CurrentScope.TryGetProperty(propertyName, out result);
1467+
Result = result;
1468+
1469+
return;
14711470
}
14721471

14731472
private void EnsureClrAllowed() {
@@ -1507,7 +1506,7 @@ public void Visit(ArrayDeclaration expression) {
15071506
var array = Global.ArrayClass.New();
15081507

15091508
// Process parameters
1510-
JsInstance[] parameters = new JsInstance[expression.Parameters.Count];
1509+
//JsInstance[] parameters = new JsInstance[expression.Parameters.Count];
15111510

15121511
for (int i = 0; i < expression.Parameters.Count; i++) {
15131512
expression.Parameters[i].Accept(this);

0 commit comments

Comments
 (0)