예제 #1
1
        public void NestedFunctionCalls_ShouldWorkCorrectly()
        {
            // Test Visit Function Call

            // arrange
            var input = @"main() : integer
                              secondary()
                          secondary() : integer
                              tertiary()
                          tertiary() : integer
                              17";

            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(input);

            Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());

            // act
            var tacs    = new ThreeAddressCodeFactory().Generate(program);
            var output  = new CodeGenerator().Generate(tacs);
            var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output);

            // assert
            Assert.That(tinyOut, Is.EqualTo(new[] { "17" }));
        }
예제 #2
1
            public void Compile([NotNull] string mainZilFile)
            {
                var compiler = new FrontEnd();

                compiler.CheckingFilePresence += (sender, e) =>
                {
                    e.Exists = inputs.ContainsKey(e.FileName);
                };

                compiler.OpeningFile += (sender, e) =>
                {
                    if (e.Writing)
                    {
                        e.Stream = outputs[e.FileName] = new MemoryStream();
                    }
                    else
                    {
                        if (inputs.TryGetValue(e.FileName, out var content))
                        {
                            var result = new MemoryStream();
                            using (var wtr = new StreamWriter(result, Encoding.UTF8, 512, true))
                            {
                                wtr.Write(content);
                                wtr.Flush();
                            }
                            result.Position = 0;
                            e.Stream        = result;
                        }
                    }
                };

                var compilationResult = compiler.Compile(mainZilFile, Path.ChangeExtension(mainZilFile, ".zap"));

                Assert.IsTrue(compilationResult.Success, "Compilation failed");
            }
예제 #3
1
        public FrontEnd GetFe()
        {
            global::System.IntPtr cPtr = pocketsphinxPINVOKE.Decoder_GetFe(swigCPtr);
            FrontEnd ret = (cPtr == global::System.IntPtr.Zero) ? null : new FrontEnd(cPtr, false);

            return(ret);
        }
