Inheritance: AstNodeBase
示例#1
0
        Expression DecodeParseString(Expression exp)
        {
            while ((_opCode = ReadByte()) != 0xFF)
            {
                switch (_opCode & 0xF)
                {
                    case 0:     // SO_AT
                        var x = GetVarOrDirectWord(OpCodeParameter.Param1);
                        var y = GetVarOrDirectWord(OpCodeParameter.Param2);
                        exp = new MethodInvocation(new MemberAccess(exp, "At")).AddArguments(x, y);
                        break;

                    case 1:     // SO_COLOR
                        var color = GetVarOrDirectByte(OpCodeParameter.Param1);
                        exp = new MethodInvocation(new MemberAccess(exp, "Color")).AddArguments(color);
                        break;

                    case 2:     // SO_CLIPPED
                        var clipped = GetVarOrDirectWord(OpCodeParameter.Param1);
                        exp = new MethodInvocation(new MemberAccess(exp, "Clipped")).AddArguments(clipped);
                        break;

                    case 4:     // SO_CENTER
                        exp = new MethodInvocation(new MemberAccess(exp, "Center"));
                        break;

                    case 6:     // SO_LEFT
                        var args = new List<Expression>();
                        if (Game.Version == 3)
                        {
                            args.Add(GetVarOrDirectWord(OpCodeParameter.Param1));
                        }
                        exp = new MethodInvocation(new MemberAccess(exp, "Left")).AddArguments(args);
                        break;

                    case 7:     // SO_OVERHEAD
                        exp = new MethodInvocation(new MemberAccess(exp, "Overhead"));
                        break;

                    case 8:
                        {	// SO_SAY_VOICE
                            var offset = GetVarOrDirectWord(OpCodeParameter.Param1);
                            var delay = GetVarOrDirectWord(OpCodeParameter.Param2);
                            exp = new MethodInvocation(new MemberAccess(exp, "PlayCDTrack")).AddArguments(offset, delay);
                        }
                        break;

                    case 15:
                        {   // SO_TEXTSTRING
                            var text = ReadCharacters();
                            exp = new MethodInvocation(new MemberAccess(exp, "Print")).AddArguments(text);
                        }
                        return exp;

                    default:
                        throw new NotImplementedException(string.Format("DecodeParseString #{0:X2} is not implemented", _opCode & 0xF));
                }
            }
            return exp;
        }
示例#2
0
        protected virtual Expression DecodeParseString(Expression target, bool withActor)
        {
            var b = ReadByte();

            switch (b)
            {
                case 65:                // SO_AT
                    {
                        var y = Pop();
                        var x = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "At")).AddArguments(x, y);
                    }
                    break;
                case 66:                // SO_COLOR
                    {
                        var color = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "Color")).AddArguments(color);
                    }
                    break;
                case 67:                // SO_CLIPPED
                    {
                        var right = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "Clipped")).AddArguments(right);
                    }
                    break;
                case 69:                // SO_CENTER
                    target = new MethodInvocation(new MemberAccess(target, "Center"));
                    break;
                case 71:                // SO_LEFT
                    target = new MethodInvocation(new MemberAccess(target, "Left"));
                    break;
                case 72:                // SO_OVERHEAD
                    target = new MethodInvocation(new MemberAccess(target, "OverHead"));
                    break;
                case 74:                // SO_MUMBLE
                    target = new MethodInvocation(new MemberAccess(target, "Mumble"));
                    break;
                case 75:                // SO_TEXTSTRING
                    target = new MethodInvocation(new MemberAccess(target, "Text")).AddArgument(ReadCharacters());
                    break;
                case 0xFE:
                    target = new MethodInvocation(new MemberAccess(target, "LoadDefault"));
                    if (withActor)
                    {
                        var actor = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "Actor")).AddArgument(actor);
                    }
                    break;
                case 0xFF:
                    target = new MethodInvocation(new MemberAccess(target, "SaveDefault"));
                    break;
                default:
                    throw new NotSupportedException(string.Format("DecodeParseString: default case 0x{0:X}", b));
            }
            return target;
        }
示例#3
0
 protected Expression GetActor(Expression index)
 {
     return new ElementAccess(Actors, index);
 }
示例#4
0
 protected virtual void PopRoomAndObject(out Expression room, out Expression obj)
 {
     room = Pop();
     obj = Pop();
 }
示例#5
0
        protected override Expression DecodeParseString(Expression target, bool withActor)
        {
            var b = ReadByte();

            switch (b)
            {
                case 0xC8:      // SO_PRINT_BASEOP
                    target = new MethodInvocation(new MemberAccess(target, "LoadDefault"));
                    if (withActor)
                    {
                        var actor = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "Actor")).AddArgument(actor);
                    }
                    break;
                case 0xC9:      // SO_PRINT_END
                    target = new MethodInvocation(new MemberAccess(target, "SaveDefault"));
                    break;
                case 0xCA:                // SO_PRINT_AT
                    {
                        var y = Pop();
                        var x = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "At")).AddArguments(x, y);
                    }
                    break;
                case 0xCB:                // SO_COLOR
                    {
                        var color = Pop();
                        target = new MethodInvocation(new MemberAccess(target, "Color")).AddArguments(color);
                    }
                    break;
                case 0xCC:                // SO_PRINT_CENTER
                    target = new MethodInvocation(new MemberAccess(target, "Center"));
                    break;
                case 0xCD:                // SO_PRINT_CHARSET Set print character set
                    target = new MethodInvocation(new MemberAccess(target, "Charset")).AddArgument(Pop());
                    break;
                case 0xCE:                // SO_PRINT_LEFT
                    target = new MethodInvocation(new MemberAccess(target, "Left"));
                    break;
                case 0xCF:                // SO_OVERHEAD
                    target = new MethodInvocation(new MemberAccess(target, "OverHead"));
                    break;
                case 0xD0:                // SO_MUMBLE
                    target = new MethodInvocation(new MemberAccess(target, "Mumble"));
                    break;
                case 0xD1:                // SO_TEXTSTRING
                    target = new MethodInvocation(new MemberAccess(target, "Text")).AddArgument(ReadCharacters());
                    break;
                case 0xD2:                // SO_PRINT_WRAP Set print wordwrap
                    target = new MethodInvocation(new MemberAccess(target, "WordWrap"));
                    break;
                default:
                    throw new NotSupportedException(string.Format("DecodeParseString: default case 0x{0:X}", b));
            }
            return target;
        }
示例#6
0
 Expression SetResult(int index, Expression value)
 {
     return new BinaryExpression(
         GetVariableAt(index), Operator.Assignment, value);
 }
示例#7
0
 Expression GetIndex(Expression exp, int index)
 {
     return new ElementAccess(exp, index);
 }
示例#8
0
 protected Expression SetResultExpression(Expression index, Expression value)
 {
     var literalExp = index as IntegerLiteralExpression;
     if (literalExp != null)
     {
         return SetResult(literalExp.Value, value);
     }
     else
     {
         return new BinaryExpression(new ElementAccess("Variables", index), Operator.Assignment, value);
     }
 }
示例#9
0
 Expression ReadVariable(Expression index)
 {
     var literal = index as IntegerLiteralExpression;
     if (literal != null)
     {
         return ReadVariable(literal.Value);
     }
     else
     {
         return ReadVariable2(index);
     }
 }
示例#10
0
 static Expression Not(Expression condition)
 {
     if (condition is UnaryExpression)
     {
         return ((UnaryExpression)condition).Not();
     }
     else if (condition is BinaryExpression)
     {
         return ((BinaryExpression)condition).Not();
     }
     else
     {
         return new UnaryExpression(condition, Operator.Not);
     }
 }
示例#11
0
 protected Expression SetResult(int index, Expression value)
 {
     return new BinaryExpression(GetResultIndex(index), Operator.Assignment, value);
 }
示例#12
0
 Statement JumpRelative(Expression condition)
 {
     var offset = (short)ReadWord();
     var binExp = condition as BinaryExpression;
     if (binExp != null)
     {
         condition = binExp.Not();
     }
     else
     {
         condition = true.ToLiteral();
     }
     return new JumpStatement(condition, (int)_br.BaseStream.Position + offset);
 }
示例#13
0
 static Expression GetActorAt(Expression index)
 {
     var ile = index as IntegerLiteralExpression;
     if (ile != null)
     {
         var id = ile.Value & 0x7F;
         if (id > 0 && id <= v0ActorNames_English.Length)
         {
             return new SimpleName(v0ActorNames_English[id - 1]);
         }
     }
     return new ElementAccess("Actors", index);
 }
示例#14
0
 static ElementAccess GetObjectAt(Expression index)
 {
     return new ElementAccess("Objects", index);
 }
示例#15
0
 Expression WriteVar(int index, Expression value)
 {
     return new BinaryExpression(new ElementAccess(VariablesName, index), Operator.Assignment, value);
 }
示例#16
0
 Expression Verb(Expression index)
 {
     return new ElementAccess(Verbs, index);
 }
示例#17
0
 protected Expression ReadVariable2(Expression var)
 {
     return new MethodInvocation("ReadVariable").AddArgument(var);
 }
示例#18
0
 Statement JumpRelative(Expression condition)
 {
     var offset = (short)FetchScriptWord();
     var binExp = condition as BinaryExpression;
     var unExp = condition as UnaryExpression;
     if (binExp != null)
     {
         condition = binExp.Not();
     }
     else if (unExp != null)
     {
         condition = unExp.Not();
     }
     else
     {
         condition = condition.Not();
     }
     return new JumpStatement(condition, (int)_br.BaseStream.Position + offset);
 }