I could NOT attach the js file, so here is from a file server: http://www.mediafire.com/file/avtnmgdaonxc7ci/md5.js/file
On Thursday, April 18, 2019 at 10:15:10 PM UTC+2, rura...@gmail.com wrote: > > Hello, > > > I am trying to make a program in visual c/c++ for configuring a specific > vendor modem via http(s). For this purpose, I am trying and testing with > v8, I need to take some variable values at runtime and use them in the next > POST or GET, but no luck with v8. > There are several javascript files downloaded from devices, but all of > them even fail to compile.They does not seem to have any error from from an > editor, are not modifiable because every time it is retrieved from modem. > There are not problems configuring modems from popular browsers, chrome > included; they don't find errors. > > e.g. It is a file md5.js downloaded from modem(in attach) > I begin from hello_world sample modified a little with shell example: > adding ReportException function in order to take more information from > compile fails: > > > > > > *G:\c++\projects\v8hello\x64\Debug>v8helloundefined:260: SyntaxError: > Unexpected token >> 8 * ((i+1)%4)) & 0xFF) << 8 )^SyntaxError: Unexpected > token >* > > > where this is line 249(not 260): (((binarray[i+1 >> 2] *>>* 8 * > ((i+1)%4)) & 0xFF) << 8 ) > , and I cannot find any error there, brackets seem ok etc. The bitwise > shift right is the problem, but why ? There bitwise shift right & left > before this statement, but they do not take attention of the compiler. > > > the source is: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *// Copyright 2015 the V8 project authors. All rights reserved.// Use of > this source code is governed by a BSD-style license that can be// found in > the LICENSE file.#include <stdio.h>#include <stdlib.h>#include > <string.h>#include <io.h>#include <fcntl.h>#include > <libplatform/libplatform.h>#include <v8.h>void ReportException(v8::Isolate* > isolate, v8::TryCatch* handler);const char* ToCString(const > v8::String::Utf8Value& value) { return *value ? *value : "<string > conversion failed>";}void ReportException(v8::Isolate* isolate, > v8::TryCatch* try_catch) { v8::HandleScope handle_scope(isolate); > v8::String::Utf8Value exception(isolate, try_catch->Exception()); const > char* exception_string = ToCString(exception); v8::Local<v8::Message> > message = try_catch->Message(); if (message.IsEmpty()) { // V8 > didn't provide any extra information about this error; just // print > the exception. fprintf(stderr, "%s\n", exception_string); } > else { // Print (filename):(line number): (message). > v8::String::Utf8Value filename(isolate, > message->GetScriptOrigin().ResourceName()); v8::Local<v8::Context> > context(isolate->GetCurrentContext()); const char* filename_string = > ToCString(filename); int linenum = > message->GetLineNumber(context).FromJust(); fprintf(stderr, "%s:%i: > %s\n", filename_string, linenum, exception_string); // Print line of > source code. v8::String::Utf8Value sourceline( isolate, > message->GetSourceLine(context).ToLocalChecked()); const char* > sourceline_string = ToCString(sourceline); fprintf(stderr, "%s\n", > sourceline_string); // Print wavy underline (GetUnderline is > deprecated). int start = > message->GetStartColumn(context).FromJust(); for (int i = 0; i < > start; i++) { fprintf(stderr, " "); } int end = > message->GetEndColumn(context).FromJust(); for (int i = start; i < > end; i++) { fprintf(stderr, "^"); } > fprintf(stderr, "\n"); v8::Local<v8::Value> stack_trace_string; > if (try_catch->StackTrace(context).ToLocal(&stack_trace_string) && > stack_trace_string->IsString() && > v8::Local<v8::String>::Cast(stack_trace_string)->Length() > 0) { > v8::String::Utf8Value stack_trace(isolate, stack_trace_string); > const char* stack_trace_string = ToCString(stack_trace); > fprintf(stderr, "%s\n", stack_trace_string); } }}int main(int > argc, char* argv[]) { // Initialize V8. > v8::V8::InitializeICUDefaultLocation(argv[0]); > v8::V8::InitializeExternalStartupData(argv[0]); > std::unique_ptr<v8::Platform> platform = > v8::platform::NewDefaultPlatform(); > v8::V8::InitializePlatform(platform.get()); v8::V8::Initialize(); // > Create a new Isolate and make it the current one. > v8::Isolate::CreateParams create_params; > create_params.array_buffer_allocator = > v8::ArrayBuffer::Allocator::NewDefaultAllocator(); v8::Isolate* isolate = > v8::Isolate::New(create_params); { v8::Isolate::Scope > isolate_scope(isolate); // Create a stack-allocated handle scope. > v8::HandleScope handle_scope(isolate); v8::TryCatch > try_catch(isolate); // Create a new context. v8::Local<v8::Context> > context = v8::Context::New(isolate); // Enter the context for compiling > and running the hello world script. v8::Context::Scope > context_scope(context); { // Create a string containing the > JavaScript source code. int fd = open("G:\\md5.js", _O_RDWR, > _S_IREAD); char bfx[200001]; int nr = read(fd, bfx, > 200000); close(fd); v8::Local<v8::String> source = > v8::String::NewFromUtf8(isolate, bfx, > v8::NewStringType::kNormal) .ToLocalChecked(); // Compile > the source code. /* v8::Local<v8::Script> script = > v8::Script::Compile(context, source).ToLocalChecked();*/ > v8::Local<v8::Script> script; if (!v8::Script::Compile(context, > source).ToLocal(&script)) { ReportException(isolate, > &try_catch); return -1; } // Run the script to get the > result. v8::Local<v8::Value> result = > script->Run(context).ToLocalChecked(); // Convert the result to an > UTF8 string and print it. v8::String::Utf8Value utf8(isolate, > result); printf("%s\n", *utf8); } } // Dispose the isolate and > tear down V8. isolate->Dispose(); v8::V8::Dispose(); > v8::V8::ShutdownPlatform(); delete create_params.array_buffer_allocator; > return 0;}* > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.