changed the compiler to emit PUSH_NIL when the braced block is empty for if
This commit is contained in:
@ -80,4 +80,3 @@ install-data-hook:
|
||||
|
||||
uninstall-hook:
|
||||
@rm -f "$(DESTDIR)$(pkgincludedir)/moo-cfg.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -17,7 +17,17 @@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@ -87,18 +97,17 @@ host_triplet = @host@
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = -lmoo-ffi -lmoo-console -lmoo-stdio
|
||||
bin_PROGRAMS = moo$(EXEEXT)
|
||||
subdir = lib
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(srcdir)/moo-cfg.h.in $(top_srcdir)/ac/depcomp \
|
||||
$(noinst_HEADERS) $(pkginclude_HEADERS)
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/argz.m4 \
|
||||
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_namespace.m4 \
|
||||
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
|
||||
$(pkginclude_HEADERS) $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = moo-cfg.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@ -219,6 +228,8 @@ am__define_uniq_tagged_files = \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/moo-cfg.h.in \
|
||||
$(top_srcdir)/ac/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)
|
||||
pkglibdir = $(libdir)
|
||||
@ -226,7 +237,6 @@ ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
ARGZ_H = @ARGZ_H@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
@ -280,9 +290,11 @@ LTDLDEPS = @LTDLDEPS@
|
||||
LTDLINCL = @LTDLINCL@
|
||||
LTDLOPEN = @LTDLOPEN@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_ARGZ_H = @LT_ARGZ_H@
|
||||
LT_CONFIG_H = @LT_CONFIG_H@
|
||||
LT_DLLOADERS = @LT_DLLOADERS@
|
||||
LT_DLPREOPEN = @LT_DLPREOPEN@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
@ -449,7 +461,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign lib/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@ -996,6 +1007,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-pkgincludeHEADERS \
|
||||
uninstall-binPROGRAMS uninstall-hook \
|
||||
uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
install-data-hook:
|
||||
@echo "#ifndef _MOO_CFG_H_" > "$(DESTDIR)$(pkgincludedir)/moo-cfg.h"
|
||||
|
@ -4278,6 +4278,7 @@ static int compile_basic_expression (moo_t* moo, const moo_oocs_t* ident, const
|
||||
|
||||
static int compile_braced_block (moo_t* moo)
|
||||
{
|
||||
moo_oow_t code_start;
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_LBRACE)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_LBRACE, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
@ -4286,24 +4287,34 @@ static int compile_braced_block (moo_t* moo)
|
||||
|
||||
GET_TOKEN (moo);
|
||||
|
||||
while (TOKEN_TYPE(moo) != MOO_IOTOK_EOF)
|
||||
code_start = moo->c->mth.code.len;
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_RBRACE)
|
||||
{
|
||||
if (compile_block_statement(moo) <= -1) return -1;
|
||||
while (TOKEN_TYPE(moo) != MOO_IOTOK_EOF)
|
||||
{
|
||||
if (compile_block_statement(moo) <= -1) return -1;
|
||||
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RBRACE) break;
|
||||
else if (TOKEN_TYPE(moo) == MOO_IOTOK_PERIOD)
|
||||
{
|
||||
GET_TOKEN (moo);
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RBRACE) break;
|
||||
if (emit_byte_instruction(moo, BCODE_POP_STACKTOP) <= -1) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_RBRACE, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
else if (TOKEN_TYPE(moo) == MOO_IOTOK_PERIOD)
|
||||
{
|
||||
GET_TOKEN (moo);
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RBRACE) break;
|
||||
if (emit_byte_instruction(moo, BCODE_POP_STACKTOP) <= -1) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_RBRACE, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moo->c->mth.code.len == code_start)
|
||||
{
|
||||
/* the block doesn't contain an instruction at all */
|
||||
if (emit_byte_instruction(moo, BCODE_PUSH_NIL) <= -1) return -1;
|
||||
}
|
||||
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_RBRACE)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_RBRACE, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
@ -4367,7 +4378,7 @@ moo_oow_t jumptoend_count = 0;
|
||||
{
|
||||
if (patch_jump_instruction (moo, jumptonext, BCODE_JUMP2_FORWARD_IF_FALSE, &brace_loc) <= -1) return -1;
|
||||
|
||||
GET_TOKEN (moo);
|
||||
GET_TOKEN (moo); /* get ( */
|
||||
if (compile_conditional(moo) <= -1) return -1;
|
||||
|
||||
/* emit code to jump to the next elsif or else */
|
||||
@ -4382,16 +4393,16 @@ moo_oow_t jumptoend_count = 0;
|
||||
jumptoend[jumptoend_count++] = moo->c->mth.code.len;
|
||||
if (emit_single_param_instruction (moo, BCODE_JUMP_FORWARD_0, MAX_CODE_JUMP) <= -1) return -1;
|
||||
|
||||
GET_TOKEN (moo);
|
||||
GET_TOKEN (moo); /* get the next token after } */
|
||||
}
|
||||
|
||||
if (patch_jump_instruction (moo, jumptonext, BCODE_JUMP2_FORWARD_IF_FALSE, &brace_loc) <= -1) return -1;
|
||||
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_ELSE)
|
||||
{
|
||||
GET_TOKEN (moo);
|
||||
GET_TOKEN (moo); /* get { */
|
||||
if (compile_braced_block (moo) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
GET_TOKEN (moo); /* get the next token after } */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -194,6 +194,15 @@ static MOO_INLINE void vm_gettime (moo_t* moo, moo_ntime_t* now)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__DOS__)
|
||||
# if defined(_INTELC32_)
|
||||
void _halt_cpu (void);
|
||||
# elif defined(__WATCOMC__)
|
||||
void _halt_cpu (void);
|
||||
# pragma aux _halt_cpu = "hlt"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static MOO_INLINE void vm_sleep (moo_t* moo, const moo_ntime_t* dur)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
@ -241,7 +250,10 @@ static MOO_INLINE void vm_sleep (moo_t* moo, const moo_ntime_t* dur)
|
||||
|
||||
/* TODO: handle clock overvlow */
|
||||
/* TODO: check if there is abortion request or interrupt */
|
||||
while (c > clock()) ;
|
||||
while (c > clock())
|
||||
{
|
||||
_halt_cpu();
|
||||
}
|
||||
|
||||
#else
|
||||
struct timespec ts;
|
||||
|
17
moo/lib/hlt.asm
Normal file
17
moo/lib/hlt.asm
Normal file
@ -0,0 +1,17 @@
|
||||
.386P
|
||||
|
||||
NAME HLT
|
||||
|
||||
PROG_CODE SEGMENT ER USE32 'CODE'
|
||||
ASSUME CS:PROG_CODE
|
||||
|
||||
PUBLIC _halt_cpu
|
||||
|
||||
_halt_cpu PROC NEAR
|
||||
HLT ; this will cause #GP(0) as it's privileged. TODO: find a way to raise privilege level.
|
||||
RET
|
||||
_halt_cpu ENDP
|
||||
|
||||
PROG_CODE ENDS
|
||||
|
||||
END
|
@ -31,8 +31,13 @@ EXEFILE=moo.exe
|
||||
MODFILE=..\mod\moomod.lib
|
||||
RSPFILE := $(EXEFILE,B,S/.*/&.RSP/)
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
all: $(OBJS) hlt.obj
|
||||
echo $(OBJS) > $(RSPFILE)
|
||||
echo hlt.obj >> $(RSPFILE)
|
||||
echo $(MODFILE) >> $(RSPFILE)
|
||||
echo $(LDFLAGS) >> $(RSPFILE)
|
||||
$(CC) @$(RSPFILE) /e $(EXEFILE)
|
||||
|
||||
hlt.obj: hlt.asm
|
||||
386asm -twocase hlt.asm
|
||||
|
@ -455,10 +455,11 @@ if (mask & MOO_LOG_GC) return; /* don't show gc logs */
|
||||
now = time(NULL);
|
||||
#if defined(__DOS__)
|
||||
tmp = localtime (&now);
|
||||
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S ", tmp); /* no timezone info */
|
||||
#else
|
||||
tmp = localtime_r (&now, &tm);
|
||||
#endif
|
||||
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||
#endif
|
||||
if (tslen == 0)
|
||||
{
|
||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||
@ -535,7 +536,7 @@ static void __interrupt timer_intr_handler (void)
|
||||
|
||||
/* The timer interrupt (normally) occurs 18.2 times per second. */
|
||||
if (g_moo) moo_switchprocess (g_moo);
|
||||
_chain_intr(prev_timer_intr_handler);
|
||||
_chain_intr (prev_timer_intr_handler);
|
||||
}
|
||||
|
||||
#elif defined(macintosh)
|
||||
|
@ -314,13 +314,15 @@
|
||||
module search path. */
|
||||
#undef LT_MODULE_PATH_VAR
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to the shared library suffix, say, ".dylib". */
|
||||
#undef LT_SHARED_EXT
|
||||
|
||||
/* Define to the shared archive member specification, say "(shr.o)". */
|
||||
#undef LT_SHARED_LIB_MEMBER
|
||||
|
||||
/* link modules statically into the main library */
|
||||
#undef MOO_ENABLE_STATIC_MODULE
|
||||
|
||||
@ -543,5 +545,5 @@
|
||||
/* Define so that glibc/gnulib argp.h does not typedef error_t. */
|
||||
#undef __error_t_defined
|
||||
|
||||
/* Define to a type to use for `error_t' if it is not otherwise available. */
|
||||
/* Define to a type to use for 'error_t' if it is not otherwise available. */
|
||||
#undef error_t
|
||||
|
Reference in New Issue
Block a user