static void BuildArgumentValues( ILocalValueScope localValues, INamedExpressionTuple expressions, ILocalIdentifierScope argumentScope, ArgumentInstanceCollection arguments, IContext argumentContext, IContext functionContext) { var argN = 0; foreach (var expression in expressions.Tuple) { var argumentName = expression.Name; if (string.IsNullOrEmpty(argumentName)) { argumentName = arguments[argN].Name; argN++; } var argument = (IArgumentInstance)argumentScope[argumentName]; var value = Dynamic((dynamic)expression.Expression, argumentContext); var casted = ImplicitCast(value, argument.Type); localValues.Add(argument, casted); } for (; argN < arguments.Count; argN++) { var argument = arguments[argN]; var value = Dynamic((dynamic)argument.Argument.Value, functionContext); localValues.Add(argument, value); } }
static void AssignArgumentInstances(ICollection <IArgumentInstance> instances, ILocalIdentifierScope identifiers, IEnumerable <IArgumentDeclaration> declarations) { foreach (var argumentDeclaration in declarations) { instances.Add((IArgumentInstance)identifiers[argumentDeclaration.Name]); } }
internal ParentedIdentifierScope(ILocalIdentifierScope locals) { _locals = locals; }
private void TypeToArguments(NamedCollection <IArgumentInstance> arguments, NamedCollection <IArgumentDeclaration> declarations, ILocalIdentifierScope identifiers, ArgumentSide side, Type type, FieldToInstance fields) { if (type == null) { return; } foreach (var field in type.GetRuntimeFields()) { var argumentDecl = new ArgumentDeclaration { IsUnrolled = field.GetCustomAttributes(typeof(ArgumentUnrolled)).Any(), IsAssignable = field.GetCustomAttributes(typeof(ArgumentAssignable)).Any(), Name = field.Name, Type = NetTypeToRebuildType(field.FieldType) //Value = field.V }; var argument = new ArgumentInstance { Argument = argumentDecl, Side = side }; declarations.Add(argumentDecl); identifiers.Add(argument); arguments.Add(argument); fields.Add(field, argument); } }
internal Context(ILocalIdentifierScope idScope, ILocalValueScope valueScope) { _identifiers = new ParentedIdentifierScope(idScope); _values = new ParentValueScope(valueScope); }