Exemplo n.º 1
0
 private void ProcessStructAllocation(StructAlloc structAlloc, IDiagnostics diagnostics)
 {
     if (structAlloc.AllocType is UnresolvedType unresolvedType)
     {
         var name = unresolvedType.Type;
         structAlloc.AllocType   = this.ResolveDataType(unresolvedType, diagnostics);
         structAlloc.Declaration = this.structs[name].Peek();
     }
 }
Exemplo n.º 2
0
        public void TestStructAlloc()
        {
            var aDecl = new StructDeclaration(
                null,
                "A",
                new List <StructField>());
            var aAlloc = new StructAlloc(
                null,
                new UnresolvedType("A", null));
            var kju = new FunctionDeclaration(
                null,
                "kju",
                UnitType.Instance,
                new List <VariableDeclaration>(),
                new InstructionBlock(
                    null,
                    new List <Expression>()
            {
                aAlloc
            }),
                false);

            var program = new Program(
                null,
                new List <StructDeclaration>()
            {
                aDecl
            },
                new List <FunctionDeclaration>()
            {
                kju
            });

            this.nameResolver.Run(program, null);

            Assert.AreEqual(StructType.GetInstance(aDecl), aAlloc.AllocType);
        }