winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2011
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
996 discussions
Start a n
N
ew thread
Jörg Höhle : winecoreaudio: Fix AudioRenderClient Get/ReleaseBuffer protocol.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 57cbb01f0cd63f6864fe98ed06ebef81332ce85a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=57cbb01f0cd63f6864fe98ed0…
Author: Jörg Höhle <hoehle(a)users.sourceforge.net> Date: Sun Aug 7 07:06:48 2011 +0200 winecoreaudio: Fix AudioRenderClient Get/ReleaseBuffer protocol. --- dlls/winecoreaudio.drv/mmdevdrv.c | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 6fd336f..78daa8c 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -127,7 +127,7 @@ struct ACImpl { UINT32 period_ms, bufsize_frames, inbuf_frames, written_frames; UINT64 last_time; AudioQueueBufferRef public_buffer; - BOOL getbuf_last; + UINT32 getbuf_last; int playing; AudioSession *session; @@ -1602,6 +1602,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, if(!data) return E_POINTER; + *data = NULL; OSSpinLockLock(&This->lock); @@ -1611,7 +1612,6 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, } if(!frames){ - This->getbuf_last = TRUE; OSSpinLockUnlock(&This->lock); return S_OK; } @@ -1656,7 +1656,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, *data = This->public_buffer->mAudioData; - This->getbuf_last = TRUE; + This->getbuf_last = frames; OSSpinLockUnlock(&This->lock); @@ -1673,11 +1673,27 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer( OSSpinLockLock(&This->lock); + if(!frames){ + This->getbuf_last = 0; + if(This->public_buffer){ + AQBuffer *buf = This->public_buffer->mUserData; + list_add_tail(&This->avail_buffers, &buf->entry); + This->public_buffer = NULL; + } + OSSpinLockUnlock(&This->lock); + return S_OK; + } + if(!This->getbuf_last){ OSSpinLockUnlock(&This->lock); return AUDCLNT_E_OUT_OF_ORDER; } + if(frames > This->getbuf_last){ + OSSpinLockUnlock(&This->lock); + return AUDCLNT_E_INVALID_SIZE; + } + if(flags & AUDCLNT_BUFFERFLAGS_SILENT){ WAVEFORMATEXTENSIBLE *fmtex = (WAVEFORMATEXTENSIBLE*)This->fmt; if((This->fmt->wFormatTag == WAVE_FORMAT_PCM || @@ -1704,7 +1720,7 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer( AudioQueuePrime(This->aqueue, 0, NULL); This->public_buffer = NULL; - This->getbuf_last = FALSE; + This->getbuf_last = 0; This->written_frames += frames; This->inbuf_frames += frames; @@ -1795,7 +1811,7 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, *flags = 0; This->written_frames += *frames; This->inbuf_frames -= *frames; - This->getbuf_last = TRUE; + This->getbuf_last = 1; if(devpos || qpcpos) AudioClock_GetPosition_nolock(This, devpos, qpcpos, FALSE); @@ -1809,8 +1825,7 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer( IAudioCaptureClient *iface, UINT32 done) { ACImpl *This = impl_from_IAudioCaptureClient(iface); - UINT32 pbuf_frames = - This->public_buffer->mAudioDataByteSize / This->fmt->nBlockAlign; + UINT32 pbuf_frames; OSStatus sc; TRACE("(%p)->(%u)\n", This, done); @@ -1822,6 +1837,7 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer( return AUDCLNT_E_OUT_OF_ORDER; } + pbuf_frames = This->public_buffer->mAudioDataByteSize / This->fmt->nBlockAlign; if(done != 0 && done != pbuf_frames){ OSSpinLockUnlock(&This->lock); return AUDCLNT_E_INVALID_SIZE; @@ -1835,7 +1851,7 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer( This->public_buffer = NULL; } - This->getbuf_last = FALSE; + This->getbuf_last = 0; OSSpinLockUnlock(&This->lock);
1
0
0
0
Jörg Höhle : mmdevapi: Accept up to 8 channels.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: df201d3ef3a485ab8899de22f2c5594dfc5057ca URL:
http://source.winehq.org/git/wine.git/?a=commit;h=df201d3ef3a485ab8899de22f…
Author: Jörg Höhle <hoehle(a)users.sourceforge.net> Date: Fri Sep 2 22:49:20 2011 +0200 mmdevapi: Accept up to 8 channels. --- dlls/winealsa.drv/mmdevdrv.c | 24 ++++++++++-------------- dlls/winecoreaudio.drv/mmdevdrv.c | 22 +++++++++------------- dlls/wineoss.drv/mmdevdrv.c | 22 +++++++++------------- 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 180dbc7..e471e2c 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -1139,25 +1139,21 @@ static DWORD get_channel_mask(unsigned int channels) case 0: return 0; case 1: - return SPEAKER_FRONT_CENTER; + return KSAUDIO_SPEAKER_MONO; case 2: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + return KSAUDIO_SPEAKER_STEREO; case 3: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | - SPEAKER_LOW_FREQUENCY; + return KSAUDIO_SPEAKER_STEREO | SPEAKER_LOW_FREQUENCY; case 4: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; + return KSAUDIO_SPEAKER_QUAD; /* not _SURROUND */ case 5: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY; + return KSAUDIO_SPEAKER_QUAD | SPEAKER_LOW_FREQUENCY; case 6: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_FRONT_CENTER; + return KSAUDIO_SPEAKER_5POINT1; /* not 5POINT1_SURROUND */ case 7: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_FRONT_CENTER | - SPEAKER_BACK_CENTER; + return KSAUDIO_SPEAKER_5POINT1 | SPEAKER_BACK_CENTER; + case 8: + return KSAUDIO_SPEAKER_7POINT1; /* not 7POINT1_SURROUND */ } FIXME("Unknown speaker configuration: %u\n", channels); return 0; @@ -1296,7 +1292,7 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface, WARN("Unable to get max channels: %d (%s)\n", err, snd_strerror(err)); goto exit; } - if(max > 7) + if(max > 8) max = 2; if(fmt->nChannels > max){ hr = S_FALSE; diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index a951673..6fd336f 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -568,25 +568,21 @@ static DWORD get_channel_mask(unsigned int channels) case 0: return 0; case 1: - return SPEAKER_FRONT_CENTER; + return KSAUDIO_SPEAKER_MONO; case 2: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + return KSAUDIO_SPEAKER_STEREO; case 3: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | - SPEAKER_LOW_FREQUENCY; + return KSAUDIO_SPEAKER_STEREO | SPEAKER_LOW_FREQUENCY; case 4: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; + return KSAUDIO_SPEAKER_QUAD; /* not _SURROUND */ case 5: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY; + return KSAUDIO_SPEAKER_QUAD | SPEAKER_LOW_FREQUENCY; case 6: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_FRONT_CENTER; + return KSAUDIO_SPEAKER_5POINT1; /* not 5POINT1_SURROUND */ case 7: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_FRONT_CENTER | - SPEAKER_BACK_CENTER; + return KSAUDIO_SPEAKER_5POINT1 | SPEAKER_BACK_CENTER; + case 8: + return KSAUDIO_SPEAKER_7POINT1; /* not 7POINT1_SURROUND */ } FIXME("Unknown speaker configuration: %u\n", channels); return 0; diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index fe0c1d8..ed3e2ba 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -592,25 +592,21 @@ static DWORD get_channel_mask(unsigned int channels) case 0: return 0; case 1: - return SPEAKER_FRONT_CENTER; + return KSAUDIO_SPEAKER_MONO; case 2: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + return KSAUDIO_SPEAKER_STEREO; case 3: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | - SPEAKER_LOW_FREQUENCY; + return KSAUDIO_SPEAKER_STEREO | SPEAKER_LOW_FREQUENCY; case 4: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; + return KSAUDIO_SPEAKER_QUAD; /* not _SURROUND */ case 5: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY; + return KSAUDIO_SPEAKER_QUAD | SPEAKER_LOW_FREQUENCY; case 6: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_FRONT_CENTER; + return KSAUDIO_SPEAKER_5POINT1; /* not 5POINT1_SURROUND */ case 7: - return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_FRONT_CENTER | - SPEAKER_BACK_CENTER; + return KSAUDIO_SPEAKER_5POINT1 | SPEAKER_BACK_CENTER; + case 8: + return KSAUDIO_SPEAKER_7POINT1; /* not 7POINT1_SURROUND */ } FIXME("Unknown speaker configuration: %u\n", channels); return 0;
1
0
0
0
Jörg Höhle : include: Define KSAUDIO_SPEAKER_5|7POINT1_SURROUND.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 4441a7aaff0b8e565eeeac071b4fb80197f77eea URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4441a7aaff0b8e565eeeac071…
Author: Jörg Höhle <hoehle(a)users.sourceforge.net> Date: Fri Sep 2 22:22:58 2011 +0200 include: Define KSAUDIO_SPEAKER_5|7POINT1_SURROUND. --- include/ksmedia.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/include/ksmedia.h b/include/ksmedia.h index 4027596..44834bb 100644 --- a/include/ksmedia.h +++ b/include/ksmedia.h @@ -34,7 +34,9 @@ DEFINE_GUID(KSDATAFORMAT_SUBTYPE_ALAW, 0x00000006, 0x0000, 0x0010, 0x80, 0x00, 0 #define KSAUDIO_SPEAKER_QUAD (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) #define KSAUDIO_SPEAKER_SURROUND (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER) #define KSAUDIO_SPEAKER_5POINT1 (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) +#define KSAUDIO_SPEAKER_5POINT1_SURROUND (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT) #define KSAUDIO_SPEAKER_7POINT1 (KSAUDIO_SPEAKER_5POINT1 | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER) +#define KSAUDIO_SPEAKER_7POINT1_SURROUND (KSAUDIO_SPEAKER_5POINT1 | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT) #ifndef REFERENCE_TIME_DEFINED #define REFERENCE_TIME_DEFINED
1
0
0
0
Jacek Caban : vbscript: Added call statement compilation implementation.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 5ecf4364493623054f9c7ea524e3a36157f17479 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5ecf4364493623054f9c7ea52…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:08:47 2011 +0200 vbscript: Added call statement compilation implementation. --- dlls/vbscript/compile.c | 70 ++++++++++++++++++++++++++++++++++++++++++--- dlls/vbscript/interp.c | 10 +++++- dlls/vbscript/vbscript.h | 18 ++++++++++-- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 4ac760b..d57abcf 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -34,6 +34,12 @@ typedef struct { vbscode_t *code; } compile_ctx_t; +static inline instr_t *instr_ptr(compile_ctx_t *ctx, unsigned id) +{ + assert(id < ctx->instr_cnt); + return ctx->code->instrs + id; +} + static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) { assert(ctx->instr_size && ctx->instr_size >= ctx->instr_cnt); @@ -53,18 +59,72 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) return ctx->instr_cnt++; } -static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func) +static HRESULT push_instr_str(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg) { - func->code_off = ctx->instr_cnt; + unsigned instr; - if(push_instr(ctx, OP_ret) == -1) + instr = push_instr(ctx, op); + if(instr == -1) return E_OUTOFMEMORY; - if(stat) { - FIXME("statements compilation not implemented\n"); + instr_ptr(ctx, instr)->arg1.str = arg; + return S_OK; +} + +static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t *expr) +{ + HRESULT hres; + + if(expr->args) { + FIXME("arguments not implemented\n"); return E_NOTIMPL; } + if(expr->obj_expr) { + FIXME("obj_expr not implemented\n"); + hres = E_NOTIMPL; + }else { + hres = push_instr_str(ctx, OP_icallv, expr->identifier); + } + + return hres; +} + +static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) +{ + HRESULT hres; + + while(stat) { + switch(stat->type) { + case STAT_CALL: + hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr); + break; + default: + FIXME("Unimplemented statement type %d\n", stat->type); + hres = E_NOTIMPL; + } + + if(FAILED(hres)) + return hres; + stat = stat->next; + } + + return S_OK; +} + +static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func) +{ + HRESULT hres; + + func->code_off = ctx->instr_cnt; + + hres = compile_statement(ctx, stat); + if(FAILED(hres)) + return hres; + + if(push_instr(ctx, OP_ret) == -1) + return E_OUTOFMEMORY; + return S_OK; } diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 7cee9c7..3ff6bbd 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -33,6 +33,12 @@ typedef struct { typedef HRESULT (*instr_func_t)(exec_ctx_t*); +static HRESULT interp_icallv(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT interp_ret(exec_ctx_t *ctx) { TRACE("\n"); @@ -42,13 +48,13 @@ static HRESULT interp_ret(exec_ctx_t *ctx) } static const instr_func_t op_funcs[] = { -#define X(x,n) interp_ ## x, +#define X(x,n,a,b) interp_ ## x, OP_LIST #undef X }; static const unsigned op_move[] = { -#define X(x,n) n, +#define X(x,n,a,b) n, OP_LIST #undef X }; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 99ed4ba..bca630a 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -62,18 +62,30 @@ typedef struct { HRESULT init_global(script_ctx_t*); -#define OP_LIST \ - X(ret, 0) +typedef enum { + ARG_NONE = 0, + ARG_STR +} instr_arg_type_t; + +#define OP_LIST \ + X(icallv, 1, ARG_STR, 0) \ + X(ret, 0, 0, 0) typedef enum { -#define X(x,n) OP_##x, +#define X(x,n,a,b) OP_##x, OP_LIST #undef X OP_LAST } vbsop_t; +typedef union { + const WCHAR *str; +} instr_arg_t; + typedef struct { vbsop_t op; + instr_arg_t arg1; + instr_arg_t arg2; } instr_t; struct _function_t {
1
0
0
0
Jacek Caban : vbscript: Added function call statement parsing beginning implementation.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 6c5570297e34fce58be2ebe6236bf793cae4cfcf URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6c5570297e34fce58be2ebe62…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:08:21 2011 +0200 vbscript: Added function call statement parsing beginning implementation. --- dlls/vbscript/compile.c | 9 ++++- dlls/vbscript/parse.h | 33 +++++++++++++++++ dlls/vbscript/parser.y | 93 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 131 insertions(+), 4 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index c51dd97..4ac760b 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -53,13 +53,18 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) return ctx->instr_cnt++; } -static HRESULT compile_func(compile_ctx_t *ctx, function_t *func) +static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func) { func->code_off = ctx->instr_cnt; if(push_instr(ctx, OP_ret) == -1) return E_OUTOFMEMORY; + if(stat) { + FIXME("statements compilation not implemented\n"); + return E_NOTIMPL; + } + return S_OK; } @@ -113,7 +118,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret) if(!ctx.code) return E_OUTOFMEMORY; - hres = compile_func(&ctx, &ctx.code->global_code); + hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->global_code); if(FAILED(hres)) { release_vbscode(ctx.code); return hres; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index fa6424f..7c9ab26 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -16,6 +16,36 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +typedef enum { + EXPR_MEMBER +} expression_type_t; + +typedef struct _expression_t { + expression_type_t type; + struct _expression_t *next; +} expression_t; + +typedef struct { + expression_t expr; + expression_t *obj_expr; + const WCHAR *identifier; + expression_t *args; +} member_expression_t; + +typedef enum { + STAT_CALL +} statement_type_t; + +typedef struct _statement_t { + statement_type_t type; + struct _statement_t *next; +} statement_t; + +typedef struct { + statement_t stat; + member_expression_t *expr; +} call_statement_t; + typedef struct { const WCHAR *code; const WCHAR *ptr; @@ -26,6 +56,9 @@ typedef struct { int last_token; unsigned last_nl; + + statement_t *stats; + statement_t *stats_tail; } parser_ctx_t; HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 0ae6008..5fb6bd2 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -33,6 +33,12 @@ static int parser_error(const char*); static void parse_complete(parser_ctx_t*); +static void source_add_statement(parser_ctx_t*,statement_t*); + +static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*); + +static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); + %} %pure_parser @@ -40,14 +46,34 @@ static void parse_complete(parser_ctx_t*); %union { const WCHAR *string; + statement_t *statement; + member_expression_t *member; } -%token tEOF tNL +%token tEOF tNL blah %token <string> tIdentifier +%type <statement> Statement StatementNl +%type <member> MemberExpression + %% -Program : tEOF { parse_complete(ctx); } +Program + : SourceElements tEOF { parse_complete(ctx); } + +SourceElements + : /* empty */ + | SourceElements StatementNl { source_add_statement(ctx, $2); } + +StatementNl + : Statement tNL { $$ = $1; } + +Statement + : MemberExpression /* FIXME: Arguments_opt */ { $$ = new_call_statement(ctx, $1); } + +MemberExpression + : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); } + /* FIXME: MemberExpressionArgs '.' tIdentifier */ %% @@ -56,11 +82,73 @@ static int parser_error(const char *str) return 0; } +static void source_add_statement(parser_ctx_t *ctx, statement_t *stat) +{ + if(ctx->stats) { + ctx->stats_tail->next = stat; + ctx->stats_tail = stat; + }else { + ctx->stats = ctx->stats_tail = stat; + } +} + static void parse_complete(parser_ctx_t *ctx) { ctx->parse_complete = TRUE; } +static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned size) +{ + expression_t *expr; + + expr = parser_alloc(ctx, size ? size : sizeof(*expr)); + if(expr) { + expr->type = type; + expr->next = NULL; + } + + return expr; +} + +static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier) +{ + member_expression_t *expr; + + expr = new_expression(ctx, EXPR_MEMBER, sizeof(*expr)); + if(!expr) + return NULL; + + expr->obj_expr = obj_expr; + expr->identifier = identifier; + expr->args = NULL; + return expr; +} + +static void *new_statement(parser_ctx_t *ctx, statement_type_t type, unsigned size) +{ + statement_t *stat; + + stat = parser_alloc(ctx, size); + if(stat) { + stat->type = type; + stat->next = NULL; + } + + return stat; +} + +static statement_t *new_call_statement(parser_ctx_t *ctx, member_expression_t *expr) +{ + call_statement_t *stat; + + stat = new_statement(ctx, STAT_CALL, sizeof(*stat)); + if(!stat) + return NULL; + + stat->expr = expr; + return &stat->stat; +} + void *parser_alloc(parser_ctx_t *ctx, size_t size) { void *ret; @@ -82,6 +170,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code) ctx->last_token = tNL; ctx->last_nl = 0; + ctx->stats = ctx->stats_tail = NULL; parser_parse(ctx);
1
0
0
0
Jacek Caban : vbscript: Added identifiers support to lexer.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 91cc7bd7197bbe51edb4ee71efde0eb779a473a1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=91cc7bd7197bbe51edb4ee71e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:08:07 2011 +0200 vbscript: Added identifiers support to lexer. --- dlls/vbscript/lex.c | 28 ++++++++++++++++++++++++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 16 +++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index f3dc8ee..d481e6a 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -26,6 +26,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript); +static inline BOOL is_identifier_char(WCHAR c) +{ + return isalnumW(c) || c == '_'; +} + +static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret) +{ + const WCHAR *ptr = ctx->ptr++; + WCHAR *str; + int len; + + while(ctx->ptr < ctx->end && is_identifier_char(*ctx->ptr)) + ctx->ptr++; + len = ctx->ptr-ptr; + + str = parser_alloc(ctx, (len+1)*sizeof(WCHAR)); + if(!str) + return 0; + + memcpy(str, ptr, (len+1)*sizeof(WCHAR)); + str[len] = 0; + *ret = str; + return tIdentifier; +} + static int parse_next_token(void *lval, parser_ctx_t *ctx) { WCHAR c; @@ -37,6 +62,9 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) c = *ctx->ptr; + if(isalphaW(c)) + return parse_identifier(ctx, lval); + switch(c) { case '\n': ctx->ptr++; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index d6dfbbc..fa6424f 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -30,3 +30,4 @@ typedef struct { HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN; int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN; +void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index e895cfd..0ae6008 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -38,13 +38,12 @@ static void parse_complete(parser_ctx_t*); %pure_parser %start Program -%token tEOF - %union { const WCHAR *string; } -%token tNL +%token tEOF tNL +%token <string> tIdentifier %% @@ -62,6 +61,17 @@ static void parse_complete(parser_ctx_t *ctx) ctx->parse_complete = TRUE; } +void *parser_alloc(parser_ctx_t *ctx, size_t size) +{ + void *ret; + + /* FIXME: leaks! */ + ret = heap_alloc(size); + if(!ret) + ctx->hres = E_OUTOFMEMORY; + return ret; +} + HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code) { ctx->code = ctx->ptr = code;
1
0
0
0
Jacek Caban : vbscript: Added lexer support for newlines and comments.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 9f8492692c1b241e3b55d6bb0cab8edbdc1b29c4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9f8492692c1b241e3b55d6bb0…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:07:54 2011 +0200 vbscript: Added lexer support for newlines and comments. --- dlls/vbscript/lex.c | 19 +++++++++++++++++-- dlls/vbscript/tests/run.c | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 0e7ecce..f3dc8ee 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -36,8 +36,23 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) return ctx->last_token == tNL ? tEOF : tNL; c = *ctx->ptr; - FIXME("Unhandled char %c in %s\n", *ctx->ptr, debugstr_w(ctx->ptr)); - return c; + + switch(c) { + case '\n': + ctx->ptr++; + return tNL; + case '\'': + ctx->ptr = strchrW(ctx->ptr, '\n'); + if(ctx->ptr) + ctx->ptr++; + else + ctx->ptr = ctx->end; + return tNL; + default: + FIXME("Unhandled char %c in %s\n", *ctx->ptr, debugstr_w(ctx->ptr)); + } + + return 0; } int parser_lex(void *lval, parser_ctx_t *ctx) diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 6ccd466..d61b81f 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -462,6 +462,7 @@ static void run_tests(void) strict_dispid_check = TRUE; parse_script_a(""); + parse_script_a("' empty ;"); } static BOOL check_vbscript(void)
1
0
0
0
Jacek Caban : vbscript: Added beginning script running tests.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: c03cecab39b1d50b3f6b136c8e5c59dc3fd90918 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c03cecab39b1d50b3f6b136c8…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:07:42 2011 +0200 vbscript: Added beginning script running tests. --- dlls/vbscript/tests/Makefile.in | 3 +- dlls/vbscript/tests/run.c | 498 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 500 insertions(+), 1 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=c03cecab39b1d50b3f6b1…
1
0
0
0
Jacek Caban : vbscript: Added beginning interpreter implementation.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: 8906a4aa622ff3de4f6306ce518e10b6f6428b6b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8906a4aa622ff3de4f6306ce5…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:07:24 2011 +0200 vbscript: Added beginning interpreter implementation. --- dlls/vbscript/Makefile.in | 1 + dlls/vbscript/interp.c | 77 +++++++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/vbscript.c | 34 +++++++++++++++++--- dlls/vbscript/vbscript.h | 1 + 4 files changed, 108 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/Makefile.in b/dlls/vbscript/Makefile.in index 977bcde..9e27dd4 100644 --- a/dlls/vbscript/Makefile.in +++ b/dlls/vbscript/Makefile.in @@ -2,6 +2,7 @@ MODULE = vbscript.dll C_SRCS = \ compile.c \ + interp.c \ lex.c \ vbdisp.c \ vbscript.c \ diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c new file mode 100644 index 0000000..7cee9c7 --- /dev/null +++ b/dlls/vbscript/interp.c @@ -0,0 +1,77 @@ +/* + * Copyright 2011 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <assert.h> + +#include "vbscript.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(vbscript); + + +typedef struct { + vbscode_t *code; + instr_t *instr; +} exec_ctx_t; + + +typedef HRESULT (*instr_func_t)(exec_ctx_t*); + +static HRESULT interp_ret(exec_ctx_t *ctx) +{ + TRACE("\n"); + + ctx->instr = NULL; + return S_OK; +} + +static const instr_func_t op_funcs[] = { +#define X(x,n) interp_ ## x, +OP_LIST +#undef X +}; + +static const unsigned op_move[] = { +#define X(x,n) n, +OP_LIST +#undef X +}; + +HRESULT exec_script(script_ctx_t *ctx, function_t *func) +{ + exec_ctx_t exec; + vbsop_t op; + HRESULT hres = S_OK; + + exec.code = func->code_ctx; + exec.instr = exec.code->instrs + func->code_off; + + while(exec.instr) { + op = exec.instr->op; + hres = op_funcs[op](&exec); + if(FAILED(hres)) { + FIXME("Failed %08x\n", hres); + break; + } + + exec.instr += op_move[op]; + } + + return hres; +} diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index ff9d2c9..f6891c7 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -63,9 +63,34 @@ static void change_state(VBScript *This, SCRIPTSTATE state) IActiveScriptSite_OnStateChange(This->site, state); } -static void exec_queued_code(VBScript *This) +static inline BOOL is_started(VBScript *This) { - FIXME("\n"); + return This->state == SCRIPTSTATE_STARTED + || This->state == SCRIPTSTATE_CONNECTED + || This->state == SCRIPTSTATE_DISCONNECTED; +} + +static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code) +{ + HRESULT hres; + + code->global_executed = TRUE; + + IActiveScriptSite_OnEnterScript(ctx->site); + hres = exec_script(ctx, &code->global_code); + IActiveScriptSite_OnLeaveScript(ctx->site); + + return hres; +} + +static void exec_queued_code(script_ctx_t *ctx) +{ + vbscode_t *iter; + + LIST_FOR_EACH_ENTRY(iter, &ctx->code_list, vbscode_t, entry) { + if(!iter->global_executed) + exec_global_code(ctx, iter); + } } static HRESULT set_ctx_site(VBScript *This) @@ -264,7 +289,7 @@ static HRESULT WINAPI VBScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE if(This->state == SCRIPTSTATE_CLOSED) return E_UNEXPECTED; - exec_queued_code(This); + exec_queued_code(This->ctx); break; case SCRIPTSTATE_INITIALIZED: FIXME("unimplemented SCRIPTSTATE_INITIALIZED\n"); @@ -530,8 +555,7 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface, if(FAILED(hres)) return hres; - FIXME("executing script not implemented\n"); - return E_NOTIMPL; + return is_started(This) ? exec_global_code(This->ctx, code) : S_OK; } static const IActiveScriptParseVtbl VBScriptParseVtbl = { diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 88f7552..99ed4ba 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -93,6 +93,7 @@ struct _vbscode_t { void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN; HRESULT compile_script(script_ctx_t*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN; +HRESULT exec_script(script_ctx_t*,function_t*) DECLSPEC_HIDDEN; HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);
1
0
0
0
Jacek Caban : vbscript: Added beginning bytecode compiler implementation.
by Alexandre Julliard
07 Sep '11
07 Sep '11
Module: wine Branch: master Commit: c674c7a7ae4e0d1e6022d16d7e70ac67d4961133 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c674c7a7ae4e0d1e6022d16d7…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 7 14:07:12 2011 +0200 vbscript: Added beginning bytecode compiler implementation. --- dlls/vbscript/Makefile.in | 1 + dlls/vbscript/compile.c | 125 +++++++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/vbscript.c | 15 ++++-- dlls/vbscript/vbscript.h | 41 +++++++++++++++ 4 files changed, 177 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/Makefile.in b/dlls/vbscript/Makefile.in index ba267f4..977bcde 100644 --- a/dlls/vbscript/Makefile.in +++ b/dlls/vbscript/Makefile.in @@ -1,6 +1,7 @@ MODULE = vbscript.dll C_SRCS = \ + compile.c \ lex.c \ vbdisp.c \ vbscript.c \ diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c new file mode 100644 index 0000000..c51dd97 --- /dev/null +++ b/dlls/vbscript/compile.c @@ -0,0 +1,125 @@ +/* + * Copyright 2011 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <assert.h> + +#include "vbscript.h" +#include "parse.h" +#include "parser.tab.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(vbscript); + +typedef struct { + parser_ctx_t parser; + + unsigned instr_cnt; + unsigned instr_size; + vbscode_t *code; +} compile_ctx_t; + +static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) +{ + assert(ctx->instr_size && ctx->instr_size >= ctx->instr_cnt); + + if(ctx->instr_size == ctx->instr_cnt) { + instr_t *new_instr; + + new_instr = heap_realloc(ctx->code->instrs, ctx->instr_size*2*sizeof(instr_t)); + if(!new_instr) + return -1; + + ctx->code->instrs = new_instr; + ctx->instr_size *= 2; + } + + ctx->code->instrs[ctx->instr_cnt].op = op; + return ctx->instr_cnt++; +} + +static HRESULT compile_func(compile_ctx_t *ctx, function_t *func) +{ + func->code_off = ctx->instr_cnt; + + if(push_instr(ctx, OP_ret) == -1) + return E_OUTOFMEMORY; + + return S_OK; +} + +void release_vbscode(vbscode_t *code) +{ + list_remove(&code->entry); + heap_free(code->source); + heap_free(code->instrs); + heap_free(code); +} + +static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) +{ + vbscode_t *ret; + + ret = heap_alloc(sizeof(*ret)); + if(!ret) + return NULL; + + ret->source = heap_strdupW(source); + if(!ret->source) { + heap_free(ret); + return NULL; + } + + ret->instrs = heap_alloc(32*sizeof(instr_t)); + if(!ret->instrs) { + release_vbscode(ret); + return NULL; + } + + ctx->instr_cnt = 0; + ctx->instr_size = 32; + + ret->global_code.code_ctx = ret; + + list_init(&ret->entry); + return ret; +} + +HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret) +{ + compile_ctx_t ctx; + HRESULT hres; + + hres = parse_script(&ctx.parser, src); + if(FAILED(hres)) + return hres; + + ctx.code = alloc_vbscode(&ctx, src); + if(!ctx.code) + return E_OUTOFMEMORY; + + hres = compile_func(&ctx, &ctx.code->global_code); + if(FAILED(hres)) { + release_vbscode(ctx.code); + return hres; + } + + list_add_tail(&script->code_list, &ctx.code->entry); + *ret = ctx.code; + return S_OK; +} diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 53e90eb..ff9d2c9 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -20,8 +20,6 @@ #include <assert.h> #include "vbscript.h" -#include "parse.h" - #include "objsafe.h" #include "wine/debug.h" @@ -89,6 +87,9 @@ static HRESULT set_ctx_site(VBScript *This) static void destroy_script(script_ctx_t *ctx) { + while(!list_empty(&ctx->code_list)) + release_vbscode(LIST_ENTRY(list_head(&ctx->code_list), vbscode_t, entry)); + while(!list_empty(&ctx->named_items)) { named_item_t *iter = LIST_ENTRY(list_head(&ctx->named_items), named_item_t, entry); @@ -483,6 +484,7 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface) if(!ctx) return E_OUTOFMEMORY; + list_init(&ctx->code_list); list_init(&ctx->named_items); old_ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL); @@ -514,18 +516,21 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface, DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo) { VBScript *This = impl_from_IActiveScriptParse(iface); - parser_ctx_t parser; + vbscode_t *code; HRESULT hres; TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter), wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo); - hres = parse_script(&parser, pstrCode); + if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED) + return E_UNEXPECTED; + + hres = compile_script(This->ctx, pstrCode, &code); if(FAILED(hres)) return hres; - FIXME("compiling script not implemented\n"); + FIXME("executing script not implemented\n"); return E_NOTIMPL; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 9c1d35c..88f7552 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -31,6 +31,9 @@ #include "wine/list.h" #include "wine/unicode.h" +typedef struct _function_t function_t; +typedef struct _vbscode_t vbscode_t; + typedef struct named_item_t { IDispatch *disp; DWORD flags; @@ -53,11 +56,44 @@ typedef struct { vbdisp_t *script_obj; + struct list code_list; struct list named_items; } script_ctx_t; HRESULT init_global(script_ctx_t*); +#define OP_LIST \ + X(ret, 0) + +typedef enum { +#define X(x,n) OP_##x, +OP_LIST +#undef X + OP_LAST +} vbsop_t; + +typedef struct { + vbsop_t op; +} instr_t; + +struct _function_t { + unsigned code_off; + vbscode_t *code_ctx; +}; + +struct _vbscode_t { + instr_t *instrs; + WCHAR *source; + + BOOL global_executed; + function_t global_code; + + struct list entry; +}; + +void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN; +HRESULT compile_script(script_ctx_t*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN; + HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); static inline void *heap_alloc(size_t len) @@ -70,6 +106,11 @@ static inline void *heap_alloc_zero(size_t len) return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); } +static inline void *heap_realloc(void *mem, size_t len) +{ + return HeapReAlloc(GetProcessHeap(), 0, mem, len); +} + static inline BOOL heap_free(void *mem) { return HeapFree(GetProcessHeap(), 0, mem);
1
0
0
0
← Newer
1
...
78
79
80
81
82
83
84
...
100
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Results per page:
10
25
50
100
200