import { pythonGenerator } from "blockly/python";

const Blockly = {
    Python: pythonGenerator || { Msg: Object.create(null) }
};
Blockly.Python.CocoRobo_type = function(a) {
    return ["type(" + (Blockly.Python.valueToCode(a, "VAR", Blockly.Python.ORDER_ATOMIC) || "None") + ")", Blockly.Python.ORDER_ATOMIC]
};
Blockly.Python.CocoRobo_type_is = function(a) {
    var b = Blockly.Python.valueToCode(a, "VAR", Blockly.Python.ORDER_ATOMIC) || "None";
    a = a.getFieldValue("TYPE");
    return ["type(" + b + ") \x3d\x3d " + a, Blockly.Python.ORDER_ATOMIC]
};
Blockly.Python.CocoRobo_eval = function(a) {
    return ["eval(" + (Blockly.Python.valueToCode(a, "VAR", Blockly.Python.ORDER_ATOMIC) || "None") + ")", Blockly.Python.ORDER_ATOMIC]
};
Blockly.Python.CocoRobo_return = function(a) {
    return "return " + (Blockly.Python.valueToCode(a, "VAR", Blockly.Python.ORDER_ATOMIC) || "None") + "\n"
};
Blockly.Python.CocoRobo_try_except = function(a) {
    var b = Blockly.Python.statementToCode(a, "TRY") || Blockly.Python.PASS;
    a = Blockly.Python.statementToCode(a, "EXCEPT") || Blockly.Python.PASS;
    return "try:\n" + b + "except:\n" + a
};
Blockly.Python.CocoRobo_try_except_finally = function(a) {
    var b = Blockly.Python.statementToCode(a, "TRY") || Blockly.Python.PASS,
        c = Blockly.Python.statementToCode(a, "EXCEPT") || Blockly.Python.PASS;
    a = Blockly.Python.statementToCode(a, "FINALLY") || Blockly.Python.PASS;
    return "try:\n" + b + "except:\n" + c + "finally:\n" + a
};
export default Blockly