Skip to content

Commit 97fc96f

Browse files
Get rest of Lib/Parser building
Compile the following files: - CharClassifier.cpp - CharSet.cpp - Parse.cpp - RegexParser.cpp - RegexPattern.cpp - RegexRuntime.cpp - Scan.cpp - StandardChars.cpp - TextbookBoyerMoore.cpp Get scan.cpp compiling Couple noteworthy items: - added _ltow_s/_ltow to the PAL - Exposed ULongMult from the PAL - Switched a __try/__finally in Scan.cpp to TryFinally
1 parent 35732ee commit 97fc96f

File tree

15 files changed

+304
-229
lines changed

15 files changed

+304
-229
lines changed

lib/Common/CommonPal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,7 @@ void TryFinally(const TryFunc& tryFunc, const FinallyFunc& finallyFunc)
391391

392392
finallyFunc(hasException);
393393
}
394+
395+
__inline
396+
HRESULT ULongMult(ULONG ulMultiplicand, ULONG ulMultiplier, ULONG* pulResult);
397+

lib/Common/DataStructures/ContinuousPageStack.h

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ template<class T, const size_t InitialPageCount>
320320
__inline T &ContinuousPageStackOfFixedElements<T, InitialPageCount>::Iterator::operator *() const
321321
{
322322
Assert(*this);
323-
Assert(nextTop <= stack.nextTop);
324-
return *reinterpret_cast<T *>(&stack.Buffer()[nextTop - sizeof(T)]);
323+
Assert(this->nextTop <= stack.nextTop);
324+
return *reinterpret_cast<T *>(&stack.Buffer()[this->nextTop - sizeof(T)]);
325325
}
326326

327327
template<class T, const size_t InitialPageCount>
@@ -334,7 +334,7 @@ template<class T, const size_t InitialPageCount>
334334
__inline typename ContinuousPageStackOfFixedElements<T, InitialPageCount>::Iterator &ContinuousPageStackOfFixedElements<T, InitialPageCount>::Iterator::operator ++() // pre-increment
335335
{
336336
Assert(*this);
337-
nextTop -= sizeof(T);
337+
this->nextTop -= sizeof(T);
338338
return *this;
339339
}
340340

@@ -361,31 +361,31 @@ __inline ContinuousPageStackOfFixedElements<T, InitialPageCount>::ContinuousPage
361361
template<class T, const size_t InitialPageCount>
362362
__inline char* ContinuousPageStackOfFixedElements<T, InitialPageCount>::Push()
363363
{
364-
return ContinuousPageStack::Push(sizeof(T));
364+
return ContinuousPageStack<InitialPageCount>::Push(sizeof(T));
365365
}
366366

367367
template<class T, const size_t InitialPageCount>
368368
__inline T* ContinuousPageStackOfFixedElements<T, InitialPageCount>::Top() const
369369
{
370-
return reinterpret_cast<T*>(ContinuousPageStack::Top(sizeof(T)));
370+
return reinterpret_cast<T*>(ContinuousPageStack<InitialPageCount>::Top(sizeof(T)));
371371
}
372372

373373
template<class T, const size_t InitialPageCount>
374374
__inline T* ContinuousPageStackOfFixedElements<T, InitialPageCount>::Pop()
375375
{
376-
return reinterpret_cast<T*>(ContinuousPageStack::Pop(sizeof(T)));
376+
return reinterpret_cast<T*>(ContinuousPageStack<InitialPageCount>::Pop(sizeof(T)));
377377
}
378378

379379
template<class T, const size_t InitialPageCount>
380380
__inline void ContinuousPageStackOfFixedElements<T, InitialPageCount>::UnPop()
381381
{
382-
return ContinuousPageStack::UnPop(sizeof(T));
382+
return ContinuousPageStack<InitialPageCount>::UnPop(sizeof(T));
383383
}
384384

385385
template<class T, const size_t InitialPageCount>
386386
__inline void ContinuousPageStackOfFixedElements<T, InitialPageCount>::PopTo(const size_t position)
387387
{
388-
ContinuousPageStack::PopTo(position);
388+
ContinuousPageStack<InitialPageCount>::PopTo(position);
389389
}
390390

391391
// -----------------------------------------------------------------------------------------------------------------------------
@@ -407,8 +407,8 @@ template<class T, const size_t InitialPageCount>
407407
__inline T &ContinuousPageStackOfVariableElements<T, InitialPageCount>::Iterator::operator *() const
408408
{
409409
Assert(*this);
410-
Assert(nextTop <= stack.nextTop);
411-
return *reinterpret_cast<T*>(reinterpret_cast<VariableElement *>(&stack.Buffer()[nextTop - topElementSize])->Data());
410+
Assert(this->nextTop <= stack.nextTop);
411+
return *reinterpret_cast<T*>(reinterpret_cast<VariableElement *>(&stack.Buffer()[this->nextTop - this->topElementSize])->Data());
412412
}
413413

414414
template<class T, const size_t InitialPageCount>
@@ -421,8 +421,8 @@ template<class T, const size_t InitialPageCount>
421421
__inline typename ContinuousPageStackOfVariableElements<T, InitialPageCount>::Iterator &ContinuousPageStackOfVariableElements<T, InitialPageCount>::Iterator::operator ++() // pre-increment
422422
{
423423
Assert(*this);
424-
Assert(nextTop <= stack.nextTop);
425-
topElementSize = reinterpret_cast<VariableElement *>(&stack.Buffer()[nextTop -= topElementSize])->PreviousElementSize();
424+
Assert(this->nextTop <= stack.nextTop);
425+
topElementSize = reinterpret_cast<VariableElement *>(&stack.Buffer()[this->nextTop -= this->topElementSize])->PreviousElementSize();
426426
return *this;
427427
}
428428

