Beispiel #1
0
 public override void Generate(Method method)
 {
     if (isval)
     {
         var index = method.GetVar(Op.ToString(), out var attribute);
         method.AddCode(attribute == 1 ? ISet.Push_local : ISet.Push_field, index);
     }
     else
     {
         method.AddCode(ISet.Push_value, Op);
     }
 }
Beispiel #2
0
 public override void Generate(Method method)
 {
     left.Generate(method);
     right.Generate(method);
     method.AddCode(
         Op.tag_value == OR ? ISet.Or :
         Op.tag_value == AND ?ISet.And :
         Op.tag_value == EQ || Op.tag_value == NE ? ISet.Equal :
         Op.tag_value == LE || Op.tag_value == '>'? ISet.Greater :ISet.Less
         );
     if (Op.tag_value == NE || Op.tag_value == LE || Op.tag_value == GE)
     {
         method.AddCode(ISet.Negate);
     }
 }
Beispiel #3
0
 public override void Generate(Method method)
 {
     for (var i = @params.Count - 1; i >= 0; i--)
     {
         @params[i].Generate(method);
     }
     method.AddCode(ISet.Call, morpheme.ToString());
 }
Beispiel #4
0
 public override void Generate(Method method)
 {
     left.Generate(method);
     right.Generate(method);
     method.AddCode(
         Op.tag_value == '+' ? ISet.Add :
         Op.tag_value == '-' ? ISet.Minus :
         Op.tag_value == '*' ? ISet.Multiply : ISet.Divide
         );
 }
Beispiel #5
0
        public override void Generate(Method generator)
        {
            value.Check(generator);
            value.Generate(generator);
            var morpheme = Phrase.GetEnd(target);

            Phrase.DoubleCheck(morpheme, MorphemeAttribute.Object);
            var index = generator.GetVar(morpheme.name, out var attribute);

            if (index == -1)
            {
                Error(UnknownVariable, lex_line, lex_ch, morpheme.name);
            }
            generator.AddCode(attribute == 1?ISet.Storeloc:ISet.StoreField, index);
        }