コード例 #1
0
        public async Task <HaxeEmitterContext> EmitAsync(CancellationToken cancellationToken)
        {
            //Log.Trace($"\tEmitting Type {CurrentType.TypeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}");
            try
            {
                switch (CurrentType.Kind)
                {
                case PhaseTypeKind.Class:
                    var classBlock = new ClassBlock(this, (PhaseClass)CurrentType);
                    classBlock.Emit(cancellationToken);
                    break;

                case PhaseTypeKind.Struct:
                    var structBlock = new ClassBlock(this, (PhaseStruct)CurrentType);
                    structBlock.Emit(cancellationToken);
                    break;

                case PhaseTypeKind.Interface:
                    var interfaceBlock = new InterfaceBlock(this, (PhaseInterface)CurrentType);
                    interfaceBlock.Emit(cancellationToken);
                    break;

                case PhaseTypeKind.Enum:
                    var enumBlock = new EnumBlock(this, (PhaseEnum)CurrentType);
                    enumBlock.Emit(cancellationToken);
                    break;

                case PhaseTypeKind.Delegate:
                    var delegateBlock = new DelegateBlock(this, (PhaseDelegate)CurrentType);
                    delegateBlock.Emit(cancellationToken);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                var location = _nodeStack.Count > 0 ? _nodeStack.Peek()?.GetLocation() : null;
                Log.Error(CultureInfo.InvariantCulture, Diagnostic.Create(PhaseErrors.PH017, location, e.ToString()));
                throw;
            }

            return(this);
        }
コード例 #2
0
        public async Task <HaxeEmitterContext> EmitAsync(CancellationToken cancellationToken)
        {
            //Log.Trace($"\tEmitting Type {CurrentType.TypeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}");
            switch (CurrentType.Kind)
            {
            case PhaseTypeKind.Class:
                var classBlock = new ClassBlock(this, (PhaseClass)CurrentType);
                classBlock.Emit(cancellationToken);
                break;

            case PhaseTypeKind.Struct:
                var structBlock = new ClassBlock(this, (PhaseStruct)CurrentType);
                structBlock.Emit(cancellationToken);
                break;

            case PhaseTypeKind.Interface:
                var interfaceBlock = new InterfaceBlock(this, (PhaseInterface)CurrentType);
                interfaceBlock.Emit(cancellationToken);
                break;

            case PhaseTypeKind.Enum:
                var enumBlock = new EnumBlock(this, (PhaseEnum)CurrentType);
                enumBlock.Emit(cancellationToken);
                break;

            case PhaseTypeKind.Delegate:
                var delegateBlock = new DelegateBlock(this, (PhaseDelegate)CurrentType);
                delegateBlock.Emit(cancellationToken);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(this);
        }