예제 #1
0
	void (*Loader::finalize(const char *entryLabel))()
	{
		if(!machineCode)
		{
			loadCode();
		}

		finalized = true;

		delete instructions;
		instructions = 0;

		delete[] listing;
		listing = 0;

		if(!entryLabel)
		{
			return (void(*)())machineCode;
		}

		const unsigned char *entryPoint = resolveLocal(entryLabel, 0);

		if(!entryPoint)
		{
			throw Error("Entry point '%s' not found", entryLabel);
		}

		return (void(*)())entryPoint;
	}
예제 #2
0
	const unsigned char *Loader::resolveReference(const char *name, const Instruction *position) const
	{
		const unsigned char *reference = resolveLocal(name, position);
		
		if(reference)
		{
			return reference;
		}
		else
		{
			reference = resolveExternal(name);
		}

		if(reference)
		{
			return reference;
		}
		else
		{
			throw Error("Unresolved identifier '%s'", name);
		}
	}
예제 #3
0
	void (*Loader::callable(const char *entryLabel))()
	{
		if(finalized) throw Error("Cannot retrieve callable from finalized code");

		if(!machineCode)
		{
			loadCode();
		}

		if(!entryLabel)
		{
			return (void(*)())machineCode;
		}

		const unsigned char *entryPoint = resolveLocal(entryLabel, 0);

		if(!entryPoint)
		{
			throw Error("Entry point '%s' not found", entryLabel);
		}

		return (void(*)())entryPoint;
	}
예제 #4
0
void resolveTree(Element* current, Change change)
{
    ASSERT(change != Detach);

    if (current->hasCustomStyleResolveCallbacks()) {
        if (!current->willRecalcStyle(change))
            return;
    }

    bool hasParentStyle = current->parentNodeForRenderingAndStyle() && current->parentNodeForRenderingAndStyle()->renderStyle();
    bool hasDirectAdjacentRules = current->childrenAffectedByDirectAdjacentRules();
    bool hasIndirectAdjacentRules = current->childrenAffectedByForwardPositionalRules();

    if (change > NoChange || current->needsStyleRecalc())
        current->resetComputedStyle();

    if (hasParentStyle && (change >= Inherit || current->needsStyleRecalc()))
        change = resolveLocal(current, change);

    if (change != Detach) {
        StyleResolverParentPusher parentPusher(current);

        RenderStyle* currentStyle = current->renderStyle();

        if (ShadowRoot* shadowRoot = current->shadowRoot()) {
            if (change >= Inherit || shadowRoot->childNeedsStyleRecalc() || shadowRoot->needsStyleRecalc()) {
                parentPusher.push();
                resolveShadowTree(shadowRoot, currentStyle, change);
            }
        }

        current->updateBeforePseudoElement(change);

        // FIXME: This check is good enough for :hover + foo, but it is not good enough for :hover + foo + bar.
        // For now we will just worry about the common case, since it's a lot trickier to get the second case right
        // without doing way too much re-resolution.
        bool forceCheckOfNextElementSibling = false;
        bool forceCheckOfAnyElementSibling = false;
        for (Node* child = current->firstChild(); child; child = child->nextSibling()) {
            if (child->isTextNode()) {
                updateTextStyle(toText(child), currentStyle, change);
                continue;
            }
            if (!child->isElementNode())
                continue;
            Element* childElement = toElement(child);
            bool childRulesChanged = childElement->needsStyleRecalc() && childElement->styleChangeType() == FullStyleChange;
            if ((forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling))
                childElement->setNeedsStyleRecalc();
            if (change >= Inherit || childElement->childNeedsStyleRecalc() || childElement->needsStyleRecalc()) {
                parentPusher.push();
                resolveTree(childElement, change);
            }
            forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
            forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);
        }

        current->updateAfterPseudoElement(change);
    }

    current->clearNeedsStyleRecalc();
    current->clearChildNeedsStyleRecalc();
    
    if (current->hasCustomStyleResolveCallbacks())
        current->didRecalcStyle(change);
}
예제 #5
0
ExprPtr Parser::primaryExpression(bool se)
{
	ExprPtr ret;
	/* TODO
	if(test(TMinus))
	{
		return inScope(new UnaryExpr(PrimaryExpression(se), Token.Minus));
	}*/

	if(token == TCase)
	{
		ret = patternMatch(se);
	}
	else if (token == TIdent || token == TTypeIdent)
	{
		string const& name = nextIdent(se);

		auto varDecl = resolveLocal(currentScope, name);

		if(varDecl)
			ret = inScope(new VarRef(varDecl));
		else
			ret = inScope(new NamedRef(name));
	}
	else if(token == TConstNum)
	{
		if(tokenStr.find('.') != string::npos)
			ret = inScope(new FConstExpr(tokenNum(se)));
		else
			ret = inScope(new ConstExpr(tokenNum(se)));
	}
	else if(test(TLParen))
	{
		ret = expression(false);
		expect(TRParen);
	}
	else if (firstControlSeq[token])
	{
		ret = controlSeqExpression(se);
	}
	else
	{
		throw CompileError(CEParseError, currentLine);
	}

	while(true)
	{
		switch(token)
		{
			case TLParen:
			{
				next(false);

				auto call = inScope(new CallExpr());

				call->func = ret;
				ret = call;

				if(token != TRParen)
				{
					do
					{
						ExprPtr const& param = expression(false);
						call->parameters.push_back(param);
					}
					while(test(TComma));
				}

				expect(TRParen, se);
				break;
			}

			/*
			case Token.Dot:
			{
				Next(false);

				var name = ExpectIdent(se);

				ret = InScope(new SlotRef(ret, name));
				break;
			}*/

			default:
				return ret;
		}
	}
}