@@ -482,22 +482,23 @@ __inline char* ContinuousPageStackOfVariableElements<T, InitialPageCount>::Push(
482482
{
483483
TemplateParameter::SameOrDerivedFrom<ActualT, T>(); // ActualT must be the same type as, or a type derived from, T
484484
VariableElement *const element =
485-
new(ContinuousPageStack::Push(VariableElement::Size<ActualT>())) VariableElement(topElementSize);
486-
topElementSize = VariableElement::Size<ActualT>();
485+
new(ContinuousPageStack<InitialPageCount>::Push(VariableElement::template
486+
Size<ActualT>())) VariableElement(topElementSize);
487+
topElementSize = VariableElement::template Size<ActualT>();
487488
return element->Data();
488489
}
489490

490491
template<class T, const size_t InitialPageCount>
491492
__inline T* ContinuousPageStackOfVariableElements<T, InitialPageCount>::Top() const
492493
{
493-
VariableElement* const element = reinterpret_cast<VariableElement*>(ContinuousPageStack::Top(topElementSize));
494+
VariableElement* const element = reinterpret_cast<VariableElement*>(ContinuousPageStack<InitialPageCount>::Top(topElementSize));
494495
return element == 0 ? 0 : reinterpret_cast<T*>(element->Data());
495496
}
496497

497498
template<class T, const size_t InitialPageCount>
498499
__inline T* ContinuousPageStackOfVariableElements<T, InitialPageCount>::Pop()
499500
{
500-
VariableElement *const element = reinterpret_cast<VariableElement*>(ContinuousPageStack::Pop(topElementSize));
501+
VariableElement *const element = reinterpret_cast<VariableElement*>(ContinuousPageStack<InitialPageCount>::Pop(topElementSize));
501502
if (element == 0)
502503
return 0;
503504
else
@@ -512,19 +513,21 @@ template<class ActualT>
512513
__inline void ContinuousPageStackOfVariableElements<T, InitialPageCount>::UnPop()
513514
{
514515
TemplateParameter::SameOrDerivedFrom<ActualT, T>(); // ActualT must be the same type as, or a type derived from, T
515-
ContinuousPageStack::UnPop(VariableElement::Size<ActualT>());
516-
Assert(reinterpret_cast<VariableElement*>(ContinuousPageStack::Top(VariableElement::Size<ActualT>()))->PreviousElementSize() == topElementSize);
517-
topElementSize = VariableElement::Size<ActualT>();
516+
ContinuousPageStack<InitialPageCount>::UnPop(VariableElement::template
517+
Size<ActualT>());
518+
Assert(reinterpret_cast<VariableElement*>(ContinuousPageStack<InitialPageCount>::Top(VariableElement::template
519+
Size<ActualT>()))->PreviousElementSize() == topElementSize);
520+
topElementSize = VariableElement::template Size<ActualT>();
518521
}
519522

520523
template<class T, const size_t InitialPageCount>
521524
__inline void ContinuousPageStackOfVariableElements<T, InitialPageCount>::PopTo(const size_t position)
522525
{
523-
Assert(position <= nextTop);
524-
if(position != nextTop)
526+
Assert(position <= this->nextTop);
527+
if(position != this->nextTop)
525528
{
526-
Assert(position + sizeof(VariableElement) <= nextTop);
527-
topElementSize = reinterpret_cast<VariableElement *>(&Buffer()[position])->PreviousElementSize();
529+
Assert(position + sizeof(VariableElement) <= this->nextTop);
530+
topElementSize = reinterpret_cast<VariableElement *>(&this->Buffer()[position])->PreviousElementSize();
528531
}
529-
ContinuousPageStack::PopTo(position);
532+
ContinuousPageStack<InitialPageCount>::PopTo(position);
530533
}

lib/Parser/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ add_library (Chakra.Parser
22
Alloc.cpp
33
BackgroundParser.cpp
44
CaseInsensitive.cpp
5-
# CharClassifier.cpp
6-
# CharSet.cpp
5+
CharClassifier.cpp
6+
CharSet.cpp
77
CharTrie.cpp
88
DebugWriter.cpp
99
Hash.cpp
1010
OctoquadIdentifier.cpp
11-
# Parse.cpp
11+
Parse.cpp
1212
ParserPch.cpp
1313
RegexCompileTime.cpp
14-
# RegexParser.cpp
15-
# RegexPattern.cpp
16-
# RegexRuntime.cpp
14+
RegexParser.cpp
15+
RegexPattern.cpp
16+
RegexRuntime.cpp
1717
RegexStats.cpp
18-
# Scan.cpp
19-
# StandardChars.cpp
20-
# TextbookBoyerMoore.cpp
18+
Scan.cpp
19+
StandardChars.cpp
20+
TextbookBoyerMoore.cpp
2121
cmperr.cpp
2222
errstr.cpp
2323
globals.cpp

lib/Parser/CharMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ namespace UnifiedRegex
177177
{
178178
if (v == defv)
179179
return;
180-
children[i] = For(allocator, level, defv);
180+
children[i] = Node::For(allocator, level, defv);
181181
}
182182
children[i]->Set(allocator, defv, level, k, v);
183183
}

lib/Parser/Parse.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7254,7 +7254,7 @@ ParseNodePtr Parser::ParseStringTemplateDecl(ParseNodePtr pnodeTagFnc)
72547254

72557255
// We are not able to pass more than a ushort worth of arguments to the tag
72567256
// so use that as a logical limit on the number of string constant pieces.
7257-
if (stringConstantCount >= USHORT_MAX)
7257+
if (stringConstantCount >= USHRT_MAX)
72587258
{
72597259
Error(ERRnoMemory);
72607260
}
@@ -7802,7 +7802,7 @@ LPCOLESTR Parser::AppendNameHints(LPCOLESTR left, IdentPtr right, ulong *pNameLe
78027802

78037803
Assert(leftLen <= ULONG_MAX); // name hints should not exceed ULONG_MAX characters
78047804

7805-
if (left == nullptr || leftLen == 0 && !wrapInBrackets)
7805+
if (left == nullptr || (leftLen == 0 && !wrapInBrackets))
78067806
{
78077807
if (right != nullptr)
78087808
{
@@ -8498,11 +8498,11 @@ PidRefStack* Parser::PushPidRef(IdentPtr pid)
84988498
Assert(GetCurrentBlock() != nullptr);
84998499
AssertMsg(pid != nullptr, "PID should be created");
85008500
PidRefStack *ref = pid->GetTopRef();
8501-
if (!ref || (ref->GetScopeId() < GetCurrentBlock()->sxBlock.blockId)
8501+
if (!ref || ((ref->GetScopeId() < GetCurrentBlock()->sxBlock.blockId)
85028502
// We could have the ref from the parameter scope if it is merged with body scope. In that case we can skip creating a new one.
85038503
&& !(m_currentBlockInfo->pBlockInfoOuter->pnodeBlock->sxBlock.blockId == ref->GetScopeId()
85048504
&& m_currentBlockInfo->pBlockInfoOuter->pnodeBlock->sxBlock.blockType == PnodeBlockType::Parameter
8505-
&& m_currentBlockInfo->pBlockInfoOuter->pnodeBlock->sxBlock.scope->GetCanMergeWithBodyScope()))
8505+
&& m_currentBlockInfo->pBlockInfoOuter->pnodeBlock->sxBlock.scope->GetCanMergeWithBodyScope())))
85068506
{
85078507
ref = Anew(&m_nodeAllocator, PidRefStack);
85088508
if (ref == nullptr)
@@ -10137,7 +10137,7 @@ ParseNodePtr Parser::ParseStatement()
1013710137
pCatch->sxCatch.pnodeNext = nullptr;
1013810138

1013910139
// create a fake name for the catch var.
10140-
WCHAR *uniqueNameStr = _u("__ehobj");
10140+
const WCHAR *uniqueNameStr = _u("__ehobj");
1014110141
IdentPtr uniqueName = m_phtbl->PidHashNameLen(uniqueNameStr, static_cast<long>(wcslen(uniqueNameStr)));
1014210142

1014310143
pCatch->sxCatch.pnodeParam = CreateNameNode(uniqueName);
@@ -10868,7 +10868,7 @@ ParseNodePtr Parser::Parse(LPCUTF8 pszSrc, size_t offset, size_t length, charcou
1086810868

1086910869
m_scriptContext->AddSourceSize(m_length);
1087010870

10871-
if(!m_parseType != ParseType_Deferred)
10871+
if (m_parseType != ParseType_Deferred)
1087210872
{
1087310873
JS_ETW(EventWriteJSCRIPT_PARSE_METHOD_STOP(m_sourceContextInfo->dwHostSourceContext, GetScriptContext(), pnodeProg->sxFnc.functionId, *m_pCurrentAstSize, false, Js::Constants::GlobalFunction));
1087410874
}
@@ -11656,7 +11656,7 @@ inline bool Parser::IsNaNOrInfinityLiteral(LPCOLESTR str)
1165611656
return str &&
1165711657
(wcscmp(_u("NaN"), str) == 0 ||
1165811658
wcscmp(_u("Infinity"), str) == 0 ||
11659-
CheckForNegativeInfinity && wcscmp(_u("-Infinity"), str) == 0);
11659+
(CheckForNegativeInfinity && wcscmp(_u("-Infinity"), str) == 0));
1166011660
}
1166111661

1166211662
template <bool buildAST>

lib/Parser/RegexParser.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace UnifiedRegex
149149
, deferredIfUnicodeError(nullptr)
150150
{
151151
if (isFromExternalSource)
152-
FromExternalSource();
152+
this->FromExternalSource();
153153
}
154154

155155
//
@@ -163,15 +163,15 @@ namespace UnifiedRegex
163163
this->inputLim = inputLim;
164164
next = input;
165165
this->inBody = inBody;
166-
RestoreMultiUnits(0);
166+
this->RestoreMultiUnits(0);
167167
}
168168

169169
template <typename P, const bool IsLiteral>
170170
inline CharCount Parser<P, IsLiteral>::Pos()
171171
{
172172
CharCount nextOffset = Chars<EncodedChar>::OSB(next, input);
173-
Assert(nextOffset >= m_cMultiUnits);
174-
return nextOffset - (CharCount)m_cMultiUnits;
173+
Assert(nextOffset >= this->m_cMultiUnits);
174+
return nextOffset - (CharCount) this->m_cMultiUnits;
175175
}
176176

177177
template <typename P, const bool IsLiteral>
@@ -208,7 +208,7 @@ namespace UnifiedRegex
208208
Assert(next + n <= inputLim);
209209
#if DBG
210210
for (CharCount i = 0; i < n; i++)
211-
Assert(!IsMultiUnitChar(next[i]));
211+
Assert(!this->IsMultiUnitChar(next[i]));
212212
#endif
213213
next += n;
214214
}
@@ -342,7 +342,7 @@ namespace UnifiedRegex
342342
// while the bottom is used during Pass 1 (which isn't done when ParseNoAST)
343343
if(this->ctAllocator != nullptr)
344344
{
345-
SurrogatePairTracker* node = Anew(this->ctAllocator, SurrogatePairTracker, location, this->tempLocationOfRange, codePoint, consumptionLength, m_cMultiUnits);
345+
SurrogatePairTracker* node = Anew(this->ctAllocator, SurrogatePairTracker, location, this->tempLocationOfRange, codePoint, consumptionLength, this->m_cMultiUnits);
346346
if (surrogatePairList == nullptr)
347347
{
348348
Assert(currentSurrogatePairNode == nullptr);
@@ -600,7 +600,7 @@ namespace UnifiedRegex
600600
{
601601
Assert(!IsEOF());
602602
// Could be an embedded 0
603-
Char c = ReadFull<true>(next, inputLim);
603+
Char c = this->template ReadFull<true>(next, inputLim);
604604
// No embedded newlines in literals
605605
if (IsLiteral && standardChars->IsNewline(c))
606606
Fail(ERRnoSlash);
@@ -1577,7 +1577,8 @@ namespace UnifiedRegex
15771577
digits++;
15781578
}
15791579
while (digits < 5 && ECCanConsume(digits + 1) && standardEncodedChars->IsDigit(ECLookahead(digits)));
1580-
if (n >= numGroups || ECCanConsume(digits + 1) && standardEncodedChars->IsDigit(ECLookahead(digits)))
1580+
if (n >= numGroups ||
1581+
(ECCanConsume(digits + 1) && standardEncodedChars->IsDigit(ECLookahead(digits))))
15811582
{
15821583
if (standardEncodedChars->IsOctal(ECLookahead()))
15831584
{
@@ -1816,7 +1817,7 @@ namespace UnifiedRegex
18161817

18171818
Assert(ECCanConsume(this->currentSurrogatePairNode->length));
18181819
ECConsumeMultiUnit(this->currentSurrogatePairNode->length);
1819-
RestoreMultiUnits(this->currentSurrogatePairNode->multiUnits);
1820+
this->RestoreMultiUnits(this->currentSurrogatePairNode->multiUnits);
18201821
this->currentSurrogatePairNode = this->currentSurrogatePairNode->next;
18211822

18221823
return true;
@@ -2076,7 +2077,7 @@ namespace UnifiedRegex
20762077
pendingCodePoint = this->currentSurrogatePairNode->value;
20772078
Assert(ECCanConsume(this->currentSurrogatePairNode->length));
20782079
ECConsumeMultiUnit(this->currentSurrogatePairNode->length);
2079-
RestoreMultiUnits(this->currentSurrogatePairNode->multiUnits);
2080+
this->RestoreMultiUnits(this->currentSurrogatePairNode->multiUnits);
20802081
this->currentSurrogatePairNode = this->currentSurrogatePairNode->next;
20812082
}
20822083
else if (nextChar == '\\')
@@ -2948,7 +2949,7 @@ namespace UnifiedRegex
29482949
{
29492950
Assert(program->source == 0);
29502951

2951-
program->source = _u("");
2952+
program->source = const_cast<Char*>(_u(""));
29522953
program->sourceLen = 0;
29532954

29542955
program->numGroups = 1;
@@ -2965,7 +2966,7 @@ namespace UnifiedRegex
29652966
// Program will own source string
29662967
program->source = RecyclerNewArrayLeaf(recycler, Char, bodyChars + 1);
29672968
// Don't need to zero out since we're writing to the buffer right here
2968-
ConvertToUnicode(program->source, bodyChars, body);
2969+
this->ConvertToUnicode(program->source, bodyChars, body);
29692970
program->source[bodyChars] = 0;
29702971
program->sourceLen = bodyChars;
29712972

@@ -3079,8 +3080,8 @@ namespace UnifiedRegex
30793080
p.ParseDynamic(0, 0, 0, 0, f);
30803081
p.ParseLiteral(0, 0, a, b, c, d, f);
30813082
p.ParseLiteralNoAST(0, 0, a, b, c, d);
3082-
p.CompileProgram<true>(0, cp, a, b, c, f);
3083-
p.CompileProgram<false>(0, cp, a, b, c, f);
3083+
p.template CompileProgram<true>(0, cp, a, b, c, f);
3084+
p.template CompileProgram<false>(0, cp, a, b, c, f);
30843085
p.CaptureEmptySourceAndNoGroups(0);
30853086
p.CaptureSourceAndGroups(0, 0, 0, 0);
30863087
p.FreeBody();

0 commit comments

Comments
 (0)