コード例 #1
0
ファイル: BartokReader.cs プロジェクト: Paul1nh0/Singularity
    Symbol GetSymbol(MetaDataTypeReference r)
    {
        if (r.ResolutionScope is MetaDataAssemblyRef)
        {
            string name = ((MetaDataAssemblyRef)r.ResolutionScope).Name;
            if (!Path.HasExtension(name))
            {
                name += ".dll";
            }
            Load(name);
        }
        if (r.Namespace == "")
        {
            if (r.ResolutionScope is MetaDataTypeReference &&
                ((MetaDataTypeReference)r.ResolutionScope).Namespace != "")
            {
                return(Import(((MetaDataTypeReference)r.ResolutionScope).FullName + "." + r.Name));
            }
            else
            {
                return(Import(r.Name));
            }
        }
        Symbol s = Import(r.Namespace + "." + r.Name);

        if (s == null)
        {
            msg.Error("type or namespace '{0}' cannot be found\n" +
                      "\t(missing using directive or assembly reference?)", r.FullName);
            return(global.Types.Object);
        }
        return(s);
    }
コード例 #2
0
ファイル: Symbols.cs プロジェクト: Paul1nh0/Singularity
    Symbol searchUsing(InputElement id, MessageWriter msg)
    {
        int    count = 0;
        Symbol t     = null;

        if (usingdirectives != null)
        {
            foreach (NameSpace n in usingdirectives)
            {
                if (n[id.str] != null)
                {
                    count++;
                    if (t == null)
                    {
                        t = n[id.str];
                    }
                }
            }
        }
        if (count > 1)
        {
            msg.Error(id, "'{0}' is ambiguous", id.str);
        }
        return(t);
    }
コード例 #3
0
ファイル: execute.cs プロジェクト: Paul1nh0/Singularity
 public static object visit(object ast, TextWriter w, string[] args, MessageWriter msg)
 {
     if (msg.Count == 0 && ast is AssemblyBuilder)
     {
         AssemblyBuilder asm = (AssemblyBuilder)ast;
         object          o   = null;
         MethodInfo      m   = null;
         int             i;
         if (args.Length > 0 && (i = args[0].LastIndexOf('.')) > 0)
         {
             o = asm.CreateInstance(args[0].Substring(0, i));
             if (o != null)
             {
                 m = o.GetType().GetMethod(args[0].Substring(i + 1));
             }
         }
         else
         {
             m = asm.EntryPoint.DeclaringType.GetMethod(asm.EntryPoint.Name);
         }
         if (m != null && o != null)
         {
             m.Invoke(o, null);
         }
         else if (m != null)
         {
             m.Invoke(null, null);
         }
         else
         {
             msg.Error("{0} not found", args.Length > 0 ? args[0] : "entry point");
         }
     }
     return(ast);
 }
コード例 #4
0
ファイル: Debug.cs プロジェクト: vmkc/research-environment
    public static object visit(object ast, TextWriter w, string[] args, MessageWriter msg)
    {
        int    nf    = 0;
        string oname = null;

        foreach (string s in args)
        {
            if (s.StartsWith("-file="))
            {
                oname = s.Substring(6);
                nf++;
            }
        }
        if (oname == null)
        {
            oname = Path.GetTempFileName();
            File.Delete(oname);
            oname = Path.ChangeExtension(oname, ".htm");
        }
        try {
            TextWriter wr = new StreamWriter(oname);
            if (oname.EndsWith(".htm") || oname.EndsWith(".html"))
            {
                Debug.DumpAllHTML(ast, wr);
            }
            else
            {
                Debug.DumpAll(ast, wr);
            }
            wr.Close();
        } catch (Exception e) {
            msg.Error("can't write \"{0}\" ({1})", oname, e.ToString());
            return(ast);
        }
        if (nf == 0)
        {
            try {
                object         o  = null;
                IWebBrowserApp ie = new SHDocVw.InternetExplorer();
                ie.Visible = true;
                ie.Navigate(oname, ref o, ref o, ref o, ref o);
            } catch (Exception e) {
                msg.Error("can't launch Internet Explorer ({0})", e.ToString());
            }
        }
        return(ast);
    }
コード例 #5
0
    ClassType Builtin(string fullname)
    {
        ClassType t = (ClassType)imp.Import(fullname);

        if (t == null && msg != null)
        {
            msg.Error("unknown built-in type '{0}'; maybe a missing -reference option", fullname);
            return(new ClassType(new InputElement(fullname), null));
        }
        Debug.Assert(t != null);
        return(t);
    }
コード例 #6
0
ファイル: Symbols.cs プロジェクト: Paul1nh0/Singularity
    public Label AddLabel(InputElement label, MessageWriter msg)
    {
        Label t = LookupLabel(label);

        if (t != null)
        {
            msg.Error(label, "label '{0}' already defined at {1}", label.str,
                      new Coordinate(t.id).ToString());
        }
        t = new Label(label, labels);
        labels.Add(label.str, t);
        return(t);
    }
コード例 #7
0
ファイル: Compiler.cs プロジェクト: vmkc/research-environment
 void compile(string[] inputs, compilation_unitList asts)
 {
     foreach (string f in inputs)
     {
         try {
             TextReader r    = new StreamReader(f);
             long       time = Debug.Clock;
             object     ast  = Parser.parse(f, r);
             if (ast != null)
             {
                 asts.Add((compilation_unit)ast);
             }
             else
             {
                 Msg.Count++;
             }
             r.Close();
         } catch (Exception e) {
             Msg.Error("can't read \"{0}\": {1}", f, e.Message);
         }
     }
 }
コード例 #8
0
ファイル: Symbols.cs プロジェクト: Paul1nh0/Singularity
    public Constant AddConstant(InputElement id, MessageWriter msg)
    {
        Symbol s = LookupLocal(id);

        if (s != null)
        {
            msg.Error(id, "constant '{0}' already defined in this or a parent scope at {1}",
                      id.str, new Coordinate(s.id).ToString());
        }
        Constant t = new Constant(id, locals);

        t.Add(id, locals, msg);
        return(t);
    }
コード例 #9
0
ファイル: Symbols.cs プロジェクト: Paul1nh0/Singularity
 static public Symbol Add(InputElement id, Symbol s, SymbolTable bindings, MessageWriter msg)
 {
     if (bindings.Contains(id.str))
     {
         string name = bindings.Owner.FullName;
         if (name.Length > 0)
         {
             name = " '" + name + "'";
         }
         msg.Error(id, "{0}{1} already contains a definition for '{2}'", bindings.Owner.Kind, name, id.str);
     }
     else
     {
         bindings.Add(id.str, s);
     }
     return(s);
 }