示例#1
0
 public PortInfo(MachinePorts target, int index, int bitSize, SourceSpan span)
 {
     this.StartIndex = index;
     this.BitSize    = bitSize;
     this.Span       = span;
     this.Target     = target;
 }
示例#2
0
        public static async Task Start(string companyName, MicroServiceEntity entity)
        {
            var projectName = Constants.appNamePrefix + entity.Name.Kebaberize();
            var projectPath = await GoFilePaths.GetProjectPath(companyName, entity.Name);

            await GoCommands.Build(projectPath);

            var buildPath = Path.Combine(projectPath, projectName + ".exe");

            var port        = MachinePorts.GetAvailablePort(3000);
            var runLocation = $"localhost:{port}";

            Console.WriteLine($"Attempting to run {entity.Name} at {runLocation}");

            using (var cli = new Cli(buildPath))
            {
                cli.ExecuteAndForget(runLocation);
                Console.WriteLine($"{entity.Name} running at {runLocation}");
            }
        }
示例#3
0
        private void Visit(LogicScriptParser.Port_infoContext context, IDictionary <string, PortInfo> dic, MachinePorts target)
        {
            var size = context.size == null ? 1 : context.size.GetConstantValue(Context);

            if (size > BitsValue.BitSize)
            {
                Errors.AddError($"The maximum bit size is {BitsValue.BitSize}", context.Span());
            }

            var name = context.IDENT().GetText();

            if (Script.Inputs.ContainsKey(name) || Script.Outputs.ContainsKey(name) || Script.Registers.ContainsKey(name))
            {
                Errors.AddError($"The port '{name}' is already registered", new SourceSpan(context.IDENT().Symbol));
                return;
            }

            int startIndex = dic.Values.Sum(o => o.BitSize);

            dic.Add(name, new PortInfo(target, startIndex, (int)size, new(context.IDENT().Symbol)));
        }