// total=11974 new=73.53% cached=0.00% other=26.47%
(function (ectx) {
'use strict';
const runtime = ectx.runtime;
const oops = ectx.oops;
const doNothing = ectx.doNothing;
const pxsim = ectx.pxsim;
const globals = ectx.globals;
const maybeYield = ectx.maybeYield;
const setupDebugger = ectx.setupDebugger;
const isBreakFrame = ectx.isBreakFrame;
const breakpoint = ectx.breakpoint;
const trace = ectx.trace;
const checkStack = ectx.checkStack;
const leave = ectx.leave;
const checkResumeConsumed = ectx.checkResumeConsumed;
const setupResume = ectx.setupResume;
const setupLambda = ectx.setupLambda;
const checkSubtype = ectx.checkSubtype;
const failedCast = ectx.failedCast;
const buildResume = ectx.buildResume;
const mkVTable = ectx.mkVTable;
const bind = ectx.bind;
const leaveAccessor = ectx.leaveAccessor;
const __this = runtime;
const pxtrt = pxsim.pxtrt;
let yieldSteps = 1;
ectx.setupYield(function() { yieldSteps = 100; })
pxsim.setTitle("datalogger");
pxsim.setConfigData({}, {});
pxtrt.mapKeyNames = [
 "",
 "filename",
 "flush"
];
__this.setupPerfCounters([]);
const pxsim_Array__getAt = pxsim.Array_.getAt;
const pxsim_Array__length = pxsim.Array_.length;
const pxsim_Array__mk = pxsim.Array_.mk;
const pxsim_Array__push = pxsim.Array_.push;
const pxsim_Boolean__bang = pxsim.Boolean_.bang;
const pxsim_String__concat = pxsim.String_.concat;
const pxsim_String__stringConv = pxsim.String_.stringConv;
const pxsim_numops_toBool = pxsim.numops.toBool;
const pxsim_numops_toBoolDecr = pxsim.numops.toBoolDecr;
const pxsim_pxtcore_mkAction = pxsim.pxtcore.mkAction;
const pxsim_pxtcore_mkClassInstance = pxsim.pxtcore.mkClassInstance;
const pxsim_pxtrt_ldlocRef = pxsim.pxtrt.ldlocRef;
const pxsim_pxtrt_mapGetByString = pxsim.pxtrt.mapGetByString;
const pxsim_pxtrt_stclo = pxsim.pxtrt.stclo;
const pxsim_pxtrt_stlocRef = pxsim.pxtrt.stlocRef;
const pxsim_Boolean_ = pxsim.Boolean_;
const pxsim_pxtcore = pxsim.pxtcore;
const pxsim_String_ = pxsim.String_;
const pxsim_ImageMethods = pxsim.ImageMethods;
const pxsim_Array_ = pxsim.Array_;
const pxsim_pxtrt = pxsim.pxtrt;
const pxsim_numops = pxsim.numops;


function _main___P58926(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    globals._intervals___59169 = (undefined);
    globals._pollEventQueue___59182 = (undefined);
    r0 = pxsim.storage.init();
    globals._headers___59387 = (undefined);
    globals._row___59391 = (undefined);
    r0 = pxsim_pxtcore_mkClassInstance(datalogger_FileStorage__C59418_VT);
    s.tmp_0 = r0;
    s.tmp_1 = datalogger_FileStorage_constructor__P59424_mk(s);
    s.tmp_1.arg0 = s.tmp_0;
    s.tmp_1.arg1 = "log.csv";
    s.callLocIdx = 3; s.pc = 1; return s.tmp_1;
  case 1:
    r0 = s.retval;
    s.tmp_2 = datalogger_setStorage__P59411_mk(s);
    s.tmp_2.arg0 = s.tmp_0;
    s.callLocIdx = 4; s.pc = 2; return s.tmp_2;
  case 2:
    r0 = s.retval;
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
_main___P58926.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"targetoverrides.ts","functionName":"<main>","argumentNames":[]}
_main___P58926.continuations = [  ]

function _main___P58926_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: _main___P58926, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  tmp_0: undefined,
  tmp_1: undefined,
  tmp_2: undefined,
} }





function datalogger_FileStorage_constructor__P59424(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    if (s.lambdaArgs) {
      s.arg0 = (s.lambdaArgs[0]);
      s.arg1 = (s.lambdaArgs[1]);
      s.lambdaArgs = null;
    }
    r0 = s.arg0;
    if (!checkSubtype(r0, datalogger_FileStorage__C59418_VT)) failedCast(r0);
    r0 = undefined;
    r0 = (s.arg0).fields["filename"] = (s.arg1);
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_FileStorage_constructor__P59424.info = {"start":192,"length":99,"line":7,"column":8,"endLine":10,"endColumn":9,"fileName":"storagedatalogger.ts","functionName":"inline","argumentNames":["this","filename"]}

function datalogger_FileStorage_constructor__P59424_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_FileStorage_constructor__P59424, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  arg0: undefined,
  arg1: undefined,
} }





function datalogger_Storage_constructor__P59385(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    if (s.lambdaArgs) {
      s.arg0 = (s.lambdaArgs[0]);
      s.lambdaArgs = null;
    }
    r0 = s.arg0;
    if (!checkSubtype(r0, datalogger_Storage__C59380_VT)) failedCast(r0);
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_Storage_constructor__P59385.info = {"start":412,"length":25,"line":20,"column":8,"endLine":21,"endColumn":9,"fileName":"datalogger.ts","functionName":"inline","argumentNames":["this"]}

function datalogger_Storage_constructor__P59385_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_Storage_constructor__P59385, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  arg0: undefined,
} }





