Giter Club home page Giter Club logo

wasm_tdg's Introduction

WebAssembly : The Definitive Guide

Welcome to the code repository for this book on WebAssembly.

This will include code samples from the books as well as additional projects and examples of new features as support is added to the various libraries and runtimes. This will allow me to continue to discuss things that were not widely supported at the time of writing including threads, SIMD, etc.

wasm_tdg's People

Contributors

bsletten avatar carducci avatar phaleth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wasm_tdg's Issues

tables in wat

In chapter 7 there is a problem with the declaration of a table in .wat

;; for example math.wat
(table (export "tbl") anyfunc (elem $add $sub)) 

returns errors:

math.wat:12:24: error: unexpected token "anyfunc", expected a natural number (e.g. 123).
        (table (export "tbl") anyfunc (elem $add $sub))
                       ^^^^^^^
math.wat:12:43: error: undefined table variable "$sub"
        (table (export "tbl") anyfunc (elem $add $sub))
                                          ^^^^

I found a fix here in paragraph Defining Tables in Wasm and the following syntax works

(table 2 funcref) ;; 2 is the initial size funcref is the element type
	(elem 
	(i32.const 0) ;; a memory offset to start populate the table
	$add $sub) ;; the content of the table

not sure whether this is the actual fix though.
By the way: your book is amazing! Congrats!

double console.log?

console.log(instance.exports.log_how_old(2021, 2000));

      console.log(instance.exports.log_how_old(2021, 2000));  

afaict log_how_old calls a function that calls console.log. why wrap the call in yet another console.log ?

(hi brian).

WebAssembly: TDG / Example 5-3. Just the howOld function FAILS

A few days ago I bought "WebAssembly: The Definite Guide". I started with chapter 5, which is the most relevant to me.

Environment:
Windows 64-bit
MSYS2 installed in C:\msys64\mingw64

Observed:
PS S:\Git\bsletten\wasm_tdg\ch05> clang --target=wasm32 -nostdlib -Wl,--no-entry -Wl,--export-all howold2.c -o howold2.wasm
At line:2 char:30
+ --target=wasm32 -nostdlib -Wl,--no-entry
+ ~
Missing argument in parameter list.
At line:3 char:4
+ -Wl,--export-all howold2.c -o howold2.wasm
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument

Expected:
Working example explained, also for Windows users.

Workaround?
I tried a few code variations, but these attempts failed.

Note:
LLVM in Windows expects Microsoft Visual Studio, which I don't have. I use VS Code (like many others do).

sorry i can't resist..

in howold.c, the function howOld can be simplified to:

int howOld(int currentYear, int yearBorn) {
  return currentYear - yearBorn;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.