@@ -0,0 +1,1872 @@
+package com.redhat.ceylon.compiler.js;%0A%0Aimport com.redhat.ceylon.compiler.typechecker.model.Declaration;%0Aimport com.redhat.ceylon.compiler.typechecker.model.Method;%0Aimport com.redhat.ceylon.compiler.typechecker.tree.Tree;%0A%0Apublic class BmeGenerator %7B%0A%0A    static void generateBme(final Tree.BaseMemberExpression bme, final GenerateJsVisitor gen, final boolean forInvoke) %7B%0A        Declaration decl = bme.getDeclaration();%0A        if (decl != null) %7B%0A            String name = decl.getName();%0A            String pkgName = decl.getUnit().getPackage().getQualifiedNameString();%0A%0A            // map Ceylon true/false/null directly to JS true/false/null%0A            if (%22ceylon.language%22.equals(pkgName)) %7B%0A                if (%22true%22.equals(name) %7C%7C %22false%22.equals(name) %7C%7C %22null%22.equals(name)) %7B%0A                    gen.out(name);%0A                    return;%0A                %7D%0A            %7D%0A        %7D%0A        String exp = gen.memberAccess(bme, null);%0A        if (decl == null && gen.isInDynamicBlock()) %7B%0A            gen.out(%22(typeof %22, exp, %22==='undefined'%7C%7C%22, exp, %22===null?%22);%0A            gen.generateThrow(%22Undefined or null reference: %22 + exp, bme);%0A            gen.out(%22:%22, exp, %22)%22);%0A        %7D else %7B%0A            final boolean isCallable = !forInvoke && decl instanceof Method && decl.isMember()%0A                    && gen.getTypeUtils().callable.equals(bme.getTypeModel().getDeclaration());%0A            String who = null;%0A            if (isCallable) %7B%0A                who = gen.getMember(bme, decl, null);%0A                if (who != null && who.length() %3E 0) %7B%0A                    gen.out(GenerateJsVisitor.getClAlias(), %22JsCallable(/*ESTEMERO*/%22, who, %22,%22);%0A                %7D else %7B%0A                    who = null;%0A                %7D%0A            %7D%0A            gen.out(exp);%0A            if (who != null) %7B%0A                gen.out(%22)%22);%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

refactor BME generation for #306