Comments (5)
I am very interested in this project. let me try it and understand the source code. most likely I will contribute to this project. Good work..!!
from ts2c.
I'm gonna try to do toLowerCase, toUpperCase and try to add bound checking (to splice() and slice()) and also, I think I'm gonna upgrade ints to 64bit, as js-os proved it doesn't break stuff.
from ts2c.
@pitust please don't hard-update to int64_t
, it should be done in a particular TSC target project, definitely not in the core. One of the main goals of this project is to be able to use resulting code on microcontrollers, and there are plenty 16-bit microcontrollers, that's why we're using int16_t
as default. But it would be great to make it as some kind of a flag so that we can easily switch between int16_t
, int32_t
and int64_t
.
from ts2c.
@andrei-markeev When you target 16-bit you should link libgcc. For example, in my OS, I simply link libgcc and even though the target is x86, no 64-bit math, it works with 64-bit ints. But OK, I'm gonna add compiler switch insted of this.
from ts2c.
I simply link libgcc and even though the target is x86, no 64-bit math, it works with 64-bit ints
I guess it depends on the platform a lot, and basically means that short
is actually 64-bit on modern PCs (which makes total sense, anyway modern processors are 64-bit and operations on 64-bit registers are actually faster). But I will not be surprised if other compilers than gcc will treat it differently. Also, there are tons of customized gcc toolchains out there, so you never know 😄
The only thing that is guaranteed about short
is that it is capable of containing 16-bit numbers: https://en.wikipedia.org/wiki/C_data_types
So basically we have to use typedef long int32_t
and typedef long long int64_t
, if we want to guarantee some sort of consistency across different compilers and target platforms.
One simple idea of how to implement it, would be to use number_t
instead of int16_t
, and typedef it conditionally to be either short
, long
or long long
depending on a command line switch or alternatively some special comment in the source file, like // @int32_t
or smth similar.
on the other hand, I feel like having explicit int16_t
/int32_t / int64_t
in the code makes the transpiled code a bit easier to understand and keep track of, so maybe naming number type explicitly is a good idea.
from ts2c.
Related Issues (20)
- Calling C Functions
- Feature: Classes (for TS at least) HOT 8
- Finishing ES3 features once and for all HOT 6
- Compiling TypeScript to C via WebAssembly HOT 2
- Please include the original code as a comment in the transpiled code HOT 12
- Memory allocation bug HOT 6
- Function.prototype.toString HOT 1
- C functions HOT 2
- Syntax errors are handled incorrectly
- Playground autocomplete keeps repeating
- Order in which properties are added is not honored
- Incorrect generation of 'free' call
- Using C++ instead of C? HOT 4
- npm - Unexpected end of JSON
- Error when combining "for in" and "for of"
- labelled statements don't work
- Ain't work HOT 1
- arguments array ain;t work
- problem with functions called main
- error with functions returning functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts2c.