Exemplo n.º 1
0
        public override void EnterInstanceDecl(DaedalusParser.InstanceDeclContext context)
        {
            _assemblyBuilder.ErrorContext.Context = context.parentReference();

            var referenceName     = context.parentReference().GetText();
            var refSymbol         = _assemblyBuilder.GetSymbolByName(referenceName);
            var referenceSymbolId = refSymbol.Index;
            var location          = GetLocation(context);

            List <DatSymbol> symbols = new List <DatSymbol>();

            for (int i = 0; i < context.nameNode().Length; ++i)
            {
                string    instanceName   = context.nameNode()[i].GetText();
                DatSymbol instanceSymbol = SymbolBuilder.BuildInstance(instanceName, referenceSymbolId, location);
                _assemblyBuilder.AddSymbol(instanceSymbol);
                symbols.Add(instanceSymbol);
            }

            _assemblyBuilder.SharedBlockStart(symbols);
            _assemblyBuilder.AddInstruction(new Ret());
            _assemblyBuilder.ExecBlockEnd();
        }
Exemplo n.º 2
0
        private InstanceDeclarationsTemporaryNode GetInstanceDeclarationsTemporaryNode(DaedalusParser.InstanceDeclContext instanceDeclContext)
        {
            DaedalusParser.ParentReferenceContext parentReferenceContext         = instanceDeclContext.parentReference();
            InheritanceParentReferenceNode        inheritanceParentReferenceNode = new InheritanceParentReferenceNode(parentReferenceContext.GetText(), GetLocation(parentReferenceContext));

            _inheritanceReferenceNodes.Add(inheritanceParentReferenceNode);

            List <DeclarationNode> instanceDeclarationNodes = new List <DeclarationNode>();

            foreach (DaedalusParser.NameNodeContext nameNodeContext in instanceDeclContext.nameNode())
            {
                NameNode nameNode = new NameNode(GetLocation(nameNodeContext), nameNodeContext.GetText());
                instanceDeclarationNodes.Add(new InstanceDefinitionNode(GetLocation(instanceDeclContext), nameNode, inheritanceParentReferenceNode, new List <StatementNode>(), definedWithoutBody: true));
            }

            return(new InstanceDeclarationsTemporaryNode(GetLocation(instanceDeclContext), instanceDeclarationNodes));
        }