progress
This commit is contained in:
parent
c59c26b387
commit
846d4e0c6a
@ -37,6 +37,7 @@ const properties = {
|
||||
mask: 'ptr', // mask (x, z) of the signal on change event
|
||||
digitCount: 'i32',
|
||||
tmpStr: 'ptr',
|
||||
tmpStr2: 'ptr',
|
||||
stackPointer: 'i32',
|
||||
id: 'ptr',
|
||||
napi_env: 'ptr'
|
||||
|
@ -3,6 +3,7 @@
|
||||
const stream = require('stream');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
// let lib = require('bindings')('vcd.node');
|
||||
const util = require('util');
|
||||
|
||||
|
||||
module.exports = async () => {
|
||||
@ -36,6 +37,8 @@ module.exports = async () => {
|
||||
s._write = function (chunk, encoding, callback) {
|
||||
console.log('about to write', chunk);
|
||||
lib.execute(cxt, lifemit, triemit2, info, chunk);
|
||||
console.log(util.inspect(info, {showHidden: true, depth : null, colorize: true}));
|
||||
// console.log(info);
|
||||
callback();
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const dotProp = require('dot-prop');
|
||||
|
||||
function _waitForStart(mod) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
mod.addOnPostRun(resolve);
|
||||
@ -64,14 +66,20 @@ module.exports = () => {
|
||||
switch(type) {
|
||||
case 0:
|
||||
boundInfo[prop] = v0;
|
||||
// console.log(`setting ${prop} to ${boundInfo[prop]}`);
|
||||
break;
|
||||
case 1:
|
||||
boundInfo[prop] = getString(v0, v1);
|
||||
// console.log(`setting ${prop} to ${boundInfo[prop]}`);
|
||||
break;
|
||||
case 2:
|
||||
dotProp.set(boundInfo, prop, getString(v0, v1));
|
||||
console.log(`setting ${prop} to ${getString(v0, v1)}`);
|
||||
break;
|
||||
|
||||
default: throw new Error();
|
||||
}
|
||||
|
||||
console.log(`setting ${prop} to ${boundInfo[prop]}`);
|
||||
|
||||
// viiiii means returns void, accepts int int int int int
|
||||
}, 'viiiii');
|
||||
@ -81,12 +89,13 @@ module.exports = () => {
|
||||
return 42;
|
||||
}, 'iii');
|
||||
|
||||
boundEE0 = wasm.addFunction(function(val) {
|
||||
ee[0].emit(val);
|
||||
}, 'vi');
|
||||
|
||||
boundEE0 = wasm.addFunction(function(name, len) {
|
||||
ee[0](getString(name, len));
|
||||
}, 'vii');
|
||||
|
||||
boundEE1 = wasm.addFunction(function(eventName, l0, time, command, value, mask) {
|
||||
ee[1].emit(getString(eventName, l0), time, command, value, mask);
|
||||
ee[1](getString(eventName, l0), time, command, value, mask);
|
||||
}, 'viiiiii');
|
||||
|
||||
};
|
||||
@ -104,7 +113,7 @@ module.exports = () => {
|
||||
context = c.init(boundEE0,boundEE1,boundSet,boundGet);
|
||||
},
|
||||
execute: (ctx, lifemit, triemit, info, chunk) => {
|
||||
c.execute(ctx,0,0,boundSet,boundGet,chunk.toString());
|
||||
c.execute(ctx,boundEE0,boundEE1,boundSet,boundGet,chunk.toString());
|
||||
},
|
||||
setTrigger: (ctx, triggerString) => {
|
||||
return c.setTrigger(ctx, triggerString);
|
||||
|
2
vcd.c
2
vcd.c
@ -124,6 +124,7 @@ METHOD(init) {
|
||||
|
||||
static char triggerString [4096] = " ";
|
||||
static char tmpStr [4096] = " ";
|
||||
static char tmpStr2 [4096] = " ";
|
||||
static uint64_t valueBuf [4096] = {};
|
||||
static uint64_t maskBuf [4096] = {};
|
||||
|
||||
@ -131,6 +132,7 @@ METHOD(init) {
|
||||
state->reason = "NO REASON";
|
||||
state->napi_env = env;
|
||||
state->tmpStr = tmpStr;
|
||||
state->tmpStr2 = tmpStr2;
|
||||
state->value = valueBuf;
|
||||
state->mask = maskBuf;
|
||||
state->digitCount = 0;
|
||||
|
24
vcd_spans.c
24
vcd_spans.c
@ -1,9 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "vcd_parser.h"
|
||||
|
||||
#ifndef VCDWASM
|
||||
#include <node_api.h>
|
||||
#else
|
||||
#include "wasm_main.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef VCDWASM
|
||||
@ -82,6 +85,9 @@ int commandSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
|
||||
// ASSERT(eventPayload, napi_create_string_latin1(env, "payload", NAPI_AUTO_LENGTH, &eventPayload))
|
||||
napi_value* argv[] = { &eventName }; // , &eventPayload };
|
||||
ASSERT(state->lifee, napi_call_function(env, undefined, state->lifee, 1, *argv, &return_val))
|
||||
#else
|
||||
set_property_string("status", "simulation");
|
||||
emit_lifee("$enddefinitions");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -95,14 +101,20 @@ int scopeIdentifierSpan(vcd_parser_t* state, const unsigned char* p, const unsig
|
||||
napi_env env = state->napi_env;
|
||||
// *(endp - 1) = 0; // FIXME NULL termination of ASCII string
|
||||
strcopy(p, endp, state->tmpStr);
|
||||
napi_value name, obj, stack, top;
|
||||
ASSERT(name, napi_create_string_latin1(env, (char*)p, (endp - p - 1), &name))
|
||||
napi_value obj, stack, top;
|
||||
ASSERT(obj, napi_create_object(env, &obj))
|
||||
ASSERT(state->info, napi_get_named_property(env, state->info, "stack", &stack))
|
||||
ASSERT(top, napi_get_element(env, stack, state->stackPointer, &top))
|
||||
printf("Got stack %d\n", state->stackPointer);
|
||||
ASSERT(top, napi_set_named_property(env, top, state->tmpStr, obj))
|
||||
printf("Set ? to %s\n", (char*)state->tmpStr);
|
||||
state->stackPointer += 1;
|
||||
ASSERT(top, napi_set_element(env, stack, state->stackPointer, obj))
|
||||
#else
|
||||
state->stackPointer += 1;
|
||||
strcopy(p, endp, state->tmpStr); // load the value into temp string 1
|
||||
snprintf(state->tmpStr2, 4096, "stack.%d\n", state->stackPointer); // load the dot-prop into string 2
|
||||
set_path_string(state->tmpStr2, state->tmpStr);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -114,16 +126,21 @@ int varSizeSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
|
||||
}
|
||||
|
||||
int varIdSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char* endp) {
|
||||
LOGSPAN;
|
||||
#ifndef VCDWASM
|
||||
napi_env env = state->napi_env;
|
||||
napi_value varId;
|
||||
ASSERT(varId, napi_create_string_latin1(env, (char*)p, (endp - p - 1), &varId))
|
||||
ASSERT(state->info, napi_set_named_property(env, state->info, "varId", varId))
|
||||
#else
|
||||
strcopy(p, endp, state->tmpStr);
|
||||
set_property_string("varId", state->tmpStr);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int varNameSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char* endp) {
|
||||
LOGSPAN;
|
||||
#ifndef VCDWASM
|
||||
napi_env env = state->napi_env;
|
||||
// *(endp - 1) = 0; // FIXME NULL termination of ASCII string
|
||||
@ -133,6 +150,9 @@ int varNameSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
|
||||
ASSERT(top, napi_get_element(env, stack, state->stackPointer, &top))
|
||||
ASSERT(state->info, napi_get_named_property(env, state->info, "varId", &varId))
|
||||
ASSERT(state->info, napi_set_named_property(env, top, state->tmpStr, varId))
|
||||
#else
|
||||
// char *varIdString =
|
||||
set_property_string("varId", state->tmpStr);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using namespace std;
|
||||
|
||||
|
||||
/// Typedef used as part of c->js call
|
||||
typedef void externalJsMethodZero(const int sz);
|
||||
typedef void externalJsMethodZero(const char* name, const size_t len);
|
||||
typedef void externalJsMethodOne (const char*, const uint64_t time, const uint8_t command, const int dnc0, const int dnc1);
|
||||
|
||||
typedef int externalJsGetProperty(const char* name, const size_t len);
|
||||
@ -20,6 +20,9 @@ static externalJsMethodZero* externalZero = 0;
|
||||
static externalJsMethodOne* externalOne = 0;
|
||||
static externalJsSetProperty* bound_set_property = 0;
|
||||
static externalJsGetProperty* bound_get_property = 0;
|
||||
static struct vcd_parser_s* state;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void set_property_int(const char* name, const int value) {
|
||||
bound_set_property(name, strlen(name), 0, value, 0);
|
||||
@ -29,14 +32,20 @@ void set_property_string(const char* name, const char* value) {
|
||||
bound_set_property(name, strlen(name), 1, (int)value, strlen(value));
|
||||
}
|
||||
|
||||
int get_property(const char* name) {
|
||||
void set_path_string(const char* name, const char* value) {
|
||||
bound_set_property(name, strlen(name), 2, (int)value, strlen(value));
|
||||
}
|
||||
|
||||
int get_property_int(const char* name) {
|
||||
return bound_get_property(name, strlen(name));
|
||||
}
|
||||
|
||||
void emit_lifee(const char* name) {
|
||||
externalZero(name, strlen(name));
|
||||
}
|
||||
|
||||
|
||||
static struct vcd_parser_s* state;
|
||||
|
||||
extern "C" {
|
||||
|
||||
// returns context
|
||||
int init(
|
||||
@ -141,7 +150,7 @@ int getTime(const int context) {
|
||||
// set_property_int("foo", 10);
|
||||
|
||||
|
||||
// int got = get_property("bar");
|
||||
// int got = get_property_int("bar");
|
||||
|
||||
// cout << "got " << got << " for bar\n";
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
// void set_property(const char* name, const int value);
|
||||
// int get_property(const char* name);
|
||||
|
||||
|
||||
void set_property_int(const char* name, const int value);
|
||||
void set_property_string(const char* name, const char* value);
|
||||
void set_path_string(const char* name, const char* value);
|
||||
int get_property_int(const char* name);
|
||||
void emit_lifee(const char* name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user