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

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

            var instanceSymbol = SymbolBuilder.BuildInstance(instanceName, referenceSymbolId, location);

            instanceSymbol.Flags |= DatSymbolFlag.Const;
            _assemblyBuilder.AddSymbol(instanceSymbol);

            _assemblyBuilder.ExecBlockStart(instanceSymbol, ExecBlockType.Instance);

            if (refSymbol.Type == DatSymbolType.Prototype)
            {
                _assemblyBuilder.AddInstruction(new Call(refSymbol));
            }
        }
Exemplo n.º 2
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();
        }