Search in sources :

Example 16 with Position

use of lucee.transformer.Position in project Lucee by lucee.

the class CFMLCompilerImpl method _compile.

/*private byte[] _compiless(ConfigImpl config,PageSource ps,SourceCode sc,String className, TagLib[] tld, FunctionLib[] fld, 
			Resource classRootDir,TransfomerSettings settings) throws TemplateException {
		Factory factory = BytecodeFactory.getInstance(config);
		
		Page page=null;
		
		TagLib[][] _tlibs=new TagLib[][]{null,new TagLib[0]};
		_tlibs[CFMLTransformer.TAG_LIB_GLOBAL]=tld;
		// reset page tlds
		if(_tlibs[CFMLTransformer.TAG_LIB_PAGE].length>0) {
			_tlibs[CFMLTransformer.TAG_LIB_PAGE]=new TagLib[0];
		}
		
		CFMLScriptTransformer scriptTransformer = new CFMLScriptTransformer();
		scriptTransformer.transform(
				BytecodeFactory.getInstance(config)
				, page
				, new EvaluatorPool()
				, _tlibs, fld
				, null
				, config.getCoreTagLib(ps.getDialect()).getScriptTags()
				, sc
				, settings);
		
		//CFMLExprTransformer extr=new CFMLExprTransformer();
		//extr.transform(factory, page, ep, tld, fld, scriptTags, cfml, settings)
		
		return null;
	}*/