예제 #4
1
        public void Compiler_Execute_AllOfTheValidSampleKleinPrograms()
        {
            var folder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\KleinPrograms\Programs\fullprograms");
            var files  = Directory.GetFiles(folder, "*.kln");

            Assert.That(files.Length, Is.GreaterThan(0));

            foreach (var file in files)
            {
                var input    = File.ReadAllText(file);
                var frontEnd = new FrontEnd();
                var program  = frontEnd.Compile(input);
                Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());
                var tacs   = new ThreeAddressCodeFactory().Generate(program);
                var output = new CodeGenerator().Generate(tacs);

                foreach (var testDatum in TestDatum.GetTestData(input))
                {
                    Console.WriteLine($"{Path.GetFileName(file)}      {testDatum}");
                    var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output, testDatum.Args);
                    Console.WriteLine(tinyOut);
                    Assert.That(tinyOut, Is.EquivalentTo(testDatum.Asserts), Path.GetFileName(file));
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZmachineV1"/> class.
 /// </summary>
 /// <param name="frontEnd">
 /// The zmachine front end.
 /// </param>
 /// <param name="story">
 /// The story.
 /// </param>
 /// <param name="random">
 /// The random number generator.
 /// </param>
 internal ZmachineV1(FrontEnd frontEnd, ImmutableArray<byte> story, IRandomNumberGenerator random)
 {
     this.frontEnd = frontEnd;
     this.memory = new Memory(story, this.FrontEnd);
     this.randomNumberGenerator = new RandomNumberGenerator(random);
     this.callStack = new CallStack(this.FrontEnd);
 }
예제 #6
0
        private static async Task DemoRunAsync(IMediator mediator)
        {
            ChatRoom SSWGroup = new ChatRoom();

            FrontEnd Nancy   = new FrontEnd("Nancy");
            FrontEnd Andrew  = new FrontEnd("Andrew");
            BackEnd  Janet   = new BackEnd("Janet");
            BackEnd  Michael = new BackEnd("Michael");

            await mediator.Send(new ChatRoomRegister(SSWGroup, Nancy));

            await mediator.Send(new ChatRoomRegister(SSWGroup, Andrew));

            await mediator.Send(new ChatRoomRegister(SSWGroup, Janet));

            await mediator.Send(new ChatRoomRegister(SSWGroup, Michael));

            await mediator.Send(new SendMessage(SSWGroup, "Nancy", "Andrew", "You Idiot"));

            await mediator.Send(new SendMessage(SSWGroup, "Andrew", "Janet", "message 1"));

            await mediator.Send(new SendMessage(SSWGroup, "Janet", "Michael", "message 2"));

            await mediator.Send(new SendMessage(SSWGroup, "Michael", "Nancy", "message 3"));
        }
예제 #7
0
 public void RenderFrontends(StringBuilder sb)
 {
     foreach (var f in FrontEnd.OrderBy(f => f.Name))
     {
         RenderFrontEnd(sb, f);
     }
 }
예제 #8
0
        public SpeakerIdentification()
        {
            URL url = new URL(URLType.Resource, Resources.speakerid_frontend_config);

            cm           = new ConfigurationManager(url);
            _audioSource = cm.Lookup("streamDataSource") as StreamDataSource;
            _frontEnd    = cm.Lookup(FrontendName) as FrontEnd;
        }
예제 #9
0
 public SpectrogramPanel(FrontEnd frontEnd, StreamDataSource dataSource, AudioData audioData)
 {
     this.zoom       = 1f;
     this.audio      = audioData;
     this.frontEnd   = frontEnd;
     this.dataSource = dataSource;
     this.audio.addChangeListener(new SpectrogramPanel_1(this));
 }
예제 #10
0
        public Program()
        {
            Database          database     = new Database();
            Backend           backend      = new Backend(database);
            IntermediateLayer intermediate = new IntermediateLayer(backend);
            FrontEnd          frontEnd     = new FrontEnd(intermediate);

            frontEnd.GetHelp(HelpItem.FrontEnd);
        }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Memory"/> class.
 /// </summary>
 /// <param name="story">
 /// The story data.
 /// </param>
 /// <param name="frontEnd">
 /// The zmachine front end.
 /// </param>
 /// <remarks>
 /// We have to initialize the low byte of Flags 2 here because the first two bits in it must always survive initialization.
 /// </remarks>
 internal Memory(ImmutableArray<byte> story, FrontEnd frontEnd)
 {
     this.story = story;
     this.storyLength = this.story.Length;
     this.frontEnd = frontEnd;
     this.dynamicMemoryLength = this.ReadStoryWord(14);
     this.dynamicMemory = new byte[this.dynamicMemoryLength];
     this.WriteByte(Flags2LowByteAddress, this.ReadStoryByte(Flags2LowByteAddress));
 }
예제 #12
0
 public SpeedTracker(Recognizer recognizer, FrontEnd frontEnd, bool showSummary, bool showDetails, bool showResponseTime, bool showTimers)
 {
     //initLogger();
     InitRecognizer(recognizer);
     InitFrontEnd(frontEnd);
     _showSummary      = showSummary;
     _showDetails      = showDetails;
     _showResponseTime = showResponseTime;
     _showTimers       = showTimers;
 }
예제 #13
0
        public void ParserErrors_Compiler_ShouldProduceCorrectErrorMessages(string filename, string message)
        {
            var file     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\KleinPrograms\Programs\parser", filename);
            var frontEnd = new FrontEnd();

            frontEnd.Compile(File.ReadAllText(file));
            var error = frontEnd.ErrorRecord;

            Assert.That(error.ErrorType, Is.Not.EqualTo(ErrorTypeEnum.No));
            Assert.That(error.ToString(), Is.EqualTo(message));
        }
예제 #14
0
 public SpeedTracker(Recognizer recognizer, FrontEnd frontEnd, bool showSummary, bool showDetails, bool showResponseTime, bool showTimers)
 {
     this.maxResponseTime = long.MinValue;
     this.minResponseTime = long.MaxValue;
     this.initLogger();
     this.initRecognizer(recognizer);
     this.initFrontEnd(frontEnd);
     this.showSummary      = showSummary;
     this.showDetails      = showDetails;
     this.showResponseTime = showResponseTime;
     this.showTimers       = showTimers;
 }
예제 #15
0
파일: FrontEnd.cs 프로젝트: eddaly/elvis
    void Awake()
    {
        // Singleton
        if (instance == null) {
            instance = FindObjectOfType (typeof(FrontEnd)) as FrontEnd;
            if (instance == null)
                instance = this;
        }

        // Need to specify if want to set UVs with original pixels because Unity rescales texture on load
        FastGUIElement.SetOriginalAtlasPixels (m_AtlasOriginalWidth, m_AtlasOriginalHeight);
    }
예제 #16
0
        protected override void ProcessRecord()
        {
            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(File.ReadAllText(Path));

            if (program == null)
            {
                var exceptionMessage = $"{Path}{frontEnd.ErrorRecord}";
                throw new Exception(exceptionMessage);
            }
            WriteObject(program);
        }
    public static void Main()
    {
        const int FRONT_END_HELP          = 1;
        const int INTERMEDIATE_LAYER_HELP = 2;
        const int GENERAL_HELP            = 3;

        Application app                     = new Application();
        IntermediateLayer intermediateLayer = new IntermediateLayer(app);
        FrontEnd frontEnd                   = new FrontEnd(intermediateLayer);

        frontEnd.getHelp(GENERAL_HELP);
    }
예제 #18
0
        }                                                     ///@property(readwrite,assign) int numNumbers;

        public FrontEndScreen(int inId, FrontEnd inMenu)
        {
            //if (!base.init()) return null;

            myId      = inId;
            menu      = inMenu;
            showSpeed = 0.15f;

            backScreenBillboard = null;            //new Billboard("fescreeback" + myId.ToString());

            //backScreen = new Texture2D_Ross();
            //return this;
        }
