Exemplo n.º 1
0
 public void AddMethod(OsgObject proc)
 {
     var methodBuilder = currentType.DefineMethod(proc.name, MethodAttributes.Static, typeof(void), System.Type.EmptyTypes);
     var ilGenerator = methodBuilder.GetILGenerator();
     proc.ILGen(ilGenerator);
     ilGenerator.Emit(OpCodes.Ret);
     proc.MethodBuilder = methodBuilder;
 }
Exemplo n.º 2
0
 public Parser()
 {
     topScope = null;
     OpenScope();
     RegisterBuiltInProc("Write",
         (iLGen =>
         {
             iLGen.Emit(OpCodes.Ldstr, "Test String");
             iLGen.Emit(OpCodes.Call,
                        typeof(System.Console).GetMethod("WriteLine",
                                                          new System.Type[] { typeof(string) }));
         }));
     //enter(OsgClassMode.Typ, 1, "Writer", TypeDesc.classType);
     universe = topScope;
 }
Exemplo n.º 3
0
        public OsgItem MakeItem(OsgObject y)
        {
            var x = new OsgItem();
            x.mode = y.@class;
            x.type = y.type;
            x.lev = y.lev;
            x.a = y.val;
            x.b = 0;
            x.osgObject = y;
            // TODO: Work out x.r

            if(y.@class == OsgClassMode.Par)
            {
                x.mode = OsgClassMode.Var;
                x.a = 0;
            }

            Debug.WriteLine(String.Format("Generator: MakeItem({0})", y.name));
            return x;
        }
Exemplo n.º 4
0
        private void RegisterBuiltInProc(string procName, GenIlDelegate ilDelegate)
        {
            var x = topScope;
            while (x.next != guard)
                x = x.next;

            var proc = new OsgObject();
            proc.name = procName;
            proc.@class = OsgClassMode.Proc;
            proc.next = guard;
            proc.ILGen = ilDelegate;

            x.next = proc;
        }
Exemplo n.º 5
0
 private void parameter(OsgObject fp)
 {
     OsgItem x;
     x = expression();
     if(IsParam(fp))
     {
         generator.Parameter(x, fp.type, fp.@class);
         fp = fp.next;
     }
     else
     {
         scanner.Mark("too many parameters");
     }
 }
Exemplo n.º 6
0
 private void OpenScope()
 {
     var s = new OsgObject();
     s.@class = OsgClassMode.Head;
     s.dsc = topScope;
     s.next = guard;
     topScope = s;
 }
Exemplo n.º 7
0
        private OsgObject NewObj(OsgClassMode proc)
        {
            OsgObject @new;
            OsgObject x = topScope;
            guard.name = scanner.id;

            while (x.next.name != scanner.id)
            {
                x = x.next;
            }

            if (x.next == guard)
            {
                @new = new OsgObject();
                @new.name = scanner.id;
                @new.@class = proc;
                @new.next = guard;
                x.next = @new;
                return @new;
            }
            else
            {
                scanner.Mark("mult def");
                return x.next;
            }
        }
Exemplo n.º 8
0
 private bool IsParam(OsgObject obj)
 {
     return (obj.@class == OsgClassMode.Par || (obj.@class == OsgClassMode.Var && obj.val > 0));
 }
Exemplo n.º 9
0
 private void enter(OsgClassMode typ, int i, string name, TypeDesc type)
 {
     OsgObject osg = new OsgObject();
     osg.@class = typ;
     osg.val = i;
     osg.name = name;
     osg.type = type;
     osg.dsc = null;
     osg.next = topScope.next;
     topScope.next = osg;
 }