private Result _compile(ConfigImpl config, PageSource ps, SourceCode sc, String className, TagLib[] tld, FunctionLib[] fld, Resource classRootDir, boolean returnValue, boolean ignoreScopes) throws TemplateException, IOException {
    if (className == null)
        className = ps.getClassName();
    Result result = null;
    // byte[] barr = null;
    Page page = null;
    Factory factory = BytecodeFactory.getInstance(config);
    try {
        page = sc == null ? cfmlTransformer.transform(factory, config, ps, tld, fld, returnValue, ignoreScopes) : cfmlTransformer.transform(factory, config, sc, tld, fld, System.currentTimeMillis(), sc.getDialect() == CFMLEngine.DIALECT_CFML && config.getDotNotationUpperCase(), returnValue, ignoreScopes);
        page.setSplitIfNecessary(false);
        try {
            result = new Result(page, page.execute(className));
        } catch (RuntimeException re) {
            String msg = StringUtil.emptyIfNull(re.getMessage());
            if (StringUtil.indexOfIgnoreCase(msg, "Method code too large!") != -1) {
                page = sc == null ? cfmlTransformer.transform(factory, config, ps, tld, fld, returnValue, ignoreScopes) : cfmlTransformer.transform(factory, config, sc, tld, fld, System.currentTimeMillis(), sc.getDialect() == CFMLEngine.DIALECT_CFML && config.getDotNotationUpperCase(), returnValue, ignoreScopes);
                page.setSplitIfNecessary(true);
                result = new Result(page, page.execute(className));
            } else
                throw re;
        } catch (ClassFormatError cfe) {
            String msg = StringUtil.emptyIfNull(cfe.getMessage());
            if (StringUtil.indexOfIgnoreCase(msg, "Invalid method Code length") != -1) {
                page = ps != null ? cfmlTransformer.transform(factory, config, ps, tld, fld, returnValue, ignoreScopes) : cfmlTransformer.transform(factory, config, sc, tld, fld, System.currentTimeMillis(), sc.getDialect() == CFMLEngine.DIALECT_CFML && config.getDotNotationUpperCase(), returnValue, ignoreScopes);
                page.setSplitIfNecessary(true);
                result = new Result(page, page.execute(className));
            } else
                throw cfe;
        }
        // store
        if (classRootDir != null) {
            Resource classFile = classRootDir.getRealResource(page.getClassName() + ".class");
            Resource classFileDirectory = classFile.getParentResource();
            if (!classFileDirectory.exists())
                classFileDirectory.mkdirs();
            IOUtil.copy(new ByteArrayInputStream(result.barr), classFile, true);
        }
        return result;
    } catch (AlreadyClassException ace) {
        byte[] bytes = ace.getEncrypted() ? readEncrypted(ace) : readPlain(ace);
        result = new Result(null, bytes);
        String displayPath = ps != null ? "[" + ps.getDisplayPath() + "] " : "";
        String srcName = ASMUtil.getClassName(result.barr);
        int dialect = sc == null ? ps.getDialect() : sc.getDialect();
        // source is cfm and target cfc
        if (dialect == CFMLEngine.DIALECT_CFML && endsWith(srcName, Constants.getCFMLTemplateExtensions(), dialect) && className.endsWith("_" + Constants.getCFMLComponentExtension() + (dialect == CFMLEngine.DIALECT_CFML ? Constants.CFML_CLASS_SUFFIX : Constants.LUCEE_CLASS_SUFFIX))) {
            throw new TemplateException("source file " + displayPath + "contains the bytecode for a regular cfm template not for a component");
        }
        // source is cfc and target cfm
        if (dialect == CFMLEngine.DIALECT_CFML && srcName.endsWith("_" + Constants.getCFMLComponentExtension() + (dialect == CFMLEngine.DIALECT_CFML ? Constants.CFML_CLASS_SUFFIX : Constants.LUCEE_CLASS_SUFFIX)) && endsWith(className, Constants.getCFMLTemplateExtensions(), dialect))
            throw new TemplateException("source file " + displayPath + "contains a component not a regular cfm template");
        // rename class name when needed
        if (!srcName.equals(className))
            result = new Result(result.page, ClassRenamer.rename(result.barr, className));
        // store
        if (classRootDir != null) {
            Resource classFile = classRootDir.getRealResource(className + ".class");
            Resource classFileDirectory = classFile.getParentResource();
            if (!classFileDirectory.exists())
                classFileDirectory.mkdirs();
            result = new Result(result.page, Page.setSourceLastModified(result.barr, ps != null ? ps.getPhyscalFile().lastModified() : System.currentTimeMillis()));
            IOUtil.copy(new ByteArrayInputStream(result.barr), classFile, true);
        }
        return result;
    } catch (TransformerException bce) {
        Position pos = bce.getPosition();
        int line = pos == null ? -1 : pos.line;
        int col = pos == null ? -1 : pos.column;
        if (ps != null)
            bce.addContext(ps, line, col, null);
        throw bce;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TemplateException(lucee.runtime.exp.TemplateException) Position(lucee.transformer.Position) Resource(lucee.commons.io.res.Resource) BytecodeFactory(lucee.transformer.bytecode.BytecodeFactory) Factory(lucee.transformer.Factory) Page(lucee.transformer.bytecode.Page) AlreadyClassException(lucee.transformer.util.AlreadyClassException) TransformerException(lucee.transformer.TransformerException)

Example 17 with Position

use of lucee.transformer.Position in project Lucee by lucee.

the class CFMLTransformer method literal.

/**
 * Liest Literale Zeichenketten ein die sich innerhalb und auserhalb von tgas befinden,
 * beim Einlesen wird unterschieden ob Expression geparsst werden muessen oder nicht,
 * dies ist abhaengig, von der Definition des Tag in dem man sich allenfalls befindet, innerhalb der TLD.
 * @param parent uebergeordnetes Element.
 * @param parseExpression Definiert on Expressions geparset werden sollen oder nicht.
 * @param transformer Expression Transfomer zum uebersetzen der Expressions innerhalb des Literals.
 * @throws TemplateException
 *
 * <br />
 * EBNF:<br />
 * <code>("<" | {?-"#"-"<"} "<" | {"#" expression "#"} "<" ) | ({?-"<"} "<")
 *			(* Welcher Teil der "oder" Bedingung ausgefuehrt wird, ist abhaengig ob die Tag-Lib vorgibt,
 *			 dass Expression geparst werden sollen oder nicht. *)</code>
 */
private void literal(TagData data, Body parent, boolean parseExpression, ExprTransformer transformer) throws TemplateException {
    // with expression
    if (parseExpression) {
        if (data.srcCode.isAfterLast())
            return;
        // data.cfml.getCurrent()
        StringBuffer text = new StringBuffer();
        int count = 0;
        while (data.srcCode.isValidIndex()) {
            count++;
            // #
            if (data.srcCode.isCurrent('#')) {
                data.srcCode.next();
                if (data.srcCode.isCurrent('#')) {
                    text.append('#');
                } else {
                    if (text.length() > 0) {
                        Position end = data.srcCode.getPosition();
                        Position start = data.srcCode.getPosition(end.pos - text.length());
                        parent.addPrintOut(data.factory, text.toString(), start, end);
                        start = end;
                        text = new StringBuffer();
                    }
                    Position end = data.srcCode.getPosition();
                    Position start = data.srcCode.getPosition(end.pos - text.length());
                    PrintOut po;
                    parent.addStatement(po = new PrintOut(transformer.transform(data.factory, data.root, data.ep, data.tlibs, data.flibs, data.scriptTags, data.srcCode, data.settings), start, end));
                    po.setEnd(data.srcCode.getPosition());
                    if (!data.srcCode.isCurrent('#'))
                        throw new TemplateException(data.srcCode, "missing terminating [#] for expression");
                }
            } else if (data.srcCode.isCurrent('<') && count > 1) {
                break;
            } else
                text.append(data.srcCode.getCurrent());
            data.srcCode.next();
        }
        if (text.length() > 0) {
            Position end = data.srcCode.getPosition();
            Position start = data.srcCode.getPosition(end.pos - text.length());
            parent.addPrintOut(data.factory, text.toString(), start, end);
        }
    } else // no expression
    {
        int start = data.srcCode.getPos();
        data.srcCode.next();
        int end = data.srcCode.indexOfNext('<');
        String text;
        if (end == -1) {
            text = data.srcCode.substring(start);
            data.srcCode.setPos(data.srcCode.length());
        } else {
            text = data.srcCode.substring(start, end - start);
            data.srcCode.setPos(end);
        }
        Position e = data.srcCode.getPosition();
        Position s = data.srcCode.getPosition(start);
        parent.addPrintOut(data.factory, text, s, e);
    }
}
Also used : PrintOut(lucee.transformer.bytecode.statement.PrintOut) Position(lucee.transformer.Position) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) TemplateException(lucee.runtime.exp.TemplateException) LitString(lucee.transformer.expression.literal.LitString)

Example 18 with Position

use of lucee.transformer.Position in project Lucee by lucee.

the class CFMLTransformer method tag.

/**
 * Liest einen Tag ein, prueft hierbei ob das Tag innerhalb einer der geladenen Tag-Lib existiert,
 * ansonsten wird ein Tag einfach als literal-string aufgenommen.
 * <br />
 * EBNF:<br />
 * <code>name-space identifier spaces attributes ("/>" | ">" [body "</" identifier spaces ">"]);(* Ob dem Tag ein Body und ein End-Tag folgt ist abhaengig von Definition des body-content in Tag-Lib, gleices gilt fuer appendix *)</code>
 * @param parent uebergeornetes Tag
 * @param parseExpression sollen Expresson innerhalb des Body geparste werden oder nicht.
 * @return Gibt zurueck ob es sich um ein Tag as einer Tag-Lib handelte oder nicht.
 * @throws TemplateException
 */
private boolean tag(TagData data, Body parent, boolean parseExpression) throws TemplateException {
    // lucee.print.ln("--->"+data.cfml.getCurrent());
    boolean hasBody = false;
    Position line = data.srcCode.getPosition();
    // int column=data.cfml.getColumn();
    int start = data.srcCode.getPos();
    data.srcCode.next();
    // read in namespace of tag
    TagLib tagLib = nameSpace(data);
    // return if no matching tag lib
    if (tagLib == null) {
        data.srcCode.previous();
        return false;
    }
    // Get matching tag from tag lib
    String strNameNormal = identifier(data.srcCode, false, true);
    if (strNameNormal == null) {
        data.srcCode.setPos((data.srcCode.getPos() - tagLib.getNameSpaceAndSeparator().length()) - 1);
        return false;
    }
    String strName = strNameNormal.toLowerCase();
    String appendix = null;
    TagLibTag tagLibTag = tagLib.getTag(strName);
    // get taglib
    if (tagLibTag == null) {
        tagLibTag = tagLib.getAppendixTag(strName);
        if (tagLibTag == null) {
            if (tagLib.getIgnoreUnknowTags()) {
                data.srcCode.setPos(start);
                return false;
            }
            throw new TemplateException(data.srcCode, "undefined tag [" + tagLib.getNameSpaceAndSeparator() + strName + "]");
        }
        appendix = StringUtil.removeStartingIgnoreCase(strNameNormal, tagLibTag.getName());
    }
    // CFXD Element
    Tag tag;
    try {
        tag = tagLibTag.getTag(data.factory, line, data.srcCode.getPosition());
    } catch (Exception e) {
        throw new TemplateException(data.srcCode, e);
    }
    parent.addStatement(tag);
    // get tag from tag library
    if (appendix != null) {
        tag.setAppendix(appendix);
        tag.setFullname(tagLibTag.getFullName().concat(appendix));
    } else {
        tag.setFullname(tagLibTag.getFullName());
    }
    // if(tag.getFullname().equalsIgnoreCase("cfcomponent"))data.page.setIsComponent(true);	// MUST to hardcoded, to better
    // else if(tag.getFullname().equalsIgnoreCase("cfinterface"))data.page.setIsInterface(true);	// MUST to hardcoded, to better
    tag.setTagLibTag(tagLibTag);
    comment(data.srcCode, true);
    // Tag Translator Evaluator
    if (tagLibTag.hasTTE()) {
        data.ep.add(tagLibTag, tag, data.flibs, data.srcCode);
    }
    // get Attributes
    attributes(data, tagLibTag, tag);
    if (tagLibTag.hasAttributeEvaluator()) {
        try {
            tagLibTag = tagLibTag.getAttributeEvaluator().evaluate(tagLibTag, tag);
        } catch (AttributeEvaluatorException e) {
            throw new TemplateException(data.srcCode, e);
        }
    }
    // TODO muss erlaubt sein
    if (data.srcCode.forwardIfCurrent('>')) {
        hasBody = tagLibTag.getHasBody();
    } else if (data.srcCode.forwardIfCurrent('/', '>')) {
        if (tagLibTag.getHasBody())
            tag.setBody(new BodyBase(data.factory));
    } else {
        throw createTemplateException(data.srcCode, "tag [" + tagLibTag.getFullName() + "] is not closed", tagLibTag);
    }
    // Body
    if (hasBody) {
        // get Body
        if (tagLibTag.isTagDependent()) {
            // get TagDependentBodyTransformer
            TagDependentBodyTransformer tdbt = null;
            try {
                tdbt = tagLibTag.getBodyTransformer();
            } catch (TagLibException e) {
                throw new TemplateException(data.srcCode, e);
            }
            if (tdbt == null)
                throw createTemplateException(data.srcCode, "Tag dependent body Transformer is invalid for Tag [" + tagLibTag.getFullName() + "]", tagLibTag);
            tag.setBody(tdbt.transform(data.factory, data.root, data.ep, data.tlibs, data.flibs, tagLibTag.getFullName(), data.scriptTags, data.srcCode, data.settings));
            // get TagLib of end Tag
            if (!data.srcCode.forwardIfCurrent("</")) {
                // MUST this is a patch, do a more proper implementation
                TemplateException te = new TemplateException(data.srcCode, "invalid construct");
                if (tdbt instanceof CFMLScriptTransformer && ASMUtil.containsComponent(tag.getBody())) {
                    throw new CFMLScriptTransformer.ComponentTemplateException(te);
                }
                throw te;
            }
            TagLib tagLibEnd = nameSpace(data);
            // same NameSpace
            if (!(tagLibEnd != null && tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())))
                throw new TemplateException(data.srcCode, "invalid construct");
            // get end Tag
            String strNameEnd = identifier(data.srcCode, true, true).toLowerCase();
            // not the same name Tag
            if (!strName.equals(strNameEnd)) {
                data.srcCode.setPos(start);
                throw new TemplateException(data.srcCode, "Start and End Tag has not the same Name [" + tagLib.getNameSpaceAndSeparator() + strName + "-" + tagLibEnd.getNameSpaceAndSeparator() + strNameEnd + "]");
            }
            data.srcCode.removeSpace();
            if (!data.srcCode.forwardIfCurrent('>'))
                throw new TemplateException(data.srcCode, "End Tag [" + tagLibEnd.getNameSpaceAndSeparator() + strNameEnd + "] not closed");
        } else {
            // get body of Tag
            BodyBase body = new BodyBase(data.factory);
            body.setParent(tag);
            // parseExpression=(tagLibTag.getParseBody())?true:parseExpression;
            if (tagLibTag.getParseBody())
                parseExpression = true;
            while (true) {
                // Load Expession Transformer from TagLib
                ExprTransformer transfomer = null;
                if (parseExpression) {
                    try {
                        transfomer = tagLibTag.getTagLib().getExprTransfomer();
                    } catch (TagLibException e) {
                        throw new TemplateException(data.srcCode, e);
                    }
                }
                // call body
                body(data, body, parseExpression, transfomer);
                // no End Tag
                if (data.srcCode.isAfterLast()) {
                    if (tagLibTag.isBodyReq()) {
                        data.srcCode.setPos(start);
                        throw createTemplateException(data.srcCode, "No matching end tag found for tag [" + tagLibTag.getFullName() + "]", tagLibTag);
                    }
                    body.moveStatmentsTo(parent);
                    return executeEvaluator(data, tagLibTag, tag);
                }
                // Invalid Construct
                int posBeforeEndTag = data.srcCode.getPos();
                if (!data.srcCode.forwardIfCurrent('<', '/'))
                    throw createTemplateException(data.srcCode, "Missing end tag for [" + tagLibTag.getFullName() + "]", tagLibTag);
                // get TagLib of end Tag
                int _start = data.srcCode.getPos();
                TagLib tagLibEnd = nameSpace(data);
                // same NameSpace
                if (tagLibEnd != null) {
                    String strNameEnd = "";
                    // lucee.print.ln(data.cfml.getLine()+" - "+data.cfml.getColumn()+" - "+tagLibEnd.getNameSpaceAndSeperator()+".equals("+tagLib.getNameSpaceAndSeperator()+")");
                    if (tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())) {
                        // get end Tag
                        strNameEnd = identifier(data.srcCode, true, true).toLowerCase();
                        // not the same name Tag
                        // new part
                        data.srcCode.removeSpace();
                        if (strName.equals(strNameEnd)) {
                            if (!data.srcCode.forwardIfCurrent('>'))
                                throw new TemplateException(data.srcCode, "End Tag [" + tagLibEnd.getNameSpaceAndSeparator() + strNameEnd + "] not closed");
                            break;
                        }
                    }
                    // new part
                    if (tagLibTag.isBodyReq()) {
                        TagLibTag endTag = tagLibEnd.getTag(strNameEnd);
                        if (endTag != null && !endTag.getHasBody())
                            throw new TemplateException(data.srcCode, "End Tag [" + tagLibEnd.getNameSpaceAndSeparator() + strNameEnd + "] is not allowed, for this tag only a Start Tag is allowed");
                        data.srcCode.setPos(start);
                        if (tagLibEnd.getIgnoreUnknowTags() && (tagLibEnd.getTag(strNameEnd)) == null) {
                            data.srcCode.setPos(_start);
                        } else
                            throw new TemplateException(data.srcCode, "Start and End Tag has not the same Name [" + tagLib.getNameSpaceAndSeparator() + strName + "-" + tagLibEnd.getNameSpaceAndSeparator() + strNameEnd + "]");
                    } else {
                        body.moveStatmentsTo(parent);
                        data.srcCode.setPos(posBeforeEndTag);
                        return executeEvaluator(data, tagLibTag, tag);
                    }
                // / new part
                }
                body.addPrintOut(data.factory, "</", null, null);
            }
            tag.setBody(body);
        }
    }
    if (tag instanceof StatementBase)
        ((StatementBase) tag).setEnd(data.srcCode.getPosition());
    return executeEvaluator(data, tagLibTag, tag);
}
Also used : CFMLScriptTransformer(lucee.transformer.cfml.script.CFMLScriptTransformer) TagLibTag(lucee.transformer.library.tag.TagLibTag) AttributeEvaluatorException(lucee.transformer.cfml.attributes.AttributeEvaluatorException) Position(lucee.transformer.Position) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) TemplateException(lucee.runtime.exp.TemplateException) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) SimpleExprTransformer(lucee.transformer.cfml.expression.SimpleExprTransformer) ExprTransformer(lucee.transformer.cfml.ExprTransformer) LitString(lucee.transformer.expression.literal.LitString) TagLibException(lucee.transformer.library.tag.TagLibException) EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) AttributeEvaluatorException(lucee.transformer.cfml.attributes.AttributeEvaluatorException) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) TagLibException(lucee.transformer.library.tag.TagLibException) TemplateException(lucee.runtime.exp.TemplateException) IOException(java.io.IOException) ApplicationException(lucee.runtime.exp.ApplicationException) ProcessingDirectiveException(lucee.transformer.cfml.evaluator.impl.ProcessingDirectiveException) StatementBase(lucee.transformer.bytecode.statement.StatementBase) TagLib(lucee.transformer.library.tag.TagLib) CustomTagLib(lucee.transformer.library.tag.CustomTagLib) TagLibTag(lucee.transformer.library.tag.TagLibTag) Tag(lucee.transformer.bytecode.statement.tag.Tag) BodyBase(lucee.transformer.bytecode.BodyBase)

