Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tag decorator #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add tag decorator #85

wants to merge 2 commits into from

Conversation

cdonovick
Copy link
Owner

@cdonovick cdonovick commented Aug 2, 2019

Sorry, ignore this comment

@cdonovick cdonovick requested review from phanrahan and rdaly525 August 2, 2019 17:27
@phanrahan
Copy link
Collaborator

LGTM. Thanks for the quick turnaround.

@phanrahan
Copy link
Collaborator

Shouldn't we also change encode ...

def encode(inst, *args):
    #print(inst, type(inst))
    if isinstance(inst, AbstractBitVector):
        word = int(inst) << inst.bitfield
    elif isinstance(inst,Enum):
        word = inst.value << inst.bitfield
    elif isinstance(inst,Product):
        word = 0
        for key in type(inst).field_dict.keys():
            word |= encode(getattr(inst, key))
    elif isinstance(inst,Sum):
        t = type(inst)
        if hasattr(t, 'tags'):
            i = t.tags[type(inst.value)]
        else:
            i = list(t.fields).index(type(inst.value))
        word = (i << t.bitfield) | encode(inst.value)
...

@cdonovick
Copy link
Owner Author

Probably, I don't use encode anywhere, feel free to modify as you see fit.

In the long term I think it would be an appropriate to remove encode and build anAssembler with the same logic. The AssembledADT infrastructure that is about to exist relies on people subclassing AbstractAssembler so that it can translate adt[key] and adt.attr to bv[idx]

@phanrahan
Copy link
Collaborator

Let me build out encode so that is assembles the pdp8 and riscv, and then we can figure out how to merge those ideas into Assembler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants