void Lexer::setCode(const SourceCode& source, ParserArena& arena)
{
    m_arena = &arena.identifierArena();

    m_lineNumber = source.firstLine();
    m_delimited = false;
    m_lastToken = -1;

    const UChar* data = source.provider()->data();

    m_source = &source;
    m_codeStart = data;
    m_code = data + source.startOffset();
    m_codeEnd = data + source.endOffset();
    m_error = false;
    m_atLineStart = true;

    m_buffer8.reserveInitialCapacity(initialReadBufferCapacity);
    m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2);

    if (LIKELY(m_code < m_codeEnd))
        m_current = *m_code;
    else
        m_current = -1;
    ASSERT(currentOffset() == source.startOffset());
}
Beispiel #2
0
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
    UString program;
    if (args.isEmpty())
        program = "(function(){})";
    else if (args.size() == 1)
        program = "(function(){" + args.at(exec, 0)->toString(exec) + "})";
    else {
        program = "(function(" + args.at(exec, 0)->toString(exec);
        for (size_t i = 1; i < args.size() - 1; i++)
            program += "," + args.at(exec, i)->toString(exec);
        program += "){" + args.at(exec, args.size() - 1)->toString(exec) + "})";
    }

    int errLine;
    UString errMsg;
    SourceCode source = makeSource(program, sourceURL, lineNumber);
    RefPtr<ProgramNode> programNode = exec->globalData().parser->parse<ProgramNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);

    FunctionBodyNode* body = functionBody(programNode.get());
    if (!body)
        return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());

    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue());
    return new (exec) JSFunction(exec, functionName, body, scopeChain.node());
}
Beispiel #3
0
SourceCode* getSourceCode()
{
	string SourceCodeNode = "SourceCode";
	TiXmlElement *pNode = NULL;

	vector<TiXmlElement *> Nodes;

	if (GetNodePointerByName(pProjectNodes,SourceCodeNode,pNode))
	{
		string urlNode = "Url";
		string versionNode = "Version";
		string localPathNode = "LocalPath";
		TiXmlElement *pTempNode = pNode;
		SourceCode* sourceCode = new SourceCode();
		if (GetChildNodeByName(pTempNode,urlNode,pNode))
		{
			sourceCode->SetUrl(pNode->GetText());
			if (GetChildNodeByName(pTempNode,versionNode,pNode))
			{
				sourceCode->SetVersion(pNode->GetText());
				if (GetChildNodeByName(pTempNode,localPathNode,pNode))
				{
					sourceCode->SetLocalPath(pNode->GetText());

					//delete pNode;
					//delete pTempNode;
					return sourceCode;
				}
			}
		}
	}

	return NULL;
}
Beispiel #4
0
void OnSingleLine(SourceCode& sourceCode)
{
	while (sourceCode.IsPosValid())
		if (sourceCode.PeekChar() == '\n')
			return;
		else
			sourceCode.AdvanceChar();		
}
Beispiel #5
0
void OnMultiLine(SourceCode& sourceCode)
{
	while (sourceCode.IsPosValid())
		if (sourceCode.AdvanceIfMatch("*/"s))
			return;
		else
			sourceCode.AdvanceChar();
	throw SyntaxError("*/ lost");
}
Beispiel #6
0
FunctionExecutable::FunctionExecutable(JSGlobalData& globalData, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine)
    : ScriptExecutable(globalData.functionExecutableStructure.get(), globalData, source, unlinkedExecutable->isInStrictContext())
    , m_unlinkedExecutable(globalData, this, unlinkedExecutable)
{
    ASSERT(!source.isNull());
    ASSERT(source.length());
    m_firstLine = firstLine;
    m_lastLine = lastLine;
}
FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine)
    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext())
    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
{
    RELEASE_ASSERT(!source.isNull());
    ASSERT(source.length());
    m_firstLine = firstLine;
    m_lastLine = lastLine;
}
Beispiel #8
0
ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
    : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false, EvalContextType::None, NoIntrinsic)
{
    ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Program);
    m_typeProfilingStartOffset = 0;
    m_typeProfilingEndOffset = source.length() - 1;
    if (exec->vm().typeProfiler() || exec->vm().controlFlowProfiler())
        exec->vm().functionHasExecutedCache()->insertUnexecutedRange(sourceID(), m_typeProfilingStartOffset, m_typeProfilingEndOffset);
}
Beispiel #9
0
 SourceCode *Interpreter::loadSourceCode(QString url) {
     url = normalizeUrl(url);
     SourceCode *source;
     if(!(source = sourceCodeIsAlreadyLoaded(url))) {
         source = LIU_SOURCE_CODE(url);
         sourceCodes()->set(Text::make(url), source);
         source->parse();
     }
     return source;
 }
Beispiel #10
0
PDMBUILDER_API void getCodeInfo(char *url,char *version,char *localpath)
{
	SourceCode *sourceCode = getSourceCode();
	
	strcpy(url,sourceCode->GetUrl().c_str());
	strcpy(version,sourceCode->GetVersion().c_str());
	strcpy(localpath,sourceCode->GetLocalPath().c_str());

	delete sourceCode;
	//url = (char *)sourceCode->GetUrl().c_str();
	//version = (char *)sourceCode->GetVersion().c_str();
	//localpath = (char *)sourceCode->GetLocalPath().c_str();
}
JSValue* DebuggerCallFrame::evaluate(const UString& script, JSValue*& exception) const
{
    if (!m_callFrame->codeBlock())
        return noValue();

    int errLine;
    UString errMsg;
    SourceCode source = makeSource(script);
    RefPtr<EvalNode> evalNode = m_callFrame->scopeChain()->globalData->parser->parse<EvalNode>(m_callFrame, m_callFrame->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
    if (!evalNode)
        return Error::create(m_callFrame, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());

    return m_callFrame->scopeChain()->globalData->interpreter->execute(evalNode.get(), m_callFrame, thisObject(), m_callFrame->scopeChain(), &exception);
}
Beispiel #12
0
FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, bool bodyIncludesBraces)
    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext())
    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
    , m_bodyIncludesBraces(bodyIncludesBraces)
{
    RELEASE_ASSERT(!source.isNull());
    ASSERT(source.length());
    m_firstLine = firstLine;
    m_lastLine = lastLine;
    ASSERT(startColumn != UINT_MAX);
    ASSERT(endColumn != UINT_MAX);
    m_startColumn = startColumn;
    m_endColumn = endColumn;
}
Beispiel #13
0
FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, Intrinsic intrinsic)
    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, EvalContextType::None, intrinsic)
    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
{
    RELEASE_ASSERT(!source.isNull());
    ASSERT(source.length());
    m_firstLine = firstLine;
    m_lastLine = lastLine;
    ASSERT(startColumn != UINT_MAX);
    ASSERT(endColumn != UINT_MAX);
    m_startColumn = startColumn;
    m_endColumn = endColumn;
    m_parametersStartOffset = unlinkedExecutable->parametersStartOffset();
    m_typeProfilingStartOffset = unlinkedExecutable->typeProfilingStartOffset();
    m_typeProfilingEndOffset = unlinkedExecutable->typeProfilingEndOffset();
}
Beispiel #14
0
ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
    : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false)
{
    m_typeProfilingStartOffset = 0;
    m_typeProfilingEndOffset = source.length() - 1;
    if (exec->vm().typeProfiler() || exec->vm().controlFlowProfiler())
        exec->vm().functionHasExecutedCache()->insertUnexecutedRange(sourceID(), m_typeProfilingStartOffset, m_typeProfilingEndOffset);
}
Beispiel #15
0
PDMBUILDER_API string import()
{
	SourceCode *scode = getSourceCode();
	string sourceUrl = scode->GetUrl();

	int tagsIndex = sourceUrl.find("tags");
	int branchesIndex = sourceUrl.find("branches");
	int trunkIndex = sourceUrl.find("trunk");
	if (tagsIndex>0&&branchesIndex==string::npos&&trunkIndex==string::npos)
	{
		return "";
	}else if (tagsIndex>trunkIndex||tagsIndex>branchesIndex)
	{
		return "";
	}

	list<ImportStep *> *importStep = getImportStep();
	string log;

	for(list<ImportStep *>::iterator iter=importStep->begin();iter != importStep->end();++iter)
	{
		string name = (*iter)->GetName();
		string url = (*iter)->GetUrl();
		list<ImportItem *> item = (*iter)->GetItem();

		vector<string> source;
		vector<string> target;
		for(list<ImportItem *>::iterator iterItem=item.begin();iterItem != item.end();++iterItem)
		{
			string path =workspace+"\\"+(*iterItem)->GetSource();
			path = changeSeparator(path);
			source.push_back(path);
			
			target.push_back(changeSeparator((*iterItem)->GetTarget()));
		}
		//string logPath = workspace + "\\log";
		source.push_back(workspace+"\\log");
		target.push_back(".");
		//delete item;
		log += ImportLibStep(name,url,sourceUrl,source,target);
	}

	delete scode;
	delete importStep;
	return log;
}
void
TeamWindow::_HandleSourceCodeChanged()
{
	// If we don't have an active function anymore, the message is obsolete.
	if (fActiveFunction == NULL)
		return;

	// get a reference to the source code
	AutoLocker< ::Team> locker(fTeam);

	SourceCode* sourceCode = fActiveFunction->GetFunction()->GetSourceCode();
	LocatableFile* sourceFile = NULL;
	BString sourceText;
	BString truncatedText;
	if (sourceCode == NULL)
		sourceCode = fActiveFunction->GetSourceCode();

	if (sourceCode != NULL)
		sourceFile = fActiveFunction->GetFunctionDebugInfo()->SourceFile();

	if (sourceFile != NULL && !sourceFile->GetLocatedPath(sourceText))
		sourceFile->GetPath(sourceText);

	if (sourceCode != NULL && sourceCode->GetSourceFile() == NULL
		&& sourceFile != NULL) {
		sourceText.Prepend("Click to locate source file '");
		sourceText += "'";
		truncatedText = sourceText;
		fSourcePathView->TruncateString(&truncatedText, B_TRUNCATE_MIDDLE,
			fSourcePathView->Bounds().Width());
		if (sourceText != truncatedText)
			fSourcePathView->SetToolTip(sourceText.String());
		fSourcePathView->SetText(truncatedText.String());
	} else if (sourceFile != NULL) {
		sourceText.Prepend("File: ");
		fSourcePathView->SetText(sourceText.String());
	} else
		fSourcePathView->SetText("Source file unavailable.");

	BReference<SourceCode> sourceCodeReference(sourceCode);

	locker.Unlock();

	_SetActiveSourceCode(sourceCode);
}
Beispiel #17
0
FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource, int overrideLineNumber)
{
    SourceCode source = m_sourceOverride ? SourceCode(m_sourceOverride) : ownerSource;
    unsigned firstLine = source.firstLine() + m_firstLineOffset;
    unsigned startOffset = source.startOffset() + m_startOffset;

    // Adjust to one-based indexing.
    bool startColumnIsOnFirstSourceLine = !m_firstLineOffset;
    unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? source.startColumn() : 1);
    bool endColumnIsOnStartLine = !m_lineCount;
    unsigned endColumn = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? startColumn : 1);

    SourceCode code(source.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn);
    FunctionExecutable* result = FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumn);
    if (overrideLineNumber != -1)
        result->setOverrideLineNumber(overrideLineNumber);
    return result;
}
Beispiel #18
0
WASMModuleParser::WASMModuleParser(VM& vm, JSGlobalObject* globalObject, const SourceCode& source, JSObject* imports, JSArrayBuffer* arrayBuffer)
    : m_vm(vm)
    , m_globalObject(vm, globalObject)
    , m_source(source)
    , m_imports(vm, imports)
    , m_reader(static_cast<WebAssemblySourceProvider*>(source.provider())->data())
    , m_module(vm, JSWASMModule::create(vm, globalObject->wasmModuleStructure(), arrayBuffer))
{
}
Beispiel #19
0
UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(JSGlobalData* globalData, Structure* structure, const SourceCode& source, FunctionBodyNode* node)
    : Base(*globalData, structure)
    , m_numCapturedVariables(node->capturedVariableCount())
    , m_forceUsesArguments(node->usesArguments())
    , m_isInStrictContext(node->isStrictMode())
    , m_hasCapturedVariables(node->hasCapturedVariables())
    , m_name(node->ident())
    , m_inferredName(node->inferredName())
    , m_parameters(node->parameters())
    , m_firstLineOffset(node->firstLine() - source.firstLine())
    , m_lineCount(node->lastLine() - node->firstLine())
    , m_functionStartOffset(node->functionStart() - source.startOffset())
    , m_startOffset(node->source().startOffset() - source.startOffset())
    , m_sourceLength(node->source().length())
    , m_features(node->features())
    , m_functionNameIsInScopeToggle(node->functionNameIsInScopeToggle())
{
}
Beispiel #20
0
CodeBlockHash::CodeBlockHash(const SourceCode& sourceCode, CodeSpecializationKind kind)
    : m_hash(0)
{
    SHA1 sha1;
    sha1.addBytes(sourceCode.toString().utf8());
    Vector<uint8_t, 20> digest;
    sha1.computeHash(digest);
    m_hash += digest[0] | (digest[1] << 8) | (digest[2] << 16) | (digest[3] << 24);
    m_hash ^= static_cast<unsigned>(kind);
}
FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource, Optional<int> overrideLineNumber, Intrinsic intrinsic)
{
    SourceCode source = m_sourceOverride ? SourceCode(m_sourceOverride) : ownerSource;
    unsigned firstLine = source.firstLine() + m_firstLineOffset;
    unsigned startOffset = source.startOffset() + m_startOffset;
    unsigned lineCount = m_lineCount;

    // Adjust to one-based indexing.
    bool startColumnIsOnFirstSourceLine = !m_firstLineOffset;
    unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? source.startColumn() : 1);
    bool endColumnIsOnStartLine = !lineCount;
    unsigned endColumn = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? startColumn : 1);

    SourceCode code(source.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn);
    FunctionOverrides::OverrideInfo overrideInfo;
    bool hasFunctionOverride = false;

    if (UNLIKELY(Options::functionOverrides())) {
        hasFunctionOverride = FunctionOverrides::initializeOverrideFor(code, overrideInfo);
        if (hasFunctionOverride) {
            firstLine = overrideInfo.firstLine;
            lineCount = overrideInfo.lineCount;
            startColumn = overrideInfo.startColumn;
            endColumn = overrideInfo.endColumn;
            code = overrideInfo.sourceCode;
        }
    }

    FunctionExecutable* result = FunctionExecutable::create(vm, code, this, firstLine, firstLine + lineCount, startColumn, endColumn, intrinsic);
    if (overrideLineNumber)
        result->setOverrideLineNumber(*overrideLineNumber);

    if (UNLIKELY(hasFunctionOverride)) {
        result->overrideParameterAndTypeProfilingStartEndOffsets(
            overrideInfo.parametersStartOffset,
            overrideInfo.typeProfilingStartOffset,
            overrideInfo.typeProfilingEndOffset);
    }

    return result;
}
Beispiel #22
0
UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& parentSource, SourceCode&& parentSourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment& parentScopeTDZVariables, DerivedContextType derivedContextType)
    : Base(*vm, structure)
    , m_firstLineOffset(node->firstLine() - parentSource.firstLine().oneBasedInt())
    , m_lineCount(node->lastLine() - node->firstLine())
    , m_unlinkedFunctionNameStart(node->functionNameStart() - parentSource.startOffset())
    , m_unlinkedBodyStartColumn(node->startColumn())
    , m_unlinkedBodyEndColumn(m_lineCount ? node->endColumn() : node->endColumn() - node->startColumn())
    , m_startOffset(node->source().startOffset() - parentSource.startOffset())
    , m_sourceLength(node->source().length())
    , m_parametersStartOffset(node->parametersStart())
    , m_typeProfilingStartOffset(node->functionKeywordStart())
    , m_typeProfilingEndOffset(node->startStartOffset() + node->source().length() - 1)
    , m_parameterCount(node->parameterCount())
    , m_functionLength(node->functionLength())
    , m_features(0)
    , m_sourceParseMode(node->parseMode())
    , m_isInStrictContext(node->isInStrictContext())
    , m_hasCapturedVariables(false)
    , m_isBuiltinFunction(kind == UnlinkedBuiltinFunction)
    , m_constructAbility(static_cast<unsigned>(constructAbility))
    , m_constructorKind(static_cast<unsigned>(node->constructorKind()))
    , m_functionMode(static_cast<unsigned>(node->functionMode()))
    , m_scriptMode(static_cast<unsigned>(scriptMode))
    , m_superBinding(static_cast<unsigned>(node->superBinding()))
    , m_derivedContextType(static_cast<unsigned>(derivedContextType))
    , m_name(node->ident())
    , m_ecmaName(node->ecmaName())
    , m_inferredName(node->inferredName())
    , m_parentSourceOverride(WTFMove(parentSourceOverride))
    , m_classSource(node->classSource())
{
    // Make sure these bitfields are adequately wide.
    ASSERT(m_constructAbility == static_cast<unsigned>(constructAbility));
    ASSERT(m_constructorKind == static_cast<unsigned>(node->constructorKind()));
    ASSERT(m_functionMode == static_cast<unsigned>(node->functionMode()));
    ASSERT(m_scriptMode == static_cast<unsigned>(scriptMode));
    ASSERT(m_superBinding == static_cast<unsigned>(node->superBinding()));
    ASSERT(m_derivedContextType == static_cast<unsigned>(derivedContextType));

    m_parentScopeTDZVariables.swap(parentScopeTDZVariables);
}
Beispiel #23
0
UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, FunctionBodyNode* node, UnlinkedFunctionKind kind)
    : Base(*vm, structure)
    , m_numCapturedVariables(node->capturedVariableCount())
    , m_forceUsesArguments(node->usesArguments())
    , m_isInStrictContext(node->isStrictMode())
    , m_hasCapturedVariables(node->hasCapturedVariables())
    , m_isBuiltinFunction(kind == UnlinkedBuiltinFunction)
    , m_name(node->ident())
    , m_inferredName(node->inferredName())
    , m_parameters(node->parameters())
    , m_firstLineOffset(node->firstLine() - source.firstLine())
    , m_lineCount(node->lastLine() - node->firstLine())
    , m_unlinkedFunctionNameStart(node->functionNameStart() - source.startOffset())
    , m_unlinkedBodyStartColumn(node->startColumn())
    , m_unlinkedBodyEndColumn(m_lineCount ? node->endColumn() : node->endColumn() - node->startColumn())
    , m_startOffset(node->source().startOffset() - source.startOffset())
    , m_sourceLength(node->source().length())
    , m_features(node->features())
    , m_functionMode(node->functionMode())
{
}
Beispiel #24
0
bool FunctionOverrides::initializeOverrideFor(const SourceCode& origCode, FunctionOverrides::OverrideInfo& result)
{
    ASSERT(Options::functionOverrides());
    FunctionOverrides& overrides = FunctionOverrides::overrides();

    auto it = overrides.m_entries.find(origCode.toString());
    if (it == overrides.m_entries.end())
        return false;

    initializeOverrideInfo(origCode, it->value, result);
    return true;
}
Beispiel #25
0
void Lexer::setCode(const SourceCode& source, ParserArena& arena)
{
    m_arena = &arena.identifierArena();

    m_lineNumber = source.firstLine();
    m_delimited = false;
    m_lastToken = -1;

    const UChar* data = source.provider()->data();

    m_source = &source;
    m_codeStart = data;
    m_code = data + source.startOffset();
    m_codeEnd = data + source.endOffset();
    m_error = false;
    m_atLineStart = true;

    // ECMA-262 calls for stripping all Cf characters, but we only strip BOM characters.
    // See <https://bugs.webkit.org/show_bug.cgi?id=4931> for details.
    if (source.provider()->hasBOMs()) {
        for (const UChar* p = m_codeStart; p < m_codeEnd; ++p) {
            if (UNLIKELY(*p == byteOrderMark)) {
                copyCodeWithoutBOMs();
                break;
            }
        }
    }

    // Read the first characters into the 4-character buffer.
    shift4();
    ASSERT(currentOffset() == source.startOffset());
}
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
#if PLATFORM(APOLLO)
    if (!exec->dynamicGlobalObject()->canConstructFunctions())
        return throwError(exec, GeneralError, "Adobe AIR runtime security violation for JavaScript code in the application security sandbox (Function constructor)", -1, -1, NULL); // Unsafe JavaScript
#endif    

	// Functions need to have a space following the opening { due to for web compatibility
    // see https://bugs.webkit.org/show_bug.cgi?id=24350
    // We also need \n before the closing } to handle // comments at the end of the last line
    UString program;
    if (args.isEmpty())
        program = "(function() { \n})";
    else if (args.size() == 1)
        program = makeString("(function() { ", args.at(0).toString(exec), "\n})");
    else {
        StringBuilder builder;
        builder.append("(function(");
        builder.append(args.at(0).toString(exec));
        for (size_t i = 1; i < args.size() - 1; i++) {
            builder.append(",");
            builder.append(args.at(i).toString(exec));
        }
        builder.append(") { ");
        builder.append(args.at(args.size() - 1).toString(exec));
        builder.append("\n})");
        program = builder.build();
    }

    int errLine;
    UString errMsg;
    SourceCode source = makeSource(program, sourceURL, lineNumber);
    RefPtr<FunctionExecutable> function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
    if (!function)
        return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());

    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    ScopeChain scopeChain(globalObject, globalObject->globalData(), globalObject, exec->globalThisValue());
    return new (exec) JSFunction(exec, function, scopeChain.node());
}
Beispiel #27
0
PDMBUILDER_API string publish()
{
	
	SourceCode *scode = getSourceCode();
	string sourceUrl = scode->GetUrl();

	int tagsIndex = sourceUrl.find("tags");
	int branchesIndex = sourceUrl.find("branches");
	int trunkIndex = sourceUrl.find("trunk");
	if (tagsIndex<0&&branchesIndex>0||trunkIndex>0)
	{
		return "";
	}else if (tagsIndex<trunkIndex||tagsIndex<branchesIndex)
	{
		return "";
	}
	
	Publish *publish = getPublish();

	list<ImportItem *> itemList = publish->GetImportItem();
	vector<string> source;
	vector<string> target;
	for (list<ImportItem *>::iterator iter = itemList.begin();iter != itemList.end();++iter)
	{
		string path =workspace+"\\"+(*iter)->GetSource();
		path = changeSeparator(path);
		source.push_back(path);

		//source.push_back((*iter)->GetSource());
		target.push_back((*iter)->GetTarget());
	}

	string log = ExeComponentUpLoad((char *)publish->GetUrl().c_str(),"component",(char *)publish->GetCategory().c_str(),(char *)publish->GetComponent().c_str(),(char *)publish->GetVersion().c_str(),source,target);
	
	//delete itemList;
	delete scode;
	delete publish;

	return log;
}
Beispiel #28
0
CodeBlockHash::CodeBlockHash(const SourceCode& sourceCode, CodeSpecializationKind kind)
    : m_hash(0)
{
    SHA1 sha1;
    sha1.addBytes(sourceCode.toUTF8());
    Vector<uint8_t, 20> digest;
    sha1.computeHash(digest);
    m_hash += digest[0] | (digest[1] << 8) | (digest[2] << 16) | (digest[3] << 24);
    m_hash ^= static_cast<unsigned>(kind);
    
    // Ensure that 0 corresponds to the hash not having been computed.
    if (!m_hash)
        m_hash = 1;
}
void WebDebugListenerImpl::sourceParsed(ExecState* execState, const SourceCode& source, int errorLine, const UString& errorMsg)
{
    if (m_listener && !m_inDebug) {
        m_inDebug = true;

        WebCore::String coreSourceURL = WebCore::ustringToString(source.provider()->url());
        WebCore::Frame *frame = static_cast<WebCore::JSDOMWindow*>(execState->lexicalGlobalObject())->impl()->frame();
        if (!(coreSourceURL.isNull() || coreSourceURL.isEmpty())) {
            WebCore::KURL sourceURL(WebCore::ParsedURLString, coreSourceURL);
            WebCore::KURL mappedURL;
            if(WebCore::FrameLoaderClientApollo::mapFrameUrl(frame, sourceURL, &mappedURL)) {
                coreSourceURL = mappedURL.string();
            }
        }

        WebCore::String coreErrorMsg = WebCore::ustringToString(errorMsg);

        WebCore::String coreSource(source.data(), source.length());

        m_listener->m_pVTable->sourceParsed(m_listener, source.provider()->asID(), coreSourceURL.webString(), coreSource.webString(), source.firstLine(), errorLine, coreErrorMsg.webString());

        m_inDebug = false;
    }
}
Beispiel #30
0
PDMBUILDER_API string checkout(string workspace)
{
	SourceCode *sourceCode = getSourceCode();

	char ExportCmd[500];
	memset(ExportCmd,0,sizeof(ExportCmd));

	string url  = sourceCode->GetUrl();
	string log("<---------------------------checkout--------------------------->\nCheckout: ");
	log.append(url).append("\n");
	//string fullpath(workspace+"\\"+sourceCode->GetLocalPath());
	string fullpath = sourceCode->GetLocalPath();
	fullpath = changeSeparator(fullpath);

	if(sourceCode->GetVersion() == "head"){
		sprintf(ExportCmd, "svn checkout --force --non-interactive --username %s --password %s %s \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetUrl().c_str(), fullpath.c_str());
	}else{
		sprintf(ExportCmd, "svn checkout -r %s --force  --non-interactive --username %s --password %s %s \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetVersion().c_str(),sourceCode->GetUrl().c_str(),fullpath.c_str());
	}

	int exitCode = 0;
	log += ExeCommand(ExportCmd,exitCode,(char *)workspace.c_str());
	if (exitCode>0&&exitCode!=STILL_ACTIVE)
	{
		return log +"\nerror";
	}
	int errorindex = log.find("svn: E");
	if (errorindex!=string::npos)
	{
		return log +"\nerror";
	}
	if ("head" == sourceCode->GetVersion())
	{
		//int length = log.length();
		int index = log.rfind("Checked out revision");
		if(index!=string::npos){
			int in = log.rfind(".");
			index += 21;
			sourceVersion = log.substr(index,in-index);
		}
	}else{
		sourceVersion = sourceCode->GetVersion();
	}
	delete sourceCode;
	
	return log;
}