示例#1
0
        public void Visit(AttrAssignment asn)
        {
            /*
             * ;set_obj_attribute
             * ;params are on user stack
             * ;top param is new value
             * ;next param is attr to set
             * ;next is object
             */

            sw.WriteLine("\tnop ;writing a set attribute statement");

            //            sw.WriteLine("\tpop bx ; pull value (rhs)");
            //           sw.WriteLine("\tpop ax ; pull obj # (lhs)");
            //            sw.WriteLine("\tpshu a ; push obj # param");

            try
            {
                //stuff here
                sw.WriteLine("\tpop cx ; save value");
                sw.WriteLine("\tpop bx ; save obj id");

                sw.WriteLine("\tmov ax," + attrIndexes[asn.attrName] + " ; push attr index");
                sw.WriteLine("\tpush cx ; push value");
                sw.WriteLine("\tpush ax ; push attr # param");
                sw.WriteLine("\tpush bx ; push object id");
                sw.WriteLine("\tcall set_obj_attr");
                sw.WriteLine("\tadd sp,6 ; pop params");
            }
            catch (Exception e)
            {
                throw new Exception(asn.attrName + " is not a valid attr for " + asn.objName, e);
            }
        }
        public void Visit(AttrAssignment asn)
        {
            /*
             * ;set_obj_attribute
             * ;params are on user stack
             * ;top param is new value
             * ;next param is attr to set
             * ;next is object
             */

            sw.WriteLine(Tabs() + "// ;writing a set attribute statement");

            //            sw.WriteLine(Tabs()+"pop bx ; pull value (rhs)");
            //           sw.WriteLine(Tabs()+"pop ax ; pull obj # (lhs)");
            //            sw.WriteLine(Tabs()+"pshu a ; push obj # param");

            try
            {
                //stuff here
                sw.WriteLine(Tabs() + "param3 = param_stack_pop() ; //save value");
                sw.WriteLine(Tabs() + "param1 = param_stack_pop() ; //save obj id");
                sw.WriteLine(Tabs() + "param2 = " + attrIndexes[asn.attrName] + " ; // attr index");
                sw.WriteLine(Tabs() + "set_object_attr(param1,param2,param3);");
            }
            catch (Exception e)
            {
                throw new Exception(asn.attrName + " is not a valid attr for " + asn.objName, e);
            }
        }
示例#3
0
        public void Visit(AttrAssignment asn)
        {
            /*
             * ;set_object_attribute
             * ;params are on system stack
             * ;top param is new value
             * ;next param is attr to set
             * ;next is object
             */

            sw.WriteLine("\t;writing a set attribute statement");

            sw.WriteLine("\tpuls b ; pull value (rhs)");
            sw.WriteLine("\tclra ; ");
            sw.WriteLine("\ttfr d,x ; ");
            sw.WriteLine("\tpuls b ; pull obj # (lhs)");
            sw.WriteLine("\ttfr d,y ; save obj # param");

            try
            {
                sw.WriteLine("\tldb #" + attrIndexes[asn.attrName] + " ; push attr index");
            }
            catch (Exception e)
            {
                throw new Exception(asn.attrName + " is not a valid attr for " + asn.objName, e);
            }

            sw.WriteLine("\tpshs x ; push value param");
            sw.WriteLine("\tpshs d ; push attr param");
            sw.WriteLine("\tpshs y ; push attr param");
            sw.WriteLine("\tjsr set_object_attr");
            sw.WriteLine("\tleas 6,s");
        }
示例#4
0
 public void Visit(AttrAssignment m)
 {
     // set property c of object b to register a
     sw.WriteLine("\tpop af  ; pop value");
     //sw.WriteLine("\tld b," + game.GetObjectId(m.objName));
     sw.WriteLine("\tpop bc ; pop obj id");
     sw.WriteLine("\tld c," + attrIndexes[m.attrName] + " ; " + m.attrName);
     sw.WriteLine("\tcall set_obj_attr");
 }
        /// <summary>
        /// Builds the call to assign and object's attr
        /// </summary>
        /// <param name="va"></param>
        public void Visit(AttrAssignment va)
        {
            sw.WriteLine("\t; building set attr call");

            sw.WriteLine("\tpla ; attr val -> x");
            sw.WriteLine("\ttax");
            try
            {
                sw.WriteLine("\tlda #" + attrIndexes[va.attrName] + "   ; attr # -> y (" + va.attrName + ")");
                sw.WriteLine("\ttay ; ");
            }
            catch
            {
                throw new Exception(va.attrName + " is not a valid attribute");
            }

            sw.WriteLine("\tpla ; pull object # off stack");

            sw.WriteLine("\tjsr set_obj_attr");
//            Console.WriteLine("jsr set_obj_attr");
        }