001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.transformer.cfml.script;
020
021import lucee.runtime.exp.TemplateException;
022import lucee.transformer.bytecode.Page;
023import lucee.transformer.bytecode.expression.Expression;
024import lucee.transformer.bytecode.statement.tag.Tag;
025import lucee.transformer.cfml.TransfomerSettings;
026import lucee.transformer.cfml.evaluator.EvaluatorPool;
027import lucee.transformer.cfml.tag.CFMLTransformer;
028import lucee.transformer.cfml.tag.TagDependentBodyTransformer;
029import lucee.transformer.library.function.FunctionLib;
030import lucee.transformer.library.tag.TagLib;
031import lucee.transformer.library.tag.TagLibTag;
032import lucee.transformer.util.CFMLString;
033
034public class CFMLScriptTransformer extends AbstrCFMLScriptTransformer implements TagDependentBodyTransformer {
035        
036        
037        @Override
038        public void transform(Page page,CFMLTransformer parentTransformer,EvaluatorPool ep,TagLib[][] tlibs, FunctionLib[] fld, Tag tag,TagLibTag libTag,TagLibTag[] scriptTags, CFMLString cfml,TransfomerSettings settings) throws TemplateException  {
039                //Page page = ASMUtil.getAncestorPage(tag);
040                boolean isCFC= page.isComponent();
041                boolean isInterface= page.isInterface();
042                
043                ExprData data = init(page,ep,tlibs,fld,scriptTags,cfml,settings,true);
044                data.insideFunction=false; 
045                data.tagName=libTag.getFullName();
046                data.isCFC=isCFC;
047                data.isInterface=isInterface;
048                //data.scriptTags=((ConfigImpl) config).getCoreTagLib().getScriptTags();
049                
050                tag.setBody(statements(data));
051        }
052
053        /**
054         * @see lucee.transformer.data.cfml.expression.data.cfmlExprTransformer#expression()
055         */
056        public final Expression expression(ExprData data) throws TemplateException {
057                Expression expr;
058                expr = super.expression(data);
059                comments(data);
060                return expr;
061        }
062}