Repository: flex-falcon Updated Branches: refs/heads/develop 44eaace85 -> bb8dcba82
More JSTypeUtil refactoring. - Framework pretty much ready to have major changes if needed. Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/bb8dcba8 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/bb8dcba8 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/bb8dcba8 Branch: refs/heads/develop Commit: bb8dcba825ea085b11fe8c84c0f2bb85251e82f0 Parents: 44eaace Author: Michael Schmalle <[email protected]> Authored: Fri Jun 26 09:05:21 2015 -0400 Committer: Michael Schmalle <[email protected]> Committed: Fri Jun 26 09:05:21 2015 -0400 ---------------------------------------------------------------------- .../externals/reference/ClassReference.java | 5 +- .../externals/reference/FieldReference.java | 2 +- .../codegen/externals/utils/FunctionUtils.java | 5 -- .../codegen/externals/utils/JSTypeUtils.java | 78 +++++--------------- 4 files changed, 19 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bb8dcba8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java index 692d759..d74684a 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java @@ -158,10 +158,7 @@ public class ClassReference extends BaseReference OBJECTLIT 50 */ - JSTypeExpression enumParameterType = comment.getEnumParameterType(); - // XXX Fix this, encapulate toType() - String overrideStringType = JSTypeUtils.transformType(getModel().evaluate( - enumParameterType).toAnnotationString()); + String overrideStringType = JSTypeUtils.toEnumTypeString(this); Node objLit = null; if (node.isVar()) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bb8dcba8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java index f91290b..328f89d 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java @@ -193,7 +193,7 @@ public class FieldReference extends MemberReference { if (overrideStringType != null) return overrideStringType; - return JSTypeUtils.toFieldString(this); + return JSTypeUtils.toFieldTypeString(this); } @Override http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bb8dcba8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java index 8c2d99a..77a5106 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java @@ -41,11 +41,6 @@ public class FunctionUtils else { returnType = JSTypeUtils.toReturnTypeString(reference); - // if (returnType.indexOf("|") != -1 || returnType.indexOf('?') != -1) - // returnType = "*"; - // - // if (returnType.indexOf("|") != -1) - // returnType = "Object /* TODO " + returnType + "*/"; } sb.append(returnType); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bb8dcba8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java index e351870..3b4ae40 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/JSTypeUtils.java @@ -48,7 +48,7 @@ public class JSTypeUtils return "Object"; String type = toTypeExpressionString(reference, expression); - type = transformParamType(type); + type = transformType(type); return type; } @@ -60,12 +60,12 @@ public class JSTypeUtils return "void"; String type = toTypeExpressionString(reference, expression); - type = transformReturnType(type); + type = transformType(type); return type; } - public static String toFieldString(BaseReference reference) + public static String toFieldTypeString(BaseReference reference) { JSTypeExpression expression = reference.getComment().getType(); if (expression == null) @@ -77,6 +77,15 @@ public class JSTypeUtils return type; } + public static String toEnumTypeString(BaseReference reference) + { + JSTypeExpression enumParameterType = reference.getComment().getEnumParameterType(); + String overrideStringType = transformType(reference.getModel().evaluate( + enumParameterType).toAnnotationString()); + + return overrideStringType; + } + public static String toConstantTypeString(ConstantReference reference) { JSTypeExpression expression = reference.getComment().getType(); @@ -91,27 +100,9 @@ public class JSTypeUtils //-------------------------------------------------------------------------- - // XXX shouldn't be public - public static String transformType(String type) - { - HashMap<String, String> map = new HashMap<String, String>(); - map.put("?", "Object /* ? */"); - map.put("*", "*"); - map.put("string", "String"); - map.put("number", "Number"); - map.put("boolean", "Boolean"); - map.put("undefined", "Object /* undefined */"); - map.put("null", "Object /* null */"); - - if (map.containsKey(type)) - return map.get(type); - - return type; - } - - // XXX These are NOT for returned types - private static String transformParamType(String type) + private static String transformType(String type) { + // XXX This is an error but, needs to be reduced in @param union if (type.indexOf("|") != -1) return "Object"; @@ -130,49 +121,15 @@ public class JSTypeUtils return type; } - private static String transformReturnType(String type) - { - if (type.indexOf("|") != -1) - return "Object"; - - HashMap<String, String> map = new HashMap<String, String>(); - map.put("?", "Object /* ? */"); - map.put("*", "*"); - map.put("string", "String"); - map.put("number", "Number"); - map.put("boolean", "Boolean"); - map.put("undefined", "Object /* undefined */"); - map.put("null", "void /* null */"); - - if (map.containsKey(type)) - return map.get(type); - - return type; - } - private static String toTypeExpressionString(BaseReference reference, JSTypeExpression expression) { - String type = null; - - if (expression != null) - { - JSType jsType = getJsType(reference.getModel(), expression); - - if (jsType != null) - { - type = one(jsType); - } - else - { - return "Object"; // TemplateType - } - } - + JSType jsType = getJsType(reference.getModel(), expression); + String type = toTypeString(jsType); return type; } - private static String one(JSType jsType) + private static String toTypeString(JSType jsType) { String type = jsType.toString(); @@ -215,5 +172,4 @@ public class JSTypeUtils return jsType; } - }
