public override void Bundle(iObject argument, ArgumentBundle bundle) { foreach (var item in (Array)argument) { bundle.Splat.Add(item); } }
public override void Bundle(iObject argument, ArgumentBundle bundle) { foreach (var pair in (Hash)argument) { var array = (Array)pair; bundle.Keywords[array[0]] = array[1]; } }
public override iObject Bind(ArgumentBundle bundle) { if (Parameter.Position >= bundle.Splat.Count) { throw new ArgumentError( $"required parameter `{Parameter.Name}' with index {Parameter.Position} was not passed"); } return(bundle.Splat[Parameter.Position]); }
public CallFrame(CallSite callSite, iObject instance, ArgumentBundle arguments = null, CallFrame caller = null) { CallSite = callSite; Instance = instance; Caller = caller ?? Current; Arguments = arguments ?? new ArgumentBundle(); Locals = new LinkedDictionary <Symbol, LocalVariable>(); }
public override iObject Bind(ArgumentBundle bundle) { var value = bundle.Keywords[new Symbol(Parameter.Name)]; if (value != null) { return(value); } throw new ArgumentError( $"required keyword parameter `{Parameter.Name}' with index {Parameter.Position} was not passed"); }
public override iObject Bind(ArgumentBundle bundle) { var value = bundle.Keywords[new Symbol(Parameter.Name)]; if (value != null) { return(value); } var defaultValue = Parameter.Parameter.HasDefaultValue ? Object.Box(Parameter.Parameter.DefaultValue) : null; return(defaultValue); }
public override iObject Bind(ArgumentBundle bundle) { var available = bundle.Splat.Count - Method.ParameterCounter.Required; if (available > 0 && Parameter.Position < bundle.Splat.Count) { return(bundle.Splat[Parameter.Position]); } var defaultValue = Parameter.Parameter.HasDefaultValue ? Object.Box(Parameter.Parameter.DefaultValue) : null; return(defaultValue); }
public override iObject Bind(ArgumentBundle bundle) { var numParameters = Method.ParameterCounter.Required + Method.ParameterCounter.Optional + (Method.ParameterCounter.HasRest ? 1 : 0); var splatPosition = bundle.Splat.Count + numParameters - Parameter.Position - 2; if (splatPosition < 0 || splatPosition >= bundle.Splat.Count) { throw new ArgumentError( $"required parameter `{Parameter.Name}' with index {Parameter.Position} not passed"); } return(bundle.Splat[splatPosition]); }
public override iObject Bind(ArgumentBundle bundle) { var parameters = Method.Parameters.Where(p => p.IsKeyRequired || p.IsKeyOptional); var keysToExclude = new HashSet <Symbol>(parameters.Select(p => new Symbol(p.Name))); var keys = new HashSet <Symbol>(bundle.Keywords.Keys.Cast <Symbol>()); keys.RemoveWhere(key => keysToExclude.Contains(key)); var rest = new Hash(keys.Count); foreach (var key in keys) { rest[key] = bundle.Keywords[key]; } return(rest); }
public override iObject Bind(ArgumentBundle bundle) { var begin = Method.ParameterCounter.PrefixRequired + Method.ParameterCounter.Optional; var end = bundle.Splat.Count - Method.ParameterCounter.SuffixRequired; var count = end - begin; if (count <= 0) { return(new Array()); } var values = bundle.Splat.Skip(begin).Take(count); var result = new Array(values); var hasKeyRestParameter = Method.ParameterCounter.HasKeyRest; var restIncludesKeyRest = bundle.HasKeyArguments != hasKeyRestParameter; if (restIncludesKeyRest) { result.Add(bundle.Keywords.Duplicate()); } return(result); }
public abstract void Bundle(iObject argument, ArgumentBundle bundle);
public override void Bundle(iObject argument, ArgumentBundle bundle) { var labeledArg = (Array)argument; bundle.Keywords[labeledArg[0]] = labeledArg[1]; }
public override iObject Bind(ArgumentBundle bundle) => bundle.Block ?? new NilClass();
public override void Bundle(iObject argument, ArgumentBundle bundle) { bundle.Block = argument; }
public static CallFrame Push(CallSite callSite, iObject instance, ArgumentBundle arguments = null) => Current = new CallFrame(callSite, instance, arguments);
public override void Bundle(iObject argument, ArgumentBundle bundle) { bundle.Splat.Add(argument); }
public abstract iObject Bind(ArgumentBundle bundle);