示例#1
0
        void GenerateCode(Node node, Parser.ValueNode value)
        {
            // Push a value onto the stack

            switch (value.value.type)
            {
            case Value.Type.Number:
                Emit(node, ByteCode.PushNumber, value.value.numberValue);
                break;

            case Value.Type.String:
                // TODO: we use 'null' as the line ID here because strings used in expressions
                // don't have a #line: tag we can use
                var id = program.RegisterString(value.value.stringValue, node.name, null, value.lineNumber, false);
                Emit(node, ByteCode.PushString, id);
                break;

            case Value.Type.Bool:
                Emit(node, ByteCode.PushBool, value.value.boolValue);
                break;

            case Value.Type.Variable:
                Emit(node, ByteCode.PushVariable, value.value.variableName);
                break;

            case Value.Type.Null:
                Emit(node, ByteCode.PushNull);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        void GenerateCode(Node node, Parser.ValueNode value)
        {
            // Push a value onto the stack

            switch (value.value.type)
            {
            case Value.Type.Number:
                Emit(node, ByteCode.PushNumber, value.value.AsNumber);
                break;

            case Value.Type.String:
                // TODO: we use 'null' as the line ID here because strings used in expressions
                // don't have a #line: tag we can use
                var id = program.RegisterString(value.value.AsString, node.name, null, value.lineNumber, false);
                Emit(node, ByteCode.PushString, id);
                break;

            case Value.Type.Bool:
                Emit(node, ByteCode.PushBool, value.value.AsBool);
                break;

            case Value.Type.Variable:
                Emit(node, ByteCode.PushVariable, value.value.AsString);
                break;

            case Value.Type.Null:
                Emit(node, ByteCode.PushNull);
                break;

            default:
                throw new ArgumentOutOfRangeException();  // Since the language can't actually produce an object, this is okay.
            }
        }
示例#3
0
        void GenerateCode(Node node, Parser.ValueNode value)
        {
            // Push a value onto the stack

            switch (value.value.type)
            {
            case Value.Type.Number:
                Emit(node, ByteCode.PushNumber, value.value.numberValue);
                break;

            case Value.Type.String:
                var id = program.RegisterString(value.value.stringValue);
                Emit(node, ByteCode.PushString, id);
                break;

            case Value.Type.Bool:
                Emit(node, ByteCode.PushBool, value.value.boolValue);
                break;

            case Value.Type.Variable:
                Emit(node, ByteCode.PushVariable, value.value.variableName);
                break;

            case Value.Type.Null:
                Emit(node, ByteCode.PushNull);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }