http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/AS3DebuggerRules.jbg ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/AS3DebuggerRules.jbg b/debugger/src/flash/tools/debugger/expression/AS3DebuggerRules.jbg deleted file mode 100644 index 9664a03..0000000 --- a/debugger/src/flash/tools/debugger/expression/AS3DebuggerRules.jbg +++ /dev/null @@ -1,746 +0,0 @@ -/* - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -Pattern foldedExpressionPattern -FoldedExpressionID(void); - -foldedExpression = Pattern foldedExpressionPattern: 1 -JBurg.Reduction reducer.reduceLazyExpression(__p); - -Pattern logicalAndExprLazy -Op_LogicalAndID(expression l, foldedExpression r); - -Pattern logicalOrExprLazy -Op_LogicalOrID(expression l, foldedExpression r); - -/* - * AS3DebuggerRules.jbg holds the rewrite rules for debugger support. - * @see compiler/CmcPatterns.jbg, which holds the corresponding patterns. - */ - -/* - * Assignment to a simple name. - */ -expression = Pattern assignToNameExpr: 2 -JBurg.Reduction reducer.reduce_assignToNameExpr_to_expression(__p, lval,r); - -/* - * Assignment to a more general lvalue. - */ -expression = Pattern assignToMemberExpr : 10 -JBurg.Reduction reducer.reduce_assignToMemberExpr_to_expression(__p, stem, member, r); - -/* - * Assignment to a[i] type lvalue. - */ -expression = Pattern assignToBracketExpr: 1 -JBurg.Reduction reducer.reduce_assignToBracketExpr_to_expression(__p, stem, index, r, false); - -expression = Pattern assignToSuperBracketExpr: 1 -JBurg.Reduction reducer.reduce_assignToBracketExpr_to_expression(__p, null, index, r, true); - -/* - * Assignment to qualified names and attributes. - */ -expression = Pattern assignToQualifiedMemberExpr : 1 -JBurg.Reduction reducer.reduce_assignToQualifiedMemberExpr(__p, stem, qualifier, member, r, NEED_VALUE); - -expression = Pattern assignToQualifiedRuntimeMemberExpr : 1 -JBurg.Reduction reducer.reduce_assignToQualifiedRuntimeMemberExpr(__p, stem, qualifier, member, r, NEED_VALUE); - -expression = Pattern assignToQualifiedAttributeExpr : 1 -JBurg.Reduction reducer.reduce_assignToQualifiedAttributeExpr(__p, stem, qualifier, attribute, r, NEED_VALUE); - -expression = Pattern assignToUnqualifiedRuntimeAttributeExpr : 1 -JBurg.Reduction reducer.reduce_assignToUnqualifiedRuntimeAttributeExpr(__p, stem, rt_attr_name, r, NEED_VALUE); - -expression = Pattern assignToUnqualifiedRuntimeDescendantsAttributeExpr : 1 -JBurg.Reduction reducer.reduce_assignToUnqualifiedRuntimeAttributeExpr(__p, stem, rt_attr_name, r, NEED_VALUE); - -/* - * Assignment to descendants. - */ -expression = Pattern assignToDescendantsExpr : 1 -JBurg.Reduction reducer.reduce_assignToDescendantsExpr(__p, stem, member, r, NEED_VALUE); - -/* - * Error trap for diagnosing parser/CG mismatches. - * The cost is unfeasibly high for a normal reduction, - * so this will only be chosen if no other reduction works. - */ -expression = Op_AssignId(expression non_lvalue, expression rvalue ) : ERROR_TRAP -JBurg.Reduction reducer.error_reduce_Op_AssignId(__p, non_lvalue, rvalue); - -/* - * Miscellaneous void expressions. - */ -expression = Pattern nilExpr : 1 -JBurg.Reduction reducer.reduce_nilExpr_to_expression(__p); - -/* - * Binary logical operators. - */ -comparison_expression = Pattern equalExpr : 1 -JBurg.Reduction reducer.binaryOp (__p, l, r, OP_equals); - -comparison_expression = Pattern neqExpr : 1 -JBurg.Reduction reducer.reduce_neqExpr (__p, l, r); - -comparison_expression = Pattern stricteqExpr : 1 -JBurg.Reduction reducer.binaryOp (__p, l, r, OP_strictequals); - -comparison_expression = Pattern strictneqExpr : 1 -JBurg.Reduction reducer.reduce_strictneqExpr (__p, l, r); - -comparison_expression = Pattern greaterThanExpr: 1 -JBurg.Reduction reducer.binaryOp (__p, l, r, OP_greaterthan); - -comparison_expression = Pattern greaterThanEqExpr: 1 -JBurg.Reduction reducer.binaryOp (__p, l, r, OP_greaterequals); - -comparison_expression = Pattern lessExpr : 1 -JBurg.Reduction reducer.binaryOp (__p, l, r, OP_lessthan); - -comparison_expression = Pattern lessEqExpr : 1 -JBurg.Reduction reducer.binaryOp (__p, l, r, OP_lessequals); - -// Closure rule: any comparison_expression -// is also an expression without further conversion. -expression = comparison_expression; - -expression = Pattern logicalAndExprLazy : 5 -JBurg.Reduction reducer.reduce_logicalAndExpr (__p, l, r); - -expression = Pattern logicalOrExprLazy : 5 -JBurg.Reduction reducer.reduce_logicalOrExpr (__p, l, r); - -expression = Pattern logicalNotExpr : 1 -JBurg.Reduction reducer.reduce_logicalNotExpr (__p, expr); - -expression = Pattern ternaryExpr : 1 -JBurg.Reduction reducer.reduce_ternaryExpr (__p, test, when_true, when_false); - -/* - * Binary arithmetic operators. - */ - -expression = Pattern divideExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_divide); - -expression = Pattern multExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_multiply); - -expression = Pattern moduloExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_modulo); - -expression = Pattern addExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_add); - -expression = Pattern subtractExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_subtract); - -expression = Pattern bitwiseLeftShiftExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_lshift); - -expression = Pattern bitwiseRightShiftExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_rshift); - -expression = Pattern bitwiseUnsignedRightShiftExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_urshift); - -expression = Pattern bitwiseAndExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_bitand); - -expression = Pattern bitwiseOrExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_bitor); - -expression = Pattern bitwiseXorExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, l, r, OP_bitxor); - -/* - * pre/postfix unary operators. - */ - -expression = Pattern postIncNameExpr : 7 -JBurg.Reduction reducer.reduce_postIncNameExpr(__p, unary, true); - -expression = Pattern preIncNameExpr : 7 -JBurg.Reduction reducer.reduce_preIncNameExpr(__p, unary, true); - -expression = Pattern preIncMemberExpr : 8 -JBurg.Reduction reducer.reduce_preIncMemberExpr(__p, stem, field, true); - -expression = Pattern postIncMemberExpr: 8 -JBurg.Reduction reducer.reduce_postIncMemberExpr(__p, stem, field, true); - -expression = Pattern preIncBracketExpr: 8 -JBurg.Reduction reducer.reduce_preIncBracketExpr(__p, stem, index, true); - -expression = Pattern postIncBracketExpr: 8 -JBurg.Reduction reducer.reduce_postIncBracketExpr(__p, stem, index, true); - -expression = Pattern postDecNameExpr : 7 -JBurg.Reduction reducer.reduce_postDecNameExpr(__p, unary, true); - -expression = Pattern preDecNameExpr : 7 -JBurg.Reduction reducer.reduce_preDecNameExpr(__p, unary, true); - -expression = Pattern preDecMemberExpr : 8 -JBurg.Reduction reducer.reduce_preDecMemberExpr(__p, stem, field, true); - -expression = Pattern postDecMemberExpr: 8 -JBurg.Reduction reducer.reduce_postDecMemberExpr(__p, stem, field, true); - -expression = Pattern preDecBracketExpr: 8 -JBurg.Reduction reducer.reduce_preDecBracketExpr(__p, stem, index, true); - -expression = Pattern postDecBracketExpr: 8 -JBurg.Reduction reducer.reduce_postDecBracketExpr(__p, stem, index, true); - -/* - * Unary expressions. - */ -expression = Pattern unaryMinusExpr: 1 -JBurg.Reduction reducer.unaryOp(__p, e, OP_negate); - -expression = Pattern unaryPlusExpr: 0 -{ - return reducer.unaryOp(__p, e, OP_convert_d); -} - -expression = Pattern typeofExpr: 10 -JBurg.Reduction reducer.reduce_typeof_expr(__p, expr); - -expression = Pattern typeofName: 1 -JBurg.Reduction reducer.reduce_typeof_name(__p, n); - -expression = Pattern bitNotExpr: 1 -JBurg.Reduction reducer.unaryOp(__p, unary, OP_bitnot); - -/* - * Miscellaneous binary expressions. - */ -expression = Pattern istypeExprLate : 1 -JBurg.Reduction reducer.binaryOp(__p, expr, typename, OP_istypelate); - -expression = Pattern astypeExprLate : 1 -JBurg.Reduction reducer.binaryOp(__p, expr, typename, OP_astypelate); - -expression = Pattern inExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, needle, haystack, OP_in); - -expression = Pattern instanceofExpr : 1 -JBurg.Reduction reducer.binaryOp(__p, expr, typename, OP_instanceof); - -// lhs += rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_add" \ - compoundAssignToName="assignPlusToNameExpr" \ - compoundAssignToMember="assignPlusToMemberExpr" \ - compoundAssignToBracket="assignPlusToBracketExpr" - -// lhs *= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_multiply" \ - compoundAssignToName="assignMultiplyToNameExpr" \ - compoundAssignToMember="assignMultiplyToMemberExpr" \ - compoundAssignToBracket="assignMultiplyToBracketExpr" - -// lhs -= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_subtract" \ - compoundAssignToName="assignMinusToNameExpr" \ - compoundAssignToMember="assignMinusToMemberExpr" \ - compoundAssignToBracket="assignMinusToBracketExpr" - -// lhs /= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_divide" \ - compoundAssignToName="assignDivideToNameExpr" \ - compoundAssignToMember="assignDivideToMemberExpr" \ - compoundAssignToBracket="assignDivideToBracketExpr" - -// lhs %= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_modulo" \ - compoundAssignToName="assignModuloToNameExpr" \ - compoundAssignToMember="assignModuloToMemberExpr" \ - compoundAssignToBracket="assignModuloToBracketExpr" - -// lhs <<= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_lshift" \ - compoundAssignToName="assignLeftShiftToNameExpr" \ - compoundAssignToMember="assignLeftShiftToMemberExpr" \ - compoundAssignToBracket="assignLeftShiftToBracketExpr" - -// lhs <<= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_rshift" \ - compoundAssignToName="assignRightShiftToNameExpr" \ - compoundAssignToMember="assignRightShiftToMemberExpr" \ - compoundAssignToBracket="assignRightShiftToBracketExpr" - -// lhs >>>= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_urshift" \ - compoundAssignToName="assignUnsignedRightShiftToNameExpr" \ - compoundAssignToMember="assignUnsignedRightShiftToMemberExpr" \ - compoundAssignToBracket="assignUnsignedRightShiftToBracketExpr" - -// lhs &= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_bitand" \ - compoundAssignToName="assignBitwiseAndToNameExpr" \ - compoundAssignToMember="assignBitwiseAndToMemberExpr" \ - compoundAssignToBracket="assignBitwiseAndToBracketExpr" - -// lhs |= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_bitor" \ - compoundAssignToName="assignBitwiseOrToNameExpr" \ - compoundAssignToMember="assignBitwiseOrToMemberExpr" \ - compoundAssignToBracket="assignBitwiseOrToBracketExpr" - -// lhs ^= rhs -JBurg.include "AS3DebuggerCompoundAssignmentRules.jbg" \ - Op_COMPOUND_ASSIGN="OP_bitxor" \ - compoundAssignToName="assignBitwiseXorToNameExpr" \ - compoundAssignToMember="assignBitwiseXorToMemberExpr" \ - compoundAssignToBracket="assignBitwiseXorToBracketExpr" - -/* - * Primary expressions. - */ -expression = Pattern memberAccessExpr : 10 -JBurg.Reduction reducer.reduce_memberAccessExpr (__p, stem, member, OP_getproperty); - -expression = Pattern qualifiedMemberAccessExpr : 10 -JBurg.Reduction reducer.reduce_qualifiedMemberAccessExpr(__p, stem, qualifier, member, OP_getproperty); - -expression = Pattern qualifiedDescendantsExpr : 10 -JBurg.Reduction reducer.reduce_qualifiedMemberAccessExpr(__p, stem, qualifier, member, OP_getdescendants); - -expression = Pattern qualifiedDescendantsRuntimeExpr : 1 -JBurg.Reduction reducer.reduce_qualifiedAttributeRuntimeMemberExpr(__p, stem, qualifier, runtime_member, OP_getdescendants); - -expression = Pattern qualifiedAttributeExpr : 1 -JBurg.Reduction reducer.reduce_qualifiedAttributeExpr(__p, stem, qualifier, member, OP_getproperty); - -expression = Pattern qualifiedDescendantsAttributeExpr : 1 -JBurg.Reduction reducer.reduce_qualifiedAttributeExpr(__p, stem, qualifier, member, OP_getdescendants); - -expression = Pattern qualifiedAttributeRuntimeMemberExpr : 1 -JBurg.Reduction reducer.reduce_qualifiedAttributeRuntimeMemberExpr(__p, stem, qualifier, runtime_member, OP_getproperty); - -expression = Pattern qualifiedDescendantsRuntimeMemberExpr : 1 -JBurg.Reduction reducer.reduce_qualifiedAttributeRuntimeMemberExpr(__p, stem, qualifier, runtime_member, OP_getdescendants); - -// Prefer the basic memberAccessExpr pattern where feasible. -expression = Pattern qualifiedMemberRuntimeNameExpr : 100 -JBurg.Reduction reducer.reduce_qualifiedMemberRuntimeNameExpr(__p, stem, qualifier, runtime_member); - -expression = Pattern unqualifiedAttributeExpr : 1 -JBurg.Reduction reducer.reduce_unqualifiedAttributeExpr(__p, stem, expr, OP_getproperty); - -expression = Pattern unqualifiedDescendantsAttributeExpr : 1 -JBurg.Reduction reducer.reduce_unqualifiedAttributeExpr(__p, stem, expr, OP_getdescendants); - -expression = Pattern runtimeAttributeExp : 1 -JBurg.Reduction reducer.reduce_runtimeAttributeExp(__p, expr); - -expression = Pattern arrayIndexExpr : 1 -JBurg.Reduction reducer.reduce_arrayIndexExpr (__p, stem, false, index); - -expression = Pattern superIndexExpr : 1 -JBurg.Reduction reducer.reduce_arrayIndexExpr (__p, null, true, index); - -expression = Pattern functionCallExpr : 3 // Cost artificially inflated -JBurg.Reduction reducer.reduce_functionCallExpr_to_expression (__p, method_name, args); - -expression = Pattern functionCallSpecial : 1 // We want this to win over other function calls to simple names -JBurg.Reduction reducer.reduce_functionCallSpecial_to_expression (__p, specialName, args); - -expression = Pattern newVectorLiteral: 0 -JBurg.Reduction reducer.reduce_newVectorLiteral(__p, literal); - -// 'new Whatever(...)' has cost 2, so it gets beaten by the two previous rules. -// Use this reduction if the type is known; -// it allows much better error checking of the constructor call. -expression = Pattern newExpr : 2 -JBurg.Reduction reducer.reduce_newExpr (__p, class_binding, args); - -expression = Pattern newMemberProperty: 10 -JBurg.Reduction reducer.reduce_newMemberProperty(__p, stem, member, args); - -expression = Pattern newAsRandomExpr : 30 -JBurg.Reduction reducer.reduce_newAsRandomExpr (__p, random_expr, args); - -expression = Pattern functionCallOfSuperclassMethod : 2 -JBurg.Reduction reducer.reduce_functionCallOfSuperclassMethod_to_expression (__p, null, method_name, args); - -expression = Pattern functionCallOfExplicitObjectSuperclassMethod : 2 -JBurg.Reduction reducer.reduce_functionCallOfSuperclassMethod_to_expression (__p, stem, method_name, args); - -expression = Pattern functionAsMemberExpr : 4 // Cost inflated to prefer functionCallOfSuperclassMethod -JBurg.Reduction reducer.reduce_functionAsMemberExpr (__p, stem, method_name, args); - -expression = Pattern functionAsBracketExpr : 4 -JBurg.Reduction reducer.reduce_functionAsBracketExpr (__p, stem, index, args); - -expression = Pattern functionAsRandomExpr : 30 -JBurg.Reduction reducer.reduce_functionAsRandomExpr (__p, random_expr, args); - -/* - * Delete expressions. - */ -expression = Pattern deleteNameExpr: 2 -JBurg.Reduction reducer.reduce_deleteNameExpr(__p, n); - -expression = Pattern deleteBracketExpr: 1 -JBurg.Reduction reducer.reduce_deleteBracketExpr(__p, stem, index); - -expression = Pattern deleteAtBracketExpr: 1 -JBurg.Reduction reducer.reduce_deleteAtBracketExpr(__p, stem, index); - -expression = Pattern deleteMemberExpr: 1 -JBurg.Reduction reducer.reduce_deleteMemberExpr(__p, stem, field); - -expression = Pattern deleteRuntimeNameExpr: 1 -JBurg.Reduction reducer.reduce_deleteRuntimeNameExpr(__p, stem, rt_name); - -expression = Pattern deleteDescendantsExpr: 1 -JBurg.Reduction reducer.reduce_deleteDescendantsExpr(__p, stem, field); - -expression = Pattern deleteAnyExprExprExpr: 2000 -JBurg.Reduction reducer.reduce_deleteExprExprExpr(__p, expr); - -/* - * Comma expression. - */ -expression = Pattern commaExpr: 0 -JBurg.Reduction reducer.reduce_commaExpr(__p, payload_expr, exprs); - -/* - * Names and reference expressions built from names. - */ -name = Pattern simpleName : 0 -JBurg.Reduction reducer.reduce_simpleName (__p); - -qualifiedNamePart = Pattern simpleName: 0 -JBurg.Reduction reducer.getIdentifierContent(__p); - -name = Pattern typedVariableExpression : 0 -JBurg.Reduction reducer.reduce_typedVariableExpression (__p, var_name, var_type); - -dottedNamePart = Pattern dottedName : 0 -JBurg.Reduction reducer.reduce_by_concatenation (__p, first, second); - -dottedNamePart = qualifiedNamePart; - -name = Pattern dottedName : isDottedName() -JBurg.Reduction reducer.dottedName (__p, first, second); - -name = Pattern dottedName : isPackageName() -JBurg.Reduction reducer.errorPackageName(__p, first, second); - -// This reduction handles an entire dotted name subtree. -name = Pattern fullName : 0 -JBurg.Reduction reducer.dottedName(__p, first, second); - -// qualified namespace is the same as a full name, -// it's just what gets produced when we're in a use namespace directive -// use namespace a.b.Foo; -name = Pattern qualifiedNamespaceName : 0 -JBurg.Reduction reducer.dottedName(__p, first, second); - -// This reduction handles the bar.T part of foo.bar.T -dottedNamePart = Pattern fullName : 0 -JBurg.Reduction reducer.reduce_by_concatenation (__p, first, second); - -name = Pattern superAccess : 0 -JBurg.Reduction reducer.reduce_superAccess (__p, qualified_name); - -// A bare parameterized type name can only be -// used as a type annotation. In code it's necessary -// to expand it into an expression that calls applytype. -// Note: this reduction gets an error-trapping cost if -// the parameter type is not constant; this forces -// expression-oriented reductions to try and reduce -// the type parameter as an expression. -type_name = Pattern parameterizedName : parameterTypeIsConstant() -JBurg.Reduction reducer.reduce_parameterizedTypeName (__p, base, param); - -// A name can be a type_name, which in combination with -// the reduction above yields the set of possible type_names: -// identifiers and * -type_name = name : 1 -JBurg.Reduction reducer.reduce_nameToTypeName(name, true); - -// The 'new' expression takes a pseduo-type name: -// when it can be resolved, the semantic analysis -// code can check the constructor. When it can't -// be resolved, it's a generalized expression. -new_type_name = name; - -// Inflate this cost so it's only selected -// if the type_name isn't a name. -new_type_name = type_name : 20 -JBurg.Reduction reducer.reduce_nameToTypeName(type_name, false); - -// The parameter of a parameterized type expression may be an expression -// or a type name; if it resolves to a type, it's a type name. -type_param_expression = name: isKnownType() -JBurg.Reduction reducer.reduce_typeNameParameterAsType(__p, name); - -// any expression can be used as a type param name in an expression context. -type_param_expression = expression; - -expression = Pattern parameterizedTypeExpression : 1 -JBurg.Reduction reducer.reduce_parameterizedTypeExpression (__p, base, param); - -expression = name: 2000 -JBurg.Reduction reducer.transform_name_to_expression(__p, name); - -type_name = Pattern voidExpr : 0 -JBurg.Reduction reducer.reduce_voidExpr_to_type_name(__p); - -name = Pattern attributeName : 0 -JBurg.Reduction reducer.reduce_attributeName (__p, attr_name); - -// ns1::foo and rt_ns::foo look alike to -// the parser, so they must be disambiguated -// by checking their semantic annotations. -name = Pattern namespaceAccess : qualifierIsCompileTimeConstant() -JBurg.Reduction reducer.reduce_namespaceAccess (__p, qualifier, qualified_name); - -// Error trap for an unresolved namespace in a context -// where it must be declared. -name = Pattern namespaceAccess: ERROR_TRAP -JBurg.Reduction reducer.error_namespaceAccess(__p, qualifier, qualified_name); - -// A namespace-qualified name reference whose name -// is a runtime expression, e.g., ns1::[foo]. -// The parser doesn't know the difference between -// ns1::[foo] and rt_ns::[foo], so we need a cost -// function to disambiguate the tree. -runtime_name_expression = Pattern namespaceMultinameL: qualifierIsCompileTimeConstant() -JBurg.Reduction reducer.reduce_namespaceMultinameL(__p, qualifier, expr); - -runtime_name_expression = Pattern namespaceRTQName : 2000 -JBurg.Reduction reducer.reduce_namespaceRTQName (__p, qualifier, qualfied_name); - -expression = Pattern embedExpression : 2 -JBurg.Reduction reducer.reduce_embed(__p); - -/* - * E4X expressions (except literals) - */ - -expression = Pattern e4xFilter : 3 -JBurg.Reduction reducer.reduce_e4xFilter (__p, stem, filter); - -runtime_name_expression = Pattern namespaceRTQNameL : 2000 -JBurg.Reduction reducer.reduce_namespaceRTQNameL (__p, qualifier, expr); - -expression = runtime_name_expression : 1 -JBurg.Reduction reducer.transform_runtime_name_expression(__p, runtime_name_expression); - -expression = Pattern runtimeNameExpression: 1 -JBurg.Reduction reducer.reduce_runtimeNameExpression(__p, expr); - -name = Pattern namespaceAsName: 1 -JBurg.Reduction reducer.reduce_namespaceAsName_to_name(__p); - -expression = Pattern namespaceAsName: 1 -JBurg.Reduction reducer.reduce_namespaceAsName_to_expression(__p); - -void_expression = Pattern assignToRuntimeNameExpr: 1 -JBurg.Reduction reducer.reduce_assignToRuntimeNameExpr(__p, lval, r, DISCARD_VALUE); - -expression = Pattern assignToRuntimeNameExpr: 1 -JBurg.Reduction reducer.reduce_assignToRuntimeNameExpr(__p, lval, r, NEED_VALUE); - -expression = Pattern descendantsExpression : 1 -JBurg.Reduction reducer.reduce_memberAccessExpr(__p, stem, descendants, OP_getdescendants); - -/* - * Literals. - */ -e4x_literal = Pattern XMLLiteral : 0 -JBurg.Reduction reducer.getStringLiteralContent (__p); - -string_constant = e4x_literal; - -expression = Pattern XMLContent: 1 -JBurg.Reduction reducer.reduce_XMLContent(__p, exprs); - -expression = Pattern XMLList: 2 -JBurg.Reduction reducer.reduce_XMLList(__p, exprs); - -expression = Pattern XMLListConst: 1 -JBurg.Reduction reducer.reduce_XMLListConst(__p, elements); - -expression = literal; -literal = object_literal; -literal = boolean_literal; -literal = array_literal; - -expression = string_constant : 1 -JBurg.Reduction reducer.transform_string_constant(__p, string_constant); - -integer_constant = Pattern numericLiteral: isIntLiteral() -JBurg.Reduction reducer.getIntegerContent(__p); - -expression = integer_constant : 1 -JBurg.Reduction reducer.transform_integer_constant(__p, integer_constant); - -uint_constant = Pattern numericLiteral: isIntLiteral() -JBurg.Reduction reducer.getUintContent(__p); - -expression = uint_constant : 1 -JBurg.Reduction reducer.transform_uint_constant(__p, uint_constant); - -expression = boolean_constant : 1 -JBurg.Reduction reducer.transform_boolean_constant(__p, boolean_constant); - - -/** - * Constant values - */ -// Error trap for non-constant expressions -// used in a context where only a constant is valid, -// e.g., foo() in function needsConstantInit(x = foo()). -required_constant_value = expression : ERROR_TRAP -JBurg.Reduction reducer.transform_expression_to_constant_value(__p, expression); - -// A name can be used as a constant in some contexts, -// e.g., if it's a Namespace or otherwise known to be -// a compile-time constant. - -integer_constant = LiteralIntegerZeroID(void) : 1 -JBurg.Reduction reducer.getIntegerZeroContent(__p); - -integer_constant = LiteralIntegerID(void) : 1 -JBurg.Reduction reducer.getIntegerContent(__p); - -uint_constant = LiteralIntegerZeroID(void) : 1 -JBurg.Reduction reducer.getIntegerZeroContentAsLong(__p); - -float_constant = Pattern numericLiteral : isFloatLiteral() -JBurg.Reduction reducer.getFloatContent(__p); - -constant_value = Pattern nullLiteral : 0 -JBurg.Reduction reducer.reduce_nullLiteral_to_constant_value (__p); - -constant_value = Pattern void0Literal: 0 -JBurg.Reduction reducer.reduce_void0Literal_to_constant_value(__p); - -constant_value = Pattern voidConstant: 0 -JBurg.Reduction reducer.reduce_voidOperator_to_constant_value(__p, value); - -boolean_constant = Pattern booleanLiteral: 0 -JBurg.Reduction reducer.reduce_booleanLiteral(__p); - -string_constant = Pattern stringLiteral : 0 -JBurg.Reduction reducer.getStringLiteralContent (__p); - -numeric_constant = integer_constant; -numeric_constant = uint_constant; -numeric_constant = double_constant; -numeric_constant = float_constant; - - -constant_value = string_constant : 1 -JBurg.Reduction reducer.transform_string_constant_to_constant(__p, string_constant); - -constant_value = boolean_constant : 1 -JBurg.Reduction reducer.transform_boolean_constant_to_constant(__p, boolean_constant); - -constant_value = numeric_constant : 1 -JBurg.Reduction reducer.transform_numeric_constant_to_constant(__p, numeric_constant); - -required_constant_value = constant_value; - -double_constant = Pattern numericLiteral : isDoubleLiteral() -JBurg.Reduction reducer.getDoubleContent(__p); - -double_constant = Pattern doubleLiteral : isDoubleLiteral() -JBurg.Reduction reducer.getDoubleContent(__p); - -// Fallback code-gen choice if conversion to -// double failed in LiteralNumberNode.getNodeID(). -// It's not likely to work better here, -// but the BURM will emit some diagnostics. -double_constant = Pattern numericLiteral : 3 -JBurg.Reduction reducer.getDoubleContent(__p); - -expression = double_constant : 5 -JBurg.Reduction reducer.transform_double_constant(__p, double_constant); - -expression = integer_constant : 5 -JBurg.Reduction reducer.transform_integer_constant(__p, integer_constant); - -expression = numeric_constant : 5 -JBurg.Reduction reducer.transform_numeric_constant(__p, numeric_constant); - -expression = float_constant : 5 -JBurg.Reduction reducer.transform_float_constant(__p, float_constant); - -expression = constant_value : 0 -JBurg.Reduction reducer.transform_constant_value(__p, constant_value); - -object_literal = Pattern nullLiteral : 1 -JBurg.Reduction reducer.reduce_nullLiteral_to_object_literal (__p); - -object_literal = Pattern objectLiteral : 3 -JBurg.Reduction reducer.reduce_objectLiteral (__p, elements); - -object_literal_element = Pattern objectLiteralElement : 0 -JBurg.Reduction reducer.reduce_objectLiteralElement (__p, id, value); - -non_resolving_identifier = Pattern nonResolvingIdentifier : 0 -JBurg.Reduction reducer.getIdentifierContent(__p); - -expression = non_resolving_identifier : 1 -JBurg.Reduction reducer.transform_non_resolving_identifier(__p, non_resolving_identifier); - -object_literal = Pattern regexLiteral: 5 -JBurg.Reduction reducer.reduce_regexLiteral(__p); - -object_literal = Pattern void0Literal: 1 -JBurg.Reduction reducer.reduce_void0Literal_to_object_literal(__p); - -object_literal = Pattern void0Operator: 1 -JBurg.Reduction reducer.reduce_void0Operator(__p); - -expression = Pattern voidOperator : 1 -JBurg.Reduction reducer.reduce_voidOperator_to_expression (__p, expr); - -boolean_literal = boolean_constant: 1 -JBurg.Reduction reducer.transform_boolean_constant(__p, boolean_constant); - -array_literal = Pattern arrayLiteral : 1 -JBurg.Reduction reducer.reduce_arrayLiteral (__p, elements); - -vector_literal = Pattern vectorLiteral: 1 -JBurg.Reduction reducer.reduce_vectorLiteral(__p, type_param, elements); - -decl_name = Pattern simpleName : 0 -JBurg.Reduction reducer.reduce_declName(__p); -
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/ASTBuilder.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/ASTBuilder.java b/debugger/src/flash/tools/debugger/expression/ASTBuilder.java deleted file mode 100644 index a3950a1..0000000 --- a/debugger/src/flash/tools/debugger/expression/ASTBuilder.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import java.io.IOException; -import java.io.Reader; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.flex.compiler.problems.ICompilerProblem; -import org.apache.flex.compiler.tree.as.IASNode; - -import flash.localization.LocalizationManager; -import flash.tools.debugger.DebuggerLocalizer; - -/** - * ASTBuilder.java - * - * This class creates an abstract syntax tree representation - * of an expression given a sequence of tokens. - * - * The tree is built by calling the ActionScript compiler and - * having it parse the expression, then converting the result - * to a form we prefer. - * - * No compression is performed on the tree, thus expressions - * such as (3*4) will result in 3 nodes. - * - */ -public class ASTBuilder implements IASTBuilder -{ - private static LocalizationManager s_localizationManager; - - /** - * whether the fdb indirection operators are allowed, e.g. asterisk (*x) or - * trailing dot (x.) - */ - private boolean m_isIndirectionOperatorAllowed = true; - - static - { - // set up for localizing messages - s_localizationManager = new LocalizationManager(); - s_localizationManager.addLocalizer( new DebuggerLocalizer("flash.tools.debugger.expression.expression.") ); //$NON-NLS-1$ - } - - /** - * @param isIndirectionOperatorAllowed - * whether the fdb indirection operators are allowed, e.g. - * asterisk (*x) or trailing dot (x.) - */ - public ASTBuilder(boolean isIndirectionOperatorAllowed) - { - m_isIndirectionOperatorAllowed = isIndirectionOperatorAllowed; - } - - /** - * @return whether the fdb indirection operators are allowed, e.g. asterisk - * (*x) or trailing dot (x.) - */ - public boolean isIndirectionOperatorAllowed() - { - return m_isIndirectionOperatorAllowed; - } - - - /* - * @see flash.tools.debugger.expression.IASTBuilder#parse(java.io.Reader) - */ - public ValueExp parse(Reader in) throws IOException, ParseException - { - DebuggerExpression retval = new DebuggerExpression(); - - StringBuilder sb = new StringBuilder(); - int ch; - while ( (ch=in.read()) != -1 ) - sb.append((char)ch); - - String s = sb.toString(); - - // FB-16879: If expression begins with "#N" where N is a number, - // replace that with "$obj(N)". For example, "#3" would become - // "$obj(3)". Later, in PlayerSession.callFunction(), we will - // detect the $obj() function and handle it. - s = s.replaceFirst("^#([0-9]+)", "\\$obj($1)"); //$NON-NLS-1$ //$NON-NLS-2$ - - if (isIndirectionOperatorAllowed()) { - if (s.endsWith(".")) { //$NON-NLS-1$ - retval.setLookupMembers(true); - s = s.substring(0, s.length() - 1); - } else if (s.startsWith("*")) { //$NON-NLS-1$ - retval.setLookupMembers(true); - s = s.substring(1); - } - } - - // Enclose the expression in parentheses, in order to ensure that the - // parser considers it to be an expression. For example, "{x:3}" would - // be considered to be a block with label "x" and value "3", but, - // "({x:3})" is considered to be an inline object with field "x" that - // has value 3. - s = "(" + s + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - - final List<ICompilerProblem> errors = new ArrayList<ICompilerProblem>(); -// CompilerHandler newHandler = new CompilerHandler() { -// @Override -// public void error(final String filename, int ln, int col, String msg, String source) { -// ErrorInfo ei = new ErrorInfo(); -// ei.filename = filename; -// ei.ln = ln; -// ei.col = col; -// ei.msg = msg; -// ei.source = source; -// errors.add(ei); -// } -// }; -// cx.setHandler(newHandler); -// cx.scriptAssistParsing = true; - // Parser parser = new Parser(cx, s, "Expression"); //$NON-NLS-1$ - IASNode programNode = DebuggerUtil.parseExpression(s, errors); - //ProgramNode programNode = parser.parseProgram(); - - if (errors.size() > 0) { - ICompilerProblem firstError = errors.get(0); - throw new ParseException(firstError.toString(), firstError.getColumn()); - } - - retval.setProgramNode(programNode); - return retval; - } - - - static LocalizationManager getLocalizationManager() - { - return s_localizationManager; - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/Context.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/Context.java b/debugger/src/flash/tools/debugger/expression/Context.java deleted file mode 100644 index 0088ac3..0000000 --- a/debugger/src/flash/tools/debugger/expression/Context.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import flash.tools.debugger.Session; -import flash.tools.debugger.Value; - -/** - * An object which returns a value given a name and - * appropriate context information. - */ -public interface Context -{ - /** - * Looks for an object of the given name in this context -- for example, a member variable. - * - * The returned Object can be of any type at all. For example, it could be: - * - * <ul> - * <li> a <code>flash.tools.debugger.Variable</code> </li> - * <li> your own wrapper around <code>Variable</code> </li> - * <li> a <code>flash.tools.debugger.Value</code> </li> - * <li> any built-in Java primitive such as <code>Long</code>, <code>Integer</code>, - * <code>Double</code>, <code>Boolean</code>, or <code>String</code> </li> - * <li> any other type you want which has a good <code>toString()</code>; see below </li> - * </ul> - * - * Since the return type is just Object, the returned value is only meaningful when - * passed to other functions this interface. For example, the returned Object can be - * passed to createContext(), assign(), or toValue(). - * - * @param o the object to look up; most commonly a string representing the name of - * a member variable. - */ - public Object lookup(Object o) throws NoSuchVariableException, PlayerFaultException; - - /** - * Looks for the members of an object. - * - * @param o - * A variable whose members we want to look up - * @return Some object which represents the members; could even be just a - * string. See lookup() for more information about the returned - * type. - * @see #lookup(Object) - */ - public Object lookupMembers(Object o) throws NoSuchVariableException; - - /** - * Creates a new context object by combining the current one and o. - * For example, if the user typed "myVariable.myMember", then this function - * will get called with o equal to the object which represents "myVariable". - * This function should return a new context which, when called with - * lookup("myMember"), will return an object for that member. - * - * @param o any object which may have been returned by this class's lookup() function - */ - public Context createContext(Object o); - - /** - * Assign the object o, the value v. - * - * @param o - * a variable to assign to -- this should be some value returned - * by an earlier call to lookup(). - * @param v - * a value, such as a Boolean, Long, String, etc. - */ - public void assign(Object o, Value v) throws NoSuchVariableException, PlayerFaultException; - - /** - * Enables/disables the creation of variables during lookup calls. - * This is ONLY used by AssignmentExp for creating a assigning a value - * to a property which currently does not exist. - */ - public void createPseudoVariables(boolean oui); - - /** - * Converts the object to a Value. - * - * @param o - * Either object that was returned by an earlier call to - * <code>lookup()</code>, or one of the raw types that can be - * returned by <code>Value.getValueAsObject()</code>. - * @return the corresponding Value, or <code>null</code>. - * @see Value#getValueAsObject() - */ - public Value toValue(Object o); - - /** - * Converts the context to a Value. Very similar to - * <code>toValue(Object o)</code>, except that the object being converted - * is the object that was used to initialize this context. - * - * @return the corresponding Value, or <code>null</code>. - */ - public Value toValue(); - - /** - * Returns the session associated with this context, or null. - * This can legitimately be null; for example, in fdb, you are - * allowed to do things like "set $columnwidth = 120" before - * beginning a debugging session. - */ - public Session getSession(); - - /** - * The worker id to which this context object belongs. - */ - public int getIsolateId(); -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/DebuggerExpression.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/DebuggerExpression.java b/debugger/src/flash/tools/debugger/expression/DebuggerExpression.java deleted file mode 100644 index 14eab90..0000000 --- a/debugger/src/flash/tools/debugger/expression/DebuggerExpression.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package flash.tools.debugger.expression; - -import java.util.HashSet; - -import org.apache.flex.compiler.internal.projects.ASCProject; -import org.apache.flex.compiler.internal.tree.as.BinaryOperatorLogicalAndNode; -import org.apache.flex.compiler.internal.tree.as.ExpressionNodeBase; -import org.apache.flex.compiler.internal.workspaces.Workspace; -import org.apache.flex.compiler.projects.ICompilerProject; -import org.apache.flex.compiler.tree.ASTNodeID; -import org.apache.flex.compiler.tree.as.IASNode; -import org.apache.flex.compiler.tree.as.IExpressionNode; -import org.apache.flex.compiler.workspaces.IWorkspace; - -import flash.tools.debugger.PlayerDebugException; - -/** - * A wrapper around an abstract syntax tree (AST) that was provided by the - * ActionScript Compiler (ASC), suitable for use by the debugger. - * - * When {@link #evaluate(Context)} is called, this will walk the AST and return - * a value. But please note that this class's implementation of expression - * evaluation should not be taken as a model of 100% perfect ActionScript - * evaluation. While this implementation handles all the cases the debugger is - * likely to run into, there are many edge cases that this class can't handle. - * For most cases where you need an on-the-fly expression evaluator, you would - * be better off using the code from the "esc" project. - * - * @author Mike Morearty - */ -class DebuggerExpression implements ValueExp { - - private final static HashSet<ASTNodeID> ASSIGN_OPRATORS = new HashSet<ASTNodeID>(); - static { - ASSIGN_OPRATORS.add(ASTNodeID.Op_AssignId); - ASSIGN_OPRATORS.add(ASTNodeID.Op_LeftShiftAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_RightShiftAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_UnsignedRightShiftAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_MultiplyAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_DivideAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_ModuloAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_BitwiseAndAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_BitwiseXorAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_BitwiseOrAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_AddAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_SubtractAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_LogicalAndAssignID); - ASSIGN_OPRATORS.add(ASTNodeID.Op_LogicalOrAssignID); - } - /** - * The AST representing the expression. - */ - private IASNode m_programNode; - - /** - * @see #isLookupMembers() - */ - private boolean m_lookupMembers = false; - - /** - * @return the AST representing the expression. - */ - public IASNode getProgramNode() { - return m_programNode; - } - - /** - * Sets the AST representing the expression. - */ - public void setProgramNode(IASNode programNode) { - m_programNode = programNode; - } - - /* - * @see flash.tools.debugger.expression.ValueExp#isLookupMembers() - */ - public boolean isLookupMembers() { - return m_lookupMembers; - } - - /** - * @see #isLookupMembers() - */ - public void setLookupMembers(boolean value) { - m_lookupMembers = value; - } - - /* - * @see flash.tools.debugger.expression.ValueExp#containsAssignment() - */ - public boolean containsAssignment() { - return containsAssignment(m_programNode); - } - - /** - * @param containsAssignment - */ - private boolean containsAssignment(IASNode node) { - if (ASSIGN_OPRATORS.contains(node.getNodeID())) { - return true; - } - for (int i = 0; i < node.getChildCount(); i++) { - if (containsAssignment(node.getChild(i))) { - return true; - } - } - return false; - } - - /* - * @see - * flash.tools.debugger.expression.ValueExp#evaluate(flash.tools.debugger - * .expression.Context) - */ - public Object evaluate(Context context) throws NumberFormatException, - NoSuchVariableException, PlayerFaultException, PlayerDebugException { - // assert m_cx.getScopeDepth() == 0; - // m_cx.pushScope(new ExpressionEvaluatorScope(context)); - try { - IExpressionEvaluator eval = new DebuggerExpressionEvaluator(); - DebuggerValue value = eval.evaluate(context, m_programNode); - - if (isLookupMembers()) { - return context.lookupMembers(value.debuggerValue); - } else { - return value.debuggerValue; - } - } catch (Exception e) { - // e.printStackTrace();//TODO : ASC3 : remove - if (e.getCause() instanceof NumberFormatException) { - throw (NumberFormatException) e.getCause(); - } else if (e.getCause() instanceof NoSuchVariableException) { - throw (NoSuchVariableException) e.getCause(); - } else if (e.getCause() instanceof PlayerFaultException) { - throw (PlayerFaultException) e.getCause(); - } else if (e.getCause() instanceof PlayerDebugException) { - throw (PlayerDebugException) e.getCause(); - } else { - e.printStackTrace(); - throw new PlayerDebugException(e.getLocalizedMessage()); - } - } finally { - // m_cx.popScope(); - } - } - -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/DebuggerExpressionEvaluator.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/DebuggerExpressionEvaluator.java b/debugger/src/flash/tools/debugger/expression/DebuggerExpressionEvaluator.java deleted file mode 100644 index 8536a51..0000000 --- a/debugger/src/flash/tools/debugger/expression/DebuggerExpressionEvaluator.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import org.apache.flex.compiler.internal.projects.ASCProject; -import org.apache.flex.compiler.internal.workspaces.Workspace; -import org.apache.flex.compiler.projects.ICompilerProject; -import org.apache.flex.compiler.tree.as.IASNode; - -/** - * @author ggv - * - */ -public class DebuggerExpressionEvaluator implements IExpressionEvaluator { - - private final ICompilerProject project; - private final IASTFolder logicalOperatorFolder; - - /** - * - */ - public DebuggerExpressionEvaluator() { - project = new ASCProject(new Workspace(), true); - logicalOperatorFolder = new LogicalOperatorsFolder(); - - } - - /** - * @param project2 - */ - public DebuggerExpressionEvaluator(ICompilerProject project2) { - logicalOperatorFolder = new LogicalOperatorsFolder(); - this.project = project2; - } - - @Override - public DebuggerValue evaluate(Context context, IASNode node) - throws Exception { - - if (node instanceof FoldedExpressionNode) { - /* - * Unfold the folded node, and if the unfolded subtree has a logical - * operator, fold the RHS of that - */ - node = logicalOperatorFolder - .unfoldOneLevel((FoldedExpressionNode) node); - } else { - /* - * Where ever it finds a logical operator, fold the rhs of that. - */ - node = logicalOperatorFolder.fold(node); - } - AS3DebuggerBURM burm = new AS3DebuggerBURM(); - burm.reducer = new AS3DebuggerReducer(context, project); - - burm.burm(node, AS3DebuggerBURM.__expression_NT); - DebuggerValue value = (DebuggerValue) burm.getResult(); - return value; - } - -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/DebuggerUtil.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/DebuggerUtil.java b/debugger/src/flash/tools/debugger/expression/DebuggerUtil.java deleted file mode 100644 index c5492f2..0000000 --- a/debugger/src/flash/tools/debugger/expression/DebuggerUtil.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import java.io.FileNotFoundException; -import java.io.Reader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; - -import org.apache.flex.compiler.common.SourceLocation; -import org.apache.flex.compiler.filespecs.IFileSpecification; -import org.apache.flex.compiler.internal.parsing.as.ASParser; -import org.apache.flex.compiler.internal.scopes.ASFileScope; -import org.apache.flex.compiler.internal.semantics.PostProcessStep; -import org.apache.flex.compiler.internal.tree.as.NodeBase; -import org.apache.flex.compiler.internal.tree.as.ScopedBlockNode; -import org.apache.flex.compiler.internal.workspaces.Workspace; -import org.apache.flex.compiler.problems.ICompilerProblem; -import org.apache.flex.compiler.tree.as.IASNode; -import org.apache.flex.compiler.workspaces.IWorkspace; - -/** - * - * @author ggv - */ -public class DebuggerUtil -{ - - /** - * - * @param code - * @param problems - * @return - */ - public static IASNode parseExpression(String code, List<ICompilerProblem> problems) - { - IWorkspace workspace = new Workspace(); - DebuggerUtil.InMemoryFileSpecification imfs = new DebuggerUtil.InMemoryFileSpecification(code); - EnumSet<PostProcessStep> empty = EnumSet.noneOf(PostProcessStep.class); - IASNode exprAST = ASParser.parseFile(imfs, workspace, empty, null, false, false, new ArrayList<String>(), null, null, null); - - // Have to create a fake ScopedBlockNode so the expression can do things - // like resolve, which means it has to be able to find a scope. - // For parsing an expression in a file, one would hook up the expression - // AST to whatever the real scope was. - ScopedBlockNode scopedNode = new ScopedBlockNode(); - scopedNode.addChild((NodeBase)exprAST); - scopedNode.setScope(new ASFileScope(workspace, "fake")); - scopedNode.runPostProcess(EnumSet.of(PostProcessStep.CALCULATE_OFFSETS)); - - // return the first (and only child). This is essentially unwrapping the - // FileNode that was wrapped around the expression being parsed - return exprAST.getChild(0); - } - - public static class InMemoryFileSpecification implements IFileSpecification - { - public InMemoryFileSpecification(String s) - { - this.s = s; - } - - private String s; - - public String getPath() - { - return "flash.tools.debugger"; - } - - public Reader createReader() throws FileNotFoundException - { - return new StringReader(s); - } - - public long getLastModified() - { - return 0; - } - - public boolean isOpenDocument() - { - return false; - } - } - -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/DebuggerValue.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/DebuggerValue.java b/debugger/src/flash/tools/debugger/expression/DebuggerValue.java deleted file mode 100644 index cd647bc..0000000 --- a/debugger/src/flash/tools/debugger/expression/DebuggerValue.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package flash.tools.debugger.expression; - -public class DebuggerValue { - public Object debuggerValue; - - public DebuggerValue(Object v) - { - debuggerValue = v; - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/ECMA.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/ECMA.java b/debugger/src/flash/tools/debugger/expression/ECMA.java deleted file mode 100644 index 39c3308..0000000 --- a/debugger/src/flash/tools/debugger/expression/ECMA.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package flash.tools.debugger.expression; - -import flash.tools.debugger.Isolate; -import flash.tools.debugger.PlayerDebugException; -import flash.tools.debugger.Session; -import flash.tools.debugger.Value; -import flash.tools.debugger.VariableType; -import flash.tools.debugger.concrete.DValue; -import flash.tools.debugger.events.ExceptionFault; - -/** - * Implementations of some of the conversion functions defined by - * the ECMAScript spec ( http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf ). - * Please note, these conversion functions should not be considered to - * be 100% accurate; they handle all the cases the debugger's expression - * evaluator is likely to run into, but there are some edge cases that - * fall through the cracks. - * - * @author Mike Morearty - */ -public class ECMA -{ - /** Used by defaultValue() etc. */ - private enum PreferredType { NUMBER, STRING } - - /** - * ECMA 4.3.2 - */ - public static boolean isPrimitive(Value v) - { - v = safeValue(v, Isolate.DEFAULT_ID); - Object o = v.getValueAsObject(); - return (o == Value.UNDEFINED || o == null || o instanceof Boolean - || o instanceof Double || o instanceof String); - } - - private static Value callFunction(Session session, Value v, String functionName, Value[] args, int isolateId) - { - v = safeValue(v, isolateId); - - try - { - return session.getWorkerSession(isolateId).callFunction(v, functionName, args); - } - catch (PlayerDebugException e) - { - throw new ExpressionEvaluatorException(e); - } - } - - /** - * Calls the valueOf() function of an object. - */ - private static Value callValueOf(Session session, Value v, int isolateId) - { - v = safeValue(v, isolateId); - return callFunction(session, v, "valueOf", new Value[0], isolateId); //$NON-NLS-1$ - } - - /** - * Do not confuse this with toString()! toString() represents the official - * ECMA definition of [[ToString]], as defined in ECMA section 9.8. This - * function, on the other hand, represents calling the toString() function - * of an object. - */ - private static Value callToString(Session session, Value v, int isolateId) - { - v = safeValue(v, isolateId); - return callFunction(session, v, "toString", new Value[0], isolateId); //$NON-NLS-1$ - } - - /** - * ECMA 8.6.2.6 - * - * @param v - * @param optionalPreferredType - * either NUMBER, STRING, or null. - */ - public static Value defaultValue(Session session, Value v, - PreferredType optionalPreferredType, - int isolateId) - { - v = safeValue(v, isolateId); - String typename = v.getTypeName(); - int at = typename.indexOf('@'); - if (at != -1) - typename = typename.substring(0, at); - - if (optionalPreferredType == null) - { - if (typename.equals("Date")) //$NON-NLS-1$ - optionalPreferredType = PreferredType.STRING; - else - optionalPreferredType = PreferredType.NUMBER; - } - - if (optionalPreferredType == PreferredType.NUMBER) - { - Value result = callValueOf(session, v, isolateId); - if (isPrimitive(result)) - return result; - result = callToString(session, v, isolateId); - if (isPrimitive(result)) - return result; - throw new RuntimeException(new PlayerFaultException(new ExceptionFault(ASTBuilder.getLocalizationManager().getLocalizedTextString("typeError"), false, null, isolateId))); //$NON-NLS-1$ - } - else - { - Value result = callToString(session, v, isolateId); - if (isPrimitive(result)) - return result; - result = callValueOf(session, v, isolateId); - if (isPrimitive(result)) - return result; - throw new RuntimeException(new PlayerFaultException(new ExceptionFault(ASTBuilder.getLocalizationManager().getLocalizedTextString("typeError"), false, null, isolateId))); //$NON-NLS-1$ - } - } - - /** - * ECMA 9.1 - * - * @param v - * @param optionalPreferredType - * either NUMBER_TYPE, STRING_TYPE, or null. - * @return - */ - public static Value toPrimitive(Session session, Value v, - PreferredType optionalPreferredType, int isolateId) - { - v = safeValue(v, isolateId); - switch (v.getType()) - { - case VariableType.UNDEFINED: - case VariableType.NULL: - case VariableType.BOOLEAN: - case VariableType.NUMBER: - case VariableType.STRING: - return v; - - default: - return defaultValue(session, v, optionalPreferredType, isolateId); - } - } - - /** ECMA 9.2 */ - public static boolean toBoolean(Value v) - { - v = safeValue(v, Isolate.DEFAULT_ID); - switch (v.getType()) - { - case VariableType.UNDEFINED: - case VariableType.NULL: - return false; - case VariableType.BOOLEAN: - return ((Boolean) v.getValueAsObject()).booleanValue(); - case VariableType.NUMBER: - { - double d = ((Double) v.getValueAsObject()).doubleValue(); - if (d == 0 || Double.isNaN(d)) - { - return false; - } - else - { - return true; - } - } - case VariableType.STRING: - return ((String) v.getValueAsObject()).length() != 0; - default: - return true; - } - } - - /** ECMA 9.3 */ - public static double toNumber(Session session, Value v) - { - v = safeValue(v, Isolate.DEFAULT_ID); - switch (v.getType()) - { - case VariableType.UNDEFINED: - return Double.NaN; - case VariableType.NULL: - return 0; - case VariableType.BOOLEAN: - return ((Boolean) v.getValueAsObject()).booleanValue() ? 1 : 0; - case VariableType.NUMBER: - return ((Double) v.getValueAsObject()).doubleValue(); - case VariableType.STRING: - { - String s = (String) v.getValueAsObject(); - if (s.length() == 0) - { - return 0; - } - else - { - try - { - return Double.parseDouble(s); - } - catch (NumberFormatException e) - { - return Double.NaN; - } - } - } - default: - return toNumber(session, toPrimitive(session, v, PreferredType.NUMBER, v.getIsolateId())); - } - } - - private static final double _2pow31 = Math.pow(2, 31); - private static final double _2pow32 = Math.pow(2, 32); - - /** ECMA 9.5 */ - public static int toInt32(Session session, Value v) - { - v = safeValue(v, Isolate.DEFAULT_ID); - double d = toNumber(session, v); - if (d == Double.POSITIVE_INFINITY || d == Double.NEGATIVE_INFINITY) - { - return 0; - } - else - { - double sign = Math.signum(d); - d = Math.floor(Math.abs(d)); - d %= _2pow32; - while (d >= _2pow31) - d -= _2pow32; - return (int) (sign*d); - } - } - - /** ECMA 9.6 */ - public static long toUint32(Session session, Value v) - { - v = safeValue(v, Isolate.DEFAULT_ID); - long n = toInt32(session, v); - if (n < 0) - n = n + (long) 0x10000 * (long) 0x10000; - return n; - } - - /** ECMA 9.8 */ - public static String toString(Session session, Value v) - { - v = safeValue(v, Isolate.DEFAULT_ID); - switch (v.getType()) - { - case VariableType.UNDEFINED: - case VariableType.NULL: - case VariableType.BOOLEAN: - case VariableType.STRING: - return v.getValueAsString(); - case VariableType.NUMBER: - { - double d = ((Double) v.getValueAsObject()).doubleValue(); - if (d == (long) d) - { - return Long.toString((long) d); // avoid the ".0" on the end - } - else - { - return v.toString(); - } - } - default: - return toString(session, toPrimitive(session, v, PreferredType.STRING, v.getIsolateId())); - } - } - - /** ECMA 11.8.5. Returns true, false, or undefined. */ - public static Value lessThan(Session session, Value x, Value y) - { - x = safeValue(x, Isolate.DEFAULT_ID); - y = safeValue(y, Isolate.DEFAULT_ID); - Value px = toPrimitive(session, x, PreferredType.NUMBER, x.getIsolateId()); - Value py = toPrimitive(session, y, PreferredType.NUMBER, y.getIsolateId()); - if (px.getType() == VariableType.STRING - && py.getType() == VariableType.STRING) - { - String sx = px.getValueAsString(); - String sy = py.getValueAsString(); - return DValue.forPrimitive(new Boolean(sx.compareTo(sy) < 0), x.getIsolateId()); - } - else - { - double dx = toNumber(session, px); - double dy = toNumber(session, py); - if (Double.isNaN(dx) || Double.isNaN(dy)) - return DValue.forPrimitive(Value.UNDEFINED, x.getIsolateId()); - return DValue.forPrimitive(new Boolean(dx < dy), x.getIsolateId()); - } - } - - /** ECMA 11.9.3 */ - public static boolean equals(Session session, Value xv, Value yv) - { - xv = safeValue(xv, Isolate.DEFAULT_ID); - yv = safeValue(yv, Isolate.DEFAULT_ID); - - Object x = xv.getValueAsObject(); - Object y = yv.getValueAsObject(); - - if (xv.getType() == yv.getType()) - { - if (x == Value.UNDEFINED) - return true; - if (x == null) - return true; - if (x instanceof Double) - { - double dx = ((Double) x).doubleValue(); - double dy = ((Double) y).doubleValue(); - return dx == dy; - } - if (x instanceof String || x instanceof Boolean) - return x.equals(y); - - // see if they are the same object - if (xv.getId() != -1 || yv.getId() != -1) - return xv.getId() == yv.getId(); - return false; - } - else - { - if (x == null && y == Value.UNDEFINED) - return true; - if (x == Value.UNDEFINED && y == null) - return true; - if (x instanceof Double && y instanceof String) - { - double dx = ((Double) x).doubleValue(); - double dy = toNumber(session, yv); - return dx == dy; - } - if (x instanceof String && y instanceof Double) - { - double dx = toNumber(session, xv); - double dy = ((Double) y).doubleValue(); - return dx == dy; - } - if (x instanceof Boolean) - return equals(session, DValue.forPrimitive(new Double(toNumber(session, xv)), xv.getIsolateId()), yv); - if (y instanceof Boolean) - return equals(session, xv, DValue.forPrimitive(new Double(toNumber(session, yv)), xv.getIsolateId())); - if ((x instanceof String || x instanceof Double) && yv.getType() == VariableType.OBJECT) - { - return equals(session, xv, toPrimitive(session, yv, null, yv.getIsolateId())); - } - if (xv.getType() == VariableType.OBJECT && (y instanceof String || y instanceof Double)) - { - return equals(session, toPrimitive(session, xv, null, xv.getIsolateId()), yv); - } - return false; - } - } - - /** ECMA 11.9.6 */ - public static boolean strictEquals(Value xv, Value yv) - { - xv = safeValue(xv, Isolate.DEFAULT_ID); - yv = safeValue(yv, Isolate.DEFAULT_ID); - - Object x = xv.getValueAsObject(); - Object y = yv.getValueAsObject(); - - if (xv.getType() == yv.getType()) - { - if (x == Value.UNDEFINED) - return true; - if (x == null) - return true; - if (x instanceof Double) - { - double dx = ((Double) x).doubleValue(); - double dy = ((Double) y).doubleValue(); - return dx == dy; - } - if (x instanceof String || x instanceof Boolean) - return x.equals(y); - - // see if they are the same object - if (xv.getId() != -1 || yv.getId() != -1) - return xv.getId() == yv.getId(); - return false; - } - else - { - return false; - } - } - - /** - * Returns a "safe" (non-null) form of the specified Value -- that is, if - * the specified Value is null, returns a non-null Value that *represents* - * null. - * - * @param v - * any Value, possibly null - * @return a non-null Value - */ - public static Value safeValue(Value v, int isolateId) - { - if (v == null) - { - v = DValue.forPrimitive(null, isolateId); - assert v != null; - } - return v; - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/ExpressionEvaluatorException.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/ExpressionEvaluatorException.java b/debugger/src/flash/tools/debugger/expression/ExpressionEvaluatorException.java deleted file mode 100644 index d10485d..0000000 --- a/debugger/src/flash/tools/debugger/expression/ExpressionEvaluatorException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -/** - * An exception raised while evaluating an expression. This is a bit - * of a hack -- we need this to extend <code>RuntimeException</code> - * because the functions in the <code>Evaluator</code> interface don't - * throw anything, but our <code>DebuggerEvaluator</code> has many - * places where it needs to bail out. - * - * @author Mike Morearty - */ -public class ExpressionEvaluatorException extends RuntimeException { - private static final long serialVersionUID = -7005526599250035578L; - - public ExpressionEvaluatorException(String message) { - super(message); - } - - public ExpressionEvaluatorException(Throwable cause) { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/FoldedExpressionNode.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/FoldedExpressionNode.java b/debugger/src/flash/tools/debugger/expression/FoldedExpressionNode.java deleted file mode 100644 index e2fbac8..0000000 --- a/debugger/src/flash/tools/debugger/expression/FoldedExpressionNode.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import org.apache.flex.compiler.filespecs.IFileSpecification; -import org.apache.flex.compiler.internal.tree.as.ExpressionNodeBase; -import org.apache.flex.compiler.tree.ASTNodeID; -import org.apache.flex.compiler.tree.as.IASNode; -import org.apache.flex.compiler.tree.as.IExpressionNode; -import org.apache.flex.compiler.tree.as.IScopedNode; - -/** - * @author ggv - * - */ -public class FoldedExpressionNode extends ExpressionNodeBase implements - IExpressionNode { - - private final IASNode rootNode; - - /** - * - */ - public FoldedExpressionNode(IASNode rootNode) { - this.rootNode = rootNode; - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.common.ISourceLocation#getStart() - */ - @Override - public int getStart() { - return getUnderLyingNode().getStart(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.common.ISourceLocation#getEnd() - */ - @Override - public int getEnd() { - return getUnderLyingNode().getEnd(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.common.ISourceLocation#getLine() - */ - @Override - public int getLine() { - return getUnderLyingNode().getLine(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.common.ISourceLocation#getColumn() - */ - @Override - public int getColumn() { - return 0; - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.common.ISourceLocation#getAbsoluteStart() - */ - @Override - public int getAbsoluteStart() { - return getUnderLyingNode().getAbsoluteStart(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.common.ISourceLocation#getAbsoluteEnd() - */ - @Override - public int getAbsoluteEnd() { - return getUnderLyingNode().getAbsoluteEnd(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getNodeID() - */ - @Override - public ASTNodeID getNodeID() { - return ASTNodeID.FoldedExpressionID; - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#contains(int) - */ - @Override - public boolean contains(int offset) { - return getUnderLyingNode().contains(offset); - } - - /* - * (non-Javadoc) - * - * @see - * com.adobe.flash.compiler.tree.as.IASNode#getAncestorOfType(java.lang. - * Class) - */ - @Override - public IASNode getAncestorOfType(Class<? extends IASNode> nodeType) { - return getUnderLyingNode().getAncestorOfType(nodeType); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getChild(int) - */ - @Override - public IASNode getChild(int i) { - return null; - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getChildCount() - */ - @Override - public int getChildCount() { - return 0; - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getContainingNode(int) - */ - @Override - public IASNode getContainingNode(int offset) { - return getUnderLyingNode().getContainingNode(offset); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getContainingScope() - */ - @Override - public IScopedNode getContainingScope() { - return getUnderLyingNode().getContainingScope(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getPackageName() - */ - @Override - public String getPackageName() { - return getUnderLyingNode().getPackageName(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getParent() - */ - @Override - public IASNode getParent() { - return getUnderLyingNode().getParent(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getFileSpecification() - */ - @Override - public IFileSpecification getFileSpecification() { - return getUnderLyingNode().getFileSpecification(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getSpanningStart() - */ - @Override - public int getSpanningStart() { - return getUnderLyingNode().getSpanningStart(); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#getSucceedingNode(int) - */ - @Override - public IASNode getSucceedingNode(int offset) { - return getUnderLyingNode().getSucceedingNode(offset); - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.tree.as.IASNode#isTerminal() - */ - @Override - public boolean isTerminal() { - return true; - } - - /** - * @return the rootNode - */ - public IASNode getUnderLyingNode() { - return rootNode; - } - - /* - * (non-Javadoc) - * - * @see com.adobe.flash.compiler.internal.tree.as.ExpressionNodeBase#copy() - */ - @Override - protected ExpressionNodeBase copy() { - return null; - } - -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/IASTBuilder.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/IASTBuilder.java b/debugger/src/flash/tools/debugger/expression/IASTBuilder.java deleted file mode 100644 index ba4bb72..0000000 --- a/debugger/src/flash/tools/debugger/expression/IASTBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import java.io.IOException; -import java.io.Reader; -import java.text.ParseException; - -public interface IASTBuilder -{ - /** - * A parser that should do a fairly good job at - * parsing a general expression string. - * - * Exceptions: - * ParseException - a general parsing error occurred. - * - */ - public ValueExp parse(Reader in) throws IOException, ParseException; -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/IASTFolder.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/IASTFolder.java b/debugger/src/flash/tools/debugger/expression/IASTFolder.java deleted file mode 100644 index 30ac679..0000000 --- a/debugger/src/flash/tools/debugger/expression/IASTFolder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import org.apache.flex.compiler.tree.as.IASNode; - -/** - * @author ggv - * - */ -public interface IASTFolder { - - /** - * This will perform folding of certain nodes, based on implementation - * - * @param rootNode - * @return - */ - public IASNode fold(IASNode rootNode); - - /** - * Unfolds onlevel, if required will fold the children - * - * @param rootNode - * @return - */ - public IASNode unfoldOneLevel(FoldedExpressionNode rootNode); -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/IExpressionEvaluator.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/IExpressionEvaluator.java b/debugger/src/flash/tools/debugger/expression/IExpressionEvaluator.java deleted file mode 100644 index c1ffe03..0000000 --- a/debugger/src/flash/tools/debugger/expression/IExpressionEvaluator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import org.apache.flex.compiler.tree.as.IASNode; - -/** - * @author ggv - * - */ -public interface IExpressionEvaluator { - - public abstract DebuggerValue evaluate(Context context, IASNode node) throws Exception; - -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/LogicalOperatorsFolder.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/LogicalOperatorsFolder.java b/debugger/src/flash/tools/debugger/expression/LogicalOperatorsFolder.java deleted file mode 100644 index 84709bd..0000000 --- a/debugger/src/flash/tools/debugger/expression/LogicalOperatorsFolder.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import org.apache.flex.compiler.internal.tree.as.BinaryOperatorLogicalAndAssignmentNode; -import org.apache.flex.compiler.internal.tree.as.BinaryOperatorLogicalAndNode; -import org.apache.flex.compiler.internal.tree.as.BinaryOperatorLogicalOrAssignmentNode; -import org.apache.flex.compiler.internal.tree.as.BinaryOperatorLogicalOrNode; -import org.apache.flex.compiler.internal.tree.as.ExpressionNodeBase; -import org.apache.flex.compiler.tree.as.IASNode; -import org.apache.flex.compiler.tree.as.IExpressionNode; - -/** - * The logical operator's right hand operands are folded into - * FoldedExperessionNode, so that they are not evaluated by the burm. - * - * This is required for shortcircuit evaluation - * - * @author ggv - * - */ -public class LogicalOperatorsFolder implements IASTFolder { - - /* - * (non-Javadoc) - * - * @see - * flash.tools.debugger.expression.IASTFolder#fold(com.adobe.flash.compiler - * .tree.as.IASNode) - */ - @Override - public IASNode fold(IASNode rootNode) { - foldLazyRHSOperandsForLogicalOperators(rootNode); - return rootNode; - } - - /** - * @param node - */ - private void foldLazyRHSOperandsForLogicalOperators(IASNode node) { - - if (node instanceof BinaryOperatorLogicalAndNode - || node instanceof BinaryOperatorLogicalAndAssignmentNode) { - - BinaryOperatorLogicalAndNode opNode = ((BinaryOperatorLogicalAndNode) node); - opNode.setRightOperandNode(fold(opNode.getRightOperandNode())); - foldLazyRHSOperandsForLogicalOperators(opNode.getLeftOperandNode()); - - } else if (node instanceof BinaryOperatorLogicalOrNode - || node instanceof BinaryOperatorLogicalOrAssignmentNode) { - - BinaryOperatorLogicalOrNode opNode = ((BinaryOperatorLogicalOrNode) node); - opNode.setRightOperandNode(fold(opNode.getRightOperandNode())); - foldLazyRHSOperandsForLogicalOperators(opNode.getLeftOperandNode()); - - } else { - int chCount = node.getChildCount(); - for (int i = 0; i < chCount; i++) { - IASNode childNode = node.getChild(i); - foldLazyRHSOperandsForLogicalOperators(childNode); - } - } - } - - /** - * @param rightOperandNode - * @return - */ - private ExpressionNodeBase fold(IExpressionNode rightOperandNode) { - return new FoldedExpressionNode(rightOperandNode); - } - - /* - * (non-Javadoc) - * - * @see - * flash.tools.debugger.expression.IASTFolder#unfoldOneLevel(flash.tools - * .debugger.expression.FoldedExpressionNode) - */ - @Override - public IASNode unfoldOneLevel(FoldedExpressionNode foldedExpressionNode) { - IASNode node = foldedExpressionNode.getUnderLyingNode(); - fold(node); - return node; - } - -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/NoSuchVariableException.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/NoSuchVariableException.java b/debugger/src/flash/tools/debugger/expression/NoSuchVariableException.java deleted file mode 100644 index 05e69ca..0000000 --- a/debugger/src/flash/tools/debugger/expression/NoSuchVariableException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import java.util.HashMap; -import java.util.Map; - -/** - * Thrown when a variable name cannot be resolved in the current scope - */ -public class NoSuchVariableException extends Exception -{ - private static final long serialVersionUID = -400396588945206074L; - - public NoSuchVariableException(String s) { super(s); } - public NoSuchVariableException(Object o) { super(o.toString()); } - - @Override - public String getLocalizedMessage() - { - Map<String, String> args = new HashMap<String, String>(); - args.put("arg2", getMessage() ); //$NON-NLS-1$ - return ASTBuilder.getLocalizationManager().getLocalizedTextString("noSuchVariable", args); //$NON-NLS-1$ - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/07f5a7de/debugger/src/flash/tools/debugger/expression/PlayerFaultException.java ---------------------------------------------------------------------- diff --git a/debugger/src/flash/tools/debugger/expression/PlayerFaultException.java b/debugger/src/flash/tools/debugger/expression/PlayerFaultException.java deleted file mode 100644 index 5cec3a1..0000000 --- a/debugger/src/flash/tools/debugger/expression/PlayerFaultException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flash.tools.debugger.expression; - -import flash.tools.debugger.events.FaultEvent; - -/** - * Thrown when the player generates a fault. For example, if - * an attempt to assign a value to a variable results in the player - * generating a fault because that value has no setter, or because - * the setter throws an exception for any other reason, then this - * exception will be generated. - */ -public class PlayerFaultException extends Exception { - private static final long serialVersionUID = 7754580337597815207L; - private FaultEvent m_event; - - public PlayerFaultException(FaultEvent event) - { - m_event = event; - } - - public FaultEvent getFaultEvent() - { - return m_event; - } - - @Override - public String getMessage() - { - return m_event.information; - } -}