001 package railo.transformer.cfml.evaluator.func.impl; 002 003 import railo.runtime.exp.TemplateException; 004 import railo.runtime.type.util.ArrayUtil; 005 import railo.transformer.bytecode.expression.Expression; 006 import railo.transformer.bytecode.expression.var.Argument; 007 import railo.transformer.bytecode.expression.var.BIF; 008 import railo.transformer.bytecode.literal.LitDouble; 009 import railo.transformer.bytecode.literal.LitInteger; 010 import railo.transformer.bytecode.literal.LitString; 011 import railo.transformer.cfml.evaluator.FunctionEvaluator; 012 import railo.transformer.library.function.FunctionLibFunction; 013 014 public class GetTickCount implements FunctionEvaluator{ 015 016 public void evaluate(BIF bif, FunctionLibFunction flf) throws TemplateException { 017 Argument[] args = bif.getArguments(); 018 if(ArrayUtil.isEmpty(args)) return; 019 020 Argument arg = args[0]; 021 Expression value = arg.getValue(); 022 if(value instanceof LitString) { 023 String unit=((LitString)value).getString(); 024 if("nano".equalsIgnoreCase(unit)) 025 arg.setValue(LitDouble.toExprDouble(railo.runtime.functions.other.GetTickCount.UNIT_NANO), "number"); 026 else if("milli".equalsIgnoreCase(unit)) 027 arg.setValue(LitDouble.toExprDouble(railo.runtime.functions.other.GetTickCount.UNIT_MILLI), "number"); 028 else if("micro".equalsIgnoreCase(unit)) 029 arg.setValue(LitDouble.toExprDouble(railo.runtime.functions.other.GetTickCount.UNIT_MICRO), "number"); 030 else if("second".equalsIgnoreCase(unit)) 031 arg.setValue(LitDouble.toExprDouble(railo.runtime.functions.other.GetTickCount.UNIT_SECOND), "number"); 032 } 033 } 034 035 }