예제 #19
0
        static void Main(string[] args)
        {
            FrontEnd Nancy   = new FrontEnd("Nancy");
            FrontEnd Andrew  = new FrontEnd("Andrew");
            BackEnd  Janet   = new BackEnd("Janet");
            BackEnd  Michael = new BackEnd("Michael");

            Nancy.Send(Janet, "You Idiot");
            Andrew.Send(Nancy, "message 1");
            Janet.Send(Michael, "message 2");
            Michael.Send(Andrew, "message 3");
            Console.ReadKey();
        }
예제 #20
0
        private static void Main(string[] args)
        {
            Dictionary <string, string> compilationList = new Dictionary <string, string>
            {
                [Path.Combine(FourUp, "AB", "spec", "appbuilder.eng")]  = Path.Combine(FourUp, "AB"),
                [Path.Combine(FourUp, "EAX", "specs", "Fuzzy.eng")]     = Path.Combine(FourUp, "EAX", "Fuzzy"),
                [Path.Combine(FourUp, "EAX", "specs", "OpenClose.eng")] = Path.Combine(FourUp, "EAX", "OpenClose")
            };

            foreach (var spec in compilationList.Keys)
            {
                FrontEnd.FullPipeline(spec, compilationList[spec]);
            }
        }
예제 #21
0
        public BandDetector()
        {
            // standard frontend
            _source = new AudioFileDataSource(320, null);
            var windower   = new RaisedCosineWindower(0.97f, 25.625f, 10.0f);
            var fft        = new DiscreteFourierTransform(512, false);
            var filterbank = new MelFrequencyFilterBank(130.0, 6800.0, Bands);

            var list = new List <IDataProcessor> {
                _source, windower, fft, filterbank
            };

            _frontend = new FrontEnd(list);
        }
