Example #1
0
        //Compiles an 'open' module directive.
        private void CompileModuleInclude(ElaModuleInclude s, LabelMap map)
        {
            var modFrame = IncludeModule(
                s.Alias,             //alias
                s.Name,              //name
                s.DllName,           //dllname
                s.Path.ToArray(),    //path
                s.Line,              //line
                s.Column,            //col
                s.RequireQualified,  //qualified
                s,                   //ElaExpression
                true,                //add variable
                false);              //NoPrelude

            //Process explicit import list for a module if module is valid and has an import list
            if (s.HasImportList && modFrame != null)
            {
                var il = s.ImportList;

                for (var i = 0; i < il.Count; i++)
                {
                    var im = il[i];
                    var a = AddVariable(im.LocalName, im, im.Private ? ElaVariableFlags.Private : ElaVariableFlags.None, -1);
                    var sv = default(ScopeVar);

                    //Query a name from an import list directly in a module
                    if (!modFrame.GlobalScope.Locals.TryGetValue(im.Name, out sv))
                        AddError(ElaCompilerError.UndefinedNameInModule, im, s.Alias, im.Name);

                    AddLinePragma(im);
                    cw.Emit(Op.Pushext, (frame.HandleMap.Count - 1) | sv.Address << 8);
                    PopVar(a);
                }
            }
        }
Example #2
0
        void IncludeStatElement(bool qual)
        {
            var inc = new ElaModuleInclude(t) { RequireQualified=qual };
            Qualident(inc.Path);
            var name = inc.Path[inc.Path.Count - 1];
            inc.Path.RemoveAt(inc.Path.Count - 1);
            inc.Alias = inc.Name = name;
            Program.Includes.Add(inc);

            if (la.kind == 51) {
            Get();
            if (la.kind == 1) {
                Get();
                inc.DllName = t.val;
            } else if (la.kind == 5) {
                Get();
                inc.DllName = ReadString(t.val);
            } else SynErr(105);
            }
            if (la.kind == 30) {
            Get();
            Expect(1);
            inc.Alias = t.val;
            }
            if (la.kind == 54) {
            var imp = default(ElaImportedVariable);
            Get();
            ImportName(out imp);
            inc.ImportList.Add(imp);
            while (la.kind == 56) {
                Get();
                ImportName(out imp);
                inc.ImportList.Add(imp);
            }
            Expect(55);
            }
            if (la.kind == 1 || la.kind == 5) {
            IncludeStatElement(qual);
            }
        }