Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Unit


        URI fromUrl = getAbsoluteObjectUrl(from);
        Module module = getModule(from);
        String filename;
        File folder;
        if (modPkgOrDecl instanceof Element) {
            Unit unit = ((Element)modPkgOrDecl).getUnit();
            filename = unit.getFilename();
            folder = getFolder(unit.getPackage());
        } else if (modPkgOrDecl instanceof Package) {
            filename = "package.ceylon";
            folder = getFolder((Package)modPkgOrDecl);
        } else if (modPkgOrDecl instanceof Module) {
            Module moduleDecl = (Module)modPkgOrDecl;
View Full Code Here


   
    private boolean isConstantValue(Declaration d) {
        if(Decl.isValue(d)) {
            Value value = (Value) d;
            if( value.isShared() && !value.isVariable() ) {
                Unit unit = value.getUnit();
                TypeDeclaration type = value.getTypeDeclaration();
               
                if (type == unit.getSequentialDeclaration()) {
                    ProducedType elementType = unit.getIteratedType(value.getType());
                    type = elementType.getDeclaration();
                }

                if (unit.getStringDeclaration().equals(type)
                        || unit.getIntegerDeclaration().equals(type)
                        || unit.getFloatDeclaration().equals(type)
                        || unit.getCharacterDeclaration().equals(type)) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

    public static boolean inlinePowerAsMultiplication(Tree.PowerOp op) {
        java.lang.Long power;
        try {
            power = ExpressionTransformer.getIntegerLiteralPower(op);
            if (power != null) {
                Unit unit = op.getUnit();
                ProducedType baseType = op.getLeftTerm().getTypeModel();
                // Although the optimisation still works for powers > 64, it ends
                // up bloating the code (e.g. imagine x^1_000_000_000)
                if (power > 0
                        && power <= 64
                        && baseType.isExactly(unit.getIntegerDeclaration().getType())) {
                    return true;
                }
                else if (power > 0
                        && power <= 64
                        && baseType.isExactly(unit.getFloatDeclaration().getType())) {
                    return true;
                }
            }
        } catch (ErroneousException e) {
            return false;
View Full Code Here

        this.elements = prevElements;
        appendLiteralArgument(t, (CollectionLiteralAnnotationTerm)this.term);
    }

    private CollectionLiteralAnnotationTerm startCollection(Tree.Term t) {
        Unit unit = t.getUnit();
        // Continue the visit to collect the elements
        ProducedType iteratedType = unit.getIteratedType(parameter().getType());
        TypeDeclaration declaration = iteratedType.getDeclaration();
        LiteralAnnotationTerm factory;
        if (unit.getStringDeclaration().equals(declaration)) {
            factory = StringLiteralAnnotationTerm.FACTORY;
        } else if (unit.getIntegerDeclaration().equals(declaration)) {
            factory = IntegerLiteralAnnotationTerm.FACTORY;
        } else if (unit.getCharacterDeclaration().equals(declaration)) {
            factory = CharacterLiteralAnnotationTerm.FACTORY;
        } else if (unit.getBooleanDeclaration().equals(declaration)) {
            factory = BooleanLiteralAnnotationTerm.FACTORY;
        } else if (unit.getFloatDeclaration().equals(declaration)) {
            factory = FloatLiteralAnnotationTerm.FACTORY;
        } else if (Decl.isEnumeratedTypeWithAnonCases(iteratedType)) {
            factory = ObjectLiteralAnnotationTerm.FACTORY;
        } else if (Decl.isAnnotationClass(declaration)) {
            t.addError("compiler bug: iterables of annotation classes or annotation constructors not supported as literal " + (checkingDefaults ? "defaulted parameters" : "arguments"));
            return null;
        } else if (iteratedType.isSubtypeOf(((TypeDeclaration)unit.getLanguageModuleDeclarationDeclaration("Declaration")).getType())) {
            factory = DeclarationLiteralAnnotationTerm.FACTORY;
        } else {
            throw new RuntimeException();
        }
        CollectionLiteralAnnotationTerm result = this.elements;
View Full Code Here

        }

        LazyPackage pkg = findOrCreatePackage(module, pkgName);

        // find/make its Unit
        Unit unit = getCompiledUnit(pkg, classMirror);

        // set all the containers
        for(Declaration d : decls){
       
            // add it to its Unit
            d.setUnit(unit);
            unit.addDeclaration(d);

            setContainer(classMirror, d, pkg);
        }

        return decl;
View Full Code Here

        }
        return true;
    }

    protected Unit getCompiledUnit(LazyPackage pkg, ClassMirror classMirror) {
        Unit unit = unitsByPackage.get(pkg);
        if(unit == null){
            unit = new Unit();
            unit.setPackage(pkg);
            unitsByPackage.put(pkg, unit);
        }
        return unit;
    }
View Full Code Here

        Package pkg = packages.get(0);
        if(pkg instanceof LazyPackage == false){
            System.err.println("No lazy package for module "+module.getNameAsString());
            return null;
        }
        Unit unit = getCompiledUnit((LazyPackage) pkg, null);
        if(unit == null){
            System.err.println("No unit for module "+module.getNameAsString());
            return null;
        }
        return unit;
View Full Code Here

        char[] oldType = lexer.type;
        int oldIndex = lexer.index;
        int oldMark = lexer.mark;
        Scope oldScope = this.scope;
        Module oldModuleScope = this.moduleScope;
        Unit oldUnit = this.unit;
        try{
            // setup the new state
            lexer.setup(type);
            this.scope = scope;
            this.moduleScope = moduleScope;
View Full Code Here

  protected Logger log;
 
    public ReflectionModelLoader(ModuleManager moduleManager, Modules modules, Logger log){
        this.moduleManager = moduleManager;
        this.modules = modules;
        this.typeFactory = new Unit();
        this.typeParser = new TypeParser(this);
        this.timer = new Timer(false);
        this.log = log;
    }
View Full Code Here

        // Delegate to an external typechecker (e.g. the IDE build)
        compilerDelegate.typeCheck(listOfUnits);

        // This phase is proper to the Java backend
        for (PhasedUnit pu : listOfUnits) {
            Unit unit = pu.getUnit();
            final CompilationUnit compilationUnit = pu.getCompilationUnit();
            for (Declaration d: unit.getDeclarations()) {
                if (d instanceof TypedDeclaration && !(d instanceof Setter)) {
                    compilationUnit.visit(new MethodOrValueReferenceVisitor((TypedDeclaration) d));
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Unit

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.