예제 #22
0
 private void initFrontEnd(FrontEnd frontEnd)
 {
     if (this.frontEnd == null)
     {
         this.frontEnd = frontEnd;
         this.frontEnd.addSignalListener(this);
     }
     else if (this.frontEnd != frontEnd)
     {
         this.frontEnd.removeSignalListener(this);
         this.frontEnd = frontEnd;
         this.frontEnd.addSignalListener(this);
     }
 }
예제 #23
0
 private void InitFrontEnd(FrontEnd newFrontEnd)
 {
     if (_frontEnd == null)
     {
         _frontEnd = newFrontEnd;
         _frontEnd.AddSignalListener(this);
     }
     else if (_frontEnd != newFrontEnd)
     {
         _frontEnd.RemoveSignalListener(this);
         _frontEnd = newFrontEnd;
         _frontEnd.AddSignalListener(this);
     }
 }
예제 #24
0
        public void CompileTest()
        {
            var failed = new List <(string Path, string Message)>(
                Directory.GetFiles(SourceDir, "*.rk").MapParallelAll(src =>
            {
                var filename = Path.GetFileName(src);
                var txt      = File.ReadAllText(src);
                var lines    = txt.SplitLine();
                var il       = Path.Combine(ObjDir, Path.GetFileNameWithoutExtension(src) + ".il");
                try
                {
                    FrontEnd.Compile(new StringReader(txt), il, new string[] { "System.Runtime" });

                    var valid = GetLineContent(lines, "###start", "###end");
                    if (!valid.Found)
                    {
                        return(filename, "test code not found ###start - ###end");
                    }
                    var il_src = File.ReadAllText(il).Trim();

                    if (valid.Text.Trim() != il_src)
                    {
                        return(filename, "il make a difference");
                    }
                }
                catch (Exception ex)
                {
                    var error = GetLineContent(lines, "###error", "###end");
                    if (!error.Found || error.Text.Trim() != ex.Message)
                    {
                        return(filename, ex.Message);
                    }
                    File.WriteAllText(il, $@"
.assembly {filename} {{}}
.method public static void main()
{{
    .entrypoint
    ret
}}
");
                }
                return(filename, "");
            }).Where(x => x.Item2 != ""));

            if (failed.Count > 0)
            {
                Assert.Fail(failed.Map(x => $"{x.Path}: {x.Message}").Join("\n"));
            }
        }
예제 #25
0
        private static void processFile(string text, string outFilePattern, ConfigurationManager configurationManager)
        {
            FrontEnd            frontEnd            = (FrontEnd)configurationManager.lookup("endpointer");
            AudioFileDataSource audioFileDataSource = (AudioFileDataSource)configurationManager.lookup("audioFileDataSource");

            [email protected](text);
            audioFileDataSource.setAudioFile(new File(text), null);
            WavWriter wavWriter = (WavWriter)configurationManager.lookup("wavWriter");

            wavWriter.setOutFilePattern(outFilePattern);
            frontEnd.initialize();
            while (frontEnd.getData() != null)
            {
            }
        }
        // GET: Portfolio
        public ActionResult Index()
        {
            //int id = 1;
            FrontEnd FrontEndData = new FrontEnd();

            FrontEndData.User           = db.Users.FirstOrDefault();
            FrontEndData.Skills         = db.Skills.ToList();
            FrontEndData.Tags           = db.Tags.ToList();
            FrontEndData.portfolioItems = db.PortfolioItems.Include("Tags").ToList();
            FrontEndData.JournalItems   = db.JournalItems.ToList();
            FrontEndData.Services       = db.Services.ToList();
            FrontEndData.Slides         = db.Slides.ToList();
            FrontEndData.Values         = db.Values.ToList();
            return(View(FrontEndData));
        }
 /// <summary>
 /// <see cref="Service{T, TContext}.Service(IRepository{T, TContext})"
 /// </summary>
 public UserService(
     IRepository <User> repo,
     IOptions <FrontEnd> frontEndConfig,
     IOptions <ResetSecurity> securityConfig,
     ITranslationProvider translationProvider,
     ILogger <UserService> logger,
     MailSender mailSender)
     : base(repo)
 {
     this.frontEndConfig      = frontEndConfig.Value;
     this.securityConfig      = securityConfig.Value;
     this.translationProvider = translationProvider;
     this.mailSender          = mailSender;
     this.logger = logger;
 }
예제 #28
0
        public void Or_IfBothAreFalse_ShouldReturn0()
        {
            // arrange
            var input = @"main() : boolean
                              false or false";

            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(input);

            Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());

            // act
            var tacs    = new ThreeAddressCodeFactory().Generate(program);
            var output  = new CodeGenerator().Generate(tacs);
            var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output);

            // assert
            Assert.That(tinyOut, Is.EqualTo(new[] { "0" }));
        }