function datalogger_setStorage__P59411(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    if (s.lambdaArgs) {
      s.arg0 = (s.lambdaArgs[0]);
      s.lambdaArgs = null;
    }
    s.tmp_0 = datalogger_flush__P59412_mk(s);
    s.callLocIdx = 0; s.pc = 1; return s.tmp_0;
  case 1:
    r0 = s.retval;
    globals._storage___59393 = (s.arg0);
    s.tmp_0 = datalogger_clear__P59406_mk(s);
    s.callLocIdx = 1; s.pc = 2; return s.tmp_0;
  case 2:
    r0 = s.retval;
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_setStorage__P59411.info = {"start":4000,"length":114,"line":151,"column":4,"endLine":155,"endColumn":5,"fileName":"datalogger.ts","functionName":"setStorage","argumentNames":["storage"]}

function datalogger_setStorage__P59411_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_setStorage__P59411, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  tmp_0: undefined,
  arg0: undefined,
} }





function datalogger_clear__P59406(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    globals._headers___59387 = (undefined);
    globals._row___59391 = (undefined);
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_clear__P59406.info = {"start":1145,"length":80,"line":51,"column":4,"endLine":54,"endColumn":5,"fileName":"datalogger.ts","functionName":"clear","argumentNames":[]}

function datalogger_clear__P59406_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_clear__P59406, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
} }





function datalogger_flush__P59412(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    s.tmp_0 = r0 = globals._headers___59387;
    r0 = pxsim_numops_toBool(s.tmp_0);
    if (r0) { step = 1; continue; }
    r0 = s.tmp_0;
    { step = 2; continue; }
  case 1:
    r0 = globals._storage___59393;
  case 2:
    // jmp value (already in r0)
    s.tmp_1 = r0;
    r0 = pxsim_numops_toBoolDecr(s.tmp_1);
    if (!r0) { step = 3; continue; }
    s.tmp_2 = datalogger_Storage__C59380_v0_1_mk(s);
    s.tmp_2.arg0 = globals._storage___59393;
    if (!checkSubtype(s.tmp_2.arg0, datalogger_Storage__C59380_VT)) failedCast(s.tmp_2.arg0);
    s.tmp_2.fn = s.tmp_2.arg0.vtable.methods.flush;
    s.pc = 5; return s.tmp_2;
  case 5:
    r0 = s.retval;
  case 3:
  case 4:
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_flush__P59412.info = {"start":4184,"length":95,"line":161,"column":4,"endLine":164,"endColumn":5,"fileName":"datalogger.ts","functionName":"flush","argumentNames":[]}

function datalogger_flush__P59412_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_flush__P59412, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  tmp_0: undefined,
  tmp_1: undefined,
  tmp_2: undefined,
} }





function datalogger_Storage_flush__P59384(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    if (s.lambdaArgs) {
      s.arg0 = (s.lambdaArgs[0]);
      s.lambdaArgs = null;
    }
    r0 = s.arg0;
    if (!checkSubtype(r0, datalogger_Storage__C59380_VT)) failedCast(r0);
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_Storage_flush__P59384.info = {"start":807,"length":17,"line":37,"column":8,"endLine":37,"endColumn":25,"fileName":"datalogger.ts","functionName":"flush","argumentNames":["this"]}

function datalogger_Storage_flush__P59384_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_Storage_flush__P59384, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  arg0: undefined,
} }





function datalogger_FileStorage_flush__P59423(s) {
let r0 = s.r0, step = s.pc;
s.pc = -1;


while (true) {
if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) return null;
switch (step) {
  case 0:

    if (s.lambdaArgs) {
      s.arg0 = (s.lambdaArgs[0]);
      s.lambdaArgs = null;
    }
    r0 = s.arg0;
    if (!checkSubtype(r0, datalogger_FileStorage__C59418_VT)) failedCast(r0);
    r0 = undefined;
    return leave(s, r0)
  default: oops()
} } }
datalogger_FileStorage_flush__P59423.info = {"start":1121,"length":27,"line":38,"column":8,"endLine":40,"endColumn":9,"fileName":"storagedatalogger.ts","functionName":"flush","argumentNames":["this"]}

function datalogger_FileStorage_flush__P59423_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: datalogger_FileStorage_flush__P59423, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  arg0: undefined,
} }




function datalogger_Storage__C59380_v0_1_mk(s) {
    checkStack(s.depth);
    return {
        parent: s, fn: null, depth: s.depth + 1,
        pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
  tmp_0: undefined,
  tmp_1: undefined,
  tmp_2: undefined,
  tmp_3: undefined,
  tmp_4: undefined,
  arg0: undefined,
} }

const datalogger_Storage__C59380_VT = mkVTable({
  name: "Storage",
  numFields: 0,
  classNo: 16,
  lastSubtypeNo: 17,
  maxBgInstances: null,
  methods: {
    "flush": datalogger_Storage_flush__P59384,
  },
  iface: {
    "flush": datalogger_Storage_flush__P59384,
  },
});
const datalogger_FileStorage__C59418_VT = mkVTable({
  name: "FileStorage",
  numFields: 1,
  classNo: 17,
  lastSubtypeNo: 17,
  maxBgInstances: null,
  methods: {
    "flush": datalogger_FileStorage_flush__P59423,
  },
  iface: {
    "filename": null,
    "set/filename": null,
    "flush": datalogger_FileStorage_flush__P59423,
  },
});

const breakpoints = setupDebugger(1, ["_headers___59387","_row___59391","_storage___59393"])

return _main___P58926
})
