public static RCVector <L> DoAt <L> (RCClosure closure, RCVector <L> left, RCVector <decimal> right) { L[] result = new L[right.Count]; for (int i = 0; i < right.Count; ++i) { if (right[i] < 0) { int j = (int)(left.Count + right[i]); if (j < 0 || j >= left.Count) { throw RCException.Range(closure, (long)right[i], left.Count); } result[i] = left[j]; } else { int j = (int)right[i]; if (j < 0 || j >= left.Count) { throw RCException.Range(closure, (long)right[i], left.Count); } result[i] = left[j]; } } return((RCVector <L>)RCVectorBase.FromArray(new RCArray <L> (result))); }
public void EvalDyadic(RCRunner runner, RCClosure closure, object left, object right) { // Brian! come back here to prevent the native exception RCOperator op = (RCOperator)closure.Code; RCVectorBase leftVector = left as RCVectorBase; RCVectorBase rightVector = right as RCVectorBase; if (leftVector == null || rightVector == null) { throw RCException.Overload(closure, op.Name, left, right); } runner.Yield(closure, VectorMath.InvokeDyadic(closure, op.Name, leftVector, rightVector)); }
public static RCVector <L> DoAt <L> (RCClosure closure, RCVector <L> left, RCVector <byte> right) { L[] result = new L[right.Count]; for (int i = 0; i < right.Count; ++i) { int j = right[i]; if (j < 0 || j >= left.Count) { throw RCException.Range(closure, right[i], left.Count); } result[i] = left[j]; } return((RCVector <L>)RCVectorBase.FromArray(new RCArray <L> (result))); }
public static RCValue InvokeSequential(RCClosure closure, string name, RCVectorBase right) { RCActivator.OverloadKey key = new RCActivator.OverloadKey(name, typeof(object), null, right.ScalarType); Overload overload; if (!_overloads.TryGetValue(key, out overload)) { throw RCException.Overload(closure, name, right); } object array = overload.Invoke(right.Array); return(RCVectorBase.FromArray(array)); }
public override RCClosure Handle(RCRunner runner, RCClosure closure, Exception exception, long status, out RCValue result) { // When the runner finds out about an exception it will try to call this // Handle method on all of the parents in the stack until it gets to // one that returns a closure to eval next. RCBlock wrapper = new RCBlock("status", ":", new RCLong(status)); RCException rcex = exception as RCException; string message; if (rcex != null) { if (RCSystem.Args.OutputEnum == RCOutput.Test) { message = rcex.ToTestString(); } else { message = rcex.ToString(); } } else { message = exception.Message; } RCBlock report = new RCBlock("", ":", new RCString(message + "\n")); int escapeCount = RCTemplate.CalculateReportTemplateEscapeLevel(message); if (RCSystem.Args.OutputEnum == RCOutput.Test) { wrapper = new RCBlock(wrapper, "data", ":", new RCTemplate(report, escapeCount, true)); } else { wrapper = new RCBlock(wrapper, "data", ":", new RCTemplate(report, escapeCount, true)); } result = wrapper; return(base.Next(runner, closure, closure, result)); }