예제 #29
0
        public void AllArithmaticTogether_ShouldNestAndAll_ThatAndMiraculouslyWork()
        {
            // arrange
            var input = @"main(n : integer, m : integer) : integer
                              -(n-1)/2 * (m+1)";

            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(input);

            Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());

            // act
            var tacs    = new ThreeAddressCodeFactory().Generate(program);
            var output  = new CodeGenerator().Generate(tacs);
            var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output, "9 11");

            // assert
            Assert.That(tinyOut, Is.EqualTo(new[] { "-48" }));
        }
예제 #30
0
        public void Equality_IfTheNumbersAreTheSame_1_ShouldBeReturned()
        {
            // arrange
            var input = @"main() : boolean
                              2 = 2";

            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(input);

            Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());

            // act
            var tacs    = new ThreeAddressCodeFactory().Generate(program);
            var output  = new CodeGenerator().Generate(tacs);
            var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output);

            // assert
            Assert.That(tinyOut, Is.EqualTo(new[] { "1" }));
        }
예제 #31
0
        public void And_LeftAndRightAreTrue_AndReturn1()
        {
            // arrange
            var input = @"main() : boolean
                              true and true";

            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(input);

            Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());

            // act
            var tacs    = new ThreeAddressCodeFactory().Generate(program);
            var output  = new CodeGenerator().Generate(tacs);
            var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output);

            // assert
            Assert.That(tinyOut, Is.EqualTo(new[] { "1" }));
        }
예제 #32
0
        public void Compiler_ShouldCompile_AllOfMyPrograms()
        {
            var  folder  = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\KleinPrograms");
            var  files   = Directory.GetFiles(folder, "*.kln");
            bool allPass = true;
            var  result  = new StringBuilder();

            foreach (var file in files)
            {
                var input    = File.ReadAllText(file);
                var frontEnd = new FrontEnd();
                if (frontEnd.Compile(input) == null)
                {
                    allPass = false;
                    result.AppendLine($"{Path.GetFileName(file)}{frontEnd.ErrorRecord.FilePosition} {frontEnd.ErrorRecord}");
                }
            }
            ConsoleWriteLine.If(allPass != true, result.ToString());
            Assert.That(allPass, Is.True);
        }
        /// <summary>
        /// process the deserialized request message
        /// </summary>
        /// <param name="requestMessage">deserialized request message</param>
        /// <returns>response message</returns>
        protected ResponseMessage ProcessRequest(RequestMessage requestMessage)
        {
            LastActivity = DateTime.Now.Ticks;

            ResponseMessage response = null;

            if (requestMessage == null)
            {
                Console.WriteLine("No request.");
            }
            else
            {
                if (!Initialized)
                {
                    // special processing for InitConnectionRequest
                    if (requestMessage is InitConnectionRequest)
                    {
                        string incomingSessionId = ((InitConnectionRequest)requestMessage).SessionId;

                        if (incomingSessionId == null)
                        {
                            // client is not expecting an old ContextManager
                            response = new InitConnectionResponse(SessionId);
                        }
                        else
                        {
                            // client is expecting an old ContextManager
                            FrontEnd.RestoreContextManagerFromSessionId(incomingSessionId, SessionId, this);
                            response = new InitConnectionResponse(SessionId);
                        }
                        Initialized = true;
                    }
                }
                else
                {
                    response = PerformService(requestMessage);
                }
            }

            return(response);
        }
예제 #34
0
        public void TheValueReturnedFromMain_ShouldBeSentToStdOut()
        {
            // Tests Visit Program, Definition, Body and IntegerLiteral

            // arrange
            var input = @"main() : integer
                              1";

            var frontEnd = new FrontEnd();
            var program  = frontEnd.Compile(input);

            Assert.That(program, Is.Not.Null, frontEnd.ErrorRecord.ToString());

            // act
            var tacs = new ThreeAddressCodeFactory().Generate(program);

            Console.WriteLine(tacs);
            // assert
            Assert.That(tacs.ToString(), Is.EqualTo(@"
Init 0  
BeginCall main 0 t0
t0 := Call main 
BeginCall print 1 t1
Param t0  
t1 := Call print 
Halt   

BeginFunc print 1
PrintVariable arg0  
EndFunc print  

BeginFunc main 0
t0 := 1
Return t0  
EndFunc main  
"));
            var output  = new CodeGenerator().Generate(tacs);
            var tinyOut = new TinyMachine(ExePath, TestFilePath).Execute(output);

            Assert.That(tinyOut, Is.EqualTo(new[] { "1" }));
        }
예제 #35
0
파일: Start.cs 프로젝트: DingyClot/Tymrr
 public Start(FrontEnd ui)
 {
     this.ui = ui;
 }
예제 #36
0
 public AppUnderTest(FrontEnd ui)
 {
     UserTasks = new UserTaskCollection(ui);
 }
예제 #37
0
 public UserTaskCollection(FrontEnd ui)
 {
     this.ui = ui;
 }
예제 #38
0
파일: GenCode.cs 프로젝트: tagg7/cflat435
 /************************ Utility Methods **************************/
 private string getStructName(FrontEnd.CbType t)
 {
     string name = null;
     if (t is FrontEnd.CbStruct)
     {
         FrontEnd.CbStruct s = (FrontEnd.CbStruct)t;
         name = s.Name;
     }
     return name;
 }
예제 #39
0
파일: GenCode.cs 프로젝트: tagg7/cflat435
 // returns the size of a type
 private int getTypeSize(FrontEnd.CbType t)
 {
     //Console.WriteLine("gTS: Type is '{0}'", t);
     if (t == FrontEnd.CbType.Int || t == FrontEnd.CbType.String || t is FrontEnd.CbArray)
         return 4; // ints are words, and so are pointers to strings and arrays
     else if (t is FrontEnd.CbStruct)
     {
         FrontEnd.CbStruct s = (FrontEnd.CbStruct) t;
         int size = 0;
         foreach (FrontEnd.CbField f in s.Fields.Values)
             size += getTypeSize(f.Type);
         return size;
     }
     else
         throw new Exception("getTypeSize: Unknown type: " + t);
 }
예제 #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZmachineV3"/> class.
 /// </summary>
 /// <param name="frontEnd">
 /// The front end.
 /// </param>
 /// <param name="story">
 /// The story.
 /// </param>
 /// <param name="random">
 /// The random number generator.
 /// </param>
 internal ZmachineV3(FrontEnd frontEnd, ImmutableArray<byte> story, IRandomNumberGenerator random) : base(frontEnd, story, random)
 {
 }
예제 #41
0
파일: Create.cs 프로젝트: DingyClot/Tymrr
 public Create(FrontEnd ui)
 {
     this.ui = ui;
 }
예제 #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CallStack"/> class.
 /// </summary>
 /// <param name="frontEnd">
 /// The zmachine front end.
 /// </param>
 public CallStack(FrontEnd frontEnd)
 {
     this.frontEnd = frontEnd;
 }