Skip to content

Fix void operator and property statement #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions Project/Assets/Plugins/Jint/ExecutionVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using Jint.Expressions;
Expand Down Expand Up @@ -343,15 +343,15 @@ public void Visit(ExpressionStatement statement) {

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

if (statement.InitialisationStatement is VariableDeclarationStatement) {
globalDeclaration = ((VariableDeclarationStatement)statement.InitialisationStatement).Global;
//globalDeclaration = ((VariableDeclarationStatement)statement.InitialisationStatement).Global;
identifier = ((VariableDeclarationStatement)statement.InitialisationStatement).Identifier;
}
else if (statement.InitialisationStatement is Identifier) {
globalDeclaration = true;
//globalDeclaration = true;
identifier = ((Identifier)statement.InitialisationStatement).Text;
}
else {
Expand Down Expand Up @@ -542,6 +542,7 @@ public void Visit(ThrowStatement statement) {
statement.Expression.Accept(this);
}

UnityEngine.Debug.LogError(Result.Value.ToString());
throw new JsException(Result);
}

Expand Down Expand Up @@ -1131,7 +1132,7 @@ public void Visit(UnaryExpression expression) {

case UnaryExpressionType.Void:

expression.Accept(this);
expression.Expression.Accept(this);
Result = JsUndefined.Instance;
break;

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

string propertyName = lastIdentifier = expression.Text;

JsInstance result = null;
if (CurrentScope.TryGetProperty(propertyName, out result)) {
Result = result;
if (Result != null)
return;
}

if (propertyName == "null") {
if (propertyName == "null")
{
Result = JsNull.Instance;
return;
}

if (propertyName == "undefined") {
if (propertyName == "undefined")
{
Result = JsUndefined.Instance;
return;
}

// Try to record full path in case it's a type
if (Result == null) {
typeFullname.Append(propertyName);
}
JsInstance result = null;
CurrentScope.TryGetProperty(propertyName, out result);
Result = result;

return;
}

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

// Process parameters
JsInstance[] parameters = new JsInstance[expression.Parameters.Count];
//JsInstance[] parameters = new JsInstance[expression.Parameters.Count];

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