flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - handle print #objectrefnumber in FDB
Date Tue, 09 Jun 2015 05:19:56 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop e96f9f228 -> edea80cd8


handle print #objectrefnumber in FDB


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/edea80cd
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/edea80cd
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/edea80cd

Branch: refs/heads/develop
Commit: edea80cd89c863e6befaaacd2b6ce1ffd17b65ae
Parents: e96f9f2
Author: Alex Harui <aharui@apache.org>
Authored: Mon Jun 8 22:19:43 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Jun 8 22:19:43 2015 -0700

----------------------------------------------------------------------
 .../debugger/expression/AS3DebuggerBURM.jbg     | 67 ++++++++++++++++++++
 .../debugger/expression/AS3DebuggerReducer.java | 22 ++++++-
 .../debugger/expression/AS3DebuggerRules.jbg    |  8 ++-
 3 files changed, 95 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/edea80cd/debugger/src/flash/tools/debugger/expression/AS3DebuggerBURM.jbg
----------------------------------------------------------------------
diff --git a/debugger/src/flash/tools/debugger/expression/AS3DebuggerBURM.jbg b/debugger/src/flash/tools/debugger/expression/AS3DebuggerBURM.jbg
index 555cf0a..d2918be 100644
--- a/debugger/src/flash/tools/debugger/expression/AS3DebuggerBURM.jbg
+++ b/debugger/src/flash/tools/debugger/expression/AS3DebuggerBURM.jbg
@@ -266,4 +266,71 @@ DefaultErrorHandler
  *  Patterns and rules are stored in their own, shareable file.
  */
 JBurg.include "../compiler/src/org/apache/flex/compiler/internal/as/codegen/CmcPatterns.jbg"
