use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class Trace method _doEndTag.
public void _doEndTag() throws IOException, PageException {
PageSource ps = pageContext.getCurrentTemplatePageSource();
// var
String varValue = null;
Object value = null, traceValue = null;
if (!StringUtil.isEmpty(var)) {
try {
if (caller instanceof Scope)
value = VariableInterpreter.getVariable(pageContext, var, (Scope) caller);
else
value = pageContext.getVariable(var);
} catch (PageException e) {
varValue = "(undefined)";
follow = false;
}
if (follow) {
// print.o(1);
if (StringUtil.isEmpty(text, true))
text = var;
// print.o(2);
traceValue = TraceObjectSupport.toTraceObject(pageContext.getDebugger(), value, type, category, text);
if (caller instanceof Scope)
VariableInterpreter.setVariable(pageContext, var, traceValue, (Scope) caller);
else
pageContext.setVariable(var, traceValue);
}
try {
varValue = new ScriptConverter().serialize(value);
} catch (ConverterException e) {
if (value != null)
varValue = "(" + Caster.toTypeName(value) + ")";
}
}
DebugTrace trace = ((DebuggerImpl) pageContext.getDebugger()).addTrace(type, category, text, ps, var, varValue);
DebugTrace[] traces = pageContext.getDebugger().getTraces(pageContext);
String total = "(1st trace)";
if (traces.length > 1) {
long t = 0;
for (int i = 0; i < traces.length; i++) {
t += traces[i].getTime();
}
total = "(" + t + ")";
}
boolean hasCat = !StringUtil.isEmpty(trace.getCategory());
boolean hasText = !StringUtil.isEmpty(trace.getText());
boolean hasVar = !StringUtil.isEmpty(var);
// inline
if (inline) {
lucee.runtime.format.TimeFormat tf = new lucee.runtime.format.TimeFormat(pageContext.getConfig().getLocale());
StringBuffer sb = new StringBuffer();
sb.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"white\">");
sb.append("<tr>");
// sb.append("<td><img src=\"/CFIDE/debug/images/Error_16x16.gif\" alt=\"Error type\">");
sb.append("<td>");
sb.append("<font color=\"orange\">");
sb.append("<b>");
sb.append(DebugTraceImpl.toType(trace.getType(), "INFO") + " - ");
sb.append("[CFTRACE " + tf.format(new DateTimeImpl(pageContext.getConfig()), "hh:mm:ss:l") + "]");
sb.append("[" + trace.getTime() + " ms " + total + "]");
sb.append("[" + trace.getTemplate() + " @ line: " + trace.getLine() + "]");
if (hasCat || hasText)
sb.append(" -");
if (hasCat)
sb.append(" [" + trace.getCategory() + "]");
if (hasText)
sb.append(" <i>" + trace.getText() + " </i>");
sb.append("</b>");
sb.append("</font>");
sb.append("</td>");
sb.append("</tr>");
sb.append("</table>");
pageContext.forceWrite(sb.toString());
if (hasVar)
Dump.call(pageContext, value, var);
}
// log
Log log = ((ConfigImpl) pageContext.getConfig()).getLog("trace");
StringBuffer msg = new StringBuffer();
msg.append("[" + trace.getTime() + " ms " + total + "] ");
msg.append("[" + trace.getTemplate() + " @ line: " + trace.getLine() + "]");
if (hasCat || hasText || hasVar)
msg.append("- ");
if (hasCat)
msg.append("[" + trace.getCategory() + "] ");
if (hasVar)
msg.append("[" + var + "=" + varValue + "] ");
if (hasText)
msg.append(" " + trace.getText() + " ");
log.log(trace.getType(), "cftrace", msg.toString());
// abort
if (abort)
throw new Abort(Abort.SCOPE_REQUEST);
}
use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class FDVariableComparator method getVariables.
private static List getVariables(FDStackFrameImpl frame, PageContextImpl pc, List list, String strScope) throws FDLanguageException {
Scope scope;
try {
scope = pc.scope(strScope, null);
if (scope != null)
return copyValues(frame, list, scope);
Object value = pc.undefinedScope().get(strScope, null);
if (value != null) {
if (value instanceof Struct)
return copyValues(frame, new ArrayList(), (Struct) value);
throw new FDLanguageException("[" + strScope + "] is not of type scope, type is [" + Caster.toTypeName(value) + "]");
}
throw new FDLanguageException("[" + strScope + "] does not exist in the current context");
} catch (PageException e) {
throw new FDLanguageException(e);
}
}
use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class Evaluate method call.
public static Object call(PageContext pc, Object[] objs, boolean preciseMath) throws PageException {
// define a ohter enviroment for the function
if (objs.length > 1 && objs[objs.length - 1] instanceof Scope) {
// Variables Scope
Variables var = null;
Local lcl = null, cLcl = null;
Argument arg = null, cArg = null;
if (objs[objs.length - 1] instanceof Variables) {
var = (Variables) objs[objs.length - 1];
} else if (objs[objs.length - 1] instanceof CallerImpl) {
CallerImpl ci = ((CallerImpl) objs[objs.length - 1]);
var = ci.getVariablesScope();
lcl = ci.getLocalScope();
arg = ci.getArgumentsScope();
}
if (var != null) {
Variables cVar = pc.variablesScope();
pc.setVariablesScope(var);
if (lcl != null && !(lcl instanceof LocalNotSupportedScope)) {
cLcl = pc.localScope();
cArg = pc.argumentsScope();
pc.setFunctionScopes(lcl, arg);
}
try {
return _call(pc, objs, objs.length - 1, preciseMath);
} finally {
pc.setVariablesScope(cVar);
if (cLcl != null)
pc.setFunctionScopes(cLcl, cArg);
}
} else // Undefined Scope
if (objs[objs.length - 1] instanceof Undefined) {
PageContextImpl pci = (PageContextImpl) pc;
Undefined undefined = (Undefined) objs[objs.length - 1];
boolean check = undefined.getCheckArguments();
Variables orgVar = pc.variablesScope();
Argument orgArgs = pc.argumentsScope();
Local orgLocal = pc.localScope();
pci.setVariablesScope(undefined.variablesScope());
if (check)
pci.setFunctionScopes(undefined.localScope(), undefined.argumentsScope());
try {
return _call(pc, objs, objs.length - 1, preciseMath);
} finally {
pc.setVariablesScope(orgVar);
if (check)
pci.setFunctionScopes(orgLocal, orgArgs);
}
}
}
return _call(pc, objs, objs.length, preciseMath);
}
use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class CFMLExpressionInterpreter method startElement.
/**
* Extrahiert den Start Element einer Variale,
* dies ist entweder eine Funktion, eine Scope Definition oder eine undefinierte Variable.
* <br />
* EBNF:<br />
* <code>identifier "(" functionArg ")" | scope | identifier;</code>
* @param name Einstiegsname
* @return CFXD Element
* @throws PageException
*/
private Ref startElement(String name) throws PageException {
// check function
if (!limited && cfml.isCurrent('(')) {
FunctionLibFunction function = fld.getFunction(name);
Ref[] arguments = functionArg(name, true, function, ')');
if (function != null)
return new BIFCall(function, arguments);
Ref ref = new lucee.runtime.interpreter.ref.var.Scope(Scope.SCOPE_UNDEFINED);
return new UDFCall(ref, name, arguments);
}
// check scope
return scope(name);
}
use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class ValueList method toColumn.
protected static QueryColumn toColumn(PageContext pc, String strQueryColumn) throws PageException {
// if(strQueryColumn.indexOf('.')<1)
// throw new ExpressionException("invalid query column definition ["+strQueryColumn+"]");
VariableReference ref = ((PageContextImpl) pc).getVariableReference(strQueryColumn);
if (ref.getParent() instanceof Scope)
throw new ExpressionException("invalid query column definition [" + strQueryColumn + "]");
Query query = Caster.toQuery(ref.getParent());
return query.getColumn(ref.getKey());
}
Aggregations