1- import { Compiler , Target , ConversionKind , typeToNativeType , typeToNativeOne , typeToNativeZero } from "./compiler" ;
2- import { DiagnosticCode } from "./diagnostics" ;
3- import { Node , Expression , IdentifierExpression } from "./ast" ;
4- import { Type } from "./types" ;
5- import { Module , ExpressionRef , UnaryOp , BinaryOp , HostOp , NativeType , FunctionTypeRef } from "./module" ;
6- import { Program , ElementFlags , Element , Global , FunctionPrototype , Local } from "./program" ;
1+ import {
2+ Compiler ,
3+ Target ,
4+ ConversionKind
5+ } from "./compiler" ;
6+
7+ import {
8+ DiagnosticCode
9+ } from "./diagnostics" ;
10+
11+ import {
12+ Node ,
13+ Expression
14+ } from "./ast" ;
15+
16+ import {
17+ Type
18+ } from "./types" ;
19+
20+ import {
21+ Module ,
22+ UnaryOp ,
23+ BinaryOp ,
24+ HostOp ,
25+ NativeType ,
26+ ExpressionRef ,
27+ FunctionTypeRef
28+ } from "./module" ;
29+
30+ import {
31+ Program ,
32+ Global ,
33+ FunctionPrototype ,
34+ Local
35+ } from "./program" ;
736
837/** Initializes the specified program with built-in functions. */
938export function initialize ( program : Program ) : void {
@@ -149,7 +178,7 @@ export function compileGetGlobal(compiler: Compiler, global: Global): Expression
149178 return compiler . module . createF64 ( Infinity ) ;
150179
151180 case "HEAP_BASE" : // constant, but never inlined
152- return compiler . module . createGetGlobal ( "HEAP_BASE" , typeToNativeType ( compiler . currentType = < Type > global . type ) ) ;
181+ return compiler . module . createGetGlobal ( "HEAP_BASE" , ( compiler . currentType = < Type > global . type ) . toNativeType ( ) ) ;
153182
154183 default :
155184 throw new Error ( "not implemented: " + global . internalName ) ;
@@ -539,7 +568,7 @@ export function compileCall(compiler: Compiler, prototype: FunctionPrototype, ty
539568 return module . createUnreachable ( ) ;
540569 arg0 = compiler . compileExpression ( operands [ 0 ] , usizeType ) ; // reports
541570 if ( ( compiler . currentType = typeArguments [ 0 ] ) != Type . void )
542- return module . createLoad ( typeArguments [ 0 ] . byteSize , typeArguments [ 0 ] . isSignedInteger , arg0 , typeToNativeType ( typeArguments [ 0 ] ) ) ;
571+ return module . createLoad ( typeArguments [ 0 ] . byteSize , typeArguments [ 0 ] . isSignedInteger , arg0 , typeArguments [ 0 ] . toNativeType ( ) ) ;
543572 break ;
544573
545574 case "store" : // store<T>(offset: usize, value: T) -> void
@@ -550,7 +579,7 @@ export function compileCall(compiler: Compiler, prototype: FunctionPrototype, ty
550579 arg1 = compiler . compileExpression ( operands [ 1 ] , typeArguments [ 0 ] ) ; // reports
551580 compiler . currentType = Type . void ;
552581 if ( typeArguments [ 0 ] != Type . void )
553- return module . createStore ( typeArguments [ 0 ] . byteSize , arg0 , arg1 , typeToNativeType ( typeArguments [ 0 ] ) ) ;
582+ return module . createStore ( typeArguments [ 0 ] . byteSize , arg0 , arg1 , typeArguments [ 0 ] . toNativeType ( ) ) ;
554583 break ;
555584
556585 case "sizeof" : // sizeof<T>() -> usize
@@ -685,7 +714,7 @@ export function compileCall(compiler: Compiler, prototype: FunctionPrototype, ty
685714 return module . createUnreachable ( ) ;
686715 }
687716 arg0 = compiler . compileExpression ( operands [ 0 ] , Type . i32 ) ; // reports
688- arg1 = operands . length > 1 ? compiler . compileExpression ( operands [ 1 ] , usizeType ) : typeToNativeZero ( module , usizeType ) ; // TODO: string type
717+ arg1 = operands . length > 1 ? compiler . compileExpression ( operands [ 1 ] , usizeType ) : usizeType . toNativeZero ( module ) ; // TODO: string type
689718 compiler . currentType = Type . void ;
690719 return compiler . options . noAssert
691720 ? module . createNop ( )
0 commit comments