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

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


                    endLine(true);
                }               
            }
            else if (bmeDecl instanceof MethodOrValue) {
                // "attr = expr;" in an initializer or method
                final MethodOrValue moval = (MethodOrValue)bmeDecl;
                if (moval.isVariable()) {
                    // simple assignment to a variable attribute
                    BmeGenerator.generateMemberAccess(bme, new GenerateCallback() {
                        @Override public void generateValue() {
                            int boxType = boxUnboxStart(expr.getTerm(), moval);
                            if (dynblock > 0 && !Util.isTypeUnknown(moval.getType())
                                    && Util.isTypeUnknown(expr.getTypeModel())) {
                                TypeUtils.generateDynamicCheck(expr, moval.getType(), GenerateJsVisitor.this, false,
                                        expr.getTypeModel().getTypeArguments());
                            } else {
                                expr.visit(GenerateJsVisitor.this);
                            }
                            if (boxType == 4) {
                                out(",");
                                if (moval instanceof Method) {
                                    //Add parameters
                                    TypeUtils.encodeParameterListForRuntime(specStmt,
                                            ((Method)moval).getParameterLists().get(0), GenerateJsVisitor.this);
                                    out(",");
                                } else {
                                    //TODO extract parameters from Value
                                    out("[/*VALUE Callable params", moval.getClass().getName(), "*/],");
                                }
                                TypeUtils.printTypeArguments(expr, expr.getTypeModel().getTypeArguments(),
                                        GenerateJsVisitor.this, false, expr.getTypeModel().getVarianceOverrides());
                            }
                            boxUnboxEnd(boxType);
                        }
                    }, null, this);
                    out(";");
                } else if (moval.isMember()) {
                    if (moval instanceof Method) {
                        //same as fat arrow
                        qualify(specStmt, bmeDecl);
                        out(names.name(moval), "=function ", names.name(moval), "(");
                        //Build the parameter list, we'll use it several times
View Full Code Here


            }
        }
        compareTypes(seq0, seq1, new ArrayList<String>());
        System.out.println("src " + seq0 + " - js " + seq1);
        compareTypeDeclarations(d0, d1);
        MethodOrValue m0 = (MethodOrValue)d0.getDirectMember("last", null, false);
        MethodOrValue m1 = (MethodOrValue)d1.getDirectMember("last", null, false);
        System.out.println("Iterable.last " + m0 + " vs " + m1);
        System.out.println("refined member " + d0.getRefinedMember("last", null, false).getContainer() + " vs " + d1.getRefinedMember("last", null, false).getContainer());
        System.out.println("last is transient? " + m0.isTransient() + " vs " + m1.isTransient());
        System.out.println("refined " + m0.getRefinedDeclaration().getContainer() + " vs " + m1.getRefinedDeclaration().getContainer());
    }
View Full Code Here

                    pm.put(KEY_DEFAULT, 1);
                }
                if (parm.isAtLeastOne()) {
                    pm.put("$min1", 1);
                }
                final MethodOrValue parmtype = parm.getModel();
                if (parmtype != null && parmtype.getDeclarationKind()==DeclarationKind.TYPE_PARAMETER) {
                    pm.put(KEY_TYPE, parmtype.getName());
                } else {
                    pm.put(KEY_TYPE, typeMap(parm.getType(), from));
                }
                if (parm.isHidden()) {
                    pm.put("$hdn", 1);
View Full Code Here

    }

    public String name(Parameter param) {
        if (param == null) { return null; }
        String name = param.getName();
        MethodOrValue decl = param.getModel();
        final boolean nonLocal = (decl.isShared() && decl.isMember())
                || (decl.isToplevel() && decl instanceof Method);
        if (nonLocal) {
            // The identifier might be accessed from other .js files, so it must
            // be reliably reproducible. In most cases simply using the original
            // name is ok because otherwise it would result in a name collision in
            // Ceylon too. We just have to take care of a few exceptions:
View Full Code Here

                    Tree.BaseMemberExpression bme =
                            (Tree.BaseMemberExpression) me;
                    bme.setDeclaration(that.getDeclaration());
                }
                else if (d instanceof MethodOrValue) {
                    MethodOrValue mv = (MethodOrValue) d;
                    if (mv.isShortcutRefinement()) {
                        String desc;
                        if (d instanceof Value) {
                            desc = "value";
                        }
                        else {
                            desc = "function";
                        }
                        me.addError(desc + " already specified: '" +
                                    d.getName(unit) + "'");
                    }
                    else if (!mv.isVariable() && !mv.isLate()) {
                        String desc;
                        if (d instanceof Value) {
                            desc = "value is neither variable nor late and";
                        }
                        else {
                            desc = "function";
                        }
                        if (mv.isToplevel()) {
                            me.addError("toplevel " + desc +
                                    " may not be specified: '" +
                                    d.getName(unit) + "'", 803);
                        }
                        else if (!mv.isDefinedInScope(that.getScope())) {
                            me.addError(desc + " may not be specified here: '" +
                                    d.getName(unit) + "'", 803);
                        }
                    }
                }
View Full Code Here

    }
   
    @Override public void visit(Tree.InitializerParameter that) {
        super.visit(that);
        Parameter p = that.getParameterModel();
        MethodOrValue model = p.getModel();
        if (model!=null) {
          ProducedType type =
                  model.getTypedReference().getFullType();
          if (type!=null && !isTypeUnknown(type)) {
            checkType(type, that.getSpecifierExpression());
          }
        }
        else {
View Full Code Here

        }
    }

    private void checkAliasArg(Parameter param, Tree.Expression e) {
        if (e!=null && param!=null) {
            MethodOrValue p = param.getModel();
            if (p!=null) {
                Tree.Term term = e.getTerm();
                if (term instanceof Tree.BaseMemberExpression) {
                    Declaration d =
                            ((Tree.BaseMemberExpression) term).getDeclaration();
                    if (d!=null && !d.equals(p)) {
                        e.addUnsupportedError("argument must be a parameter reference to " +
                                p.getName());
                    }
                }
                else {
                    e.addUnsupportedError("argument must be a parameter reference to " +
                            p.getName());
                }
            }
        }
    }
View Full Code Here

            }
            /*else if (a.isDefault()) {
                that.addError("initializer parameter refers to a default attribute: " +
                        d.getName());
            }*/
            MethodOrValue mov = (MethodOrValue) a;
            mov.setInitializerParameter(p);
            p.setModel(mov);
        }
        /*if (d.isHidden() && d.getDeclaration() instanceof Method) {
            if (a instanceof Method) {
                that.addWarning("initializer parameters for inner methods of methods not yet supported");
View Full Code Here

        if (Decl.equal(declaration, refinedDeclaration)
                && declaration instanceof MethodOrValue
                && ((MethodOrValue)declaration).isParameter()
                && declaration.getContainer() instanceof Class){
            // maybe it is really inherited from a field?
            MethodOrValue methodOrValueForParam = (MethodOrValue)declaration;
            if(methodOrValueForParam != null){
                // make sure we get the refined version of that member
                refinedDeclaration = (TypedDeclaration) methodOrValueForParam.getRefinedDeclaration();
            }
        }
       
        // inherit underlying type constraints
        if(!Decl.equal(refinedDeclaration, declaration) && type.getUnderlyingType() == null
View Full Code Here

    /**
     * Determines whether a method wrapping the Callable should be generated
     * for a FunctionalParameter
     */
    static boolean createMethod(Parameter parameter) {
        MethodOrValue model = parameter.getModel();
        return createMethod(model);
    }
View Full Code Here

TOP

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

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.