Browse files

Remove support for Has/Get/SetProperty, Add/RemoveHandler

Move Has/Get/SetField, InvokeMethod, GetScriptType, and CreateInstance to Script type
  • Loading branch information...
1 parent dcb3326 commit 9b5ae70fc29c1aaa8b1caf18d7d24cd35b7e1ac8 @nikhilk committed Aug 26, 2012
View
22 src/Core/Compiler/Compiler/ExpressionBuilder.cs
@@ -1148,7 +1148,7 @@ MethodExpression methodExpression
else {
bool lateBound = false;
- if (method.Parent == typeType) {
+ if (method.Parent == scriptType) {
LateBoundOperation lateBoundOperation = LateBoundOperation.InvokeMethod;
if (method.Name.Equals("InvokeMethod", StringComparison.Ordinal)) {
@@ -1166,22 +1166,6 @@ MethodExpression methodExpression
lateBound = true;
lateBoundOperation = LateBoundOperation.SetField;
}
- else if (method.Name.Equals("GetProperty", StringComparison.Ordinal)) {
- lateBound = true;
- lateBoundOperation = LateBoundOperation.GetProperty;
- }
- else if (method.Name.Equals("SetProperty", StringComparison.Ordinal)) {
- lateBound = true;
- lateBoundOperation = LateBoundOperation.SetProperty;
- }
- else if (method.Name.Equals("AddHandler", StringComparison.Ordinal)) {
- lateBound = true;
- lateBoundOperation = LateBoundOperation.AddHandler;
- }
- else if (method.Name.Equals("RemoveHandler", StringComparison.Ordinal)) {
- lateBound = true;
- lateBoundOperation = LateBoundOperation.RemoveHandler;
- }
else if (method.Name.Equals("GetScriptType", StringComparison.Ordinal)) {
lateBound = true;
lateBoundOperation = LateBoundOperation.GetScriptType;
@@ -1194,10 +1178,6 @@ MethodExpression methodExpression
lateBound = true;
lateBoundOperation = LateBoundOperation.HasMethod;
}
- else if (method.Name.Equals("HasProperty", StringComparison.Ordinal)) {
- lateBound = true;
- lateBoundOperation = LateBoundOperation.HasProperty;
- }
else if (method.Name.Equals("CreateInstance", StringComparison.Ordinal)) {
Debug.Assert(args.Count >= 1);
View
82 src/Core/Compiler/Generator/ExpressionGenerator.cs
@@ -537,8 +537,7 @@ internal static class ExpressionGenerator {
if (expression.Operation == LateBoundOperation.GetScriptType) {
writer.Write("typeof(");
}
- else if ((expression.Operation == LateBoundOperation.HasMethod) ||
- (expression.Operation == LateBoundOperation.HasProperty)) {
+ else if (expression.Operation == LateBoundOperation.HasMethod) {
writer.Write("(typeof(");
}
else if (expression.Operation == LateBoundOperation.HasField) {
@@ -608,68 +607,6 @@ internal static class ExpressionGenerator {
writer.Write("]");
}
break;
- case LateBoundOperation.GetProperty:
- if (Utility.IsValidIdentifier(name)) {
- writer.Write(".get_");
- writer.Write(name);
- }
- else {
- writer.Write("['get_'");
- writer.WriteTrimmed(" + ");
- GenerateExpression(generator, symbol, expression.NameExpression);
- writer.Write("]");
- }
-
- writer.Write("()");
- break;
- case LateBoundOperation.SetProperty:
- if (Utility.IsValidIdentifier(name)) {
- writer.Write(".set_");
- writer.Write(name);
- }
- else {
- writer.Write("['set_'");
- writer.WriteTrimmed(" + ");
- GenerateExpression(generator, symbol, expression.NameExpression);
- writer.Write("]");
- }
-
- writer.Write("(");
- GenerateExpressionList(generator, symbol, expression.Parameters);
- writer.Write(")");
- break;
- case LateBoundOperation.AddHandler:
- if (Utility.IsValidIdentifier(name)) {
- writer.Write(".add_");
- writer.Write(name);
- }
- else {
- writer.Write("['add_'");
- writer.WriteTrimmed(" + ");
- GenerateExpression(generator, symbol, expression.NameExpression);
- writer.Write("]");
- }
-
- writer.Write("(");
- GenerateExpressionList(generator, symbol, expression.Parameters);
- writer.Write(")");
- break;
- case LateBoundOperation.RemoveHandler:
- if (Utility.IsValidIdentifier(name)) {
- writer.Write(".remove_");
- writer.Write(name);
- }
- else {
- writer.Write("['remove_'");
- writer.WriteTrimmed(" + ");
- GenerateExpression(generator, symbol, expression.NameExpression);
- writer.Write("]");
- }
-
- writer.Write("(");
- GenerateExpressionList(generator, symbol, expression.Parameters);
- writer.Write(")");
- break;
case LateBoundOperation.GetScriptType:
writer.Write(")");
break;
@@ -694,23 +631,6 @@ internal static class ExpressionGenerator {
writer.Write("'function'");
writer.Write(")");
break;
- case LateBoundOperation.HasProperty:
- if (Utility.IsValidIdentifier(name)) {
- writer.Write(".get_");
- writer.Write(name);
- }
- else {
- writer.Write("['get_'");
- writer.WriteTrimmed(" + ");
- GenerateExpression(generator, symbol, expression.NameExpression);
- writer.Write("]");
- }
-
- writer.Write(")");
- writer.WriteTrimmed(" === ");
- writer.Write("'function'");
- writer.Write(")");
- break;
}
}
View
16 src/Core/Compiler/ScriptModel/Expressions/LateBoundOperation.cs
@@ -17,20 +17,10 @@ internal enum LateBoundOperation {
DeleteField = 3,
- GetProperty = 4,
+ HasField = 4,
- SetProperty = 5,
+ HasMethod = 5,
- AddHandler = 6,
-
- RemoveHandler = 7,
-
- GetScriptType = 8,
-
- HasField = 9,
-
- HasMethod = 10,
-
- HasProperty = 11
+ GetScriptType = 6,
}
}

0 comments on commit 9b5ae70

Please sign in to comment.