Package tree.type

Examples of tree.type.HaxeType


    {
        if (operationType == null || leftType == null || rightType == null)
        {
            return null;
        }
        HaxeType intType = TypeUtils.getInt();
        switch (operationType)
        {
            //If both expressions are Int then return Int, else if both
            //expressions are either Int or Float then return Float, else return String.
            case PLUS:
                if (leftType.equals(intType) && rightType.equals(intType))
                {
                    return intType;
                }
                HaxeType floatType = TypeUtils.getFloat();
                if ((leftType.equals(intType) || rightType.equals(intType)) &&
                        (leftType.equals(floatType) || rightType.equals(floatType)))
                {
                    return floatType;
                }
                return TypeUtils.getString();
            //Divide two numbers, return Float.
            case DIVIDE:
                if (TypeUtils.areBothNumbers(leftType, rightType))
                {
                    return TypeUtils.getFloat();
                }
                break;
            // Return Int if both are Int and return Float
            // if they are either both Float or mixed.
            case NUMERABLE:
                if (TypeUtils.areBothNumbers(leftType, rightType))
                {
                    return TypeUtils.getCommonPrimaryType(leftType, rightType);
                }
                break;
            // bitwise operations between two Int expressions. Returns Int.
            case BITWISE:
                if (leftType.equals(intType) && rightType.equals(intType))
                {
                    return intType;
                }
                break;
            //perform normal or physical comparisons between two
            //expressions sharing a common type. Returns Bool.
            //TODO we can compare two strings ???????
            case COMPARISON:
                if (TypeUtils.isComparable(leftType, rightType))
                {
                    return TypeUtils.getBool();
                }
                break;
            //Both e1 and e2 must be Bool
            case BOOLEAN:
                HaxeType bool = TypeUtils.getBool();
                if (leftType.equals(bool) && rightType.equals(bool))
                {
                    return leftType;
                }
                break;
View Full Code Here


     * for that operation or NULL (!) if they are not.
     */
    public HaxeType defineResultType()
    {
        BoolOperations operationType = getOperationType();
        HaxeType leftType = getLeftOperand().getHaxeType();
        HaxeType rightType = getRightOperand().getHaxeType();
       
        return super.defineResultType(operationType, leftType, rightType);
    }
View Full Code Here

     * for that operation or NULL (!) if they are not.
     */
    public HaxeType defineResultType()
    {
        BoolOperations operationType = getOperationType();
        HaxeType leftType = getLeftOperand().getHaxeType();
        HaxeType rightType = getRightOperand().getHaxeType();
       
        return super.defineResultType(operationType, leftType, rightType);
    }
View Full Code Here

        HaxeTree expr = getExpression();
        if (getExpression() == null || token == null)
        {
            return;
        }
        HaxeType exprType = expr.getHaxeType();
        if (exprType == null)
        {
            return;
        }
        UnarOperations opType = getOperationTypeByToken(token.getText());
View Full Code Here

    @Override
    public HaxeType getHaxeType()
    {
        if (haxeType == null)
        {
            HaxeType arrayType = TypeUtils.getArray();
            if (arrayType == null || !(arrayType instanceof Class))
            {
                return null;
            }
            ((Class)arrayType).addToParamTypes(getMembersType());
View Full Code Here

    }
   
    private void tryDefineType()
    {
        // for empty arrays
        HaxeType type = TypeUtils.getUnknown();
        for (HaxeTree child : getChildren())
        {
            if (child.getChildIndex() == 0)
            {
                type = child.getHaxeType();
                continue;
            }
            if (child.isUndefinedType())
            {
                // it will leave type of the array as Undefined
                return;
            }
            HaxeType ctype = child.getHaxeType();
            if (TypeUtils.isAvailableAssignement(type, ctype))
            {
                continue;
            }
            else if (TypeUtils.isAvailableAssignement(ctype, type))
View Full Code Here

  public Constant(
          final int ttype, final Token token, final String varType)
  {
      this(token);
    HaxeType constantType = TypeUtils.getStandartTypeByName(varType);
    if (constantType == null)
    {
      setHaxeType(null);
    }
    else
View Full Code Here

        if (INVALID_NAMES.contains(newName))
        {
            return RefactoringStatus.createFatalErrorStatus("New is invalid");
        }
        // Parent class name the same as new var name
        HaxeType type = TreeUtils.getParentType(targetNode);
        HaxeTree decl = type.getDeclaration(newName);
        if (decl != null)
        {
            boolean answer = showConfirmDialog(
                    "Name collision",
                    "Some other variable have the same name, are you still want to rename?");
View Full Code Here

        Declaration firstDecl = (Declaration)tree.getChild(0);
        Declaration secondDecl = (Declaration)tree.getChild(1);
        firstDecl.updateInfo();
        secondDecl.updateInfo();
       
        HaxeType intType = TypeUtils.getInt();
        assertTrue(!firstDecl.getHaxeType().equals(secondDecl.getHaxeType()));
        assertTrue(secondDecl.getHaxeType().equals(intType));
        assertTrue(!firstDecl.getHaxeType().equals(intType));
       
        assertTrue(secondDecl.getChild(secondDecl.getChildCount()-1).getChild(0) instanceof Constant);
View Full Code Here

    {
        HaxeTree tree = parseFunction("function main() { var x:Int; x=123.1;}");
        linker.visit(tree, new Environment());
        Assignment node = TestHelper.getAssignment(tree);
       
        HaxeType firstType = node.getLeftOperand().getHaxeType();
        HaxeType secondType = node.getRightOperand().getHaxeType();
        assertTrue(!TypeUtils.isAvailableAssignement(firstType, secondType));
    }
View Full Code Here

TOP

Related Classes of tree.type.HaxeType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.