Example 19 with Position

use of lucee.transformer.Position in project Lucee by lucee.

the class AbstrCFMLExprTransformer method _unaryOp.

private Expression _unaryOp(ExprData data, Expression expr, int op) throws TemplateException {
    Position leftEnd = expr.getEnd(), start = null, end = null;
    comments(data);
    if (leftEnd != null) {
        start = leftEnd;
        end = new Position(leftEnd.line, leftEnd.column + 2, leftEnd.pos + 2);
    }
    return new OPUnary((Variable) expr, data.factory.DOUBLE_ONE(), OPUnary.POST, op, start, end);
// ExprDouble res = OpDouble.toExprDouble(expr, LitDouble.toExprDouble(1D,start,end),opr);
// expr=new OpVariable((Variable)expr,res,data.cfml.getPosition());
// return OpDouble.toExprDouble(expr,LitDouble.toExprDouble(1D,start,end),opr==OpDouble.PLUS? OpDouble.MINUS:OpDouble.PLUS);
}
Also used : Position(lucee.transformer.Position) OPUnary(lucee.transformer.bytecode.op.OPUnary)

Example 20 with Position

use of lucee.transformer.Position in project Lucee by lucee.

the class AbstrCFMLExprTransformer method subDynamic.

private Expression subDynamic(ExprData data, Expression expr, boolean tryStatic, boolean isStaticChild) throws TemplateException {
    String name = null;
    Invoker invoker = null;
    // Loop over nested Variables
    boolean safeNavigation;
    while (data.srcCode.isValidIndex()) {
        safeNavigation = false;
        ExprString nameProp = null, namePropUC = null;
        // []
        if (data.srcCode.forwardIfCurrent('[')) {
            isStaticChild = false;
            // get Next Var
            nameProp = structElement(data);
            namePropUC = nameProp;
            // Valid Syntax ???
            if (!data.srcCode.forwardIfCurrent(']'))
                throw new TemplateException(data.srcCode, "Invalid Syntax Closing []] not found");
        } else // .
        if (isStaticChild || data.srcCode.forwardIfCurrent('.') || (safeNavigation = data.srcCode.forwardIfCurrent('?', '.'))) {
            isStaticChild = false;
            // Extract next Var String
            comments(data);
            Position line = data.srcCode.getPosition();
            name = identifier(data, true);
            if (name == null)
                throw new TemplateException(data.srcCode, "Invalid identifier");
            comments(data);
            nameProp = Identifier.toIdentifier(data.factory, name, line, data.srcCode.getPosition());
            namePropUC = Identifier.toIdentifier(data.factory, name, data.settings.dotNotationUpper ? Identifier.CASE_UPPER : Identifier.CASE_ORIGNAL, line, data.srcCode.getPosition());
        } else // finish
        {
            break;
        }
        comments(data);
        if (expr instanceof Invoker) {
            invoker = (Invoker) expr;
        } else {
            invoker = new ExpressionInvoker(expr);
            expr = invoker;
        }
        // safe navigation
        Member member;
        if (safeNavigation) {
            List<Member> members = invoker.getMembers();
            if (members.size() > 0) {
                member = members.get(members.size() - 1);
                member.setSafeNavigated(true);
            }
        }
        // Method
        if (data.srcCode.isCurrent('(')) {
            // properly this is never used
            if (nameProp == null && name != null)
                nameProp = Identifier.toIdentifier(data.factory, name, Identifier.CASE_ORIGNAL, null, null);
            invoker.addMember(member = getFunctionMember(data, nameProp, false));
        } else
            // property
            invoker.addMember(member = data.factory.createDataMember(namePropUC));
        if (safeNavigation) {
            member.setSafeNavigated(true);
        }
    }
    // STATIC SCOPE CALL
    if (tryStatic) {
        comments(data);
        Expression staticCall = staticScope(data, expr);
        if (staticCall != null)
            return staticCall;
    }
    return expr;
}
Also used : ExpressionInvoker(lucee.transformer.bytecode.expression.ExpressionInvoker) Invoker(lucee.transformer.expression.Invoker) ExpressionInvoker(lucee.transformer.bytecode.expression.ExpressionInvoker) ExprString(lucee.transformer.expression.ExprString) TemplateException(lucee.runtime.exp.TemplateException) Position(lucee.transformer.Position) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) LitString(lucee.transformer.expression.literal.LitString) ExprString(lucee.transformer.expression.ExprString) FunctionMember(lucee.transformer.bytecode.expression.var.FunctionMember) DataMember(lucee.transformer.expression.var.DataMember) Member(lucee.transformer.expression.var.Member)

Aggregations

Position (lucee.transformer.Position)30 TemplateException (lucee.runtime.exp.TemplateException)21 BodyBase (lucee.transformer.bytecode.BodyBase)10 FunctionAsExpression (lucee.transformer.bytecode.expression.FunctionAsExpression)10 Expression (lucee.transformer.expression.Expression)10 Body (lucee.transformer.bytecode.Body)9 FunctionBody (lucee.transformer.bytecode.FunctionBody)9 ScriptBody (lucee.transformer.bytecode.ScriptBody)9 TagLibTag (lucee.transformer.library.tag.TagLibTag)6 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)5 Tag (lucee.transformer.bytecode.statement.tag.Tag)5 LitString (lucee.transformer.expression.literal.LitString)5 Variable (lucee.transformer.expression.var.Variable)5 OpVariable (lucee.transformer.bytecode.op.OpVariable)4 TagOther (lucee.transformer.bytecode.statement.tag.TagOther)3 PageRuntimeException (lucee.runtime.exp.PageRuntimeException)2 TransformerException (lucee.transformer.TransformerException)2 OPUnary (lucee.transformer.bytecode.op.OPUnary)2 DoWhile (lucee.transformer.bytecode.statement.DoWhile)2 ComponentTemplateException (lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException)2