+
+
+/*
+ * This pattern is used by the debugger to call special functions 
+ * like $obj() when handling the ‘print #ObjectRefNumber’ feature.
+ * I don’t think I would have a rule like this in the compiler as 
+ * calling foo() where foo is just an identifier is probably likely
+ * and “foo” has to be resolved from an identifier to, in most cases,
+ * a MemberAccessExpression, but I don’t think folks print function
+ * calls in the debugger.  And even if they do, there is a chance it
+ * will work anyway.
+ *
+ * If the debugger is missing the ability to print something, it may be
+ * that a new Pattern and Rule need to be added.  First, set a breakpoint
+ * in DebuggerExpressionEvaluator at the call to burm.burm().  Examine 
+ * the node to make sure it was parsed correctly into a tree of nodes.
+ *
+ * If the node tree is correct, step into the burm() call.  You should
+ * see the code call label() and return a different tree of instances.
+ * For lots of things, there are custom classes like:
+ *   JBurgAnnotation_FunctionCallID_2_n
+ * which represents a FunctionCallID in the AST.  If the top node is an
+ * instance of JBurgAnnotationGeneral, that means that the BURM did not
+ * expect a node of that type.  This may be true throughout the tree
+ * but I’ve seen that ContainerID, which represents parenthesis around
+ * parameters to a function also becomes a JBurgAnnotationGeneral because
+ * the BURM theoretically never examines that node in the tree, it examines
+ * its children.
+ *
+ * If a pattern is missing, add the pattern.  A Pattern seems to be a node ID
+ * with a parameter list of the children node ID’s or other Patterns.  The
+ * names you use in the parameter list will be used in the reduction function
+ * later.
+ *
+ * Then add a Rule for it in AS3DebuggerRules.jbg.  
+ *
+ * It seems like the BURM
+ * operates on “levels” of constructs, the higher order construct being an
+ * “expression”.  Expressions are composed of other expressions or lower-level
+ * constructs like name or constants (like uint_constant) or literals (like
+ * boolean_literal.  It seems like, even if the string you want the debugger
+ * to print is just a string or number, it may get “reduced” by the BURM into
+ * higher-level things first.
+ *
+ * So, I think most new Rules for complex patterns will be an expression,
+ * but if it doesn’t recognize a constant of some sort you may need to 
+ * add that.  Anyway, you add an expression like the one in this change list
+ * and then assign a value (or cost) for the rule.  Lower numbers 
+ * (but greater than 0) win.  The actual cost is computed by factoring in the
+ * cost of reducing the children.
+ *
+ * On the next line below the rule and its cost, add, for most things, a
+ * JBurg.reduction method call that you will write to do the reduction. Pass
+ * in the node (__p) and any of the parameters from the Pattern.
+ *
+ * Next, in AS3DebuggerReducer.java, add that reduction method and fill
+ * in the method body.  Try to look for similar reductions and copy what
+ * they do.  For the debugger, you eventually want to return a DebuggerValue.
+ * DebuggerValues seem to be what expressions reduce to and you’ll find they
+ * get passed into the reduction method as well.
+ *
+ */
+// $obj()
+Pattern functionCallSpecial
+FunctionCallID(IdentifierID(void) specialName, ContainerID(expression args*));
+
+
 JBurg.include "AS3DebuggerRules.jbg"

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/edea80cd/debugger/src/flash/tools/debugger/expression/AS3DebuggerReducer.java
----------------------------------------------------------------------
diff --git a/debugger/src/flash/tools/debugger/expression/AS3DebuggerReducer.java b/debugger/src/flash/tools/debugger/expression/AS3DebuggerReducer.java
index 837188c..ad5d651 100644
--- a/debugger/src/flash/tools/debugger/expression/AS3DebuggerReducer.java
+++ b/debugger/src/flash/tools/debugger/expression/AS3DebuggerReducer.java
@@ -647,7 +647,7 @@ public class AS3DebuggerReducer {
 	public int isDoubleLiteral(IASNode iNode) {
 		if (hookallreducercalls)
 			hookforreducercalls("isDoubleLiteral");
-		if (iNode.getNodeID() == ASTNodeID.LiteralNumberID) {
+		if (iNode.getNodeID() == ASTNodeID.LiteralDoubleID) {
 			return 2;
 		}
 		return Integer.MAX_VALUE;
@@ -1156,6 +1156,26 @@ public class AS3DebuggerReducer {
 		return reduce_functionCall_common(iNode, method_name, args, true, false);
 	}
 
+	public Object reduce_functionCallSpecial_to_expression(IASNode iNode,
+			Object method_name, Vector<Object> args) {
+		if (hookallreducercalls)
+			hookforreducercalls("reduce_functionCallSpecial_to_expression");
+		IdentifierNode id = (IdentifierNode)method_name;
+		
+		Context context = contextStack.scope();
+		try {
+			Object[] argValues = new Object[1];
+			for (int i = 0; i < args.size(); i++) {
+				DebuggerValue dv = (DebuggerValue) args.get(i);
+				argValues[i] = dv.debuggerValue;
+			}
+			return new DebuggerValue(callFunction(context, false,
+					id.getName(), argValues));
+		} catch (PlayerDebugException e) {
+			throw new ExpressionEvaluatorException(e);
+		}
+	}
+
 	private Object reduce_functionCall_common(IASNode iNode,
 			Object method_name, Vector<Object> args, boolean need_result,
 			boolean isConstructor) {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/edea80cd/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
index 65e0622..3be6ab7 100644
--- a/debugger/src/flash/tools/debugger/expression/AS3DebuggerRules.jbg
+++ b/debugger/src/flash/tools/debugger/expression/AS3DebuggerRules.jbg
@@ -30,7 +30,7 @@ Op_LogicalOrID(expression l, foldedExpression r);
 
 /*
  *  AS3DebuggerRules.jbg holds the rewrite rules for debugger support.
- *  @see AS3Patterns.jbg, which holds the corresponding patterns.
+ *  @see compiler/CmcPatterns.jbg, which holds the corresponding patterns.
  */
 
 /*
@@ -373,6 +373,9 @@ 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);
 
@@ -674,6 +677,9 @@ 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,


Mime
View raw message