/// <summary> /// Writes this object's state to a YAML emitter. /// </summary> /// <param name="emitter"></param> void IYamlSerializable.WriteYaml(IEmitter emitter) { foreach (var item in events) { emitter.Emit(item); } }
public Dumper(Stream stream, bool isCanonical = false, int indent = 2, int width = 80, bool allowUnicode = true, LineBreak lineBreak = LineBreak.LineFeed) { this.emitter = new Emitter(stream, isCanonical, indent, width, allowUnicode, lineBreak); }
public void Prepare(PICProject project) { w = project.Relaxation; backscattering = project.Backscattering; alfa = project.BackscatteringAlfa; beta = project.BackscatteringBeta; step = project.Step; u = project.Voltage; particles = new ParticleArrayStorage<Particle>(project.ParticlesCount); boundaryConditions = new BoundaryConditions { Top = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Neumann }, Bottom = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Neumann }, Left = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Dirichlet }, Right = new BoundaryCondition { Value = x => u, Type = BoundaryConditionType.Dirichlet } }; emitter = new Emitter2D(0, project.EmitterBottom, 0, project.EmitterTop, project.ParticlesCount, 0, 0, -0.5 * Constants.ChildLangmuirCurrent(project.Length, u), step); mover = new Leapfrog(); grid = new Grid2D(); grid.InitializeGrid(project.GridN, project.GridM, 0, project.Length, 0, project.Height); mesh = new Mesh2D(); mesh.InitializeMesh(grid.N * grid.M); interpolator = new CloudInCellCurrentLinkage(particles, grid, mesh, false); poissonSolver = new Poisson2DFdmSolver(grid, boundaryConditions); poissonSolver.FdmMatrix = poissonSolver.BuildMatrix(); h = step * Constants.LightVelocity; Monitor = new PICMonitor(grid, mesh, particles, this); density = new double[grid.N * grid.M]; Trajectories = new List<Tuple<int, double, double>>(particles.Count * 1000); }
public override bool Enter(IObjectDescriptor value, IEmitter context) { var typeConverter = typeConverters.FirstOrDefault(t => t.Accepts(value.Type)); if (typeConverter != null) { typeConverter.WriteYaml(context, value.Value, value.Type); return false; } var convertible = value.Value as IYamlConvertible; if (convertible != null) { convertible.Write(context, nestedObjectSerializer); return false; } #pragma warning disable 0618 // IYamlSerializable is obsolete var serializable = value.Value as IYamlSerializable; if (serializable != null) { serializable.WriteYaml(context); return false; } #pragma warning restore return base.Enter(value, context); }
public ExpressionListBlock(IEmitter emitter, IEnumerable<Expression> expressions, Expression paramArg) : base(emitter, null) { this.Emitter = emitter; this.Expressions = expressions; this.ParamExpression = paramArg; }
public ConstructorBlock(IEmitter emitter, ITypeInfo typeInfo, bool staticBlock) : base(emitter, typeInfo.TypeDeclaration) { this.Emitter = emitter; this.TypeInfo = typeInfo; this.StaticBlock = staticBlock; }
public void AfterTypeEmit(IEmitter emitter, ITypeInfo type) { foreach (var plugin in this.Parts) { plugin.AfterTypeEmit(emitter, type); } }
private void CreateMethodBuilder(Type returnType, Type[] parameterTypes) { methodBuilder = typeBuilder.DefineMethod( "DynamicMethod", MethodAttributes.Public | MethodAttributes.Static, returnType, parameterTypes); methodBuilder.InitLocals = true; emitter = new Emitter(methodBuilder.GetILGenerator(), parameterTypes); }
public void AfterTypesEmit(IEmitter emitter, IList<ITypeInfo> types) { foreach (var plugin in this.Parts) { plugin.AfterTypesEmit(emitter, types); } }
Token id, iprop; // id is the current ID for the current line /// <summary> /// Create a new iCalendar parser. /// </summary> /// <param name="reader">The reader that contains the stream of text iCalendar</param> /// <param name="_emitter">The emitter that will transform the iCalendar elements</param> public Parser(StreamReader reader, IEmitter _emitter) { scanner = new Scanner(reader); emitter = _emitter; emitter.VParser = this; errors = new ArrayList(); }
public void AfterEmit(IEmitter emitter, ITranslator translator) { foreach (var plugin in this.Parts) { plugin.AfterEmit(emitter, translator); } }
/// <summary> /// Writes this object's state to a YAML emitter. /// </summary> void IYamlConvertible.Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) { foreach (var item in events) { emitter.Emit(item); } }
public SwitchBlock(IEmitter emitter, CaseLabel caseLabel, string varName, bool isFirst) : base(emitter, caseLabel) { this.Emitter = emitter; this.CaseLabel = caseLabel; varName_ = varName; isFirst_ = isFirst; }
public Pdp11Assembler(Pdp11Architecture arch, Address addrBase, IEmitter emitter) { this.arch = arch; this.BaseAddress = addrBase; this.emitter = emitter; this.Equates = new Dictionary<string, object>(); this.symtab = new SymbolTable(); }
public EmitComposite Add(IEmitter node) { if (node.IsNotNull()) { _nodes.Add(node); } return this; }
public override void Emit(MappingStartEventInfo eventInfo, IEmitter emitter) { if(tagMappings.ContainsKey(eventInfo.Source.Type)) { eventInfo.Tag = tagMappings[eventInfo.Source.Type]; } base.Emit(eventInfo, emitter); }
public ExpressionListBlock(IEmitter emitter, IEnumerable<Expression> expressions, Expression paramArg, InvocationExpression invocation = null) : base(emitter, null) { this.Emitter = emitter; this.Expressions = expressions; this.ParamExpression = paramArg; this.InvocationExpression = invocation; }
public CustomSerializationObjectGraphVisitor(IEmitter emitter, IObjectGraphVisitor nextVisitor, IEnumerable<IYamlTypeConverter> typeConverters) : base(nextVisitor) { this.emitter = emitter; this.typeConverters = typeConverters != null ? typeConverters.ToList() : Enumerable.Empty<IYamlTypeConverter>(); }
public InlineArgumentsBlock(IEmitter emitter, ArgumentsInfo argsInfo, string inline) : base(emitter, argsInfo.Expression) { this.Emitter = emitter; this.ArgumentsInfo = argsInfo; this.InlineCode = inline; argsInfo.AddExtensionParam(); }
public void Serialize(IEmitter emitter, object graph) { if (emitter == null) { throw new ArgumentNullException("emitter"); } EmitDocument(emitter, new ObjectDescriptor(graph, graph != null ? graph.GetType() : typeof(object), typeof(object))); }
public SwitchBlock(IEmitter emitter, SwitchSection switchSection, string varName, bool isFirst, bool isEnd) : base(emitter, switchSection) { this.Emitter = emitter; this.SwitchSection = switchSection; varName_ = varName; isFirst_ = isFirst; isEnd_ = isEnd; }
public ArgumentsInfo(IEmitter emitter, AssignmentExpression assignmentExpression, OperatorResolveResult operatorResolveResult, IMethod method) { this.Emitter = emitter; this.Expression = assignmentExpression; this.OperatorResolveResult = operatorResolveResult; this.BuildOperatorArgumentsList(new Expression[] { assignmentExpression.Left, assignmentExpression.Right }, operatorResolveResult.UserDefinedOperatorMethod ?? method); this.BuildOperatorTypedArguments(); }
public LambdaBlock(IEmitter emitter, IEnumerable<ParameterDeclaration> parameters, AstNode body, AstNode context, bool isAsync) : base(emitter, context) { this.Emitter = emitter; this.Parameters = parameters; this.Body = body; this.Context = context; this.IsAsync = isAsync; }
public FieldBlock(IEmitter emitter, ITypeInfo typeInfo, bool staticBlock, bool fieldsOnly) : base(emitter, typeInfo.TypeDeclaration) { this.Emitter = emitter; this.TypeInfo = typeInfo; this.StaticBlock = staticBlock; this.FieldsOnly = fieldsOnly; this.Injectors = new List<string>(); }
public static TypeDefinition GetBaseType(TypeDefinition type, IEmitter emitter) { if (type == null || type.BaseType == null) { return null; } return Helpers.ToTypeDefinition(type.BaseType, emitter); }
public NameBlock(IEmitter emitter, string name, Expression namedExpression, Expression expression) : base(emitter, null) { this.Emitter = emitter; this.NamedExpression = namedExpression; this.Expression = expression; this.Name = name; this.Emitter.Translator.EmitNode = namedExpression ?? expression; }
public static OverloadsCollection Create(IEmitter emitter, IndexerDeclaration indexerDeclaration, bool isSetter = false) { string key = indexerDeclaration.GetHashCode().ToString() + isSetter.GetHashCode().ToString(); if (emitter.OverloadsCache.ContainsKey(key)) { return emitter.OverloadsCache[key]; } return new OverloadsCollection(emitter, indexerDeclaration, isSetter); }
protected CompilerContext(string filePath, StreamReader inputReader, Importer importer, IEmitter emitter, CompilationFlags flags) { FilePath = filePath; Flags = flags; Emitter = emitter; CompileErrors = new ErrorList(); Importer = importer; SymbolTable = new SymbolTable(); Lexer = Lexer.Create(inputReader, CompileErrors); }
public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) { var defaultValueAttribute = key.GetCustomAttribute<DefaultValueAttribute>(); var defaultValue = defaultValueAttribute != null ? defaultValueAttribute.Value : GetDefault(key.Type); return !_objectComparer.Equals(value.Value, defaultValue) && base.EnterMapping(key, value, context); }
public static OverloadsCollection Create(IEmitter emitter, ConstructorDeclaration constructorDeclaration) { string key = constructorDeclaration.GetHashCode().ToString(); if (emitter.OverloadsCache.ContainsKey(key)) { return emitter.OverloadsCache[key]; } return new OverloadsCollection(emitter, constructorDeclaration); }
public AbstractMethodBlock(IEmitter emitter, AstNode node) : base(emitter, node) { }
/// <summary> /// Serializes an object to specified stream in YAML format. /// </summary> /// <param name="emitter">The emitter.</param> /// <param name="instance">The object to serialize.</param> /// <param name="type">The type.</param> /// <param name="keepOnlySealedOverrides">if set to <c>true</c> [keep only sealed overrides].</param> public static void Serialize(IEmitter emitter, object instance, Type type, bool keepOnlySealedOverrides = false) { var serializer = GetYamlSerializer(keepOnlySealedOverrides); serializer.Serialize(emitter, instance, type); }
public ThrowBlock(IEmitter emitter, ThrowStatement throwStatement) : base(emitter, throwStatement) { this.Emitter = emitter; this.ThrowStatement = throwStatement; }
public static string ToJavaScript(object value, IEmitter emitter) { string s = null; if (value is double) { double d = (double)value; if (double.IsNaN(d)) { s = JS.Types.Number.NaN; } else if (double.IsPositiveInfinity(d)) { s = JS.Types.Number.Infinity; } else if (double.IsNegativeInfinity(d)) { s = JS.Types.Number.InfinityNegative; } else { s = emitter.ToJavaScript(value); } } else if (value is float) { float f = (float)value; if (float.IsNaN(f)) { s = JS.Types.Number.NaN; } else if (float.IsPositiveInfinity(f)) { s = JS.Types.Number.Infinity; } else if (float.IsNegativeInfinity(f)) { s = JS.Types.Number.InfinityNegative; } else { s = emitter.ToJavaScript(value); } } else if (value is char) { s = emitter.ToJavaScript((int)(char)value); } else if (value is decimal) { s = JS.Types.SYSTEM_DECIMAL + "(" + AbstractEmitterBlock.DecimalConstant((decimal)value, emitter) + ")"; } else if (value is long) { s = JS.Types.System.Int64.NAME + "(" + AbstractEmitterBlock.LongConstant((long)value, emitter) + ")"; } else if (value is ulong) { s = JS.Types.SYSTEM_UInt64 + "(" + AbstractEmitterBlock.ULongConstant((ulong)value, emitter) + ")"; } else { s = emitter.ToJavaScript(value); } return(s); }
public void WriteYaml(IEmitter emitter, object value, Type type) { var version = (SemanticVersion)value; emitter.Emit(new Scalar(version.ToString())); }
public VisitorMethodBlock(IEmitter emitter, MethodDeclaration methodDeclaration) : base(emitter, methodDeclaration) { this.Emitter = emitter; this.MethodDeclaration = methodDeclaration; }
public void WriteYaml(IEmitter emitter, object value, Type type) { var color = (Color)value; emitter.Emit(new Scalar(color.ToArgb().ToString("X"))); }
public TypeBlock(IEmitter emitter, AstType type) : base(emitter, type) { this.Emitter = emitter; this.Type = type; }
/// <summary> /// Serializes the specified object. /// </summary> /// <param name="emitter">The <see cref="IEmitter" /> where to serialize the object.</param> /// <param name="obj">The object to serialize.</param> public void Serialize(IEmitter emitter, object obj) { Serialize(emitter, obj, obj is null ? typeof(object) : null); }
public void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) { nestedObjectSerializer("int"); }
public NullReferenceBlock(IEmitter emitter, AstNode nullNode) : base(emitter, nullNode) { this.Emitter = emitter; this.NullNode = nullNode; }
public ClassBlock(IEmitter emitter, ITypeInfo typeInfo) : base(emitter, typeInfo.TypeDeclaration) { this.TypeInfo = typeInfo; }
public static CompilerRule Get(IEmitter emitter, IEntity entity) { CompilerRule memberRule = null; CompilerRule[] classRules = null; CompilerRule[] assemblyRules = null; CompilerRule[] interfaceRules = null; if (entity is IMember) { var attr = Helpers.GetInheritedAttribute(entity, attributeName); if (attr != null) { memberRule = Rules.ToRule(attr, CompilerRuleLevel.Member); } var typeDef = entity.DeclaringTypeDefinition; if (typeDef != null) { classRules = Rules.GetClassRules(emitter, typeDef); } interfaceRules = Rules.GetVirtualMemberRules(emitter, entity); } else if (entity is ITypeDefinition) { classRules = Rules.GetClassRules(emitter, (ITypeDefinition)entity); } var assembly = entity.ParentAssembly; if (emitter.AssemblyCompilerRuleCache.ContainsKey(assembly)) { assemblyRules = emitter.AssemblyCompilerRuleCache[assembly]; } else { IAttribute[] assemblyAttrs = assembly.AssemblyAttributes.Where(a => a.AttributeType.FullName == Rules.attributeName).ToArray(); assemblyRules = new CompilerRule[assemblyAttrs.Length]; for (int i = 0; i < assemblyAttrs.Length; i++) { assemblyRules[i] = Rules.ToRule(assemblyAttrs[i], CompilerRuleLevel.Assembly); } emitter.AssemblyCompilerRuleCache.Add(assembly, assemblyRules); } var rules = new List <CompilerRule>(); if (memberRule != null) { rules.Add(memberRule); } if (classRules != null && classRules.Length > 0) { rules.AddRange(classRules); } if (interfaceRules != null && interfaceRules.Length > 0) { rules.AddRange(interfaceRules); } rules.Add(emitter.AssemblyInfo.Rules); if (assemblyRules != null && assemblyRules.Length > 0) { rules.AddRange(assemblyRules); } return(MergeRules(rules)); }
public ForeachBlock(IEmitter emitter, ForeachStatement foreachStatement) : base(emitter, foreachStatement) { this.Emitter = emitter; this.ForeachStatement = foreachStatement; }
public void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) { nestedObjectSerializer(new List <Attribute>(this)); }
private IEventEmitter CreateEventEmitter(IEmitter emitter) { WriterEventEmitter nextEmitter = new WriterEventEmitter(emitter); return(!this.IsOptionSet(SerializationOptions.JsonCompatible) ? ((IEventEmitter) new TypeAssigningEventEmitter(nextEmitter, this.IsOptionSet(SerializationOptions.Roundtrip))) : ((IEventEmitter) new JsonEventEmitter(nextEmitter))); }
public void WriteYaml(IEmitter emitter, object value, Type type) { throw new NotImplementedException(); }
public ConditionalBlock(IEmitter emitter, ConditionalExpression conditionalExpression) { this.Emitter = emitter; this.ConditionalExpression = conditionalExpression; }
public Pdp11TextAssembler(IEmitter emitter) { this.emitter = emitter; this.ImageSymbols = new List <ImageSymbol>(); }
public EmitBlock(IEmitter emitter) : base(emitter, null) { Emitter = emitter; }
public static string GetThisAlias(IEmitter emitter) { return("this"); }
public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) { bool retVal = false; if (value.Value == null) { return(retVal); } if (typeof(System.Collections.IEnumerable).IsAssignableFrom(value.Value.GetType())) { // We have a collection var enumerableObject = (System.Collections.IEnumerable)value.Value; if (enumerableObject.GetEnumerator().MoveNext()) // Returns true if the collection is not empty. { // Don't skip this item - serialize it as normal. retVal = base.EnterMapping(key, value, context); } // Else we have an empty collection and the initialized return value of false is correct. } else { // Not a collection, normal serialization. retVal = base.EnterMapping(key, value, context); } return(retVal); }
public AssignmentBlock(IEmitter emitter, AssignmentExpression assignmentExpression) : base(emitter, assignmentExpression) { this.Emitter = emitter; this.AssignmentExpression = assignmentExpression; }
public PropertyBlock(IEmitter emitter, PropertyDeclaration propertyDeclaration) : base(emitter, propertyDeclaration) { this.Emitter = emitter; this.PropertyDeclaration = propertyDeclaration; }
public EmptyBlock(IEmitter emitter, EmptyStatement emptyStatement) : base(emitter, emptyStatement) { Emitter = emitter; EmptyStatement = emptyStatement; }
public ParenthesizedBlock(IEmitter emitter, ParenthesizedExpression parenthesizedExpression) : base(emitter, parenthesizedExpression) { this.Emitter = emitter; this.ParenthesizedExpression = parenthesizedExpression; }
public OperatorBlock(IEmitter emitter, OperatorDeclaration operatorDeclaration) : base(emitter, operatorDeclaration) { this.Emitter = emitter; this.OperatorDeclaration = operatorDeclaration; }
public ContinueBlock(IEmitter emitter, ContinueStatement continueStatement) { this.Emitter = emitter; this.ContinueStatement = continueStatement; }
public EventDeclarationBlock(IEmitter emitter, EventDeclaration eventDeclaration) : base(emitter, eventDeclaration) { this.Emitter = emitter; this.EventDeclaration = eventDeclaration; }
public static string ToJsName(IType type, IEmitter emitter, bool asDefinition = false, bool excludens = false, bool isAlias = false, bool skipMethodTypeParam = false, bool removeScope = true, bool nomodule = false, bool ignoreLiteralName = true, bool ignoreVirtual = false, bool excludeTypeOnly = false) { var itypeDef = type.GetDefinition(); H5Type h5Type = emitter.H5Types.Get(type, true); if (itypeDef != null) { string globalTarget = H5Types.GetGlobalTarget(itypeDef, null, removeScope); if (globalTarget != null) { if (h5Type != null && !nomodule) { bool customName; globalTarget = H5Types.AddModule(globalTarget, h5Type, excludens, false, out customName); } return(globalTarget); } } if (itypeDef != null && itypeDef.Attributes.Any(a => a.AttributeType.FullName == "H5.NonScriptableAttribute")) { throw new EmitterException(emitter.Translator.EmitNode, "Type " + type.FullName + " is marked as not usable from script"); } if (type.Kind == TypeKind.Array) { if (type is ArrayType arrayType && arrayType.ElementType != null) { string typedArrayName; if (emitter.AssemblyInfo.UseTypedArrays && (typedArrayName = Helpers.GetTypedArrayName(arrayType.ElementType)) != null) { return(typedArrayName); } var elementAlias = H5Types.ToJsName(arrayType.ElementType, emitter, asDefinition, excludens, isAlias, skipMethodTypeParam, excludeTypeOnly: excludeTypeOnly); if (isAlias) { return($"{elementAlias}$Array{(arrayType.Dimensions > 1 ? "$" + arrayType.Dimensions : "")}"); } if (arrayType.Dimensions > 1) { return(string.Format(JS.Types.System.Array.TYPE + "({0}, {1})", elementAlias, arrayType.Dimensions)); } return(string.Format(JS.Types.System.Array.TYPE + "({0})", elementAlias)); } return(JS.Types.ARRAY); } if (type.Kind == TypeKind.Delegate) { return(JS.Types.FUNCTION); } if (type.Kind == TypeKind.Dynamic) { return(JS.Types.System.Object.NAME); } if (type is ByReferenceType) { return(H5Types.ToJsName(((ByReferenceType)type).ElementType, emitter, asDefinition, excludens, isAlias, skipMethodTypeParam, excludeTypeOnly: excludeTypeOnly)); } if (ignoreLiteralName) { var isObjectLiteral = itypeDef != null && emitter.Validator.IsObjectLiteral(itypeDef); var isPlainMode = isObjectLiteral && emitter.Validator.GetObjectCreateMode(emitter.GetTypeDefinition(type)) == 0; if (isPlainMode) { return("System.Object"); } } if (type.Kind == TypeKind.Anonymous) { if (type is AnonymousType at && emitter.AnonymousTypes.ContainsKey(at)) { return(emitter.AnonymousTypes[at].Name); } else { return(JS.Types.System.Object.NAME); } }